2017-01-20 08:36:52 -05:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
#ifndef DEBUG
|
|
|
|
// Hide AntiCheat in embeded symbol names
|
|
|
|
#define AntiCheat SubComponent
|
2017-06-23 04:04:43 -04:00
|
|
|
#else
|
2017-06-28 15:30:00 -04:00
|
|
|
# ifndef DISABLE_ANTICHEAT
|
|
|
|
# define DISABLE_ANTICHEAT
|
|
|
|
# endif
|
2017-01-19 16:23:59 -05:00
|
|
|
#endif
|
|
|
|
|
2017-01-26 14:41:39 -05:00
|
|
|
// Uncomment to enable process protection (conflicts with steam!)
|
2017-01-27 16:04:26 -05:00
|
|
|
#define PROCTECT_PROCESS
|
2017-01-26 14:41:39 -05:00
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
namespace Components
|
|
|
|
{
|
|
|
|
class AntiCheat : public Component
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AntiCheat();
|
|
|
|
~AntiCheat();
|
|
|
|
|
2018-05-10 11:24:03 -04:00
|
|
|
class LibUnlocker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LibUnlocker()
|
|
|
|
{
|
|
|
|
UninstallLibHook();
|
|
|
|
}
|
|
|
|
~LibUnlocker()
|
|
|
|
{
|
|
|
|
InstallLibHook();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
static void CrashClient();
|
|
|
|
|
|
|
|
static void InitLoadLibHook();
|
|
|
|
|
|
|
|
static void ReadIntegrityCheck();
|
|
|
|
static void ScanIntegrityCheck();
|
|
|
|
static void FlagIntegrityCheck();
|
|
|
|
|
2017-03-04 07:51:41 -05:00
|
|
|
static unsigned long ProtectProcess();
|
|
|
|
|
2017-03-26 14:41:37 -04:00
|
|
|
static void PatchVirtualProtect(void* vp, void* vpex);
|
2017-06-10 14:24:42 -04:00
|
|
|
static void PatchThreadCreation();
|
|
|
|
|
|
|
|
static void VerifyThreadIntegrity();
|
2017-03-26 14:41:37 -04:00
|
|
|
|
2017-06-14 06:06:04 -04:00
|
|
|
static void QuickCodeScanner1();
|
|
|
|
static void QuickCodeScanner2();
|
2017-06-11 15:24:32 -04:00
|
|
|
|
2017-07-02 07:41:31 -04:00
|
|
|
static void UninstallLibHook();
|
|
|
|
static void InstallLibHook();
|
|
|
|
|
2019-01-06 13:56:06 -05:00
|
|
|
static void CheckStartupTime();
|
|
|
|
static void SystemTimeDiff(LPSYSTEMTIME stA, LPSYSTEMTIME stB, LPSYSTEMTIME stC);
|
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
private:
|
|
|
|
enum IntergrityFlag
|
|
|
|
{
|
|
|
|
NO_FLAG = (0),
|
|
|
|
INITIALIZATION = (1 << 0),
|
|
|
|
MEMORY_SCAN = (1 << 1),
|
|
|
|
SCAN_INTEGRITY_CHECK = (1 << 2),
|
2017-01-26 14:41:39 -05:00
|
|
|
|
|
|
|
#ifdef PROCTECT_PROCESS
|
2017-01-19 16:23:59 -05:00
|
|
|
READ_INTEGRITY_CHECK = (1 << 3),
|
2017-01-26 14:41:39 -05:00
|
|
|
#endif
|
2017-01-19 16:23:59 -05:00
|
|
|
|
|
|
|
MAX_FLAG,
|
|
|
|
};
|
|
|
|
|
|
|
|
static Utils::Time::Interval LastCheck;
|
|
|
|
static unsigned long Flags;
|
|
|
|
|
|
|
|
static void PerformScan();
|
|
|
|
static void PatchWinAPI();
|
|
|
|
|
|
|
|
static void NullSub();
|
|
|
|
|
2017-03-26 14:41:37 -04:00
|
|
|
static bool IsPageChangeAllowed(void* callee, void* addr, size_t len);
|
2017-01-19 16:23:59 -05:00
|
|
|
static void AssertCalleeModule(void* callee);
|
|
|
|
|
|
|
|
#ifdef DEBUG_LOAD_LIBRARY
|
2017-02-13 12:32:07 -05:00
|
|
|
static HANDLE LoadLibary(std::wstring library, HANDLE file, DWORD flags, void* callee);
|
2017-01-19 16:23:59 -05:00
|
|
|
static HANDLE WINAPI LoadLibaryAStub(const char* library);
|
|
|
|
static HANDLE WINAPI LoadLibaryWStub(const wchar_t* library);
|
2017-02-13 12:32:07 -05:00
|
|
|
static HANDLE WINAPI LoadLibaryExAStub(const char* library, HANDLE file, DWORD flags);
|
|
|
|
static HANDLE WINAPI LoadLibaryExWStub(const wchar_t* library, HANDLE file, DWORD flags);
|
2017-01-19 16:23:59 -05:00
|
|
|
#endif
|
|
|
|
|
2017-03-26 14:41:37 -04:00
|
|
|
static BOOL WINAPI VirtualProtectStub(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
|
2017-06-14 06:06:04 -04:00
|
|
|
static BOOL WINAPI VirtualProtectExStub(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
|
2017-03-26 14:41:37 -04:00
|
|
|
|
2017-01-19 16:23:59 -05:00
|
|
|
static void LostD3DStub();
|
|
|
|
static void CinematicStub();
|
|
|
|
static void SoundInitStub(int a1, int a2, int a3);
|
|
|
|
static void SoundInitDriverStub();
|
|
|
|
|
|
|
|
static void DObjGetWorldTagPosStub();
|
|
|
|
static void AimTargetGetTagPosStub();
|
|
|
|
|
2017-06-29 18:41:15 -04:00
|
|
|
static void AcquireDebugPrivilege(HANDLE hToken);
|
2017-03-04 07:51:41 -05:00
|
|
|
|
2017-06-10 14:24:42 -04:00
|
|
|
static NTSTATUS NTAPI NtCreateThreadExStub(PHANDLE hThread, ACCESS_MASK desiredAccess, LPVOID objectAttributes, HANDLE processHandle, LPTHREAD_START_ROUTINE startAddress, LPVOID parameter, BOOL createSuspended, DWORD stackZeroBits, DWORD sizeOfStackCommit, DWORD sizeOfStackReserve, LPVOID bytesBuffer);
|
|
|
|
static int ValidateThreadTermination(void* addr);
|
|
|
|
static void ThreadEntryPointStub();
|
|
|
|
|
|
|
|
static std::mutex ThreadMutex;
|
|
|
|
static std::vector<DWORD> OwnThreadIds;
|
|
|
|
static std::map<DWORD, std::shared_ptr<Utils::Hook>> ThreadHookMap;
|
|
|
|
|
|
|
|
static Utils::Hook CreateThreadHook;
|
|
|
|
static Utils::Hook LoadLibHook[6];
|
2017-03-26 14:41:37 -04:00
|
|
|
static Utils::Hook VirtualProtectHook[2];
|
2017-01-19 16:23:59 -05:00
|
|
|
};
|
|
|
|
}
|
2019-01-06 13:56:06 -05:00
|
|
|
|