Bitwise operator patching
This commit is contained in:
parent
3d10c578e0
commit
0bbdba60f3
@ -5,8 +5,7 @@ namespace Components
|
|||||||
void Console::ToggleConsole()
|
void Console::ToggleConsole()
|
||||||
{
|
{
|
||||||
// possibly cls.keyCatchers?
|
// possibly cls.keyCatchers?
|
||||||
DWORD catcher = 0xB2C538;
|
Utils::Hook::Xor<DWORD>(0xB2C538, 1);
|
||||||
Utils::Hook::Set<DWORD>(catcher, Utils::Hook::Get<DWORD>(catcher) ^ 1);
|
|
||||||
|
|
||||||
// g_consoleField
|
// g_consoleField
|
||||||
Game::Field_Clear((void*)0xA1B6B0);
|
Game::Field_Clear((void*)0xA1B6B0);
|
||||||
|
@ -116,16 +116,16 @@ namespace Components
|
|||||||
Dvar::Dvar()
|
Dvar::Dvar()
|
||||||
{
|
{
|
||||||
// set flags of cg_drawFPS to archive
|
// set flags of cg_drawFPS to archive
|
||||||
*(BYTE*)0x4F8F69 |= Game::dvar_flag::DVAR_FLAG_SAVED;
|
Utils::Hook::Or<BYTE>(0x4F8F69, Game::dvar_flag::DVAR_FLAG_SAVED);
|
||||||
|
|
||||||
// un-cheat cg_fov and add archive flags
|
// un-cheat cg_fov and add archive flags
|
||||||
*(BYTE*)0x4F8E35 ^= Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED;
|
Utils::Hook::Xor<BYTE>(0x4F8E35, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED);
|
||||||
|
|
||||||
// set cg_fov max to 90.0
|
// set cg_fov max to 90.0
|
||||||
static float cgFov90 = 90.0f;
|
static float cgFov90 = 90.0f;
|
||||||
*(DWORD*)0x4F8E28 = (DWORD)&cgFov90;
|
Utils::Hook::Set<float*>(0x4F8E28, &cgFov90);
|
||||||
|
|
||||||
Dvar::Var::Register<bool>("zob", true, Game::dvar_flag::DVAR_FLAG_NONE, "test dvar");
|
//Dvar::Var::Register<bool>("zob", true, Game::dvar_flag::DVAR_FLAG_NONE, "test dvar");
|
||||||
//Dvar::Var::Register<const char*>("zob2", "test", Game::dvar_flag::DVAR_FLAG_NONE, "test dvar3");
|
//Dvar::Var::Register<const char*>("zob2", "test", Game::dvar_flag::DVAR_FLAG_NONE, "test dvar3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "STDInclude.hpp"
|
#include "STDInclude.hpp"
|
||||||
|
|
||||||
Utils::Hook EntryPointHook;
|
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
|
static Utils::Hook EntryPointHook;
|
||||||
|
|
||||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
@ -16,6 +17,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
|
|||||||
EntryPointHook.Uninstall();
|
EntryPointHook.Uninstall();
|
||||||
Components::Loader::Initialize();
|
Components::Loader::Initialize();
|
||||||
__asm jmp EntryPointHook.Place
|
__asm jmp EntryPointHook.Place
|
||||||
|
|
||||||
}))->Install();
|
}))->Install();
|
||||||
}
|
}
|
||||||
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
|
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
|
||||||
|
@ -36,6 +36,39 @@ namespace Utils
|
|||||||
return Set<T>((void*)place, value);
|
return Set<T>((void*)place, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> static void Xor(void* place, T value)
|
||||||
|
{
|
||||||
|
*(T*)place ^= value;
|
||||||
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> static void Xor(DWORD place, T value)
|
||||||
|
{
|
||||||
|
return Xor<T>((void*)place, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> static void Or(void* place, T value)
|
||||||
|
{
|
||||||
|
*(T*)place |= value;
|
||||||
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> static void Or(DWORD place, T value)
|
||||||
|
{
|
||||||
|
return Or<T>((void*)place, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> static void And(void* place, T value)
|
||||||
|
{
|
||||||
|
*(T*)place &= value;
|
||||||
|
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> static void And(DWORD place, T value)
|
||||||
|
{
|
||||||
|
return And<T>((void*)place, value);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> static T Get(void* place)
|
template <typename T> static T Get(void* place)
|
||||||
{
|
{
|
||||||
return *(T*)place;
|
return *(T*)place;
|
||||||
|
Loading…
Reference in New Issue
Block a user