feat(Protections): Added freemode_script_recovery
This commit is contained in:
parent
0fe1dd48cb
commit
b34cc84694
@ -8,4 +8,7 @@ namespace big::functions
|
|||||||
using run_script_threads_t = bool(*)(std::uint32_t ops_to_execute);
|
using run_script_threads_t = bool(*)(std::uint32_t ops_to_execute);
|
||||||
using get_native_handler_t = rage::scrNativeHandler(*)(rage::scrNativeRegistrationTable*, rage::scrNativeHash);
|
using get_native_handler_t = rage::scrNativeHandler(*)(rage::scrNativeRegistrationTable*, rage::scrNativeHash);
|
||||||
using fix_vectors_t = void(*)(rage::scrNativeCallContext*);
|
using fix_vectors_t = void(*)(rage::scrNativeCallContext*);
|
||||||
|
|
||||||
|
using gta_thread_tick = __int64(GtaThread* a1, unsigned int a2);
|
||||||
|
using gta_thread_kill = __int64(GtaThread* a1);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,10 @@ namespace big
|
|||||||
m_set_cursor_pos_hook("SetCursorPos", memory::module("user32.dll").get_export("SetCursorPos").as<void*>(), &hooks::set_cursor_pos),
|
m_set_cursor_pos_hook("SetCursorPos", memory::module("user32.dll").get_export("SetCursorPos").as<void*>(), &hooks::set_cursor_pos),
|
||||||
|
|
||||||
m_run_script_threads_hook("Script hook", g_pointers->m_run_script_threads, &hooks::run_script_threads),
|
m_run_script_threads_hook("Script hook", g_pointers->m_run_script_threads, &hooks::run_script_threads),
|
||||||
m_convert_thread_to_fiber_hook("ConvertThreadToFiber", memory::module("kernel32.dll").get_export("ConvertThreadToFiber").as<void*>(), &hooks::convert_thread_to_fiber)
|
m_convert_thread_to_fiber_hook("ConvertThreadToFiber", memory::module("kernel32.dll").get_export("ConvertThreadToFiber").as<void*>(), &hooks::convert_thread_to_fiber),
|
||||||
|
|
||||||
|
m_gta_thread_tick_hook("GTA Thread Tick", g_pointers->m_gta_thread_tick, &hooks::gta_thread_tick),
|
||||||
|
m_gta_thread_kill_hook("GTA Thread Kill", g_pointers->m_gta_thread_kill, &hooks::gta_thread_kill)
|
||||||
{
|
{
|
||||||
m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present);
|
m_swapchain_hook.hook(hooks::swapchain_present_index, &hooks::swapchain_present);
|
||||||
m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers);
|
m_swapchain_hook.hook(hooks::swapchain_resizebuffers_index, &hooks::swapchain_resizebuffers);
|
||||||
@ -63,6 +65,9 @@ namespace big
|
|||||||
m_run_script_threads_hook.enable();
|
m_run_script_threads_hook.enable();
|
||||||
m_convert_thread_to_fiber_hook.enable();
|
m_convert_thread_to_fiber_hook.enable();
|
||||||
|
|
||||||
|
m_gta_thread_kill_hook.enable();
|
||||||
|
m_gta_thread_tick_hook.enable();
|
||||||
|
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +75,9 @@ namespace big
|
|||||||
{
|
{
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
|
|
||||||
|
m_gta_thread_tick_hook.disable();
|
||||||
|
m_gta_thread_kill_hook.disable();
|
||||||
|
|
||||||
m_convert_thread_to_fiber_hook.disable();
|
m_convert_thread_to_fiber_hook.disable();
|
||||||
m_run_script_threads_hook.disable();
|
m_run_script_threads_hook.disable();
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "detour_hook.hpp"
|
#include "detour_hook.hpp"
|
||||||
#include "gta/fwddec.hpp"
|
#include "gta/fwddec.hpp"
|
||||||
|
#include "gta/script_thread.hpp"
|
||||||
#include "script_hook.hpp"
|
#include "script_hook.hpp"
|
||||||
#include "vmt_hook.hpp"
|
#include "vmt_hook.hpp"
|
||||||
|
|
||||||
@ -20,6 +21,9 @@ namespace big
|
|||||||
|
|
||||||
static LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
static LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
static BOOL set_cursor_pos(int x, int y);
|
static BOOL set_cursor_pos(int x, int y);
|
||||||
|
|
||||||
|
static rage::eThreadState gta_thread_tick(GtaThread* a1, unsigned int a2);
|
||||||
|
static rage::eThreadState gta_thread_kill(GtaThread* thread);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct minhook_keepalive
|
struct minhook_keepalive
|
||||||
@ -48,6 +52,9 @@ namespace big
|
|||||||
|
|
||||||
detour_hook m_run_script_threads_hook;
|
detour_hook m_run_script_threads_hook;
|
||||||
detour_hook m_convert_thread_to_fiber_hook;
|
detour_hook m_convert_thread_to_fiber_hook;
|
||||||
|
|
||||||
|
detour_hook m_gta_thread_tick_hook;
|
||||||
|
detour_hook m_gta_thread_kill_hook;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline hooking *g_hooking{};
|
inline hooking *g_hooking{};
|
||||||
|
51
BigBaseV2/src/hooks/freemode_script_recovery.cpp
Normal file
51
BigBaseV2/src/hooks/freemode_script_recovery.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include "hooking.hpp"
|
||||||
|
#include "gta/script_thread.hpp"
|
||||||
|
|
||||||
|
namespace big
|
||||||
|
{
|
||||||
|
using namespace rage;
|
||||||
|
|
||||||
|
static char struct_backup[sizeof(GtaThread)];
|
||||||
|
static char stack_buffer[0xFFFF];
|
||||||
|
static bool freemode_terminated = false;
|
||||||
|
|
||||||
|
eThreadState hooks::gta_thread_tick(GtaThread* thread, unsigned int a2)
|
||||||
|
{
|
||||||
|
eThreadState state = thread->m_context.m_state;
|
||||||
|
|
||||||
|
if (thread->m_script_hash == RAGE_JOAAT("freemode") && state == eThreadState::running && !freemode_terminated)
|
||||||
|
{
|
||||||
|
memcpy(struct_backup, (void*)thread, sizeof(GtaThread));
|
||||||
|
if (thread->m_stack)
|
||||||
|
memcpy(stack_buffer, thread->m_stack, thread->m_context.m_stack_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
eThreadState result = g_hooking->m_gta_thread_tick_hook.get_original<decltype(>a_thread_tick)>()(thread, a2);
|
||||||
|
|
||||||
|
if (thread->m_script_hash == RAGE_JOAAT("freemode"))
|
||||||
|
{
|
||||||
|
if (result == eThreadState::killed && state == eThreadState::running && !freemode_terminated)
|
||||||
|
{
|
||||||
|
result = eThreadState::running;
|
||||||
|
|
||||||
|
memcpy(thread, struct_backup, sizeof(GtaThread));
|
||||||
|
if (thread->m_stack)
|
||||||
|
memcpy(thread->m_stack, stack_buffer, thread->m_context.m_stack_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freemode_terminated) freemode_terminated = !(result == eThreadState::running);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
eThreadState hooks::gta_thread_kill(GtaThread* thread)
|
||||||
|
{
|
||||||
|
eThreadState result = g_hooking->m_gta_thread_kill_hook.get_original<decltype(>a_thread_kill)>()(thread);
|
||||||
|
|
||||||
|
if (thread->m_script_hash == RAGE_JOAAT("freemode"))
|
||||||
|
freemode_terminated = !(result == eThreadState::running);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -112,6 +112,16 @@ namespace big
|
|||||||
|
|
||||||
memset(incompatible_version, 0x90, 0x1E);
|
memset(incompatible_version, 0x90, 0x1E);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
main_batch.add("Thread Tick", "48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 80 B9 ? ? ? ? ? 8B FA 48 8B D9 74 05", [this](memory::handle ptr)
|
||||||
|
{
|
||||||
|
m_gta_thread_tick = ptr.as<decltype(m_gta_thread_tick)>();
|
||||||
|
});
|
||||||
|
|
||||||
|
main_batch.add("Thread Kill", "48 89 5C 24 ? 57 48 83 EC 20 48 83 B9 ? ? ? ? ? 48 8B D9 74 14", [this](memory::handle ptr)
|
||||||
|
{
|
||||||
|
m_gta_thread_kill = ptr.as<decltype(m_gta_thread_kill)>();
|
||||||
|
});
|
||||||
|
|
||||||
main_batch.run(memory::module(nullptr));
|
main_batch.run(memory::module(nullptr));
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ namespace big
|
|||||||
std::vector<PVOID> m_event_ptr;
|
std::vector<PVOID> m_event_ptr;
|
||||||
unsigned char m_event_restore[event_count];
|
unsigned char m_event_restore[event_count];
|
||||||
char* m_event_register;
|
char* m_event_register;
|
||||||
|
|
||||||
|
functions::gta_thread_tick* m_gta_thread_tick{};
|
||||||
|
functions::gta_thread_kill* m_gta_thread_kill{};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline pointers *g_pointers{};
|
inline pointers *g_pointers{};
|
||||||
|
Reference in New Issue
Block a user