I'm dealing with an USB storage device that contains a proprietary file system. So, I need to read these device's 512 bytes blocks to implement a viewer for this filesystem.
How should I go about this? Is there some material on it using Delphi?
Steps to Recover Data from a RAW USB Flash Drive Another option is to make use of a data recovery tool like Disk Drill. This can be used to recover data in a variety of ways in a range of circumstances, including when a drive has gone RAW for some reason.
We have RawDisk product which provides read and write access to raw partitions under XP, Vista and Windows 7 (there exist certain security restrictions when using Windows API and RawDisk lets you bypass those restrictions). Code is available for all versions of Delphi from Delphi 5 to Delphi XE (XE2 support will be added in a couple of days).
#1 The most obvious symptom of a USB drive having turned RAW is that you will simply not be able to access any of the files you know are stored on it. If you look at the properties of the drive you are having problems with, you will see that the file system is RAW or – in some cases – the format may not be recognized at all.
You just need the first sector Physical Disk Access (may work for you) Raw Disk Access (may work for you) TDiskIO (too old, works only under w9x) Those components won't compile on Delphi 2010 (and probably all Delphis above 2009) and porting them is giving me a hard time.
I hate components so here is some code
var
RawMBR : array [0..511] of byte;
btsIO : DWORD;
begin
hDevice := CreateFile('\\.\PHYSICALDRIVE1', GENERIC_READ,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);
if hDevice <> INVALID_HANDLE_VALUE then
begin
SetFilePointer(hDevice,512 * 0,nil,FILE_BEGIN); // replace 0 with sector that you wish to read
ReadFile(hDevice, RawMBR[0], 512, btsIO, nil);
CloseHandle(hDevice);
end;
end;
Did you try RawDiskAccess component, source for Delphi 7 here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With