Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

appending a binary file (C/++)


ghost's Avatar
0 0

well im trying to append to a binary file like so

if(!(elf = fopen(file, "a+b"))){  return;}
	fseek(elf,elfpheader->offset+address,SEEK_SET);
	printf("offset 0x%0x\n",elfpheader->offset+address);
	fwrite((void*)value, sizeof(u32), 1, elf);```

the offset is the line in the file i want to edit and the value is obviously the new value i want to append, but when i try this it runs smoothely until it trys to write the value. ive had to cast the value from a "unsigned int" to "void*" VC Express just gives me an error inside the fread.c line 93 saying "Expression: buffer != NULL" this also happens when i try to read from here aswell.