Sunday 15 April 2012

c++ - How does one pass on parameters in assembly? -



c++ - How does one pass on parameters in assembly? -

im working on hook in c++ , asm , have made easy inline hook places jump in first instruction of target function in case outputdebugstring testing purposes.

the thing hook fianlly works after 3 days of research , figuring out bits , peaces of how things work, there 1 problem have no thought how alter parameters come in "dummy" function before jumping on rest of original function.

as u can see in code have tried alter parameter in c++ of course of study not work im poping registers afterwards :/

anyways here dummy function hooked function jumps to:

static void __declspec(naked) mydebugstring(lpctstr lpoutputstring) { __asm { pushad } //where suppose run code, not able interfere parameters :/ lpoutputstring = l"new message!"; __asm { popad mov edi, edi force ebp mov ebp, esp jmp addr } original_debugstring(lpoutputstring); }

i understand why code not working said, can't see proper solution this, help appreciated.

every compiler has protocol calling functions using assembly language. protocol may stated deep in manuals.

a faster method find function protocols have compiler generate assembly language listing function.

the best method writing inline assembly to:

first write function in c++ source code next print out assembly listing of function. review , understand how compiler generated assembly works. lastly, modify internal assembly suite needs.

my preference write c++ code efficient can (or help compiler utilize optimal assembly language). review assembly listing. alter inline assembly invoke processor special features (such block move instructions).

c++ assembly hook

No comments:

Post a Comment