Let's assume I want to change something in the 000F5344 address of an executable. How do I do it?
+9
A:
Four steps solution follows:
- Open the file with binary flag (use
fopen). - Move to the address (offset) (use
fseek). - Write your data (use
fwrite). - Close the file (use
fclose).
Use google to get help on the four mentioned functions calls. Will also work in C.
Pablo Santa Cruz
2010-08-11 22:28:56
Much appreciated.
Queops
2010-08-11 22:31:17
Just for correctness, wouldn't that be fseek instead of ftell?
TheUndeadFish
2010-08-11 22:37:03
@TheUndeadFish: yes.
mingos
2010-08-11 22:39:19
@TheUndeadFish: yes! Thanks. Fixed that.
Pablo Santa Cruz
2010-08-11 22:54:37
+9
A:
@Pablo Santa Cruz provides an excellent way, but in C. If you prefer to go pure C++, here's how:
- Open file: fstream::open (remember to use the binary flag)
- Set the put pointer position: fstream::seekp
- Write data at the put pointer position: fstream::put
- Close file: fstream::close
This is by no means better than the C version though.
mingos
2010-08-11 22:37:14