ReadSectorW2K

This function retrieves a sector from a logical hard disk drive and loads a buffer with it. Works with Windows NT, Windows 2000 and Windows XP.

long _stdcall ReadSectorW2K(LPSTR sDrive, double LowPos, double HighPos, WORD Count, LPSTR Buffer, DWORD BufferSize);

Parameters

sDrive: The string containing the drive name. Use \\.\A: to access drive A, \\.\C: to access drive C and so on.
LowPos: A double carrying the low position of the address of the sector.
HighPos: A double carrying the high position of the address of the sector.
Count: Ignored, should be set to 1.
Buffer: A string preloaded with buffersize characters. Will be used to store the sector's data.
Buffersize: Indicates the length of buffer.

To obtain the physical address of a sector use the formula Address=(NumberOfSector-1)*SectorSize where NumberOfSector is a 1-based count and SectorSize the size of the sector (512, 2048, etc). Then load the LowPos as unsigned long and HighPos as unsigned long, using the formula: Address=2^32*HighPos+LowPos. For up to 2GB HighPos should be equal to 0.

Back.