Search code examples
windows-cefat

Purposefully Corrupting a FAT File System?


Is there a way to purposefully corrupt a FAT file system using only Win32 calls or must you do it at lower level? We're encountering FAT corruption on a WinCE 5.0 device and have written a utility to detect and attempt to correct it, but don't have a means to create FAT corruption on demand. Thanks.

The media is a CF card, but it's not removable as a normal course as it's mounted internal to the device.


Solution

  • What's the FAT on (e.g. inserted USB, on-board flash, etc)? That's going to make a large difference.

    If it's the on-board flash, you need to get underneath the file system driver (FSD), which is typically going to be the flash driver itself. It's going to have access to the raw flash sectors (it's what the FSD uses for its reads and writes) either through Xxx_Write or Xxx_Ioctl. Exactly how it works is going to depend on the flash driver in use, so looking at the driver source is your best path.