diff --git a/galliumhook/README.md b/galliumhook/README.md new file mode 100644 index 0000000..2ba2d76 --- /dev/null +++ b/galliumhook/README.md @@ -0,0 +1,14 @@ +# galliumhook + +Loads `mercuryhook.dll` at startup and then forces created windows to be 1080x1920 regardless of screen resolution (or original size). + +If you want to configure galliumhook without recompiling it, make a file named `galliumhook.toml` and put this in: + +```toml +[window] +width = 1080 +height = 1920 +wndproc = 0x72AE80 +``` + +Note that sane defaults (for 3.07.01 ONLY) will be applied when this config file isn't found. Set wndproc to 0 to disable the WndProc hook. \ No newline at end of file diff --git a/galliumhook/galliumhook/dllmain.cpp b/galliumhook/galliumhook/dllmain.cpp index c97283f..7cd3ae5 100644 --- a/galliumhook/galliumhook/dllmain.cpp +++ b/galliumhook/galliumhook/dllmain.cpp @@ -48,7 +48,6 @@ int CreateHooks() { OutputDebugStringW(L"[galliumhook] CreateHooks()\r\n"); auto base = (uint64_t)GetModuleHandleW(NULL); - WndProc = (tWndProc)(base + wndProcAddr); if (MH_Initialize() != MH_OK) { @@ -56,17 +55,26 @@ int CreateHooks() return 0; } - auto createResult = MH_CreateHook(WndProc, &DetourWndProc, reinterpret_cast(&fpWndProc)); - if (createResult != MH_OK) + if (wndProcAddr != 0) { - MessageBox(NULL, L"Couldn't create WndProc hook", L"galliumhook", MB_OK); - return 0; - } + OutputDebugStringW(L"[galliumhook] Creating WndProc hook\r\n"); + WndProc = (tWndProc)(base + wndProcAddr); - if (MH_EnableHook(WndProc) != MH_OK) + if (MH_CreateHook(WndProc, &DetourWndProc, reinterpret_cast(&fpWndProc)) != MH_OK) + { + MessageBox(NULL, L"Couldn't create WndProc hook", L"galliumhook", MB_OK); + return 0; + } + + if (MH_EnableHook(WndProc) != MH_OK) + { + MessageBox(NULL, L"Couldn't enable WndProc hook", L"galliumhook", MB_OK); + return 0; + } + } + else { - MessageBox(NULL, L"Couldn't enable WndProc hook", L"galliumhook", MB_OK); - return 0; + OutputDebugStringW(L"[galliumhook] Not creating WndProc hook\r\n"); } if (MH_CreateHook(&CreateWindowExW, &DetourCreateWindowExW, reinterpret_cast(&fpCreateWindowExW)) != MH_OK)