WinAPI - Direct disk access
Posted: Mon Aug 01, 2016 2:48 pm
Hi,
I have a question that's a bit off-topic. I was playing with direct disk access:
Everything I read does not pass through PrimoCache, nor Windows cache, even though FILE_FLAG_NO_BUFFERING is not set. Is there a way to do cached read on logical volumes (or physical disks) using win32 API?
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;
}