I have code that changes the function that will be called to my new function, but I do not want to call only my new function, I also want to name the old one. This is an example, so you can understand what I'm saying:
If I parsed my .exe, I will look at this part:
L00123456: mov eax, [L00654321]
(0x123 is the address of this line) So, I used this code:
DWORD old; DWORD from = 0x123; DWORD to = MyNewFunction; VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &old); DWORD disp = to - (from + 5); *(BYTE *)(from) = 0xE8; *(DWORD *)(from + 1) = (DWORD)disp;
Now instead of calling SUB_L00999999, it calls MyNewFunction ...
So ... any ideas on how I can still call the old function?
I tried things like this (in different ways), but this is a failure of my application:
int MyNewFunction(int parameter) { DWORD oldfunction = 0x00999999; _asm push parameter _asm call oldfunction }
Notes. I am using Visual Studio C ++ 2010 and these codes are in .dll loaded in .exe.
Thanks.
source share