diff --git a/r5dev/console.cpp b/r5dev/console.cpp index ac7cd7c6..3e17cac8 100644 --- a/r5dev/console.cpp +++ b/r5dev/console.cpp @@ -9,7 +9,7 @@ #include "patterns.h" //--------------------------------------------------------------------------------- -// Console Hooks +// Console Init //--------------------------------------------------------------------------------- void SetupConsole() @@ -52,53 +52,54 @@ void SetupConsole() } } -static bool b_DebugConsole = true; +//--------------------------------------------------------------------------------- +// Console Hooks +//--------------------------------------------------------------------------------- + +static bool g_bDebugConsole = true; +static bool g_bToggleAll = false; bool Hook_ConVar_IsFlagSet(int** cvar, int flag) { int real_flags = *(*(cvar + (72 / (sizeof(void*)))) + (56 / sizeof(int))); - if (!b_DebugConsole) + if (g_bDebugConsole) { printf("----------------------------------------------\n"); printf(" Flaged: %08X\n", real_flags); } - // Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY real_flags &= 0xFFFFBFFD; - if (!b_DebugConsole) + if (g_bDebugConsole) { printf(" Masked: %08X\n", real_flags); printf(" Verify: %08X\n", flag); + printf("----------------------------------------------\n"); } - if (flag & 0x80000) - { - return true; - } + if (flag & 0x80000) { return true; } - return (real_flags & flag) != 0; + if (!g_bToggleAll) { return (real_flags & flag) != 0; } + else { return false; } } bool Hook_ConCommand_IsFlagSet(int* cmd, int flag) { int real_flags = *((cmd + (56 / sizeof(int)))); - if (!b_DebugConsole) + if (g_bDebugConsole) { printf("----------------------------------------------\n"); printf(" Flaged: %08X\n", real_flags); } - // Mask off FCVAR_CHEATS and FCVAR_DEVELOPMENTONLY real_flags &= 0xFFFFBFFD; - if (!b_DebugConsole) + if (g_bDebugConsole) { printf(" Masked: %08X\n", real_flags); printf(" Verify: %08X\n", flag); + printf("----------------------------------------------\n"); } - if (flag & 0x80000) - { - return true; - } + if (flag & 0x80000) { return true; } - return (real_flags & flag) != 0; + if (!g_bToggleAll) { return (real_flags & flag) != 0; } + else { return false; } } //--------------------------------------------------------------------------------- @@ -116,26 +117,14 @@ DWORD __stdcall ProcessConsoleWorker(LPVOID) printf(">"); std::getline(std::cin, sCommand); - if (sCommand == "toggle dev") - { - ToggleDevCommands(); - continue; - } - if (sCommand == "toggle net") - { - ToggleNetHooks(); - continue; - } - if (sCommand == "pattern test") - { - PrintHAddress(); - continue; - } - if (sCommand == "console test") - { - b_DebugConsole = !b_DebugConsole; - continue; - } + // Engine toggles + if (sCommand == "toggle net") { ToggleNetHooks(); continue; } + if (sCommand == "toggle dev") { ToggleDevCommands(); continue; } + if (sCommand == "toggle all") { g_bToggleAll = !g_bToggleAll; continue; } + + // Debug toggles + if (sCommand == "pattern test") { PrintHAddress(); continue; } + if (sCommand == "console test") { g_bDebugConsole = !g_bDebugConsole; continue; } // Execute the command in the r5 SQVM CommandExecute(NULL, sCommand.c_str()); diff --git a/r5dev/dllmain.cpp b/r5dev/dllmain.cpp index fd18e7d0..405e4c91 100644 --- a/r5dev/dllmain.cpp +++ b/r5dev/dllmain.cpp @@ -17,7 +17,6 @@ void InitializeR5Dev() printf("+-----------------------------------------------------------------------------+\n"); printf("| R5 DEV -- INITIALIZED ------------------------------------------------- |\n"); printf("+-----------------------------------------------------------------------------+\n"); - printf("\n"); } void TerminateR5Dev() diff --git a/r5dev/hooks.cpp b/r5dev/hooks.cpp index 6821773c..e2dd3593 100644 --- a/r5dev/hooks.cpp +++ b/r5dev/hooks.cpp @@ -10,7 +10,7 @@ #include "structs.h" //--------------------------------------------------------------------------------- -// Engine Hooks +// Netchan Hooks //--------------------------------------------------------------------------------- bool Hook_NET_ReceiveDatagram(int sock, void* inpacket, bool raw) @@ -22,7 +22,7 @@ bool Hook_NET_ReceiveDatagram(int sock, void* inpacket, bool raw) netpacket_t* pkt = (netpacket_t*)inpacket; // Log received packet data - HexDump("", "", "", 0, &pkt->data[i], pkt->wiresize); + HexDump("[+] NET_ReceiveDatagram", "platform\\log\\netchan.log", "a", 0, &pkt->data[i], pkt->wiresize); } return result; @@ -34,12 +34,16 @@ unsigned int Hook_NET_SendDatagram(SOCKET s, const char* buf, int len, int flags if (result) { // Log transmitted packet data - HexDump("", "", "", 0, buf, len); + HexDump("[+] NET_SendDatagram", "platform\\log\\netchan.log", "a", 0, buf, len); } return result; } +//--------------------------------------------------------------------------------- +// SquirrelVM Hooks +//--------------------------------------------------------------------------------- + void* Hook_SQVM_Print(void* sqvm, char* fmt, ...) { va_list args; @@ -63,16 +67,25 @@ bool Hook_SQVM_LoadScript(void* sqvm, const char* script_path, const char* scrip } } - printf(" + Loading SQVM Script '%s' ...\n", filepath); + printf(" [+] Loading SQVM Script '%s' ...\n", filepath); if (FileExists(filepath) && SQVM_LoadScript(sqvm, filepath, script_name, flag)) { return true; // Redirect to disk worked / script exists on disk.. } - printf(" |- FAILED, loading from SearchPath / VPK...\n"); + printf(" [!] FAILED, loading from SearchPath / VPK...\n"); return SQVM_LoadScript(sqvm, script_path, script_name, flag); } +//--------------------------------------------------------------------------------- +// Origin Hooks +//--------------------------------------------------------------------------------- + +unsigned int Hook_OriginScript(int value) +{ + return true; +} + //--------------------------------------------------------------------------------- // Hook Management //--------------------------------------------------------------------------------- @@ -83,9 +96,14 @@ void InstallHooks() DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - // Hook Functions + // Hook Engine functions DetourAttach((LPVOID*)&SQVM_Print, &Hook_SQVM_Print); DetourAttach((LPVOID*)&SQVM_LoadScript, &Hook_SQVM_LoadScript); + // Hook Origin functions + DetourAttach((LPVOID*)&Origin_IsEnabled, &Hook_OriginScript); + DetourAttach((LPVOID*)&Origin_IsUpToDate, &Hook_OriginScript); + DetourAttach((LPVOID*)&Origin_IsOnline, &Hook_OriginScript); + DetourAttach((LPVOID*)&Origin_IsReady, &Hook_OriginScript); // Commit the transaction if (DetourTransactionCommit() != NO_ERROR) @@ -101,44 +119,25 @@ void RemoveHooks() DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - // Unhook Functions + // Unhook Squirrel functions DetourDetach((LPVOID*)&SQVM_Print, &Hook_SQVM_Print); DetourDetach((LPVOID*)&SQVM_LoadScript, &Hook_SQVM_LoadScript); - DetourDetach((LPVOID*)&ConVar_IsFlagSet, &Hook_ConVar_IsFlagSet); - DetourDetach((LPVOID*)&ConCommand_IsFlagSet, &Hook_ConCommand_IsFlagSet); + // Unhook Netchan functions DetourDetach((LPVOID*)&NET_SendDatagram, &Hook_NET_SendDatagram); DetourDetach((LPVOID*)&NET_ReceiveDatagram, &Hook_NET_ReceiveDatagram); + // Unhook Console functions + DetourDetach((LPVOID*)&ConVar_IsFlagSet, &Hook_ConVar_IsFlagSet); + DetourDetach((LPVOID*)&ConCommand_IsFlagSet, &Hook_ConCommand_IsFlagSet); + // Unhook Origin functions + DetourDetach((LPVOID*)&Origin_IsEnabled, &Hook_OriginScript); + DetourDetach((LPVOID*)&Origin_IsUpToDate, &Hook_OriginScript); + DetourDetach((LPVOID*)&Origin_IsOnline, &Hook_OriginScript); + DetourDetach((LPVOID*)&Origin_IsReady, &Hook_OriginScript); // Commit the transaction DetourTransactionCommit(); } -void ToggleDevCommands() -{ - static bool g_dev = false; - - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - - if (!g_dev) - { - DetourAttach((LPVOID*)&ConVar_IsFlagSet, &Hook_ConVar_IsFlagSet); - DetourAttach((LPVOID*)&ConCommand_IsFlagSet, &Hook_ConCommand_IsFlagSet); - } - else - { - DetourDetach((LPVOID*)&ConVar_IsFlagSet, &Hook_ConVar_IsFlagSet); - DetourDetach((LPVOID*)&ConCommand_IsFlagSet, &Hook_ConCommand_IsFlagSet); - } - - if (DetourTransactionCommit() != NO_ERROR) - { - TerminateProcess(GetCurrentProcess(), 0xBAD0C0DE); - } - - g_dev = !g_dev; -} - void ToggleNetHooks() { static bool g_net = false; @@ -150,11 +149,21 @@ void ToggleNetHooks() { DetourAttach((LPVOID*)&NET_SendDatagram, &Hook_NET_SendDatagram); DetourAttach((LPVOID*)&NET_ReceiveDatagram, &Hook_NET_ReceiveDatagram); + printf("\n"); + printf("+--------------------------------------------------------+\n"); + printf("|>>>>>>>>>>>>>| NETCHANNEL TRACE ACTIVATED |<<<<<<<<<<<<<|\n"); + printf("+--------------------------------------------------------+\n"); + printf("\n"); } else { DetourDetach((LPVOID*)&NET_SendDatagram, &Hook_NET_SendDatagram); DetourDetach((LPVOID*)&NET_ReceiveDatagram, &Hook_NET_ReceiveDatagram); + printf("\n"); + printf("+--------------------------------------------------------+\n"); + printf("|>>>>>>>>>>>>| NETCHANNEL TRACE DEACTIVATED |<<<<<<<<<<<<|\n"); + printf("+--------------------------------------------------------+\n"); + printf("\n"); } if (DetourTransactionCommit() != NO_ERROR) @@ -163,4 +172,41 @@ void ToggleNetHooks() } g_net = !g_net; +} + +void ToggleDevCommands() +{ + static bool g_dev = false; + + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + + if (!g_dev) + { + DetourAttach((LPVOID*)&ConVar_IsFlagSet, &Hook_ConVar_IsFlagSet); + DetourAttach((LPVOID*)&ConCommand_IsFlagSet, &Hook_ConCommand_IsFlagSet); + printf("\n"); + printf("+--------------------------------------------------------+\n"); + printf("|>>>>>>>>>>>>>| DEVONLY COMMANDS ACTIVATED |<<<<<<<<<<<<<|\n"); + printf("+--------------------------------------------------------+\n"); + printf("\n"); + + } + else + { + DetourDetach((LPVOID*)&ConVar_IsFlagSet, &Hook_ConVar_IsFlagSet); + DetourDetach((LPVOID*)&ConCommand_IsFlagSet, &Hook_ConCommand_IsFlagSet); + printf("\n"); + printf("+--------------------------------------------------------+\n"); + printf("|>>>>>>>>>>>>| DEVONLY COMMANDS DEACTIVATED |<<<<<<<<<<<<|\n"); + printf("+--------------------------------------------------------+\n"); + printf("\n"); + } + + if (DetourTransactionCommit() != NO_ERROR) + { + TerminateProcess(GetCurrentProcess(), 0xBAD0C0DE); + } + + g_dev = !g_dev; } \ No newline at end of file diff --git a/r5dev/patterns.h b/r5dev/patterns.h index 633caeea..caf0f6ae 100644 --- a/r5dev/patterns.h +++ b/r5dev/patterns.h @@ -1,44 +1,80 @@ #pragma once +#include #include "sigscan.h" // Define the signatures or offsets to be searched and hooked namespace { - SigScan fScanner; + CSigScan Scanner; - LONGLONG p_GameConsole = fScanner.FindPattern("r5apex.exe", "\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_GameConsole; + /* =========================================================== CONSOLE =========================================================== */ + LONGLONG p_CommandExecute = 0x140244900;//Scanner.FindPattern("r5apex.exe", "\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;//p_CommandExecute; /*48 89 5C 24 ?? 57 48 83 EC 20 48 8D 0D ?? ?? ?? ?? 41 8B D8*/ - LONGLONG p_ConVarFlag = fScanner.FindPattern("r5apex.exe", "\x48\x8B\x41\x48\x85\x50\x38", "xxxxxxx"); - bool (*ConVar_IsFlagSet)(int** cvar, int flag) = (bool (*)(int**, int))p_ConVarFlag; + LONGLONG p_ConVar_IsFlagSet = 0x1404C87C0;//Scanner.FindPattern("r5apex.exe", "\x48\x8B\x41\x48\x85\x50\x38", "xxxxxxx"); + bool (*ConVar_IsFlagSet)(int** cvar, int flag) = (bool (*)(int**, int))p_ConVar_IsFlagSet;//p_ConVar_IsFlagSet; /*48 8B 41 48 85 50 38*/ - LONGLONG p_ConCommandFlag = fScanner.FindPattern("r5apex.exe", "\x85\x51\x38\x0f\x95\xc0\xc3", "xxxxxxx"); - bool (*ConCommand_IsFlagSet)(int* cmd, int flag) = (bool (*)(int*, int))p_ConCommandFlag; + LONGLONG p_ConCommand_IsFlagSet = 0x1404C7DF0;//Scanner.FindPattern("r5apex.exe", "\x85\x51\x38\x0F\x95\xC0\xC3", "xxxxxxx"); + bool (*ConCommand_IsFlagSet)(int* cmd, int flag) = (bool (*)(int*, int))p_ConCommand_IsFlagSet;// p_ConCommand_IsFlagSet; /*85 51 38 0F 95 C0 C3*/ - LONGLONG p_SquirrelVMPrint = fScanner.FindPattern("r5apex.exe", "\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_SquirrelVMPrint; + /* =========================================================== SQUIRREL ========================================================== */ + LONGLONG p_SQVM_Print = 0x1410A4330;//Scanner.FindPattern("r5apex.exe", "\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;// 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*/ - //LONGLONG p_SquirrelVMScript = fScanner.FindPattern("r5apex.exe", "\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"); // Uncomment for S0 and S1 - LONGLONG p_SquirrelVMScript = fScanner.FindPattern("r5apex.exe", "\x48\x8B\xC4\x48\x89\x48\x08\x55\x41\x56\x48\x8D\x68", "xxxxxxxxxxxxx"); // Uncomment 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_SquirrelVMScript; + LONGLONG p_SQVM_LoadScript = 0x1410A1510;//Scanner.FindPattern("r5apex.exe", "\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 + //LONGLONG p_SQVM_LoadScript = Scanner.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;//p_SQVM_LoadScript; /*E8 ?? ?? ?? ?? 84 C0 74 1C 41 B9 ?? ?? ?? ??*/ - LONGLONG p_NetRXDatagram = fScanner.FindPattern("r5apex.exe", "\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_NetRXDatagram; + /* =========================================================== NETCHAN =========================================================== */ + LONGLONG p_NET_ReceiveDatagram = 0x1402B46B0;//Scanner.FindPattern("r5apex.exe", "\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;//p_NET_ReceiveDatagram; /*E8 ?? ?? ?? ?? 84 C0 75 35 48 8B D3*/ - LONGLONG p_NetTXDatagram = fScanner.FindPattern("r5apex.exe", "\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_NetTXDatagram; + LONGLONG p_NET_SendDatagram = 0x1402B2C90;//Scanner.FindPattern("r5apex.exe", "\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;// 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*/ + + /* =========================================================== WINAPI ============================================================ */ + LONGLONG p_SetCursorPosition = 0x1403F1C70;//Scanner.FindPattern("r5apex.exe", "\x48\x85\xD2\x0F\x00\x00\x00\x00\x00\x48\x89\x6C\x24\x00\x56\x48\x83\xEC\x40\x4C", "xxxx?????xxxx?xxxxxx"); // TODO: This does not exist in anything between S1 build 525 and S4 build 856 + void (*SetCursorPosition)(int a1, int a2, unsigned int posX, unsigned int posY) = (void (*)(int, int, unsigned int, unsigned int))p_SetCursorPosition;// p_SetCursorPosition; /*48 85 D2 0F ?? ?? ?? ?? ?? 48 89 6C 24 ?? 56 48 83 EC 40 4C*/ + + //LONGLONG p_GameWindowProc = 0x1403F3C50; //Scanner.FindPattern("r5apex.exe", "\x48\x89\x4C\x24\x00\x56\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x48", "xxxx?xxxxxxxxxxx"); + //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*/ + + /* =========================================================== ORIGIN ============================================================ */ + LONGLONG p_Origin_IsEnabled = 0x1408BCCB0;//Scanner.FindPattern("r5apex.exe", "\x40\x53\x48\x83\xEC\x30\x48\x8B\xD9\xE8\x00\x00\x00\x00\x33\xC9", "xxxxxxxxxx????xx"); + unsigned int (*Origin_IsEnabled) (int value) = (unsigned int (*)(int))p_Origin_IsEnabled;// p_Origin_IsEnabled; //0x1406CC150; + + LONGLONG p_Origin_IsUpToDate = 0x1408BCC00;//Scanner.FindPattern("r5apex.exe", "\x40\x53\x48\x83\xEC\x30\x48\x8B\xD9\xE8\x00\x00\x00\x00\x8B\x4B\x68", "xxxxxxxxxx????xxx");; + unsigned int (*Origin_IsUpToDate) (int value) = (unsigned int (*)(int))p_Origin_IsUpToDate;//p_Origin_IsUpToDate; //0x1406CC0C0; + + LONGLONG p_Origin_IsOnline = 0x1408BCB60;//Scanner.FindPattern("r5apex.exe", "\x40\x53\x48\x83\xEC\x30\x48\x8B\xD9\xE8\x00\x00\x00\x00\x84\xC0\x74\x07", "xxxxxxxxxx????xxxx");; + unsigned int (*Origin_IsOnline) (int value) = (unsigned int (*)(int))p_Origin_IsOnline;// p_Origin_IsOnline; //0x1406CC010; + + LONGLONG p_Origin_IsReady = 0x1408BCA80;//Scanner.FindPattern("r5apex.exe", "\x40\x53\x48\x83\xEC\x30\x48\x8B\xD9\xE8\x00\x00\x00\x00\x84\xC0\x74\x47", "xxxxxxxxxx????xxxx");; + unsigned int (*Origin_IsReady) (int value) = (unsigned int (*)(int))p_Origin_IsReady; //p_Origin_IsReady; //0x1406CBF50; + + /* =========================================================== ------- =========================================================== */ void PrintHAddress() // Test the sigscan results { - printf("\n"); - printf("0x%llx = GameConsole\n", p_GameConsole); - printf("0x%llx = GameConsoleFlag\n", p_ConCommandFlag); - printf("0x%llx = GameConsoleFlag\n", p_ConVarFlag); - printf("0x%llx = SquirrelVMPrint\n", p_SquirrelVMPrint); - printf("0x%llx = SquirrelVMScript\n", p_SquirrelVMScript); - printf("0x%llx = NetRXDatagram\n", p_NetRXDatagram); - printf("0x%llx = NetTXDatagram\n", p_NetTXDatagram); - printf("\n"); + std::cout << "----------------------------------------------" << std::endl; + std::cout << " CommandExecute : " << std::hex << p_CommandExecute << std::endl; + std::cout << " ConCommandFlag : " << std::hex << p_ConVar_IsFlagSet << std::endl; + std::cout << " ConVarFlag : " << std::hex << p_ConCommand_IsFlagSet << std::endl; + std::cout << "----------------------------------------------" << std::endl; + std::cout << " SquirrelVMPrint : " << std::hex << p_SQVM_Print << std::endl; + std::cout << " SquirrelVMScript : " << std::hex << p_SQVM_LoadScript << std::endl; + std::cout << "----------------------------------------------" << std::endl; + std::cout << " NetReceiveDatagram : " << std::hex << p_NET_ReceiveDatagram << std::endl; + std::cout << " NetSendDatagram : " << std::hex << p_NET_SendDatagram << std::endl; + std::cout << "----------------------------------------------" << std::endl; + std::cout << " SetCursorPosition : " << std::hex << p_SetCursorPosition << std::endl; + //std::cout << " GameWindowProc : " << std::hex << p_GameWindowProc << std::endl; + std::cout << "----------------------------------------------" << std::endl; + std::cout << " OriginIsEnabled : " << std::hex << p_Origin_IsEnabled << std::endl; + std::cout << " OriginIsUpdate : " << std::hex << p_Origin_IsUpToDate << std::endl; + std::cout << " OriginIsOnline : " << std::hex << p_Origin_IsOnline << std::endl; + std::cout << " OriginIsReady : " << std::hex << p_Origin_IsReady << std::endl; + std::cout << "----------------------------------------------" << std::endl; // TODO implement error handling when sigscan fails or result is 0 } diff --git a/r5dev/sigscan.h b/r5dev/sigscan.h index 58e2b189..b97d6a4c 100644 --- a/r5dev/sigscan.h +++ b/r5dev/sigscan.h @@ -1,7 +1,7 @@ #pragma once #include -class SigScan +class CSigScan { public: // For getting information about the executing module diff --git a/r5dev/utilities.h b/r5dev/utilities.h index 2abc8587..6eefc65d 100644 --- a/r5dev/utilities.h +++ b/r5dev/utilities.h @@ -14,6 +14,7 @@ namespace !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); } + ///////////////////////////////////////////////////////////////////////////// static void DbgPrint(LPCSTR Format, ...) { CHAR Buffer[512] = { 0 }; @@ -30,8 +31,54 @@ namespace OutputDebugString(Buffer); } + ///////////////////////////////////////////////////////////////////////////// static void HexDump(const char* header, const char* file, const char* mode, int func, const void* data, int size) { - // todo.. + char ascii[17] = { 0 }; + int i, j; + ascii[16] = '\0'; + FILE* sTraceLog; + +#pragma warning(suppress : 4996) + sTraceLog = fopen(file, mode); + if (sTraceLog == NULL) + { + printf("Unable to write '%s'!\n", file); + if (func == 0) { ToggleNetHooks(); } + return; + } + + // Create block header + fprintf(sTraceLog, "%s ---- %u Bytes\n:\n", header, size); + fprintf(sTraceLog, "-------- 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF\n"); + + // Output the buffer to the file + for (i = 0; i < size; i++) + { + if (i % size == 0) { fprintf(sTraceLog, " 0x%04x ", i); fflush(NULL); } + fprintf(sTraceLog, "%02x ", ((unsigned char*)data)[i]); + fflush(NULL); + + if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') { ascii[i % 16] = ((unsigned char*)data)[i]; } + else { ascii[i % 16] = '.'; } + + if ((i + 1) % 8 == 0 || i + 1 == size) + { + fprintf(sTraceLog, " "); + fflush(NULL); + + if ((i + 1) % 16 == 0) { i++; fprintf(sTraceLog, "%s \n ", ascii); fprintf(sTraceLog, "0x%04X ", i--); fflush(NULL); } + else if (i + 1 == size) + { + ascii[(i + 1) % 16] = '\0'; + if ((i + 1) % 16 <= 8) { fprintf(sTraceLog, " "); fflush(NULL); } + for (j = (i + 1) % 16; j < 16; j++) { fprintf(sTraceLog, " "); fflush(NULL); } + fprintf(sTraceLog, "%s \n", ascii); + fprintf(sTraceLog, "---------------------------------------------------------------------------\n\n"); + } + } + } + + fclose(sTraceLog); } } \ No newline at end of file