Reputation: 47
i am trying to add a single NOP instruction at the very beginning of the .text section in a simple hello world executable that i have written, i know that it is not just that straight forward, so i am using a dissasembling library in order to patch all addresses accordinly(for example if i insert 1 byte opcode into the binary, all addresses after that instruction will be pushed 1 byte forward, so i patch all calls to that address to use the new one).
i am also updating the AddressOfEntryPoint field in the OptionalHeader of the PE header so that the entrypoint is correct, but i am still not getting this to work.
So my question is basicly, what is required of me to "fix" in the executable after adding 1 single nop instruction at the very beginning(and i checked that i do not break any instructions by inserting it). are there more field in the PE header that has to be fixed ? or what am i missing here ? :S
Upvotes: 2
Views: 787
Reputation: 1
You very probably have to relocate your binary executable (which might not be possible in the general case, e.g. for stripped binaries). Dive into Levine's Linkers and loaders book.
If you can recompile that executable, consider adding some plugin abilities to it (and use dynamic linking).
Upvotes: 2