[AntiCheat] Introduce LibUnlocker

This commit is contained in:
momo5502 2018-05-10 17:24:03 +02:00
parent 0ac7f39b05
commit 2c3f445f8f
3 changed files with 31 additions and 18 deletions

View File

@ -329,40 +329,30 @@ namespace Components
void AntiCheat::PatchWinAPI() void AntiCheat::PatchWinAPI()
{ {
AntiCheat::UninstallLibHook(); LibUnlocker _;
// Initialize directx // Initialize directx
Utils::Hook::Call<void()>(0x5078C0)(); Utils::Hook::Call<void()>(0x5078C0)();
AntiCheat::InstallLibHook();
} }
void AntiCheat::SoundInitStub(int a1, int a2, int a3) void AntiCheat::SoundInitStub(int a1, int a2, int a3)
{ {
AntiCheat::UninstallLibHook(); LibUnlocker _;
Game::SND_Init(a1, a2, a3); Game::SND_Init(a1, a2, a3);
AntiCheat::InstallLibHook();
} }
void AntiCheat::SoundInitDriverStub() void AntiCheat::SoundInitDriverStub()
{ {
AntiCheat::UninstallLibHook(); LibUnlocker _;
Game::SND_InitDriver(); Game::SND_InitDriver();
AntiCheat::InstallLibHook();
} }
void AntiCheat::LostD3DStub() void AntiCheat::LostD3DStub()
{ {
AntiCheat::UninstallLibHook(); LibUnlocker _;
// Reset directx // Reset directx
Utils::Hook::Call<void()>(0x508070)(); Utils::Hook::Call<void()>(0x508070)();
AntiCheat::InstallLibHook();
} }
__declspec(naked) void AntiCheat::CinematicStub() __declspec(naked) void AntiCheat::CinematicStub()

View File

@ -20,6 +20,19 @@ namespace Components
AntiCheat(); AntiCheat();
~AntiCheat(); ~AntiCheat();
class LibUnlocker
{
public:
LibUnlocker()
{
UninstallLibHook();
}
~LibUnlocker()
{
InstallLibHook();
}
};
static void CrashClient(); static void CrashClient();
static void InitLoadLibHook(); static void InitLoadLibHook();

View File

@ -122,12 +122,22 @@ namespace Utils
} }
void SafeShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd) void SafeShellExecute(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd)
{
#ifndef DISABLE_ANTICHEAT
Components::AntiCheat::LibUnlocker _;
#endif
[=]()
{ {
__try __try
{ {
ShellExecuteA(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd); ShellExecuteA(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd);
} }
__finally {} __finally
{}
}();
std::this_thread::yield();
} }
void OpenUrl(std::string url) void OpenUrl(std::string url)