Is it possible? Maybe you can explain it with a simple example if that's possible?
2 Answers
The IAT entries point to the function's entry point, so you can try the following:
- Save the current IAT entry value into a variable (e.g.
old_func
). - Patch the IAT entry with the address of your hook function.
- In the hook function, call the old function using
old_func
variable, then perform whatever you need before returning to the caller.
Hooking would be the same in both cases:
- Whether you wanted to manipulate a function's parameters, and then provide them to the original function. In that case the order goes:
- Execute your hook code.
- Call the original function.
- Or call the original function, then manipulate the return results. Order goes:
- Call the original function.
- Execute your hook code.
In both cases the steps will be:
- Store the original function's entry from the IAT.
- Replace the IAT entry with your hook's start address.
- Do whatever you want inside your hook function.
EDIT: Typos and Language.