codice:
#include <windows.h>
/*...*/
HANDLE hDisk=CreateFile("\\.\PHYSICALDRIVE0",GENERIC_READ,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
BOOL bRet;
DWORD dwBytesRead;
byte MBR[512];
if(hDisk==INVALID_HANDLE_VALUE)
{
printf("Impossibile aprire il disco\n");
exit(1);
}
bRet=ReadFile(hDisk,MBR,512,&dwBytesRead,NULL);
CloseHandle(hDisk);
if(!bRet || dwBytesRead!=512)
{
printf("Impossibile leggere l'MBR.\n");
exit(2);
}
printf("MBR letto con successo.\n");
/* fa quello che deve fare con l'MBR letto */