2023-12-29 16:07:00 +00:00
|
|
|
#include "hooking/hooking.hpp"
|
2022-12-18 01:00:04 +01:00
|
|
|
#include "pointers.hpp"
|
2023-11-30 04:47:39 -05:00
|
|
|
#include "security/ObfVar.hpp"
|
2023-06-14 21:29:25 +00:00
|
|
|
#include <Psapi.h>
|
|
|
|
|
2022-12-18 01:00:04 +01:00
|
|
|
namespace big
|
|
|
|
{
|
2023-11-30 04:47:39 -05:00
|
|
|
bool inline is_address_in_game_region(int64_t address)
|
2023-06-14 21:29:25 +00:00
|
|
|
{
|
2024-04-22 19:48:22 +02:00
|
|
|
if(!address) [[unlikely]]
|
2023-11-30 04:47:39 -05:00
|
|
|
return false;
|
|
|
|
static int64_t moduleBase = NULL;
|
|
|
|
static int64_t moduleSize = NULL;
|
2024-04-22 19:48:22 +02:00
|
|
|
if (!moduleBase || !moduleSize) [[unlikely]]
|
2023-06-14 21:29:25 +00:00
|
|
|
{
|
|
|
|
MODULEINFO info;
|
|
|
|
if (!GetModuleInformation(GetCurrentProcess(), GetModuleHandle(0), &info, sizeof(info)))
|
|
|
|
{
|
|
|
|
LOG(FATAL) << "GetModuleInformation failed!";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-30 04:47:39 -05:00
|
|
|
moduleBase = (int64_t)GetModuleHandle(0);
|
|
|
|
moduleSize = (int64_t)info.SizeOfImage;
|
2023-06-14 21:29:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return address > moduleBase && address < (moduleBase + moduleSize);
|
|
|
|
}
|
|
|
|
|
2023-11-30 04:47:39 -05:00
|
|
|
struct ac_verifier
|
2023-06-14 21:29:25 +00:00
|
|
|
{
|
2023-11-30 04:47:39 -05:00
|
|
|
virtual ~ac_verifier() = 0;
|
|
|
|
virtual bool run() = 0;
|
|
|
|
rage::Obf32 m_last_time; // 0x8
|
|
|
|
rage::Obf32 m_delay; // 0x18
|
|
|
|
};
|
2023-06-14 21:29:25 +00:00
|
|
|
|
2023-11-30 04:47:39 -05:00
|
|
|
bool is_unwanted_dependency(int64_t cb)
|
2023-06-14 21:29:25 +00:00
|
|
|
{
|
2023-11-30 04:47:39 -05:00
|
|
|
int64_t f1 = *reinterpret_cast<int64_t*>(cb + 0x60);
|
|
|
|
int64_t f2 = *reinterpret_cast<int64_t*>(cb + 0x100);
|
|
|
|
int64_t f3 = *reinterpret_cast<int64_t*>(cb + 0x1A0);
|
|
|
|
|
2024-04-22 19:48:22 +02:00
|
|
|
if (!is_address_in_game_region(f1) || !is_address_in_game_region(f2) || !is_address_in_game_region(f3)) [[likely]]
|
2023-11-30 04:47:39 -05:00
|
|
|
return false;
|
2023-06-14 21:29:25 +00:00
|
|
|
|
2024-04-22 19:48:22 +02:00
|
|
|
if(*reinterpret_cast<uint8_t*>(f1) != 0xE9) [[likely]]
|
2023-06-14 21:29:25 +00:00
|
|
|
return false;
|
|
|
|
|
2023-11-30 04:47:39 -05:00
|
|
|
return true;
|
2023-06-14 21:29:25 +00:00
|
|
|
}
|
|
|
|
|
2023-11-19 22:20:15 +00:00
|
|
|
static bool nullsub()
|
2023-03-01 21:27:15 +00:00
|
|
|
{
|
2023-11-19 22:20:15 +00:00
|
|
|
return true; // returning false would cause the dependency to requeue
|
|
|
|
}
|
2023-09-12 20:19:24 +02:00
|
|
|
|
2023-11-30 04:47:39 -05:00
|
|
|
int hooks::queue_dependency(void* a1, int a2, int64_t dependency)
|
2023-11-19 22:20:15 +00:00
|
|
|
{
|
2024-04-22 19:48:22 +02:00
|
|
|
if (is_unwanted_dependency(dependency)) [[unlikely]]
|
2023-03-01 21:27:15 +00:00
|
|
|
{
|
2024-04-22 19:48:22 +02:00
|
|
|
LOG(INFO) << "Blocking AC Verifier " << HEX_TO_UPPER(*reinterpret_cast<int64_t*>(dependency + 0x60) - reinterpret_cast<int64_t>(GetModuleHandle(NULL)));
|
2023-11-30 04:47:39 -05:00
|
|
|
ac_verifier* verifier = reinterpret_cast<ac_verifier*>(dependency - 0x30);
|
|
|
|
verifier->m_delay = INT_MAX; // makes it so these won't queue in the future
|
|
|
|
*reinterpret_cast<void**>(dependency + 0x60) = nullsub;
|
|
|
|
*reinterpret_cast<void**>(dependency + 0x100) = nullsub;
|
|
|
|
*reinterpret_cast<void**>(dependency + 0x1A0) = nullsub;
|
2023-03-01 21:27:15 +00:00
|
|
|
}
|
2022-12-18 01:00:04 +01:00
|
|
|
|
2023-11-19 22:20:15 +00:00
|
|
|
return g_hooking->get_original<hooks::queue_dependency>()(a1, a2, dependency);
|
2023-03-01 21:27:15 +00:00
|
|
|
}
|
2022-12-18 01:00:04 +01:00
|
|
|
}
|