C++ mid-function hook: get register values and jump back [x86 assembly on windows] -


there int value in register ebp , string in ebx. need values these registers in own function, operations on them , jump code below.

ollydbg jmp start

i jmp @ 0x46aa17 function called jmphook.

 void jmphook()  {       char *mystring;       _asm mov mystring, ebx        printf("value: %s", mystring);        _asm       {           jmp       [0x46aa87]       }   } 

as can see, trying move string @ ebx mystring , @ end jump 0x46aa87 located lines below jmp jmphook.

printf being called , mystring being output seems untidy in ollydbg. unable ebp it's being overwritten @ beginning of jmphook(saw in ollydbg). jmp @ end of jmphook not work: ollydbg error

so question how jump own function, save 2 registers there in variables , after operations jump original code.

thank you!

you can value of last ebp stack.

it first value pushed on stack when call function. if not mistaken @ [ebp].

as jump, can make instead of jumping hook, call it? after function returns code continue next address.

the reason getting error because never reach end of function. function contains prologue , epilogue, stack pointers saved , retrieved.

prologue:

push ebp mov  ebp, esp 

epilogue:

pop ebp 

since never reach end of function, pop not called, , stack corrupted.

the error getting jump because jumping location pointed memory in address 0x46aa87. wanted jump address, brackets unnecessary.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -