tags:

views:

189

answers:

2

Hi,

How can I write a program that can recover files in FAT32.

Please give me a suggestion!

+1  A: 

It depends on what happened to the files you're trying to recover. The data may still be on the partition, or it could be overwritten by now. There are a lot of pre-written solutions. A simple google search should give you a plethora of software that can try to recover the data, but it's not 100% sure to get them back. If you really want to recover them yourself, you'll need to write something the read the raw partition and ignore missing file markers.

here is a program (written by Thomas Tempelman. This guy is great.) that might help you out. You can make a copy of the partition, ignoring corrupt bits, then operate on the copy so you don't mess anything up, and you may also be able to recover the data directly with it.

Alex Fort
In my case, the file was not overwritten. Can you give some articles?
You may not be able to tell if the file has been overwritten. Once the file is marked as deleted, that space becomes available for anything that might need it. Just search google for fat32 file recovery, and you'll find plenty of resources, including freeware apps that may help.
Alex Fort
Keep in mind that not being over-written is just one part of the problem. The second part is that the file must not be fragmented, as the allocations are lost when the space is freed (this is why you should always defrag as often as possible). To really undelete a file you usually will only be successful if all the following is true:-The sectors that were allocated to it were not yet overwritten.-The file was not fragmented.-The header of the files actual data is identifiable.-The header or some known part of the file gives its file size.
Myforwik
+2  A: 

This is pretty complex, but FAT32 is very good documented:

I wrote a tool for direct FAT32 access once using only those ressources:

But I've never actually tried to recover files. If you will successfully recover a file depends on several factors:

  1. The file must still "exist" physically on the hard disk
  2. You must know where the file starts
  3. You must know what you are looking for (Headers..)
Chris