1
0
mirror of https://github.com/Raymonf/whack.git synced 2024-11-27 17:40:48 +01:00

galliumhook: readme, ability to disable wndproc hook

This commit is contained in:
Raymonf 2022-12-17 22:16:10 -05:00
parent 46d9ff33aa
commit 27dc67e8b8
No known key found for this signature in database
GPG Key ID: 438459BF619B037A
2 changed files with 31 additions and 9 deletions

14
galliumhook/README.md Normal file
View File

@ -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.

View File

@ -48,7 +48,6 @@ int CreateHooks()
{ {
OutputDebugStringW(L"[galliumhook] CreateHooks()\r\n"); OutputDebugStringW(L"[galliumhook] CreateHooks()\r\n");
auto base = (uint64_t)GetModuleHandleW(NULL); auto base = (uint64_t)GetModuleHandleW(NULL);
WndProc = (tWndProc)(base + wndProcAddr);
if (MH_Initialize() != MH_OK) if (MH_Initialize() != MH_OK)
{ {
@ -56,17 +55,26 @@ int CreateHooks()
return 0; return 0;
} }
auto createResult = MH_CreateHook(WndProc, &DetourWndProc, reinterpret_cast<LPVOID*>(&fpWndProc)); if (wndProcAddr != 0)
if (createResult != MH_OK)
{ {
MessageBox(NULL, L"Couldn't create WndProc hook", L"galliumhook", MB_OK); OutputDebugStringW(L"[galliumhook] Creating WndProc hook\r\n");
return 0; WndProc = (tWndProc)(base + wndProcAddr);
}
if (MH_EnableHook(WndProc) != MH_OK) if (MH_CreateHook(WndProc, &DetourWndProc, reinterpret_cast<LPVOID*>(&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); OutputDebugStringW(L"[galliumhook] Not creating WndProc hook\r\n");
return 0;
} }
if (MH_CreateHook(&CreateWindowExW, &DetourCreateWindowExW, reinterpret_cast<LPVOID*>(&fpCreateWindowExW)) != MH_OK) if (MH_CreateHook(&CreateWindowExW, &DetourCreateWindowExW, reinterpret_cast<LPVOID*>(&fpCreateWindowExW)) != MH_OK)