Advertisement
Guest User

Untitled

a guest
Apr 21st, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. ignoring your edits for now; you said you were hooking this, yes ? here's a more comprehensive example that I hope answers your questions:
  2.  
  3. [CODE]typedef int(__stdcall* someFunc_p)(int index, int array, int something); //declare original function prototype, this may not actually work as the correct prototype as there is no way to define your function
  4. someFunc_p someFunc_o; // _p and _o refer to 'prototype' and 'original', respectively.
  5.  
  6. __declspec(naked) void someFunc_hk() // this is your hook function that the program you are disassembling calls
  7. {
  8. __asm
  9. {
  10. push ebp
  11. mov ebp, esp
  12. push dword ptr[ebp + 0x04] // 'something'
  13. push ebx // 'array'
  14. push eax // 'index'
  15. call someFunc_o // here we call our original
  16. leave
  17. ret
  18. }
  19. }
  20.  
  21. int main() // just imagine this is where you perform your 'hook'
  22. {
  23. //...
  24.  
  25. someFunc_o = (someFunc_p)0x12345678; // setting the address of the original function call
  26.  
  27. //...
  28. }
  29.  
  30. [/CODE]
  31.  
  32. I am not 100% on this, so give it a try, but again I haven't been in this situation before and I cannot test this without the program you are working with..
  33.  
  34. now, if your function still crashes using the assembly I provided, then I cannot tell you exactly how to fix it, as I can't see your disassembly.
  35.  
  36. but what I can tell you is that if you are getting the incorrect values as you said in your edit, then either the asm we are defining here is not accurate OR, like hollow has said above, IDA is being silly and not decompiling correctly. :p
  37.  
  38. hope this helps. maybe send some disassembly shots if you still can't get it to work.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement