Here, we can simply modify the return address of any function, and customize the EIP point to execute any commands of the current process space. Here, we just make everyone better aware of the stack frame structure, there are no Inline hooks related to cross-process operations. Later, we will explain how to read any process memory and modify the execution process of any process function.
If you don't talk much about it, just serve it directly:
# Include <stdio. h> # include <windows. h>/* print the return address value of the main function (usage, you know !) Required knowledge: function stack frame structure C call convention, push argv push argc call main from right to left, JMP mainmain: Push EBP mov EBP, esp sub ESP, 0x4; 0x4 = sum (sizeof (type) * count) STACK: argv argc; new EBP + 8 EIP; main RET address = new EBP + 4 EBP; old EBP value, new EBP postation I; I local variable = new EBP-4 */INT main (INT argc, char * argv []) {int I = 0; // EBP-4 _ ASM {mov eax, [EBP + 4] mov I, eax} printf ("% 08x \ n", I ); printf ("% P \ n", * (DWORD *) (DWORD) & argc)-4); printf ("% P \ n ", * (DWORD *) (DWORD) & I) + 8); Return 0 ;}
See the following debugging diagram at a Glance:
Three methods to print the return address value of the main function (old EIP) (usage, you know !)