|
|
@ -28,6 +28,34 @@ int32_t enforceBindingsID = 413080;
|
|
|
|
|
|
|
|
|
|
|
|
std::string fun_prolog = "\x55\x8B\xEC\x83\xEC\x10";
|
|
|
|
std::string fun_prolog = "\x55\x8B\xEC\x83\xEC\x10";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef HWND (WINAPI *GETFOREGROUNDWINDOW)();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GETFOREGROUNDWINDOW fGetForegroundWindow = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HWND WINAPI DetourGetForegroundWindow()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
HWND gloscHWND = FindWindow(nullptr, L"GloSC_OverlayWindow");
|
|
|
|
|
|
|
|
return gloscHWND;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
|
|
inline MH_STATUS MH_CreateHookEx(LPVOID pTarget, LPVOID pDetour, T** ppOriginal)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return MH_CreateHook(pTarget, pDetour, reinterpret_cast<LPVOID*>(ppOriginal));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
|
|
inline MH_STATUS MH_CreateHookApiEx(
|
|
|
|
|
|
|
|
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, T** ppOriginal)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return MH_CreateHookApi(
|
|
|
|
|
|
|
|
pszModule, pszProcName, pDetour, reinterpret_cast<LPVOID*>(ppOriginal));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////// CODE ///////////////////////////////////////////
|
|
|
|
////////////////////////////////// CODE ///////////////////////////////////////////
|
|
|
|
__declspec(naked) void generalized_hookFn()
|
|
|
|
__declspec(naked) void generalized_hookFn()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -92,6 +120,30 @@ void EnforceBindings::Unpatch()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EnforceBindings::patchLizard()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Initialize MinHook.
|
|
|
|
|
|
|
|
if (MH_Initialize() != MH_OK)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create a hook for GetActiveWindow, in disabled state.
|
|
|
|
|
|
|
|
if (MH_CreateHookApiEx(L"user32", "GetForegroundWindow", &DetourGetForegroundWindow, &fGetForegroundWindow) != MH_OK)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Enable the hook for GetActiveWindow.
|
|
|
|
|
|
|
|
if (MH_EnableHook(&GetForegroundWindow) != MH_OK)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EnforceBindings::unpatchLizard()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (MH_DisableHook(&GetForegroundWindow) != MH_OK)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Uninitialize MinHook.
|
|
|
|
|
|
|
|
if (MH_Uninitialize() != MH_OK)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//places a jmp instruction to a __declspec(naked) function on a given adress
|
|
|
|
//places a jmp instruction to a __declspec(naked) function on a given adress
|
|
|
|
//nops the rest of bytes to don't break any instructions
|
|
|
|
//nops the rest of bytes to don't break any instructions
|
|
|
|