working on a shred for win32

Ryan Malayter rmalayter@bai.org
Mon Oct 1 06:29:01 2001


After reading the list archives about GnuPG's lack of a --wipe option on any
platform, and then looking at and trying many of the free/shareware Windows
file wipers out there, I decided to try to port Gnu fileutil's shred to a
GPL'd native windows command-line util. Sourceforge's otherwise excellent
windows-native ports of Gnu fileutils is missing shred. BCwipe is great, but
overkill for my situation, and a bit uweildly to manage as it requires a
local install on the destination machine.

I waded into the Gnu shred source code, and decided a feature-for-feature
port of shred was beyond my rusty C and meager Win32 API knowledge. So I
wrote a simple, single-executable DOD 5220.22-compliant shredder in ANSI C
using the free windows-native lcc environment. However, I'm having an issue:

How can I force non-cached file writes with the Win32 API? Lcc includes
Win32 libraries, but I was sticking with fopen() hoping that fflush() would
suffice for forcing data to disk. I've poked around MSDN, but I'm a DBA and
network admin, not a Win32 developer, so I had a tough time. General MSDN
searches on 'file cache', 'foce flush', etc. turn up too much noise to be
useful. Currently, my fflush() and fclose() don't overcome Windows file
caching. So despite the 32 passes I make shredding the file, I'm getting
only one overwrite on media before deletion.

Thanks for any insights,
	-ryan-