Protect .text segment
This commit is contained in:
parent
6fdf7f887a
commit
daa87d2a50
@ -51,8 +51,7 @@ namespace Components
|
|||||||
lastCheck = Game::Com_Milliseconds();
|
lastCheck = Game::Com_Milliseconds();
|
||||||
|
|
||||||
// Get base module
|
// Get base module
|
||||||
const uint8_t* module = reinterpret_cast<const uint8_t*>(GetModuleHandle(NULL));
|
std::string hash = Utils::Cryptography::SHA512::Compute(reinterpret_cast<uint8_t*>(GetModuleHandle(NULL)) + 0x1000, 0x2D6000, false);
|
||||||
std::string hash = Utils::Cryptography::SHA512::Compute(module + 0x1000, 0x2D6000, false);
|
|
||||||
|
|
||||||
// Set the hash, if none is set
|
// Set the hash, if none is set
|
||||||
if (AntiCheat::Hash.empty())
|
if (AntiCheat::Hash.empty())
|
||||||
|
@ -206,7 +206,7 @@ namespace Components
|
|||||||
Colors::Colors()
|
Colors::Colors()
|
||||||
{
|
{
|
||||||
// Disable SV_UpdateUserinfo_f, to block changing the name ingame
|
// Disable SV_UpdateUserinfo_f, to block changing the name ingame
|
||||||
*(BYTE*)0x6258D0 = 0xC3;
|
Utils::Hook::Set<BYTE>(0x6258D0, 0xC3);
|
||||||
|
|
||||||
// Allow colored names ingame
|
// Allow colored names ingame
|
||||||
Utils::Hook(0x5D8B40, Colors::ClientUserinfoChanged, HOOK_JUMP).Install()->Quick();
|
Utils::Hook(0x5D8B40, Colors::ClientUserinfoChanged, HOOK_JUMP).Install()->Quick();
|
||||||
|
@ -43,7 +43,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
|
|||||||
}
|
}
|
||||||
|
|
||||||
DWORD oldProtect;
|
DWORD oldProtect;
|
||||||
VirtualProtect(GetModuleHandle(NULL), 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect);
|
uint8_t* module = reinterpret_cast<uint8_t*>(GetModuleHandle(NULL));
|
||||||
|
VirtualProtect(module, 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect); // Unprotect the entire process
|
||||||
|
VirtualProtect(module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment
|
||||||
|
|
||||||
Main::EntryPointHook.Initialize(0x6BAC0F, [] ()
|
Main::EntryPointHook.Initialize(0x6BAC0F, [] ()
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,13 @@ namespace Utils
|
|||||||
|
|
||||||
void Hook::Nop(void* place, size_t length)
|
void Hook::Nop(void* place, size_t length)
|
||||||
{
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(place, length, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
|
||||||
memset(place, 0x90, length);
|
memset(place, 0x90, length);
|
||||||
|
|
||||||
|
VirtualProtect(place, length, oldProtect, &oldProtect);
|
||||||
|
FlushInstructionCache(GetCurrentProcess(), place, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hook::Nop(DWORD place, size_t length)
|
void Hook::Nop(DWORD place, size_t length)
|
||||||
|
@ -49,7 +49,12 @@ namespace Utils
|
|||||||
|
|
||||||
template <typename T> static void Set(void* place, T value)
|
template <typename T> static void Set(void* place, T value)
|
||||||
{
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(place, sizeof(T), PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
|
||||||
*static_cast<T*>(place) = value;
|
*static_cast<T*>(place) = value;
|
||||||
|
|
||||||
|
VirtualProtect(place, sizeof(T), oldProtect, &oldProtect);
|
||||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +65,12 @@ namespace Utils
|
|||||||
|
|
||||||
template <typename T> static void Xor(void* place, T value)
|
template <typename T> static void Xor(void* place, T value)
|
||||||
{
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(place, sizeof(T), PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
|
||||||
*static_cast<T*>(place) ^= value;
|
*static_cast<T*>(place) ^= value;
|
||||||
|
|
||||||
|
VirtualProtect(place, sizeof(T), oldProtect, &oldProtect);
|
||||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +81,12 @@ namespace Utils
|
|||||||
|
|
||||||
template <typename T> static void Or(void* place, T value)
|
template <typename T> static void Or(void* place, T value)
|
||||||
{
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(place, sizeof(T), PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
|
||||||
*static_cast<T*>(place) |= value;
|
*static_cast<T*>(place) |= value;
|
||||||
|
|
||||||
|
VirtualProtect(place, sizeof(T), oldProtect, &oldProtect);
|
||||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +97,12 @@ namespace Utils
|
|||||||
|
|
||||||
template <typename T> static void And(void* place, T value)
|
template <typename T> static void And(void* place, T value)
|
||||||
{
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(place, sizeof(T), PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
|
||||||
*static_cast<T*>(place) &= value;
|
*static_cast<T*>(place) &= value;
|
||||||
|
|
||||||
|
VirtualProtect(place, sizeof(T), oldProtect, &oldProtect);
|
||||||
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user