MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / HookLoadLibrary

Function HookLoadLibrary

emmy_hook/src/emmy_hook.windows.cpp:276–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void HookLoadLibrary()
277{
278 HMODULE hModuleKernel = GetModuleHandle("KernelBase.dll");
279 if (hModuleKernel == nullptr)
280 hModuleKernel = GetModuleHandle("kernel32.dll");
281 if (hModuleKernel != nullptr)
282 {
283 // LoadLibraryExW is called by the other LoadLibrary functions, so we
284 // only need to hook it.
285
286 // TODO hook!!!
287 LoadLibraryExW_dll = (LoadLibraryExW_t)GetProcAddress(hModuleKernel, "LoadLibraryExW");
288
289 // destroy these functions.
290 const auto hHook = new HOOK_TRACE_INFO();
291 ULONG ACLEntries[1] = {0};
292 HOOK_STATUS status = LhInstallHook(
293 (void*)LoadLibraryExW_dll,
294 (void*)LoadLibraryExW_intercept,
295 (PVOID)nullptr,
296 hHook);
297 assert(status == 0);
298 status = LhSetExclusiveACL(ACLEntries, 0, hHook);
299 assert(status == 0);
300 }
301}
302
303void redirect(int port)
304{

Callers 1

FindAndHookFunction · 0.85

Calls 2

LhInstallHookFunction · 0.85
LhSetExclusiveACLFunction · 0.85

Tested by

no test coverage detected