samedi 11 avril 2015

read boot sector using C on windows8

i tried to read the boot sector using this program



int lire_secteur(int num_sect,unsigned char* buf)
{
int retCode = 0;
unsigned char secteur[512];
char disque[10] ;
char partition ;
FILE* device ;
do
{
disque[0]='\0' ;
scanf("%c",&partition) ;
if (partition=='0')
{
strcpy(disque,"\\\\.\\PHYSICALDRIVE0") ;
}
else
{
sprintf(disque,"\\\\.\\%c:",partition) ;
}
device = fopen(disque, "rb+");
}

while (device == NULL) ;
fseek( device,num_sect*512 , SEEK_SET );
if (fread (secteur, 512,1, device) < 1)
{
printf("erreur\n");
return 1 ;
}
else
{
memcpy(buf,secteur, 512);
retCode=0;
}
return retCode;
}


i have successfully read all sectors in the hard drive but when i want to read the boot sector i have this: enter image description here


is the problem in my code or it'is due to windows8 ?


Aucun commentaire:

Enregistrer un commentaire