Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HANDLE drive = CreateFile(_T("\.PhysicalDrive0"), GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
- // error handling
- DWORD br = 0;
- DISK_GEOMETRY dg;
- DeviceIOControl(drive, IOCTL_DISK_GET_DRIVE_GEOMETRY, 0, 0, &dg, sizeof(dg), &br, 0);
- //
- LARGE_INTEGER pos;
- pos.QuadPart = static_cast<LONGLONG>(sectorToRead) * dg.BytesPerSector;
- SetFilePointerEx(drive, pos, 0, FILE_BEGIN);
- const bool success = ReadFile(drive, sectorData, dg.BytesPerSector, &br) && br == dg.BytesPerSector;
- //
- CloseHandle(drive);
- DRIVE_LAYOUT_INFORMATION_EX dl;
- DeviceIOControl(drive, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, 0, 0, &dl, sizeof(dl), &br, 0);
- if(dl.PartitionStyle == PARTITION_STYLE_RAW)
- {
- // found correct disk
- }
Add Comment
Please, Sign In to add comment