-
-
[求助]读取磁盘OK,读取卷错误
-
发表于:
2010-6-3 11:10
4474
-
很简单的代码,我打开PhysicalDrive1就可以,但打开C:就错误,请问这是为什么?
#include <stdio.h>
#include <windows.h>
#include <winioctl.h>
int main(void)
{
//LPCTSTR lpszDevice = "\\\\.\\PhysicalDrive1";
LPCTSTR lpszDevice = "\\\\.\\C:";
HANDLE hDevice = CreateFile(lpszDevice,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
if (!hDevice || (hDevice==(HANDLE)-1))
{
printf("Open Device error:0x%x\n",GetLastError());
return -1;
}
DWORD temp;
const int SECTOR_SIZE = 512;
UCHAR buffer[SECTOR_SIZE];
ReadFile(hDevice,buffer,SECTOR_SIZE,&temp,NULL);
CloseHandle(hDevice);
return 0;
}
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)