Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include "MinHook.h"
- #if defined _M_X64
- #pragma comment(lib, "libMinHook.x64.lib")
- #elif defined _M_IX86
- #pragma comment(lib, "libMinHook.x86.lib")
- #endif
- // Foo detour function
- void WINAPI DetourFunc()
- {
- MH_DisableHook(LoadLibraryExW);
- MessageBox(NULL, "HOOKED: Exiting" ,"HOOKED", MB_OK);
- ExitProcess(0);
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
- {
- void *pFoo;
- // Initialize MinHook
- if (MH_Initialize() != MH_OK)
- {
- return 1;
- }
- if (MH_CreateHook(LoadLibraryExW, &DetourFunc,
- (void**)(&pFoo)) != MH_OK)
- {
- return 1;
- }
- if (MH_EnableHook(LoadLibraryExW) != MH_OK)
- {
- return 1;
- }
- LoadLibraryExW(L"blah", NULL, 0);
- __debugbreak(); // shouldn't reach here
- return 0; // suppress a warning
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement