I am trying to code exe packer / protector as a way to learn more about assembler, C ++ and how PE files work. I am currently working, so the section containing the EP has XORed with the key, and a new section is created containing my decryption code. Everything works fine, except when I try to use JMP for the original EP after decryption.
I basically do this:
DWORD originalEntryPoint = optionalHeader->AddressOfEntryPoint;
crypted.put(0xE9);
crypted.write((char*)&orginalEntryPoint, sizeof(DWORD));
But instead of going to the entry point, ollydbg shows that this code parses:
00404030 .-E9 00100000 JMP 00405035 ; should be 00401000 =[
and when I try to change it manually, the new opcode is displayed as
00404030 -E9 CBCFFFFF JMP crypted.00401000
Where did 0xCBCFFFFF come from? How can I generate this from C ++ side?