May 4, 2025 : Writing a Secure File Deletion Tool for Windows
© 安岡喜晴 (JoyShine)

I made a file-erasing program for Windows that overwrites a file's contents before deleting it.

When you delete a file normally on Windows, in most cases the metadata that records the file's existence (NTFS MFT entries, directory references, the allocation bitmap, etc.) is typically just flagged as "unused," and the actual data area isn't guaranteed to be overwritten at that point.

This program overwrites that data area before deletion, making ordinary recovery difficult.

The implementation is based on the native Win32 API.
It opens the target file with CreateFileW, gets its size with GetFileSizeEx, rewinds to the beginning with SetFilePointerEx, and then overwrites the contents with a random or fixed pattern using WriteFile.

Once the overwrite is done, FlushFileBuffers is called, optional read-back verification is performed, and the file is finally deleted with DeleteFileW.

The default method is a single-pass random overwrite, based on the approach described in NIST SP 800-88 Rev.2.

In addition, you can select older, well-known erase profiles such as the 7-pass method equivalent to DoD 5220.22-M ECE, or the 35-pass method published by Peter Gutmann in 1996.

Note that this is a file overwrite-and-delete tool, not something that guarantees complete media sanitization.

Home  |  Profile  |  Software  |  Medicine  |  Diary  |  Photos  |  Contact