I have a question that's a bit off-topic. I was playing with direct disk access:
Code: Select all
HANDLE hDevice;
DWORD br;
buffer = (char*)malloc (32768);
hDevice = CreateFile(
devicename,
GENERIC_READ, // |GENERIC_WRITE
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, // lpSecurityAttributes
OPEN_EXISTING,
FILE_FLAG_RANDOM_ACCESS,// FILE_FLAG_NO_BUFFERING
NULL
);
if (hDevice == INVALID_HANDLE_VALUE) {
printf("error opening device!\n");
return 1;
}
SetFilePointer (hDevice, 0, NULL, FILE_BEGIN); // read boot sector
if (!ReadFile (hDevice, buffer, 512, &br, NULL) ){
printf("error reading boot sector!");
return 2;
}