2021-12-30 17:20:41 +01:00
|
|
|
#include "core/stdafx.h"
|
|
|
|
#include "windows/system.h"
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
typedef BOOL(WINAPI* IGetVersionExA)(_Inout_ LPOSVERSIONINFOA lpVersionInformation);
|
|
|
|
static IGetVersionExA g_oGetVersionExA = nullptr;
|
|
|
|
|
|
|
|
//#############################################################################
|
|
|
|
// SYSTEM HOOKS
|
|
|
|
//#############################################################################
|
|
|
|
|
|
|
|
BOOL WINAPI HGetVersionExA(_Inout_ LPOSVERSIONINFOA lpVersionInformation)
|
|
|
|
{
|
|
|
|
#ifdef DEDICATED
|
2022-03-16 02:03:06 +01:00
|
|
|
// Return false for dedicated to skip 'SetProcessDpiAwareness' in 'CEngineAPI:OnStartup()'.
|
2021-12-30 17:20:41 +01:00
|
|
|
return NULL;
|
|
|
|
#else
|
|
|
|
return g_oGetVersionExA(lpVersionInformation);
|
|
|
|
#endif // DEDICATED
|
|
|
|
}
|
|
|
|
|
|
|
|
//#############################################################################
|
|
|
|
// MANAGEMENT
|
|
|
|
//#############################################################################
|
|
|
|
|
|
|
|
void WinSys_Init()
|
|
|
|
{
|
|
|
|
g_oGetVersionExA = (IGetVersionExA)DetourFindFunction("KERNEL32.dll", "GetVersionExA");
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinSys_Attach()
|
|
|
|
{
|
|
|
|
WinSys_Init();
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
DetourTransactionBegin();
|
|
|
|
DetourUpdateThread(GetCurrentThread());
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
DetourAttach(&(LPVOID&)g_oGetVersionExA, (PBYTE)HGetVersionExA);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
DetourTransactionCommit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinSys_Detach()
|
|
|
|
{
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
DetourTransactionBegin();
|
|
|
|
DetourUpdateThread(GetCurrentThread());
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
DetourDetach(&(LPVOID&)g_oGetVersionExA, (PBYTE)HGetVersionExA);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
DetourTransactionCommit();
|
|
|
|
}
|