When I use EasyHook to hook API calls, the first bytes of the hooked API function are replaced with a so called "trampoline" which is a jump into EasyHook code.
For example this is TextOutW in Gdi32.dll disassembled:
Original code in Gdi32.dll for exported function TextOutW()
---------------------------------------------------------------
7daceeb1 8b ff MOV EDI,EDI
7daceeb3 55 PUSH EBP
7daceeb4 8b ec MOV EBP,ESP
7daceeb6 53 PUSH EBX
7daceeb7 56 PUSH ESI
7daceeb8 57 PUSH EDI
7daceeb9 8b 7d 18 MOV EDI,dword ptr [EBP + c]
....
Code modified by Easyhook:
---------------------------------------------------------------
7daceeb1 e9 82 2b 64 8d JMP LAB_0b111a38
7daceeb6 53 PUSH EBX
7daceeb7 56 PUSH ESI
7daceeb8 57 PUSH EDI
7daceeb9 8b 7d 18 MOV EDI,dword ptr [EBP + c]
....
Here you see that the first 5 bytes of the code in Gdi32.dll have been replaced with a JMP instruction.
Each time TextOutW is called, EasyHook will forward the call to my hook function.
But when I use ApiMonitor nothing in the code in Gdi32.dll is modified.
I found that ApiMonitor loads a DLL into the hooked process (Windows Calculator):
The file apimonitor-drv-x86.sys has the wrong file extension. It is not a driver.
I used the API EnumDeviceDrivers() to enumerate all drivers in the system, but apimonitor-drv-x86.sys is not listed as driver.
It is an ordinary DLL as I can prove by loading it into DependencyWalker:
It has 4 exported functions with funny ordinals.
So my question is: How does ApiMonitor hook API calls without modifying the code in the hooked DLL? There must be any magic going on in apimonitor-drv-x86.sys



