Class 07 · KP 11 / 19
MinHook: The Whole Hook in a Few Calls
/* typedef of the target's signature */
typedef int (WINAPI *MBW_t)(HWND,LPCWSTR,LPCWSTR,UINT);
MBW_t real_MessageBoxW = NULL;
int WINAPI hook_MessageBoxW(HWND h, LPCWSTR text,
LPCWSTR cap, UINT type) {
/* observe / modify, then call through */
return real_MessageBoxW(h, L"[hooked]", cap, type);
}
MH_Initialize();
MH_CreateHook(&MessageBoxW, &hook_MessageBoxW,
(LPVOID*)&real_MessageBoxW); /* fills trampoline ptr */
MH_EnableHook(&MessageBoxW);
real_MessageBoxW points at the trampoline — one clean call reaches the genuine API.