2021-04-16 14:12:39 +02:00
# pragma once
2021-05-17 07:54:13 -07:00
# include <iostream>
2021-06-08 10:54:49 -07:00
# include "utility.h"
2021-04-16 14:12:39 +02:00
// Define the signatures or offsets to be searched and hooked
namespace
{
2021-06-08 10:54:49 -07:00
/* ==== CONSOLE ========================================================================================================================================================= */
DWORD64 p_CommandExecute = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x89 \x5C \x24 \x08 \x57 \x48 \x83 \xEC \x20 \x48 \x8D \x0D \x27 \x61 \xa5 \x1E \x41 \x8B \xD8 " , " xxxx?xxxxxxxx????xxx " ) ;
void ( * CommandExecute ) ( void * self , const char * cmd ) = ( void ( * ) ( void * , const char * ) ) p_CommandExecute ; /*48 89 5C 24 ?? 57 48 83 EC 20 48 8D 0D ?? ?? ?? ?? 41 8B D8*/
2021-04-16 14:12:39 +02:00
2021-06-08 10:54:49 -07:00
DWORD64 p_ConVar_IsFlagSet = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x8B \x41 \x48 \x85 \x50 \x38 " , " xxxxxxx " ) ;
bool ( * ConVar_IsFlagSet ) ( int * * cvar , int flag ) = ( bool ( * ) ( int * * , int ) ) p_ConVar_IsFlagSet ; /*48 8B 41 48 85 50 38*/
2021-04-16 11:14:30 -07:00
2021-06-08 10:54:49 -07:00
LONGLONG p_ConCommand_IsFlagSet = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x85 \x51 \x38 \x0F \x95 \xC0 \xC3 " , " xxxxxxx " ) ;
bool ( * ConCommand_IsFlagSet ) ( int * cmd , int flag ) = ( bool ( * ) ( int * , int ) ) p_ConCommand_IsFlagSet ; /*85 51 38 0F 95 C0 C3*/
2021-04-16 14:12:39 +02:00
2021-06-08 10:54:49 -07:00
/* ==== SQUIRREL ======================================================================================================================================================== */
DWORD64 p_SQVM_Print = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x8B \xC4 \x48 \x89 \x50 \x10 \x4C \x89 \x40 \x18 \x4C \x89 \x48 \x20 \x53 \x56 \x57 \x48 \x81 \xEC \x30 \x08 \x00 \x00 \x48 \x8B \xDA \x48 \x8D \x70 \x18 \x48 \x8B \xF9 \xE8 \x00 \x00 \x00 \xFF \x48 \x89 \x74 \x24 \x28 \x48 \x8D \x54 \x24 \x30 \x33 " , " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx???xxxxxxxxxxxx " ) ;
void * SQVM_Print = ( void * ) p_SQVM_Print ; /*48 8B C4 48 89 50 10 4C 89 40 18 4C 89 48 20 53 56 57 48 81 EC 30 08 00 00 48 8B DA 48 8D 70 18 48 8B F9 E8 ?? ?? ?? FF 48 89 74 24 28 48 8D 54 24 30 33*/
2021-04-16 11:14:30 -07:00
2021-06-08 10:54:49 -07:00
DWORD64 p_SQVM_LoadScript = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x89 \x5C \x24 \x10 \x48 \x89 \x74 \x24 \x18 \x48 \x89 \x7C \x24 \x20 \x48 \x89 \x4C \x24 \x08 \x55 \x41 \x54 \x41 \x55 \x41 \x56 \x41 \x57 \x48 \x8D \x6C " , " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " ) ; // For S0 and S1
//DWORD64 p_SQVM_LoadScript = FindPattern("r5apex.exe", "\x48\x8B\xC4\x48\x89\x48\x08\x55\x41\x56\x48\x8D\x68", "xxxxxxxxxxxxx"); // For anything S2 and above (current S8)
bool ( * SQVM_LoadScript ) ( void * sqvm , const char * script_path , const char * script_name , int flag ) = ( bool ( * ) ( void * , const char * , const char * , int ) ) p_SQVM_LoadScript ; /*E8 ?? ?? ?? ?? 84 C0 74 1C 41 B9 ?? ?? ?? ??*/
2021-04-16 14:12:39 +02:00
2021-06-08 10:54:49 -07:00
/* ==== NETCHAN ========================================================================================================================================================= */
DWORD64 p_NET_ReceiveDatagram = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x89 \x74 \x24 \x18 \x48 \x89 \x7C \x24 \x20 \x55 \x41 \x54 \x41 \x55 \x41 \x56 \x41 \x57 \x48 \x8D \xAC \x24 \x50 \xEB " , " xxxxxxxxxxxxxxxxxxxxxxxxx " ) ;
bool ( * NET_ReceiveDatagram ) ( int , void * , bool ) = ( bool ( * ) ( int , void * , bool ) ) p_NET_ReceiveDatagram ; /*E8 ?? ?? ?? ?? 84 C0 75 35 48 8B D3*/
2021-04-16 11:14:30 -07:00
2021-06-08 10:54:49 -07:00
DWORD64 p_NET_SendDatagram = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x89 \x5C \x24 \x08 \x48 \x89 \x6C \x24 \x10 \x48 \x89 \x74 \x24 \x18 \x57 \x41 \x56 \x41 \x57 \x48 \x81 \xEC \x00 \x05 \x00 \x00 " , " xxxxxxxxxxxxxxxxxxxxxxx?xxx " ) ;
unsigned int ( * NET_SendDatagram ) ( SOCKET s , const char * buf , int len , int flags ) = ( unsigned int ( * ) ( SOCKET , const char * , int , int ) ) p_NET_SendDatagram ; /*48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 41 56 41 57 48 81 EC ?? 05 00 00*/
2021-04-25 14:36:55 -07:00
2021-06-08 10:54:49 -07:00
/* ==== WINAPI ========================================================================================================================================================== */
DWORD64 p_SetCursorPosition = FindPattern ( " r5apex.exe " , ( const unsigned char * ) " \x48 \x85 \xD2 \x0F \x00 \x00 \x00 \x00 \x00 \x48 \x89 \x6C \x24 \x00 \x56 \x48 \x83 \xEC \x40 \x4C " , " xxxx?????xxxx?xxxxxx " ) ; // Uncomment for anything that is not between S1 build 525 and S4 build 856
//DWORD64 p_SetCursorPosition = FindPattern("r5apex.exe", "\x48\x89\x6C\x24\x18\x48\x89\x74\x24\x20\x57\x48\x83\xEC\x40\x48\x8B\xF9", "xxxxxxxxxxxxxxxxxx"); // Uncomment for anything that is between S1 build 525 and S4 build 856
void ( * SetCursorPosition ) ( int a1 , INT64 posX , INT64 posY ) = ( void ( * ) ( int , INT64 , INT64 ) ) p_SetCursorPosition ; /*48 85 D2 0F ?? ?? ?? ?? ?? 48 89 6C 24 ?? 56 48 83 EC 40 4C*/
2021-05-17 07:54:13 -07:00
2021-06-08 10:54:49 -07:00
//DWORD64 p_GameWindowProc = FindPattern("r5apex.exe", (const unsigned char*)"\x48\x89\x4C\x24\x00\x56\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x48", "xxxx?xxxxxxxxxxx");
2021-05-17 07:54:13 -07:00
//unsigned int (*GameWindowProc)(int game, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) = (unsigned int (*)(int, HWND, UINT, WPARAM, LPARAM))p_GameWindowProc; /*48 89 4C 24 ?? 56 41 54 41 56 41 57 48 83 EC 48*/
2021-06-08 10:54:49 -07:00
/* ==== ------- ========================================================================================================================================================= */
2021-04-16 14:12:39 +02:00
void PrintHAddress ( ) // Test the sigscan results
{
2021-06-08 10:54:49 -07:00
std : : cout < < " -------------------------------------------------- " < < std : : endl ;
std : : cout < < " p_CommandExecute : " < < std : : hex < < p_CommandExecute < < std : : endl ;
std : : cout < < " p_ConVar_IsFlagSet : " < < std : : hex < < p_ConVar_IsFlagSet < < std : : endl ;
std : : cout < < " p_ConCommand_IsFlagSet : " < < std : : hex < < p_ConCommand_IsFlagSet < < std : : endl ;
std : : cout < < " -------------------------------------------------- " < < std : : endl ;
std : : cout < < " p_SQVM_Print : " < < std : : hex < < p_SQVM_Print < < std : : endl ;
std : : cout < < " p_SQVM_LoadScript : " < < std : : hex < < p_SQVM_LoadScript < < std : : endl ;
std : : cout < < " -------------------------------------------------- " < < std : : endl ;
std : : cout < < " p_NET_ReceiveDatagram : " < < std : : hex < < p_NET_ReceiveDatagram < < std : : endl ;
std : : cout < < " p_NET_SendDatagram : " < < std : : hex < < p_NET_SendDatagram < < std : : endl ;
std : : cout < < " -------------------------------------------------- " < < std : : endl ;
std : : cout < < " p_SetCursorPosition : " < < std : : hex < < p_SetCursorPosition < < std : : endl ;
//std::cout << " p_GameWindowProc : " << std::hex << p_GameWindowProc << std::endl;
std : : cout < < " -------------------------------------------------- " < < std : : endl ;
2021-04-25 14:36:55 -07:00
// TODO implement error handling when sigscan fails or result is 0
2021-04-16 14:12:39 +02:00
}
2021-06-08 10:54:49 -07:00
}