0X00 Ring3 Inline Hook 思路
探究Inline Hook中的函数调用过程 实现思路比较简单,主要**:
1、构造跳转指令。
2、在内存中找到欲HOOK函数地址,并保存欲HOOK位置处的前5个字节。(但其实并不一定就是5个字节,像是MessageBox就是6个字节)
3、将构造的跳转指令写入需HOOK的位置处。
4、当被HOOK位置被执行时会转到我们的流程执行。
5、如果要执行原来的流程,那么恢复HOOK,也就是还原被修改的字节。
6、执行函数原来的流程。
在这过程中,主要涉及到几个问题:
1、如何定位自己要hook的地址?
2、如何处理函数开头要替换的字节?
3、如何跳转以及跳转地址如何计算?
4、自己的函数执行完成后,如何跳转回来?
那么带着这几个问题,我们开始尝试实现Inline hook。