Afficher un message
Vieux 01/07/2008, 20h53   #1
Medvedev
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut I can't read the first byte of an EXE file!!!!!

i write this code to read the first byte from my EXE and compare it
with the entered EXE file
the byte read from both files supposed to be the same but that's don't
happened!!
i tried also with different EXE's but it also failed to read the first
byte which is "M"
--
here is the code:

FILE *a,*b;
int z;
char str1[2];
char str2[2];

a= fopen(argv[0],"rb"); //try to change both file with
another EXE's and u will also fail
b= fopen(argv[1],"rb+");

z= fread(str1,1,1,a);
if (z !=1)
printf("-101");

z= fread(str2,1,1,b);
if (z !=1)
printf("-102");

if(str1 == str2)
{
fwrite("a",1,1,b); // i want to change the first byte
with this char
printf("OK");
}else{
fwrite(str1,1,1,b);
printf("NO");
}
fclose(a);
fclose(b);
  Réponse avec citation
 
Page generated in 0,06102 seconds with 9 queries