2019-03-21 20:18:31 +01:00
# include "pointers.hpp"
2023-03-01 21:27:15 +00:00
# include "common.hpp"
# include "hooking.hpp"
2019-03-21 20:18:31 +01:00
# include "memory/all.hpp"
2022-11-25 22:29:03 +01:00
# include "rage/atSingleton.hpp"
# include "security/RageSecurity.hpp"
2019-03-21 20:18:31 +01:00
2023-03-01 21:27:15 +00:00
extern " C " void sound_overload_detour ( ) ;
2022-12-30 09:45:04 +08:00
std : : uint64_t g_sound_overload_ret_addr ;
2019-03-21 20:18:31 +01:00
namespace big
{
2023-04-06 20:01:23 +02:00
bool pointers : : is_pointers_cache_up_to_date ( memory : : batch & version_batch , const memory : : module & mem_region )
{
if ( version_batch . run ( mem_region ) )
{
m_pointers_cache . load ( ) ;
if ( m_pointers_cache . up_to_date ( m_game_version_uint32_t , m_online_version_float ) )
{
LOG ( INFO ) < < " Pointers cache is up to date, using it. " ;
return true ;
}
}
else
{
LOG ( WARNING ) < < " Failed to find version patterns. Can't utilize pointers cache. " ;
}
return false ;
}
// TODO: ideally the `ptr` in the lambdas should be stored in separate fields than the memory::byte_patch (ideally you'd move those memory::byte_patch away from the pointers class...)
// So that the ptrs could be cached
void pointers : : always_run_main_batch ( const memory : : module & mem_region )
{
memory : : batch main_batch ;
// Max Wanted Level
main_batch . add ( " MWL " , " 8B 43 6C 89 05 " , [ this ] ( memory : : handle ptr ) {
m_max_wanted_level = memory : : byte_patch : : make ( ptr . add ( 5 ) . rip ( ) . as < uint32_t * > ( ) , 0 ) . get ( ) ;
m_max_wanted_level_2 = memory : : byte_patch : : make ( ptr . add ( 14 ) . rip ( ) . as < uint32_t * > ( ) , 0 ) . get ( ) ;
} ) ;
// Blame Explode
main_batch . add ( " BE " , " 0F 85 ? ? ? ? 48 8B 05 ? ? ? ? 48 8B 48 08 E8 " , [ this ] ( memory : : handle ptr ) {
m_blame_explode = memory : : byte_patch : : make ( ptr . as < std : : uint16_t * > ( ) , 0xE990 ) . get ( ) ;
} ) ;
//Patch blocked explosions
main_batch . add ( " EP " , " E8 ? ? ? ? 48 8D 4C 24 20 E8 ? ? ? ? 4C 8D 9C 24 80 01 00 00 " , [ this ] ( memory : : handle ptr ) {
m_explosion_patch = memory : : byte_patch : : make ( ptr . sub ( 12 ) . as < uint16_t * > ( ) , 0x9090 ) . get ( ) ;
} ) ;
// Is Matchmaking Session Valid
main_batch . add ( " IMSV " , " 48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 54 41 55 41 56 41 57 48 83 EC 20 45 0F " , [ this ] ( memory : : handle ptr ) {
memory : : byte_patch : : make ( ptr . as < void * > ( ) , std : : to_array ( { 0xB0 , 0x01 , 0xC3 } ) ) - > apply ( ) ; // has no observable side effects
} ) ;
// Broadcast Net Array Patch
main_batch . add ( " BP " , " 74 73 FF 90 ? ? ? ? 8B D5 4C 8B 00 48 8B C8 41 FF 50 30 " , [ this ] ( memory : : handle ptr ) {
m_broadcast_patch = memory : : byte_patch : : make ( ptr . as < uint8_t * > ( ) , 0xEB ) . get ( ) ;
} ) ;
// Creator Warp Cheat Triggered Patch
main_batch . add ( " CW " , " 74 44 E8 ? ? ? ? 80 65 2B F8 48 8D 0D ? ? ? ? 48 89 4D 17 48 89 7D 1F 89 7D 27 C7 45 " , [ ] ( memory : : handle ptr ) {
memory : : byte_patch : : make ( ptr . as < uint8_t * > ( ) , 0xEB ) - > apply ( ) ;
} ) ;
// NTQVM Caller
main_batch . add ( " NTQVMC " , " 66 0F 6F 0D ? ? ? ? 66 0F 6F 05 ? ? ? ? 66 0F 66 C4 " , [ this ] ( memory : : handle ptr ) {
memory : : byte_patch : : make ( ptr . add ( 4 ) . rip ( ) . sub ( 32 ) . as < uint64_t * > ( ) , ( uint64_t ) & hooks : : nt_query_virtual_memory )
- > apply ( ) ;
} ) ;
// Sound Overload Detour
main_batch . add ( " SOD " , " 66 45 3B C1 74 38 " , [ this ] ( memory : : handle ptr ) {
g_sound_overload_ret_addr = ptr . add ( 13 + 15 ) . as < decltype ( g_sound_overload_ret_addr ) > ( ) ;
std : : vector < byte > bytes = { 0xFF , 0x25 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x90 } ; // far jump opcode + a nop opcode
* ( void * * ) ( bytes . data ( ) + 6 ) = sound_overload_detour ;
memory : : byte_patch : : make ( ptr . add ( 13 ) . as < void * > ( ) , bytes ) - > apply ( ) ;
} ) ;
// Disable Collision
main_batch . add ( " DC " , " 48 8B D1 49 8B CA ? ? ? ? ? 48 8B D1 49 8B CA " , [ this ] ( memory : : handle ptr ) {
m_disable_collision = memory : : byte_patch : : make ( ptr . sub ( 2 ) . as < uint8_t * > ( ) , 0xEB ) . get ( ) ;
} ) ;
// Crash Trigger
main_batch . add ( " CT " , " 48 3B F8 74 ? 8B 1D " , [ this ] ( memory : : handle ptr ) {
memory : : byte_patch : : make ( ptr . add ( 4 ) . as < uint8_t * > ( ) , 0x00 ) - > apply ( ) ;
} ) ;
if ( ! main_batch . run ( mem_region ) )
{
throw std : : runtime_error ( " Failed to find some patterns. " ) ;
}
}
void pointers : : run_cacheable_main_batch ( const memory : : module & mem_region )
2019-03-21 20:18:31 +01:00
{
2022-08-07 20:15:09 +08:00
memory : : batch main_batch ;
2019-03-21 20:18:31 +01:00
2023-03-01 21:27:15 +00:00
main_batch . add ( " SCREEN_RESOLUTION " , " 66 0F 6E 0D ? ? ? ? 0F B7 3D " , [ this ] ( memory : : handle ptr ) {
2022-03-31 00:21:05 +02:00
m_resolution_x = ptr . sub ( 4 ) . rip ( ) . as < int * > ( ) ;
m_resolution_y = ptr . add ( 4 ) . rip ( ) . as < int * > ( ) ;
} ) ;
2023-02-04 00:00:56 +01:00
// Region Code
2023-03-01 21:27:15 +00:00
main_batch . add ( " RC " , " 48 83 EC 28 83 3D ? ? ? ? ? 75 10 " , [ this ] ( memory : : handle ptr ) {
2023-02-04 00:00:56 +01:00
m_region_code = ptr . add ( 16 ) . rip ( ) . add ( 1 ) . as < uint32_t * > ( ) ;
2022-11-12 07:13:01 +08:00
} ) ;
2021-07-23 00:47:27 +02:00
// Game State
2023-03-01 21:27:15 +00:00
main_batch . add ( " GS " , " 83 3D ? ? ? ? ? 75 17 8B 43 20 25 " , [ this ] ( memory : : handle ptr ) {
2023-04-02 00:37:26 +08:00
m_game_state = ptr . add ( 2 ) . rip ( ) . add ( 1 ) . as < eGameState * > ( ) ;
2019-03-21 20:18:31 +01:00
} ) ;
2023-03-01 21:27:15 +00:00
// Is Session Started
main_batch . add ( " ISA " , " 40 38 35 ? ? ? ? 75 0E 4C 8B C3 49 8B D7 49 8B CE " , [ this ] ( memory : : handle ptr ) {
2019-03-21 20:18:31 +01:00
m_is_session_started = ptr . add ( 3 ) . rip ( ) . as < bool * > ( ) ;
} ) ;
2021-07-23 00:47:27 +02:00
// Ped Factory
2023-03-01 21:27:15 +00:00
main_batch . add ( " PF " , " 48 8B 05 ? ? ? ? 48 8B 48 08 48 85 C9 74 52 8B 81 " , [ this ] ( memory : : handle ptr ) {
2019-03-21 20:18:31 +01:00
m_ped_factory = ptr . add ( 3 ) . rip ( ) . as < CPedFactory * * > ( ) ;
} ) ;
2021-07-23 00:47:27 +02:00
// Network Player Manager
2023-03-01 21:27:15 +00:00
main_batch . add ( " NPM " , " 48 8B 0D ? ? ? ? 8A D3 48 8B 01 FF 50 ? 4C 8B 07 48 8B CF " , [ this ] ( memory : : handle ptr ) {
2019-03-21 20:18:31 +01:00
m_network_player_mgr = ptr . add ( 3 ) . rip ( ) . as < CNetworkPlayerMgr * * > ( ) ;
} ) ;
2023-02-15 04:18:18 +08:00
// Init Native Tables & Native Handlers
2023-03-01 21:27:15 +00:00
main_batch . add ( " NH " , " 48 8D 0D ? ? ? ? 48 8B 14 FA E8 ? ? ? ? 48 85 C0 75 0A " , [ this ] ( memory : : handle ptr ) {
m_init_native_tables = ptr . sub ( 37 ) . as < PVOID > ( ) ;
2019-03-21 20:18:31 +01:00
m_native_registration_table = ptr . add ( 3 ) . rip ( ) . as < rage : : scrNativeRegistrationTable * > ( ) ;
2023-03-01 21:27:15 +00:00
m_get_native_handler = ptr . add ( 12 ) . rip ( ) . as < functions : : get_native_handler > ( ) ;
2019-03-21 20:18:31 +01:00
} ) ;
2021-07-23 00:47:27 +02:00
// Fix Vectors
2023-03-01 21:27:15 +00:00
main_batch . add ( " FV " , " 83 79 18 00 48 8B D1 74 4A FF 4A 18 48 63 4A 18 48 8D 41 04 48 8B 4C CA " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_fix_vectors = ptr . as < functions : : fix_vectors > ( ) ;
2019-03-21 20:18:31 +01:00
} ) ;
2021-07-23 00:47:27 +02:00
// Script Threads
2023-03-01 21:27:15 +00:00
main_batch . add ( " ST " , " 45 33 F6 8B E9 85 C9 B8 " , [ this ] ( memory : : handle ptr ) {
m_script_threads = ptr . sub ( 4 ) . rip ( ) . sub ( 8 ) . as < decltype ( m_script_threads ) > ( ) ;
2022-07-05 16:54:45 -04:00
m_run_script_threads = ptr . sub ( 0x1F ) . as < functions : : run_script_threads > ( ) ;
2019-03-21 20:18:31 +01:00
} ) ;
2021-07-23 00:47:27 +02:00
// Script Programs
2023-03-01 21:27:15 +00:00
main_batch . add ( " SP " , " 48 8B 1D ? ? ? ? 41 83 F8 FF " , [ this ] ( memory : : handle ptr ) {
2022-06-24 00:23:07 +02:00
m_script_program_table = ptr . add ( 3 ) . rip ( ) . as < decltype ( m_script_program_table ) > ( ) ;
2019-03-21 20:18:31 +01:00
} ) ;
2021-07-23 00:47:27 +02:00
// Script Global
2023-03-01 21:27:15 +00:00
main_batch . add ( " SG " , " 48 8D 15 ? ? ? ? 4C 8B C0 E8 ? ? ? ? 48 85 FF 48 89 1D " , [ this ] ( memory : : handle ptr ) {
2019-03-21 20:18:31 +01:00
m_script_globals = ptr . add ( 3 ) . rip ( ) . as < std : : int64_t * * > ( ) ;
} ) ;
2021-07-23 00:47:27 +02:00
// Game Script Handle Manager
2023-03-01 21:27:15 +00:00
main_batch . add ( " CGSHM " , " 48 8B 0D ? ? ? ? 4C 8B CE E8 ? ? ? ? 48 85 C0 74 05 40 32 FF " , [ this ] ( memory : : handle ptr ) {
2019-03-21 20:18:31 +01:00
m_script_handler_mgr = ptr . add ( 3 ) . rip ( ) . as < CGameScriptHandlerMgr * * > ( ) ;
} ) ;
2021-07-23 00:47:27 +02:00
// Swapchain
2023-03-01 21:27:15 +00:00
main_batch . add ( " S " , " 48 8B 0D ? ? ? ? 48 8B 01 44 8D 43 01 33 D2 FF 50 40 8B C8 " , [ this ] ( memory : : handle ptr ) {
2019-03-21 20:18:31 +01:00
m_swapchain = ptr . add ( 3 ) . rip ( ) . as < IDXGISwapChain * * > ( ) ;
} ) ;
2022-09-20 14:51:43 +02:00
// World Model Spawn Bypass
2023-03-01 21:27:15 +00:00
main_batch . add ( " WMSB " , " 48 85 C0 0F 84 ? ? ? ? 8B 48 50 " , [ this ] ( memory : : handle ptr ) {
2022-09-20 14:51:43 +02:00
m_world_model_spawn_bypass = ptr . as < PVOID > ( ) ;
} ) ;
2021-07-23 00:47:27 +02:00
// Native Return Spoofer
2023-03-01 21:27:15 +00:00
main_batch . add ( " NRF " , " FF E3 " , [ this ] ( memory : : handle ptr ) {
2021-05-18 23:03:42 +02:00
m_native_return = ptr . add ( 0 ) . as < PVOID > ( ) ;
2020-12-26 17:35:05 +01:00
} ) ;
2021-05-19 00:07:13 +02:00
2022-01-21 23:08:00 +01:00
// GTA Thread Start
2023-03-01 21:27:15 +00:00
main_batch . add ( " GTS " , " 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 8B FA 85 D2 75 2A 8B 15 " , [ this ] ( memory : : handle ptr ) {
2022-01-21 23:08:00 +01:00
m_gta_thread_start = ptr . as < PVOID > ( ) ;
} ) ;
2022-05-18 23:17:57 +02:00
// GTA Thread Kill
2023-03-01 21:27:15 +00:00
main_batch . add ( " TK " , " 48 89 5C 24 ? 57 48 83 EC 20 48 83 B9 ? ? ? ? ? 48 8B D9 74 14 " , [ this ] ( memory : : handle ptr ) {
2022-01-21 23:08:00 +01:00
m_gta_thread_kill = ptr . as < PVOID > ( ) ;
2021-05-19 00:41:55 +02:00
} ) ;
2021-05-19 16:19:38 +02:00
2021-07-23 00:47:27 +02:00
// Trigger Script Event
2023-03-01 21:27:15 +00:00
main_batch . add ( " TSE " , " 45 8B F0 41 8B F9 48 8B EA " , [ this ] ( memory : : handle ptr ) {
2022-06-24 00:23:07 +02:00
m_trigger_script_event = ptr . sub ( 0x1C ) . as < decltype ( m_trigger_script_event ) > ( ) ;
2021-05-21 00:59:09 +02:00
} ) ;
2021-05-25 12:58:33 +02:00
// Received Event Signatures START
2022-09-20 14:51:43 +02:00
2021-07-23 00:47:27 +02:00
// Received Event Hook
2023-03-01 21:27:15 +00:00
main_batch . add ( " REH " , " 66 41 83 F9 ? 0F 83 " , [ this ] ( memory : : handle ptr ) {
2021-05-25 12:58:33 +02:00
m_received_event = ptr . as < decltype ( m_received_event ) > ( ) ;
} ) ;
2022-07-05 16:54:45 -04:00
// Send Event Acknowledge
2023-03-01 21:27:15 +00:00
main_batch . add ( " SEA " , " E8 ? ? ? ? 66 83 7B 08 5B " , [ this ] ( memory : : handle ptr ) {
2023-02-09 01:03:54 +03:00
m_send_event_ack = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_send_event_ack ) > ( ) ;
2022-07-05 16:54:45 -04:00
} ) ;
2022-07-24 16:52:30 -04:00
2022-07-05 16:54:45 -04:00
// Received Event Signatures END
2022-07-24 16:52:30 -04:00
// Read Bitbuffer WORD/DWORD
2023-03-01 21:27:15 +00:00
main_batch . add ( " RBWD " , " 48 89 74 24 ? 57 48 83 EC 20 48 8B D9 33 C9 41 8B F0 8A " , [ this ] ( memory : : handle ptr ) {
2021-05-25 12:58:33 +02:00
m_read_bitbuf_dword = ptr . sub ( 5 ) . as < decltype ( m_read_bitbuf_dword ) > ( ) ;
} ) ;
2021-07-23 00:47:27 +02:00
// Read Bitbuffer Array
2023-03-01 21:27:15 +00:00
main_batch . add ( " RBA " , " 48 89 5C 24 ? 57 48 83 EC 30 41 8B F8 4C " , [ this ] ( memory : : handle ptr ) {
2021-05-25 12:58:33 +02:00
m_read_bitbuf_array = ptr . as < decltype ( m_read_bitbuf_array ) > ( ) ;
} ) ;
2022-07-05 16:54:45 -04:00
// Read Bitbuffer String
2023-03-01 21:27:15 +00:00
main_batch . add ( " RBS " , " E8 ? ? ? ? 48 8D 4F 3C " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_read_bitbuf_string = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_read_bitbuf_string ) > ( ) ;
} ) ;
// Read Bitbuffer Boolean
2023-03-01 21:27:15 +00:00
main_batch . add ( " RBB " , " E8 ? ? ? ? 84 C0 74 41 48 8D 56 2C " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_read_bitbuf_bool = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_read_bitbuf_bool ) > ( ) ;
} ) ;
// Write Bitbuffer WORD/DWORD
2023-03-01 21:27:15 +00:00
main_batch . add ( " WBD " , " 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 83 EC 20 8B EA BF 01 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_write_bitbuf_dword = ptr . as < decltype ( m_write_bitbuf_dword ) > ( ) ;
} ) ;
// Write Bitbuffer QWORD
2023-03-01 21:27:15 +00:00
main_batch . add ( " WBQ " , " 48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 41 8B F0 48 8B EA 48 8B D9 41 83 F8 20 " , [ this ] ( memory : : handle ptr ) {
m_write_bitbuf_qword = ptr . as < decltype ( m_write_bitbuf_qword ) > ( ) ;
2022-07-05 16:54:45 -04:00
} ) ;
// Write Bitbuffer Int64
2023-03-01 21:27:15 +00:00
main_batch . add ( " WBI64 " , " E8 ? ? ? ? 8A 53 39 48 8B CF " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_write_bitbuf_int64 = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_write_bitbuf_int64 ) > ( ) ;
} ) ;
// Write Bitbuffer Int32
2023-03-01 21:27:15 +00:00
main_batch . add ( " WBI32 " , " E8 ? ? ? ? 8A 53 74 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_write_bitbuf_int32 = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_write_bitbuf_int32 ) > ( ) ;
} ) ;
// Write Bitbuffer Boolean
2023-03-01 21:27:15 +00:00
main_batch . add ( " WBB " , " E8 ? ? ? ? 8A 57 39 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_write_bitbuf_bool = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_write_bitbuf_bool ) > ( ) ;
} ) ;
// Write Bitbuffer Array
2023-03-01 21:27:15 +00:00
main_batch . add ( " WBA " , " E8 ? ? ? ? 01 7E 08 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_write_bitbuf_array = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_write_bitbuf_array ) > ( ) ;
2021-05-25 12:58:33 +02:00
} ) ;
2021-05-26 00:14:28 +02:00
2022-10-29 05:54:32 -04:00
// Write Player Game State Data Node
2023-03-01 21:27:15 +00:00
main_batch . add ( " WPGSDN " , " 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 54 41 55 41 56 41 57 48 83 EC 30 0F B7 81 " , [ this ] ( memory : : handle ptr ) {
2022-10-29 05:54:32 -04:00
m_write_player_game_state_data_node = ptr . as < functions : : write_player_game_state_data_node > ( ) ;
} ) ;
2021-08-05 23:06:47 +02:00
// Replay Interface
2023-03-01 21:27:15 +00:00
main_batch . add ( " RI " , " 0F B7 44 24 ? 66 89 44 4E " , [ this ] ( memory : : handle ptr ) {
2022-07-27 14:39:22 +02:00
m_replay_interface = ptr . add ( 0x1F ) . rip ( ) . as < rage : : CReplayInterface * * > ( ) ;
2021-08-05 23:06:47 +02:00
} ) ;
2022-11-23 06:12:40 +08:00
// Ptr To Handle
2023-03-01 21:27:15 +00:00
main_batch . add ( " PTH " , " 48 8B F9 48 83 C1 10 33 DB " , [ this ] ( memory : : handle ptr ) {
2022-06-24 00:23:07 +02:00
m_ptr_to_handle = ptr . sub ( 0x15 ) . as < decltype ( m_ptr_to_handle ) > ( ) ;
2021-08-05 23:06:47 +02:00
} ) ;
2021-08-08 10:19:04 +02:00
2022-11-23 06:12:40 +08:00
// Handle To Ptr
2023-03-01 21:27:15 +00:00
main_batch . add ( " GSH " , " 83 F9 FF 74 31 4C 8B 0D " , [ this ] ( memory : : handle ptr ) {
2022-11-23 06:12:40 +08:00
m_handle_to_ptr = ptr . as < decltype ( m_handle_to_ptr ) > ( ) ;
2022-10-18 15:08:05 -04:00
} ) ;
2022-01-25 02:55:35 +01:00
// CNetworkObjectMgr
2023-03-01 21:27:15 +00:00
main_batch . add ( " CNOM " , " 48 8B 0D ? ? ? ? 45 33 C0 E8 ? ? ? ? 33 FF 4C 8B F0 " , [ this ] ( memory : : handle ptr ) {
2022-01-25 02:55:35 +01:00
m_network_object_mgr = ptr . add ( 3 ) . rip ( ) . as < CNetworkObjectMgr * * > ( ) ;
} ) ;
2022-05-28 17:44:05 +02:00
// Network Player Mgr Init
2023-03-01 21:27:15 +00:00
main_batch . add ( " NPMI " , " 41 56 48 83 EC ? 48 8B F1 B9 ? ? ? ? 49 8B F9 41 8B E8 4C 8B F2 E8 " , [ this ] ( memory : : handle ptr ) {
2022-05-28 17:44:05 +02:00
m_network_player_mgr_init = ptr . sub ( 0x13 ) . as < decltype ( m_network_player_mgr_init ) > ( ) ;
} ) ;
2022-01-31 18:27:35 +01:00
// Network Player Mgr Shutdown
2023-03-01 21:27:15 +00:00
main_batch . add ( " NPMS " , " 48 8D 9F ? ? ? ? EB ? 48 8B 13 48 85 D2 74 ? 48 8B CB E8 ? ? ? ? 48 83 7B ? ? 75 ? 48 8D 9F " , [ this ] ( memory : : handle ptr ) {
2022-05-28 17:44:05 +02:00
m_network_player_mgr_shutdown = ptr . sub ( 0x1A ) . as < decltype ( m_network_player_mgr_shutdown ) > ( ) ;
2022-01-31 18:27:35 +01:00
} ) ;
2022-02-18 17:44:32 +01:00
2022-03-16 15:55:27 +01:00
// FriendRegistry
2023-03-01 21:27:15 +00:00
main_batch . add ( " FR " , " 3B 0D ? ? ? ? 73 17 " , [ this ] ( memory : : handle ptr ) {
2022-02-18 17:44:32 +01:00
m_friend_registry = ptr . add ( 2 ) . rip ( ) . as < FriendRegistry * > ( ) ;
} ) ;
2022-03-09 00:03:14 +01:00
2022-03-16 15:55:27 +01:00
// GET_SCREEN_COORDS_FROM_WORLD_COORDS
2023-03-01 21:27:15 +00:00
main_batch . add ( " GSCFWC " , " E8 ? ? ? ? 84 C0 74 19 F3 0F 10 44 24 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_get_screen_coords_for_world_coords = ptr . add ( 1 ) . rip ( ) . as < functions : : get_screen_coords_for_world_coords > ( ) ;
2022-03-16 00:04:09 +01:00
} ) ;
2022-03-09 00:03:14 +01:00
2022-07-24 16:52:30 -04:00
// GET_GAMEPLAY_CAM_COORDS
2023-03-01 21:27:15 +00:00
main_batch . add ( " GGCC " , " 8B 90 ? ? ? ? 89 13 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 16:54:45 -04:00
m_get_gameplay_cam_coords = ptr . sub ( 0xE ) . as < functions : : get_gameplay_cam_coords > ( ) ;
2022-03-16 00:04:09 +01:00
} ) ;
2022-03-09 00:03:14 +01:00
2022-07-03 00:03:07 +02:00
// Give Pickup Reward
2023-03-01 21:27:15 +00:00
main_batch . add ( " GPR " , " 48 8B C8 33 C0 48 85 C9 74 0A 44 8B C3 8B D7 E8 " , [ this ] ( memory : : handle ptr ) {
2022-07-03 00:03:07 +02:00
m_give_pickup_rewards = ptr . sub ( 0x28 ) . as < decltype ( m_give_pickup_rewards ) > ( ) ;
} ) ;
2022-10-06 13:30:04 +02:00
// Write Player Gamer Data Node
2023-03-01 21:27:15 +00:00
main_batch . add ( " WPGDN " , " 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 81 C1 ? ? ? ? 48 8B DA E8 " , [ this ] ( memory : : handle ptr ) {
2022-10-06 13:30:04 +02:00
m_write_player_gamer_data_node = ptr . as < PVOID > ( ) ;
} ) ;
2022-07-24 16:52:30 -04:00
// Receive Net Message
2023-03-01 21:27:15 +00:00
main_batch . add ( " RNM " , " 48 83 EC 20 4C 8B 71 50 33 ED " , [ this ] ( memory : : handle ptr ) {
2022-06-24 00:23:07 +02:00
m_receive_net_message = ptr . sub ( 0x19 ) . as < PVOID > ( ) ;
2022-05-20 18:17:41 -04:00
} ) ;
2022-07-24 16:52:30 -04:00
// Get Network Event Data
2023-03-01 21:27:15 +00:00
main_batch . add ( " GNED " , " 53 43 52 49 50 54 5F 4E 45 54 57 4F 52 4B " , [ this ] ( memory : : handle ptr ) {
2022-08-09 14:39:55 -04:00
m_get_network_event_data = * ptr . sub ( 0x38 ) . as < PVOID * > ( ) ;
} ) ;
// Assign Physical Index
2023-03-01 21:27:15 +00:00
main_batch . add ( " API " , " 48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 41 54 41 55 41 56 41 57 48 83 EC 20 41 8A E8 " , [ this ] ( memory : : handle ptr ) {
2022-08-09 14:39:55 -04:00
m_assign_physical_index = ptr . as < PVOID > ( ) ;
2022-05-20 18:17:41 -04:00
} ) ;
2022-11-19 01:49:36 +00:00
// Received Clone Create
2023-03-01 21:27:15 +00:00
main_batch . add ( " RCC " , " 48 8B C4 66 44 89 48 " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_received_clone_create = ptr . as < PVOID > ( ) ;
} ) ;
// Can Apply Data
2023-03-01 21:27:15 +00:00
main_batch . add ( " CAD " , " E8 ? ? ? ? 84 C0 0F 84 AF 01 00 00 48 8B 03 " , [ this ] ( memory : : handle ptr ) {
2022-12-14 16:27:40 +00:00
m_can_apply_data = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
2022-11-19 01:49:36 +00:00
} ) ;
2022-07-24 16:52:30 -04:00
// Received clone sync & Get sync tree for type & Get net object for player & Get sync type info & Get net object
2023-03-01 21:27:15 +00:00
main_batch . add ( " RCS/GSTFT/GNOFP/GNO/GSTI " , " 4C 8B FA 41 0F B7 D1 " , [ this ] ( memory : : handle ptr ) {
2022-06-24 00:23:07 +02:00
m_received_clone_sync = ptr . sub ( 0x1D ) . as < decltype ( m_received_clone_sync ) > ( ) ;
2023-03-13 17:10:21 -04:00
m_get_sync_tree_for_type = ptr . add ( 0x14 ) . rip ( ) . as < decltype ( m_get_sync_tree_for_type ) > ( ) ; // 0F B7 CA 83 F9 07 .as()
m_get_net_object = ptr . add ( 0x76 ) . rip ( ) . as < decltype ( m_get_net_object ) > ( ) ; // E8 ? ? ? ? 0F B7 53 7C .add(1).rip().as()
m_get_sync_type_info = ptr . add ( 0x8C ) . rip ( ) . as < decltype ( m_get_sync_type_info ) > ( ) ; // 44 0F B7 C1 4C 8D 0D .as()
2022-06-03 15:14:26 +02:00
} ) ;
2022-05-23 00:31:21 +02:00
2022-11-10 19:21:38 -05:00
// Read Bitbuffer Into Sync Tree
2023-03-01 21:27:15 +00:00
main_batch . add ( " RBIST " , " E8 ? ? ? ? 48 8B BC 24 B0 00 00 00 " , [ this ] ( memory : : handle ptr ) {
2022-11-10 19:21:38 -05:00
m_read_bitbuffer_into_sync_tree = ptr . add ( 1 ) . rip ( ) . as < functions : : read_bitbuffer_into_sync_tree > ( ) ;
} ) ;
2022-07-05 11:11:16 +02:00
// Model Hash Table
2023-03-01 21:27:15 +00:00
main_batch . add ( " MHT " , " 4C 03 05 ? ? ? ? EB 03 " , [ this ] ( memory : : handle ptr ) {
2022-07-05 11:11:16 +02:00
m_model_table = ptr . add ( 3 ) . rip ( ) . as < HashTable < CBaseModelInfo * > * > ( ) ;
} ) ;
2023-02-21 06:20:40 +08:00
// Get Model Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " GMI " , " 41 3B 0A 74 54 " , [ this ] ( memory : : handle ptr ) {
2023-02-21 06:20:40 +08:00
m_get_model_info = ptr . sub ( 46 ) . as < PVOID > ( ) ;
} ) ;
2022-07-29 14:32:02 +02:00
// Get Label Text
2023-03-01 21:27:15 +00:00
main_batch . add ( " GLT " , " 75 ? E8 ? ? ? ? 8B 0D ? ? ? ? 65 48 8B 04 25 ? ? ? ? BA ? ? ? ? 48 8B 04 C8 8B 0C 02 D1 E9 " , [ this ] ( memory : : handle ptr ) {
2022-07-29 14:32:02 +02:00
m_get_label_text = ptr . sub ( 19 ) . as < PVOID > ( ) ;
} ) ;
2023-03-01 21:27:15 +00:00
2022-10-26 15:38:01 -04:00
// Multiplayer chat filter
2023-03-01 21:27:15 +00:00
main_batch . add ( " MCF " , " E8 ? ? ? ? 83 F8 FF 75 B9 " , [ this ] ( memory : : handle ptr ) {
2023-01-17 15:22:39 -05:00
m_check_chat_profanity = ptr . add ( 1 ) . rip ( ) . as < decltype ( m_check_chat_profanity ) > ( ) ;
2022-10-26 15:38:01 -04:00
} ) ;
2022-07-29 14:32:02 +02:00
2022-09-12 18:44:47 +00:00
// Network
2023-03-01 21:27:15 +00:00
main_batch . add ( " N " , " 48 8B 0D ? ? ? ? 48 8B D7 E8 ? ? ? ? 84 C0 75 17 48 8B 0D ? ? ? ? 48 8B D7 " , [ this ] ( memory : : handle ptr ) {
2022-09-12 18:44:47 +00:00
m_network = ptr . add ( 3 ) . rip ( ) . as < Network * * > ( ) ;
} ) ;
// Reset Network Complaints
2023-03-01 21:27:15 +00:00
main_batch . add ( " RENC " , " E8 ? ? ? ? 8B 8B ? ? ? ? 03 CF " , [ this ] ( memory : : handle ptr ) {
2022-09-12 18:44:47 +00:00
m_reset_network_complaints = ptr . add ( 1 ) . rip ( ) . as < functions : : reset_network_complaints > ( ) ;
} ) ;
2022-10-19 00:30:32 +02:00
// fiDevice Get Device
2023-03-01 21:27:15 +00:00
main_batch . add ( " FDGD " , " 41 B8 07 00 00 00 48 8B F1 E8 " , [ this ] ( memory : : handle ptr ) {
2022-10-19 00:30:32 +02:00
m_fidevice_get_device = ptr . sub ( 0x1F ) . as < functions : : fidevice_get_device > ( ) ;
} ) ;
// fiDevices
2023-03-01 21:27:15 +00:00
main_batch . add ( " FDS " , " 74 1B 48 8D 0D ? ? ? ? 41 8B D6 " , [ this ] ( memory : : handle ptr ) {
m_fidevices = ptr . add ( 5 ) . rip ( ) . as < uintptr_t > ( ) ;
2022-10-19 00:30:32 +02:00
m_fidevices_len = ptr . add ( 5 ) . rip ( ) . add ( 8 ) . as < uint16_t * > ( ) ;
} ) ;
// fiPackfile ctor
2023-03-01 21:27:15 +00:00
main_batch . add ( " FPFC " , " 44 89 41 28 4C 89 41 38 4C 89 41 50 48 8D " , [ this ] ( memory : : handle ptr ) {
m_fipackfile_ctor = ptr . sub ( 0x1E ) . as < functions : : fipackfile_ctor > ( ) ;
2022-10-19 00:30:32 +02:00
m_fipackfile_instances = ptr . add ( 26 ) . rip ( ) . as < rage : : fiPackfile * * > ( ) ;
} ) ;
// fiPackfile open archive
2023-03-01 21:27:15 +00:00
main_batch . add ( " FPFOA " , " 48 8D 68 98 48 81 EC 40 01 00 00 41 8B F9 " , [ this ] ( memory : : handle ptr ) {
2022-10-19 00:30:32 +02:00
m_fipackfile_open_archive = ptr . sub ( 0x18 ) . as < functions : : fipackfile_open_archive > ( ) ;
} ) ;
// fiPackfile mount
2023-03-01 21:27:15 +00:00
main_batch . add ( " FPFM " , " 84 C0 74 1D 48 85 DB 74 0F 48 " , [ this ] ( memory : : handle ptr ) {
2022-10-19 00:30:32 +02:00
m_fipackfile_mount = ptr . sub ( 0x1E ) . as < functions : : fipackfile_mount > ( ) ;
} ) ;
// fiPackfile unmount
2023-03-01 21:27:15 +00:00
main_batch . add ( " FPFUM " , " E8 ? ? ? ? 84 C0 74 37 80 3D " , [ this ] ( memory : : handle ptr ) {
2022-10-19 00:30:32 +02:00
m_fipackfile_unmount = ptr . add ( 1 ) . rip ( ) . as < functions : : fipackfile_unmount > ( ) ;
} ) ;
2022-11-12 04:01:10 +08:00
// Invalid Mods Crash Detour
2023-03-01 21:27:15 +00:00
main_batch . add ( " IMCD " , " E8 ? ? ? ? 40 88 7C 24 ? 49 89 9C 24 " , [ this ] ( memory : : handle ptr ) {
2022-11-12 04:01:10 +08:00
m_invalid_mods_crash_detour = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
2022-11-14 23:37:38 +08:00
// Send Chat Ptr
2023-03-01 21:27:15 +00:00
main_batch . add ( " SCP " , " 83 7E 1C 01 48 8B 3D " , [ this ] ( memory : : handle ptr ) {
2023-02-28 19:45:55 +01:00
m_send_chat_ptr = ptr . add ( 7 ) . rip ( ) . as < int64_t * * > ( ) ;
2022-11-14 23:37:38 +08:00
} ) ;
// Send Chat Message
2023-03-01 21:27:15 +00:00
main_batch . add ( " SCM " , " 48 83 EC 20 48 8B F1 48 8B CA 41 8A E9 " , [ this ] ( memory : : handle ptr ) {
2022-11-14 23:37:38 +08:00
m_send_chat_message = ptr . sub ( 21 ) . as < functions : : send_chat_message > ( ) ;
} ) ;
2022-11-24 21:49:05 +00:00
// Start Get Session By Gamer Handle
2023-03-01 21:27:15 +00:00
main_batch . add ( " SGSBGH " , " E8 ? ? ? ? 84 C0 0F 84 ? ? ? ? 8B 05 ? ? ? ? 48 8D 4C 24 " , [ this ] ( memory : : handle ptr ) {
2022-10-26 14:12:29 +02:00
m_start_get_session_by_gamer_handle = ptr . add ( 1 ) . rip ( ) . as < functions : : start_get_session_by_gamer_handle > ( ) ;
} ) ;
2022-11-24 21:49:05 +00:00
// Start Matchmaking Find Sessions
2023-03-01 21:27:15 +00:00
main_batch . add ( " SGSBGH " , " E8 ? ? ? ? 84 C0 0F 84 F6 FE FF FF " , [ this ] ( memory : : handle ptr ) {
2022-11-24 21:49:05 +00:00
m_start_matchmaking_find_sessions = ptr . add ( 1 ) . rip ( ) . as < functions : : start_matchmaking_find_sessions > ( ) ;
} ) ;
2022-10-26 14:12:29 +02:00
// Join Session By Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " JSBI " , " E8 ? ? ? ? 0F B6 CB 84 C0 41 0F 44 CD " , [ this ] ( memory : : handle ptr ) {
2022-10-26 14:12:29 +02:00
m_join_session_by_info = ptr . add ( 1 ) . rip ( ) . as < functions : : join_session_by_info > ( ) ;
} ) ;
2022-11-12 18:35:28 +00:00
// Script VM
2023-03-01 21:27:15 +00:00
main_batch . add ( " VM " , " E8 ? ? ? ? 48 85 FF 48 89 1D " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_script_vm = ptr . add ( 1 ) . rip ( ) . as < functions : : script_vm > ( ) ;
2022-11-12 18:35:28 +00:00
} ) ;
2022-11-13 16:34:44 +00:00
// Generate UUID
2023-03-01 21:27:15 +00:00
main_batch . add ( " GU " , " E8 ? ? ? ? 84 C0 74 0C 48 8B 44 24 ? 48 89 03 " , [ this ] ( memory : : handle ptr ) {
2022-11-13 16:34:44 +00:00
m_generate_uuid = ptr . add ( 1 ) . rip ( ) . as < functions : : generate_uuid > ( ) ;
} ) ;
// Host Token
2023-03-01 21:27:15 +00:00
main_batch . add ( " HT " , " 48 8B 05 ? ? ? ? 48 83 F8 FF " , [ this ] ( memory : : handle ptr ) {
2022-11-13 16:34:44 +00:00
m_host_token = ptr . add ( 3 ) . rip ( ) . as < std : : uint64_t * > ( ) ;
} ) ;
// Profile Gamer Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " PGI " , " 48 8D 05 ? ? ? ? 48 8B FE " , [ this ] ( memory : : handle ptr ) {
2022-11-13 16:34:44 +00:00
m_profile_gamer_info = ptr . add ( 3 ) . rip ( ) . as < rage : : rlGamerInfo * > ( ) ;
} ) ;
// Player Info Gamer Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " PIGI " , " E8 ? ? ? ? 48 8D 4D 20 48 8B D0 E8 ? ? ? ? 41 8A CF " , [ this ] ( memory : : handle ptr ) {
2022-11-13 16:34:44 +00:00
m_player_info_gamer_info = ptr . add ( 1 ) . rip ( ) . add ( 3 ) . rip ( ) . as < rage : : rlGamerInfo * > ( ) ;
} ) ;
// Communications
2023-03-01 21:27:15 +00:00
main_batch . add ( " C " , " 48 8B 1D ? ? ? ? 48 8D 4C 24 30 " , [ this ] ( memory : : handle ptr ) {
2022-11-13 16:34:44 +00:00
m_communications = ptr . add ( 3 ) . rip ( ) . as < CCommunications * * > ( ) ;
} ) ;
2022-11-19 01:49:36 +00:00
// Serialize Ped Inventory Data Node
2023-03-01 21:27:15 +00:00
main_batch . add ( " SPIDN " , " 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 54 41 56 41 57 48 83 EC 20 48 8B 02 48 8B F1 48 8B CA 48 8B FA FF 90 " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_serialize_ped_inventory_data_node = ptr . as < PVOID > ( ) ;
} ) ;
// Serialize Vehicle Gadget Data Node
2023-03-01 21:27:15 +00:00
main_batch . add ( " SVGDN " , " 48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 83 EC 30 48 8B 02 48 8D " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_serialize_vehicle_gadget_data_node = ptr . as < PVOID > ( ) ;
} ) ;
// Get Vehicle Gadget Array Size
2023-03-01 21:27:15 +00:00
main_batch . add ( " GVGAS " , " 40 53 48 83 EC 40 33 DB E8 " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_get_vehicle_gadget_array_size = ptr . as < functions : : get_vehicle_gadget_array_size > ( ) ;
} ) ;
// Handle Join Request
2023-03-01 21:27:15 +00:00
main_batch . add ( " HJR " , " 48 8B C4 48 89 58 08 4C 89 48 20 4C 89 40 18 48 89 50 10 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 E8 " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_handle_join_request = ptr . as < PVOID > ( ) ;
} ) ;
2023-02-28 19:45:55 +01:00
// Write Join Response Data
2023-03-01 21:27:15 +00:00
main_batch . add ( " WJRD " , " E8 ?? ?? ?? ?? 41 8B DF 84 C0 " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_write_join_response_data = ptr . add ( 1 ) . rip ( ) . as < functions : : write_join_response_data > ( ) ;
} ) ;
// Queue Packet
2023-03-01 21:27:15 +00:00
main_batch . add ( " QP " , " E8 ? ? ? ? 84 C0 74 4D B3 01 " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_queue_packet = ptr . add ( 1 ) . rip ( ) . as < functions : : queue_packet > ( ) ;
} ) ;
// Sort Session Details
2023-03-01 21:27:15 +00:00
main_batch . add ( " SGS " , " C3 0F 2E 42 0C " , [ this ] ( memory : : handle ptr ) {
2022-11-19 01:49:36 +00:00
m_sort_session_details = ptr . sub ( 0x10 ) . as < PVOID > ( ) ;
} ) ;
2022-11-21 15:42:12 +00:00
// Add Player To Session
2023-03-01 21:27:15 +00:00
main_batch . add ( " APTS " , " E8 ?? ?? ?? ?? 48 8D 8D F0 01 00 00 8A D8 " , [ this ] ( memory : : handle ptr ) {
2022-11-21 15:42:12 +00:00
m_add_player_to_session = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
// Send Chat Net Message
2023-03-01 21:27:15 +00:00
main_batch . add ( " SCNM " , " E8 ? ? ? ? 41 FF C4 48 83 C5 08 " , [ this ] ( memory : : handle ptr ) {
2022-11-21 15:42:12 +00:00
m_send_chat_net_message = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
2022-11-24 21:49:05 +00:00
// Process Matchmaking Find Response
2023-03-01 21:27:15 +00:00
main_batch . add ( " PMFR " , " 48 89 5C 24 08 48 89 74 24 10 57 48 81 EC F0 00 00 00 41 83 " , [ this ] ( memory : : handle ptr ) {
2022-11-24 21:49:05 +00:00
m_process_matchmaking_find_response = ptr . as < PVOID > ( ) ;
} ) ;
// Serialize Player Data Message
2023-03-01 21:27:15 +00:00
main_batch . add ( " SPDM " , " 48 89 5C 24 08 48 89 74 24 10 48 89 7C 24 18 41 56 48 83 EC 20 BF 01 00 00 00 " , [ this ] ( memory : : handle ptr ) {
2022-11-24 21:49:05 +00:00
m_serialize_player_data_msg = ptr . as < PVOID > ( ) ;
} ) ;
// Serialize Join Request Message
2023-03-01 21:27:15 +00:00
main_batch . add ( " SJRM " , " E8 ?? ?? ?? ?? 84 C0 0F 84 9B 00 00 00 49 8D 8F 50 11 00 00 " , [ this ] ( memory : : handle ptr ) {
2022-11-24 21:49:05 +00:00
m_serialize_join_request_message = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
2022-12-06 16:12:02 +00:00
// Send Network Damage
2023-03-01 21:27:15 +00:00
main_batch . add ( " SND " , " E8 ? ? ? ? E9 E9 01 00 00 48 8B CB " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_send_network_damage = ptr . add ( 1 ) . rip ( ) . as < functions : : send_network_damage > ( ) ;
} ) ;
// Request Ragdoll
2023-03-01 21:27:15 +00:00
main_batch . add ( " RR " , " E8 ? ? ? ? 09 B3 ? ? ? ? 48 8B 5C 24 " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_request_ragdoll = ptr . add ( 1 ) . rip ( ) . as < functions : : request_ragdoll > ( ) ;
} ) ;
2023-02-09 05:46:08 +08:00
// Request Control
2023-03-01 21:27:15 +00:00
main_batch . add ( " RC " , " E8 ? ? ? ? EB 3E 48 8B D3 " , [ this ] ( memory : : handle ptr ) {
2023-02-09 05:46:08 +08:00
m_request_control = ptr . add ( 1 ) . rip ( ) . as < functions : : request_control > ( ) ;
} ) ;
2022-12-06 16:12:02 +00:00
// Get Connection Peer & Send Remove Gamer Command
2023-03-01 21:27:15 +00:00
main_batch . add ( " GCP&SRGC " , " 8D 42 FF 83 F8 FD 77 3D " , [ this ] ( memory : : handle ptr ) {
m_get_connection_peer = ptr . add ( 23 ) . rip ( ) . as < functions : : get_connection_peer > ( ) ;
2022-12-06 16:12:02 +00:00
m_send_remove_gamer_cmd = ptr . add ( 65 ) . rip ( ) . as < functions : : send_remove_gamer_cmd > ( ) ;
} ) ;
// Handle Remove Gamer Command
2023-03-01 21:27:15 +00:00
main_batch . add ( " HRGC " , " 41 FF C6 FF C7 " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_handle_remove_gamer_cmd = ptr . sub ( 0x6E ) . as < functions : : handle_remove_gamer_cmd > ( ) ;
} ) ;
// Broadcast Net Array
2023-03-01 21:27:15 +00:00
main_batch . add ( " BNA " , " 48 89 5C 24 ? 48 89 54 24 ? 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 40 48 8B 05 ? ? ? ? 66 44 89 4C 24 " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_broadcast_net_array = ptr . as < PVOID > ( ) ;
} ) ;
2022-11-25 22:29:03 +01:00
// Rage Security
2023-03-01 21:27:15 +00:00
main_batch . add ( " RS " , " 48 8B 1D ? ? ? ? 33 F6 BD C3 9E 26 00 " , [ this ] ( memory : : handle ptr ) {
2022-11-25 22:29:03 +01:00
m_security = ptr . add ( 3 ) . rip ( ) . as < rage : : atSingleton < rage : : RageSecurity > * > ( ) ;
} ) ;
2022-12-06 16:12:02 +00:00
// Send Session Matchmaking Attributes
2023-03-01 21:27:15 +00:00
main_batch . add ( " SSMA " , " 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 81 EC D0 00 00 00 49 8B " , [ this ] ( memory : : handle ptr ) {
2023-02-04 00:00:56 +01:00
m_send_session_matchmaking_attributes = ptr . as < PVOID > ( ) ;
2022-12-06 16:12:02 +00:00
} ) ;
// Serialize Take Off Ped Variation Task
2023-03-01 21:27:15 +00:00
main_batch . add ( " STOPVT " , " 40 55 53 57 41 56 48 8B EC 48 83 EC 68 " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_serialize_take_off_ped_variation_task = ptr . as < PVOID > ( ) ;
} ) ;
// Chat Data
2023-03-01 21:27:15 +00:00
main_batch . add ( " CD " , " 48 8B 05 ? ? ? ? 0F 45 DF " , [ this ] ( memory : : handle ptr ) {
2022-11-29 20:48:58 +01:00
m_chat_data = ptr . add ( 3 ) . rip ( ) . as < ChatData * * > ( ) ;
} ) ;
2022-12-17 17:24:45 +01:00
// Social Club Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " SCI " , " 48 8B D3 48 8D 4C 24 ? 48 69 D2 " , [ this ] ( memory : : handle ptr ) {
2022-12-17 17:24:45 +01:00
m_sc_info = ptr . sub ( 4 ) . rip ( ) . as < ScInfo * > ( ) ;
} ) ;
2022-12-06 16:12:02 +00:00
// Create Script Handler
2023-03-01 21:27:15 +00:00
main_batch . add ( " CSH " , " 48 8D 05 ? ? ? ? 4C 8D 0D ? ? ? ? 41 83 C8 FF 48 89 03 89 53 70 88 53 74 4C 89 4B 68 48 89 93 " , [ this ] ( memory : : handle ptr ) {
2022-12-06 16:12:02 +00:00
m_create_script_handler = * ( ptr . add ( 3 ) . rip ( ) . as < std : : uint64_t * * > ( ) + 8 ) ;
} ) ;
2022-12-10 19:28:56 -05:00
// Constraint Attachment Crash
2023-03-01 21:27:15 +00:00
main_batch . add ( " CAC " , " 40 53 48 83 EC 20 48 8B D9 48 8B 49 38 48 8B 01 " , [ this ] ( memory : : handle ptr ) {
2022-12-09 20:55:25 +01:00
m_constraint_attachment_crash = ptr . as < PVOID > ( ) ;
} ) ;
2022-12-10 19:28:56 -05:00
// Invalid Decal Crash
2023-03-01 21:27:15 +00:00
main_batch . add ( " IDC " , " E8 ? ? ? ? 8B 9C 24 B8 00 00 00 4C 8B AC 24 A8 00 00 00 " , [ this ] ( memory : : handle ptr ) {
2022-12-10 19:28:56 -05:00
m_invalid_decal_crash = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
2023-02-24 00:14:44 +08:00
// Task Parachute Object 0x270
2023-03-01 21:27:15 +00:00
main_batch . add ( " TPO270 " , " 0F 88 ? ? ? ? 75 34 " , [ this ] ( memory : : handle ptr ) {
m_task_parachute_object_0x270
= ptr . sub ( 6 ) . as < PVOID > ( ) ;
2023-02-24 00:14:44 +08:00
} ) ;
2022-12-17 14:47:01 +00:00
// Encode Session Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " ESI " , " E8 ? ? ? ? C6 83 94 01 00 00 01 " , [ this ] ( memory : : handle ptr ) {
2023-02-04 16:35:18 +00:00
m_encode_session_info = ptr . add ( 1 ) . rip ( ) . as < functions : : encode_session_info > ( ) ;
2022-12-17 14:47:01 +00:00
} ) ;
// Decode Session Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " DSI " , " E8 ?? ?? ?? ?? 84 C0 74 16 48 8B 4B 60 " , [ this ] ( memory : : handle ptr ) {
2023-02-04 00:00:56 +01:00
m_decode_session_info = ptr . add ( 1 ) . rip ( ) . as < functions : : decode_session_info > ( ) ;
2022-12-17 14:47:01 +00:00
} ) ;
2023-01-03 16:48:32 +00:00
// Decode Peer Info
2023-03-01 21:27:15 +00:00
main_batch . add ( " DPI " , " 48 89 5C 24 08 48 89 74 24 10 57 48 81 EC C0 00 00 00 48 8B F1 49 " , [ this ] ( memory : : handle ptr ) {
2023-01-03 16:48:32 +00:00
m_decode_peer_info = ptr . as < functions : : decode_peer_info > ( ) ;
} ) ;
2022-12-17 14:47:01 +00:00
// Main File Object
2023-03-01 21:27:15 +00:00
main_batch . add ( " MFO " , " 48 8D 05 ? ? ? ? 48 8D 1C D0 EB 03 " , [ this ] ( memory : : handle ptr ) {
2022-12-17 14:47:01 +00:00
m_main_file_object = ptr . add ( 3 ) . rip ( ) . as < datafile_commands : : SveFileObject * > ( ) ;
} ) ;
// Load Cloud File
2023-03-01 21:27:15 +00:00
main_batch . add ( " LCF " , " 48 89 5C 24 08 48 89 74 24 10 57 48 83 EC 40 48 8B F2 48 8B D9 41 8B D0 " , [ this ] ( memory : : handle ptr ) {
2022-12-17 14:47:01 +00:00
m_load_cloud_file = ptr . as < functions : : load_cloud_file > ( ) ;
} ) ;
// Set As Active Cloud File
2023-03-01 21:27:15 +00:00
main_batch . add ( " SAACF " , " 48 83 EC 28 45 33 C0 4C 39 " , [ this ] ( memory : : handle ptr ) {
2022-12-17 14:47:01 +00:00
m_set_as_active_cloud_file = ptr . as < functions : : set_as_active_cloud_file > ( ) ;
} ) ;
// Save JSON Data
2023-03-01 21:27:15 +00:00
main_batch . add ( " SJD " , " 48 89 5C 24 08 57 48 83 EC 30 33 DB 48 8B FA 48 " , [ this ] ( memory : : handle ptr ) {
2022-12-17 14:47:01 +00:00
m_save_json_data = ptr . as < functions : : save_json_data > ( ) ;
} ) ;
2022-12-19 17:39:06 +00:00
// Network Time
2023-03-01 21:27:15 +00:00
main_batch . add ( " NT " , " 48 8B 0D ? ? ? ? E8 ? ? ? ? 33 DB 84 C0 74 41 " , [ this ] ( memory : : handle ptr ) {
2022-12-19 17:39:06 +00:00
m_network_time = ptr . add ( 3 ) . rip ( ) . as < rage : : netTime * * > ( ) ;
} ) ;
// Sync Network Time
2023-03-01 21:27:15 +00:00
main_batch . add ( " SNT " , " E8 ? ? ? ? 8B 43 5C " , [ this ] ( memory : : handle ptr ) {
2022-12-19 17:39:06 +00:00
m_sync_network_time = ptr . add ( 1 ) . rip ( ) . as < functions : : sync_network_time > ( ) ;
} ) ;
2022-12-18 01:00:04 +01:00
// Queue Dependency
2023-03-01 21:27:15 +00:00
main_batch . add ( " QD " , " 48 89 5C 24 ? 57 48 83 EC ? 0F B6 99 " , [ this ] ( memory : : handle ptr ) {
2022-12-18 01:00:04 +01:00
m_queue_dependency = ptr . as < PVOID > ( ) ;
} ) ;
// Interval Check Function
2023-03-01 21:27:15 +00:00
main_batch . add ( " ICF " , " 48 8D 0D ? ? ? ? 88 05 ? ? ? ? 48 8D 05 " , [ this ] ( memory : : handle ptr ) {
2022-12-18 01:00:04 +01:00
m_interval_check_func = ptr . add ( 3 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
2023-01-03 16:48:32 +00:00
// Prepare Metric For Sending
2023-03-01 21:27:15 +00:00
main_batch . add ( " PMFS " , " 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 83 EC 30 49 8B E8 4C 8D 40 EC 49 8B F1 48 8B D9 40 32 FF E8 " , [ this ] ( memory : : handle ptr ) {
2022-12-30 11:49:39 +01:00
m_prepare_metric_for_sending = ptr . as < PVOID > ( ) ;
} ) ;
2023-01-03 16:48:32 +00:00
// Send Packet
2023-03-01 21:27:15 +00:00
main_batch . add ( " SP " , " 48 8B C4 48 89 58 08 48 89 70 10 48 89 78 18 4C 89 48 20 55 41 54 41 55 41 56 41 57 48 8D A8 98 " , [ this ] ( memory : : handle ptr ) {
2023-01-03 16:48:32 +00:00
m_send_packet = ptr . as < functions : : send_packet > ( ) ;
} ) ;
// Connect To Peer
2023-03-01 21:27:15 +00:00
main_batch . add ( " CTP " , " 48 89 5C 24 08 4C 89 4C 24 20 48 89 54 24 10 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 60 4D " , [ this ] ( memory : : handle ptr ) {
2023-01-03 16:48:32 +00:00
m_connect_to_peer = ptr . as < functions : : connect_to_peer > ( ) ;
} ) ;
2023-03-01 21:27:15 +00:00
2023-01-03 05:52:07 -05:00
// Fragment Physics Crash
2023-03-01 21:27:15 +00:00
main_batch . add ( " FPC " , " E8 ? ? ? ? 44 8B 4D 1C " , [ this ] ( memory : : handle ptr ) {
2023-01-03 05:52:07 -05:00
m_fragment_physics_crash = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
// Fragment Physics Crash 2
2023-03-01 21:27:15 +00:00
main_batch . add ( " FPC2 " , " E8 ? ? ? ? 84 C0 75 0B 41 FF CF " , [ this ] ( memory : : handle ptr ) {
2023-01-03 05:52:07 -05:00
m_fragment_physics_crash_2 = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
2023-01-22 21:57:32 +00:00
// Clear Ped Tasks Network
2023-03-01 21:27:15 +00:00
main_batch . add ( " CPTN " , " E8 ? ? ? ? EB 28 48 8B 8F A0 10 00 00 " , [ this ] ( memory : : handle ptr ) {
2023-01-22 21:57:32 +00:00
m_clear_ped_tasks_network = ptr . add ( 1 ) . rip ( ) . as < functions : : clear_ped_tasks_network > ( ) ;
} ) ;
// Infinite Train Crash
2023-03-01 21:27:15 +00:00
main_batch . add ( " ITC " , " E8 ? ? ? ? F3 44 0F 10 93 90 03 00 00 " , [ this ] ( memory : : handle ptr ) {
2023-01-22 21:57:32 +00:00
m_infinite_train_crash = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
2023-03-01 21:27:15 +00:00
m_get_next_carriage = ptr . add ( 1 ) . rip ( ) . add ( 0xF ) . rip ( ) . as < functions : : get_next_carriage > ( ) ;
2023-01-22 21:57:32 +00:00
} ) ;
// Get Entity Attached To
2023-03-01 21:27:15 +00:00
main_batch . add ( " GEAT " , " 48 83 EC 28 48 8B 51 50 48 85 D2 74 04 " , [ this ] ( memory : : handle ptr ) {
2023-01-22 21:57:32 +00:00
m_get_entity_attached_to = ptr . as < functions : : get_entity_attached_to > ( ) ;
} ) ;
// Received Array Update
2023-03-01 21:27:15 +00:00
main_batch . add ( " RAU " , " 48 89 5C 24 10 55 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 30 48 8B 05 " , [ this ] ( memory : : handle ptr ) {
2023-01-22 21:57:32 +00:00
m_received_array_update = ptr . as < PVOID > ( ) ;
} ) ;
2023-02-04 23:20:49 +01:00
// Receive Pickup
2023-03-01 21:27:15 +00:00
main_batch . add ( " RPI " , " 49 8B 80 ? ? ? ? 48 85 C0 74 0C F6 80 ? ? ? ? ? 75 03 32 C0 C3 " , [ this ] ( memory : : handle ptr ) {
2023-02-04 23:20:49 +01:00
m_receive_pickup = ptr . as < PVOID > ( ) ;
} ) ;
2023-02-13 20:38:30 +00:00
// Write Player Camera Data Node
2023-03-01 21:27:15 +00:00
main_batch . add ( " WPCDN " , " 48 8B C4 48 89 58 20 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 B0 48 81 EC 50 01 00 00 4C " , [ this ] ( memory : : handle ptr ) {
2023-02-13 20:38:30 +00:00
m_write_player_camera_data_node = ptr . as < PVOID > ( ) ;
} ) ;
2023-03-01 21:27:15 +00:00
// Send Player Card Stats
main_batch . add ( " SPCS " , " 48 89 5C 24 08 57 48 83 EC 30 48 83 64 24 20 00 48 8B DA 41 " , [ this ] ( memory : : handle ptr ) {
m_send_player_card_stats = ptr . as < PVOID > ( ) ;
} ) ;
// Force Player Card Refresh
main_batch . add ( " FPCR " , " 44 38 2D ? ? ? ? 74 1D 44 00 A6 BB 07 00 00 " , [ this ] ( memory : : handle ptr ) {
m_force_player_card_refresh = ptr . add ( 3 ) . rip ( ) . as < bool * > ( ) ;
} ) ;
// Serialize Stats
main_batch . add ( " SS " , " 48 89 5C 24 08 48 89 74 24 10 48 89 7C 24 20 55 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 50 45 " , [ this ] ( memory : : handle ptr ) {
m_serialize_stats = ptr . as < PVOID > ( ) ;
} ) ;
// Write Player Creation Data Node
main_batch . add ( " WPCDN " , " 48 83 EC 38 48 8B 81 F0 " , [ this ] ( memory : : handle ptr ) {
m_write_player_creation_data_node = ptr . as < PVOID > ( ) ;
} ) ;
// Write Player Appearance Data Node
main_batch . add ( " WPADN " , " 48 8B C4 48 89 50 10 48 89 48 08 53 " , [ this ] ( memory : : handle ptr ) {
m_write_player_appearance_data_node = ptr . as < PVOID > ( ) ;
} ) ;
2023-03-09 12:23:01 +00:00
// Enumerate Audio Devices
main_batch . add ( " EAD " , " 48 89 5C 24 08 48 89 7C 24 10 55 48 8B EC 48 83 EC 70 41 " , [ this ] ( memory : : handle ptr ) {
m_enumerate_audio_devices = ptr . as < PVOID > ( ) ;
} ) ;
// Direct Sound Capture Create
main_batch . add ( " DSCC " , " E8 ? ? ? ? 33 FF 85 C0 78 C1 " , [ this ] ( memory : : handle ptr ) {
m_direct_sound_capture_create = ptr . add ( 1 ) . rip ( ) . as < PVOID > ( ) ;
} ) ;
// Refresh Audio Input
main_batch . add ( " RAI " , " 40 88 3D ? ? ? ? 89 05 ? ? ? ? 40 38 3D " , [ this ] ( memory : : handle ptr ) {
m_refresh_audio_input = ptr . add ( 3 ) . rip ( ) . as < bool * > ( ) ;
} ) ;
// Allow Weapons In Vehicle
2023-04-06 02:25:20 +08:00
main_batch . add ( " AWIV " , " 49 8B 40 08 39 10 " , [ this ] ( memory : : handle ptr ) {
m_allow_weapons_in_vehicle = ptr . sub ( 23 ) . as < PVOID > ( ) ;
2023-03-09 12:23:01 +00:00
} ) ;
// Write Vehicle Proximity Migration Data Node
main_batch . add ( " WVPMDN " , " 48 89 4C 24 08 55 53 56 57 41 54 41 55 41 56 41 57 48 8B EC 48 83 EC 68 4C 8B A9 " , [ this ] ( memory : : handle ptr ) {
m_write_vehicle_proximity_migration_data_node = ptr . as < PVOID > ( ) ;
} ) ;
// Migrate Object
main_batch . add ( " MO " , " 48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 54 41 55 41 56 41 57 48 83 EC 20 41 8B F8 48 " , [ this ] ( memory : : handle ptr ) {
m_migrate_object = ptr . as < functions : : migrate_object > ( ) ;
2023-02-28 20:42:23 +08:00
} ) ;
2023-04-06 20:01:23 +02:00
// Task Jump Constructor
2023-03-13 17:10:21 -04:00
main_batch . add ( " TJC " , " 48 89 5C 24 ? 89 54 24 10 57 48 83 EC 30 0F 29 74 24 " , [ this ] ( memory : : handle ptr ) {
m_taskjump_constructor = ptr . as < PVOID > ( ) ;
} ) ;
2023-01-18 19:02:23 +00:00
if ( ! main_batch . run ( mem_region ) )
{
throw std : : runtime_error ( " Failed to find some patterns. " ) ;
}
2023-04-06 20:01:23 +02:00
}
2022-05-18 23:17:57 +02:00
2023-04-06 20:01:23 +02:00
void pointers : : run_socialclub_batch ( )
{
2022-11-13 16:34:44 +00:00
memory : : batch socialclub_batch ;
// Presence Data
2023-04-04 14:57:32 +00:00
socialclub_batch . add ( " PD " , " 48 8D 05 ? ? ? ? 48 8B F1 48 89 01 48 83 C1 08 E8 ? ? ? ? 48 8D 8E 3B 4E 00 00 " , [ this ] ( memory : : handle ptr ) {
2023-03-01 21:27:15 +00:00
auto presence_data_vft = ptr . add ( 3 ) . rip ( ) . as < PVOID * > ( ) ;
m_update_presence_attribute_int = presence_data_vft [ 1 ] ;
2022-11-13 16:34:44 +00:00
m_update_presence_attribute_string = presence_data_vft [ 3 ] ;
} ) ;
2023-01-03 16:48:32 +00:00
// Start Get Presence Attributes
2023-03-01 21:27:15 +00:00
socialclub_batch . add ( " SGPA " , " 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 54 41 56 41 57 48 83 EC 40 33 DB 41 " , [ this ] ( memory : : handle ptr ) {
2023-01-03 16:48:32 +00:00
m_start_get_presence_attributes = ptr . as < functions : : start_get_presence_attributes > ( ) ;
} ) ;
2022-11-14 22:59:02 +01:00
auto sc_module = memory : : module ( " socialclub.dll " ) ;
if ( sc_module . wait_for_module ( ) )
{
socialclub_batch . run ( sc_module ) ;
}
2023-03-01 21:27:15 +00:00
else
LOG ( WARNING ) < < " socialclub.dll module was not loaded within the time limit. " ;
2023-04-06 20:01:23 +02:00
}
2022-11-13 16:34:44 +00:00
2023-04-06 20:01:23 +02:00
void pointers : : freemode_thread_restorer_through_vm_patch ( const memory : : module & mem_region )
{
2022-10-22 00:47:34 +10:30
if ( auto pat1 = mem_region . scan ( " 3b 0a 0f 83 ? ? ? ? 48 ff c7 " ) )
2022-05-18 23:17:57 +02:00
{
2022-10-26 21:20:26 +02:00
memory : : byte_patch : : make ( pat1 . add ( 2 ) . as < uint32_t * > ( ) , 0xc9310272 ) - > apply ( ) ;
memory : : byte_patch : : make ( pat1 . add ( 6 ) . as < uint16_t * > ( ) , 0x9090 ) - > apply ( ) ;
2022-05-18 23:17:57 +02:00
}
2022-10-22 00:47:34 +10:30
if ( auto pat2 = mem_region . scan ( " 3b 0a 0f 83 ? ? ? ? 49 03 fa " ) )
2022-05-18 23:17:57 +02:00
{
2022-10-26 21:20:26 +02:00
memory : : byte_patch : : make ( pat2 . add ( 2 ) . as < uint32_t * > ( ) , 0xc9310272 ) - > apply ( ) ;
memory : : byte_patch : : make ( pat2 . add ( 6 ) . as < uint16_t * > ( ) , 0x9090 ) - > apply ( ) ;
2022-05-18 23:17:57 +02:00
}
auto pat3 = mem_region . scan_all ( " 3b 11 0f 83 ? ? ? ? 48 ff c7 " ) ;
for ( auto & handle : pat3 )
{
2022-10-26 21:20:26 +02:00
memory : : byte_patch : : make ( handle . add ( 2 ) . as < uint32_t * > ( ) , 0xd2310272 ) - > apply ( ) ;
memory : : byte_patch : : make ( handle . add ( 6 ) . as < uint16_t * > ( ) , 0x9090 ) - > apply ( ) ;
2022-05-18 23:17:57 +02:00
}
auto pat4 = mem_region . scan_all ( " 3b 11 0f 83 ? ? ? ? 49 03 fa " ) ;
for ( auto & handle : pat4 )
{
2022-10-26 21:20:26 +02:00
memory : : byte_patch : : make ( handle . add ( 2 ) . as < uint32_t * > ( ) , 0xd2310272 ) - > apply ( ) ;
memory : : byte_patch : : make ( handle . add ( 6 ) . as < uint16_t * > ( ) , 0x9090 ) - > apply ( ) ;
2022-05-18 23:17:57 +02:00
}
2023-04-06 20:01:23 +02:00
}
// Any change to the sigs should have this number bumped, especially if the existing offsets are changing
// Note: you don't need to bump that number when all the sigs stay the same and that the game updates,
// because we also check against the game version and the online version.
constexpr uint32_t pointers_version = 1 ;
pointers : : pointers ( ) :
m_pointers_cache ( g_file_manager - > get_project_file ( " ./cache/pointers.bin " ) , pointers_version )
{
memory : : batch version_batch ;
// game version + online version
version_batch . add ( " GVOV " , " 8B C3 33 D2 C6 44 24 20 " , [ this ] ( memory : : handle ptr ) {
m_game_version = ptr . add ( 0x24 ) . rip ( ) . as < const char * > ( ) ;
m_online_version = ptr . add ( 0x24 ) . rip ( ) . add ( 0x20 ) . as < const char * > ( ) ;
m_game_version_uint32_t = std : : strtoul ( m_game_version , nullptr , 10 ) ;
m_online_version_float = std : : strtof ( m_online_version , nullptr ) ;
} ) ;
const auto mem_region = memory : : module ( " GTA5.exe " ) ;
// save offsets of the fields to cache
// get the beginning and the end of what we need to save / load
constexpr size_t offset_of_cache_begin_field = offsetof ( big : : pointers , m_offset_gta_module_cache_start ) + sizeof ( uintptr_t ) ;
constexpr size_t offset_of_cache_end_field = offsetof ( big : : pointers , m_offset_gta_module_cache_end ) ;
constexpr size_t field_count = ( offset_of_cache_end_field - offset_of_cache_begin_field ) / sizeof ( void * ) ;
// stupid check to see if we are aligned, don't really guarantee that the for loop below will succeed
static_assert ( ( ( offset_of_cache_end_field - offset_of_cache_begin_field ) % sizeof ( void * ) ) = = 0 , " not aligned, prolly mean that there are rogue non cacheable fields between start and end " ) ;
const uintptr_t pointer_to_cacheable_data_start = reinterpret_cast < uintptr_t > ( this ) + offset_of_cache_begin_field ;
const uintptr_t pointer_to_cacheable_data_end = reinterpret_cast < uintptr_t > ( this ) + offset_of_cache_end_field ;
if ( ! is_pointers_cache_up_to_date ( version_batch , mem_region ) )
{
run_cacheable_main_batch ( mem_region ) ;
constexpr size_t data_size = offset_of_cache_end_field - offset_of_cache_begin_field ;
big : : cache_data cache_data_ptr = std : : make_unique < std : : uint8_t [ ] > ( data_size ) ;
// multiple things here:
// - iterate each cacheable field of the pointers instance
// - substract the base module address so that we only keep the offsets
// - save that to the cache
uintptr_t * cache_data = reinterpret_cast < uintptr_t * > ( cache_data_ptr . get ( ) ) ;
size_t i = 0 ;
for ( uintptr_t field_ptr = pointer_to_cacheable_data_start ; field_ptr ! = pointer_to_cacheable_data_end ; field_ptr + = sizeof ( uintptr_t ) )
{
const uintptr_t field_value = * reinterpret_cast < uintptr_t * > ( field_ptr ) ;
if ( mem_region . contains ( memory : : handle ( field_value ) ) )
{
const uintptr_t offset = field_value - mem_region . begin ( ) . as < uintptr_t > ( ) ;
cache_data [ i ] = offset ;
}
else
{
LOG ( FATAL ) < < " Just tried to save to cache a pointer supposedly within the gta 5 module range but wasnt!!! Offset from start of pointers instance: " < < ( field_ptr - reinterpret_cast < uintptr_t > ( this ) ) ;
}
i + + ;
}
LOG ( INFO ) < < " Pointers cache: saved " < < ( data_size / sizeof ( uintptr_t ) ) < < " fields to the cache " ;
m_pointers_cache . set_data ( std : : move ( cache_data_ptr ) , data_size ) ;
m_pointers_cache . set_header_version ( m_game_version_uint32_t , m_online_version_float ) ;
m_pointers_cache . write ( ) ;
}
else
{
// fill pointers instance fields by reading the file data into it
LOG ( INFO ) < < " Loading pointers instance from cache " ;
// multiple things here:
// - iterate each cacheable field of the pointers instance
// - add the base module address to the current offset retrieved from the cache
// - assign that ptr to the pointers field
uintptr_t * cache_data = reinterpret_cast < uintptr_t * > ( m_pointers_cache . data ( ) ) ;
const size_t field_count_from_cache = m_pointers_cache . data_size ( ) / sizeof ( uintptr_t ) ;
LOG ( INFO ) < < " Pointers cache: Loading " < < field_count_from_cache < < " fields from the cache " ;
uintptr_t * field_ptr = reinterpret_cast < uintptr_t * > ( pointer_to_cacheable_data_start ) ;
for ( size_t i = 0 ; i < field_count_from_cache ; i + + )
{
uintptr_t offset = cache_data [ i ] ;
uintptr_t gta_module_ptr = offset + mem_region . begin ( ) . as < uintptr_t > ( ) ;
if ( mem_region . contains ( memory : : handle ( gta_module_ptr ) ) )
{
* field_ptr = gta_module_ptr ;
}
else
{
LOG ( FATAL ) < < " Just tried to load from cache a pointer supposedly within the gta 5 module range but wasnt!!! Offset from start of pointers instance: " < < ( reinterpret_cast < uintptr_t > ( field_ptr ) - reinterpret_cast < uintptr_t > ( this ) ) ;
}
field_ptr + + ;
}
}
m_pointers_cache . free ( ) ;
always_run_main_batch ( mem_region ) ;
run_socialclub_batch ( ) ;
freemode_thread_restorer_through_vm_patch ( mem_region ) ;
2019-03-21 20:18:31 +01:00
m_hwnd = FindWindowW ( L " grcWindow " , nullptr ) ;
2022-07-24 16:52:30 -04:00
2019-03-21 20:18:31 +01:00
if ( ! m_hwnd )
throw std : : runtime_error ( " Failed to find the game's window. " ) ;
g_pointers = this ;
}
pointers : : ~ pointers ( )
{
2022-10-21 13:25:37 +02:00
memory : : byte_patch : : restore_all ( ) ;
2022-05-17 15:56:17 +02:00
2019-03-21 20:18:31 +01:00
g_pointers = nullptr ;
}
}