Jump to content
  • Advertisement
Sign in to follow this  
roby65

[C++ASM] Problem hooking

This topic is 3659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, i'm learning hooking and i have problems with parameters..... code in asm: --- push param call realfunc realfunc: jmp mycode [C++] int _stdcall mycode(int id) { ... } --- now, the problem: id is incorrect, if i push 100 another value is found in id.....why?! i can't find out the problem.... :( edit: _stdcall is because the original asm code wants the return value into eax :)

Share this post


Link to post
Share on other sites
Advertisement
Why aren't you calling mycode(int) directly? I'm pretty sure the problem here is that you are pushing the parameter, then making a call which will push the return address, then jumping (why?) to the function you really want, which will probably then have its own prologue to set up a new stack frame - leaving your desired parameter essentially in the middle of nowhere.

Just

push param
call mycode

Share this post


Link to post
Share on other sites
it's because i have to hook a function that's called in more points of a program, so the "jmp mycode" is into the start of the real function......

Share this post


Link to post
Share on other sites
Quote:
Original post by TheUnbeliever
In that case, I'm guessing the problem is still the stack frame that mycode is setting up. I'm not sure what compiler you're using, but you probably want an equivalent of __declspec(naked).


i tryed to use it, but i get problems getting the parameter.....
maybe there is another declaration specification that i have to use?

Share this post


Link to post
Share on other sites
Quote:
Original post by LessBread
What you think is the parameter might be the original return address.


yes it could be, but the return works well..... (it returns to the point after the call...)

Share this post


Link to post
Share on other sites
Quote:
Original post by LessBread
What you think is the parameter might be the original return address.


OMG it's true, i checked right now.....how to fix this? :(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!