[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()
{
AntiCheat::UninstallLibHook();
LibUnlocker _;
// Initialize directx
Utils::Hook::Call<void()>(0x5078C0)();
AntiCheat::InstallLibHook();
}
void AntiCheat::SoundInitStub(int a1, int a2, int a3)
{
AntiCheat::UninstallLibHook();
LibUnlocker _;
Game::SND_Init(a1, a2, a3);
AntiCheat::InstallLibHook();
}
void AntiCheat::SoundInitDriverStub()
{
AntiCheat::UninstallLibHook();
LibUnlocker _;
Game::SND_InitDriver();
AntiCheat::InstallLibHook();
}
void AntiCheat::LostD3DStub()
{
AntiCheat::UninstallLibHook();
LibUnlocker _;
// Reset directx
Utils::Hook::Call<void()>(0x508070)();
AntiCheat::InstallLibHook();
}
__declspec(naked) void AntiCheat::CinematicStub()

View File

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

View File

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