From c0be5d7cadbd88d529acc873ae3c42ccfc8c39af Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 9 Nov 2022 17:10:08 +0100 Subject: [PATCH] Prepare symbols for process wrapping --- src/client/game/game.hpp | 11 +++-- src/client/game/symbols.hpp | 63 +++++++++++++------------- src/client/loader/component_loader.cpp | 7 ++- src/client/loader/component_loader.hpp | 1 + 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/client/game/game.hpp b/src/client/game/game.hpp index 8cdea0c1..29f4ee50 100644 --- a/src/client/game/game.hpp +++ b/src/client/game/game.hpp @@ -1,10 +1,11 @@ #pragma once #include "structs.hpp" +#include "loader/component_loader.hpp" namespace game { - #define Com_Error(code, fmt, ...) \ +#define Com_Error(code, fmt, ...) \ Com_Error_(__FILE__, __LINE__, code, fmt, ##__VA_ARGS__) int Conbuf_CleanText(const char* source, char* target); @@ -15,16 +16,16 @@ namespace game { public: symbol(const size_t address) - : address_(reinterpret_cast(address)) + : address_(address) { } T* get() const { - return address_; + return reinterpret_cast(get_game_address(this->address_)); } - operator T* () const + operator T*() const { return this->get(); } @@ -35,7 +36,7 @@ namespace game } private: - T* address_; + size_t address_; }; // Global game definitions diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 9f66d9b0..f9ddb7ac 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -1,7 +1,6 @@ #pragma once #include "structs.hpp" -#include "loader/component_loader.hpp" #define WEAK __declspec(selectany) @@ -10,18 +9,18 @@ namespace game // CL WEAK symbol CL_ConnectFromLobby - {0x14134C570_g}; + {0x14134C570}; // Com - WEAK symbol Com_Printf{0x1421499C0_g}; - WEAK symbol Com_Error_{0x1420F8BD0_g}; - WEAK symbol Com_SessionMode_IsMode{0x1420F7DD0_g}; + WEAK symbol Com_Printf{0x1421499C0}; + WEAK symbol Com_Error_{0x1420F8BD0}; + WEAK symbol Com_SessionMode_IsMode{0x1420F7DD0}; - WEAK symbol Cbuf_AddText{0x1420EC8B0_g}; + WEAK symbol Cbuf_AddText{0x1420EC8B0}; WEAK symbol Cmd_AddCommandInternal{ 0x1420ED530_g }; - WEAK symbol Con_GetTextCopy{0x14133A7D0_g}; + WEAK symbol Con_GetTextCopy{0x14133A7D0}; // DB WEAK symbol DB_LoadXAssets{ @@ -29,27 +28,27 @@ namespace game }; // Live - WEAK symbol Live_GetConnectivityInformation{0x141E0C410_g}; + WEAK symbol Live_GetConnectivityInformation{0x141E0C410}; // MSG - WEAK symbol MSG_ReadByte{0x142155EB0_g}; + WEAK symbol MSG_ReadByte{0x142155EB0}; // NET - WEAK symbol NET_SendPacket{0x142332F70_g}; - WEAK symbol NET_StringToAdr{0x1421731E0_g}; - WEAK symbol NetAdr_InitFromString{0x142332F70_g}; + WEAK symbol NET_SendPacket{0x142332F70}; + WEAK symbol NET_StringToAdr{0x1421731E0}; + WEAK symbol NetAdr_InitFromString{0x142332F70}; // Sys - WEAK symbol Sys_Milliseconds{0x142333430_g}; - WEAK symbol Sys_ShowConsole{0x142333F80_g}; - WEAK symbol Sys_GetTLS{0x142184210_g}; + WEAK symbol Sys_Milliseconds{0x142333430}; + WEAK symbol Sys_ShowConsole{0x142333F80}; + WEAK symbol Sys_GetTLS{0x142184210}; // Dvar - WEAK symbol Dvar_FindVar{0x1422BD730_g}; - WEAK symbol Dvar_GenerateHash{0x14133DBF0_g}; - WEAK symbol Dvar_FindMalleableVar{0x1422BD6A0_g}; - WEAK symbol Dvar_GetDebugName{0x1422BDCB0_g}; - WEAK symbol Dvar_GetString{0x1422BFFF0_g}; + WEAK symbol Dvar_FindVar{0x1422BD730}; + WEAK symbol Dvar_GenerateHash{0x14133DBF0}; + WEAK symbol Dvar_FindMalleableVar{0x1422BD6A0}; + WEAK symbol Dvar_GetDebugName{0x1422BDCB0}; + WEAK symbol Dvar_GetString{0x1422BFFF0}; WEAK symbol Dvar_SetFromStringByName{ 0x1422C7F60_g }; @@ -60,22 +59,22 @@ namespace game }; // Variables - WEAK symbol cmd_functions{0x15689FF58_g}; - WEAK symbol sv_cmd_args{0x15689CE30_g}; + WEAK symbol cmd_functions{0x15689FF58}; + WEAK symbol sv_cmd_args{0x15689CE30}; - WEAK symbol ip_socket{0x157E77818_g}; + WEAK symbol ip_socket{0x157E77818}; - WEAK symbol s_join{0x15574C640_g}; + WEAK symbol s_join{0x15574C640}; namespace s_wcd { - WEAK symbol codLogo{0x157E77A50_g}; - WEAK symbol hfBufferFont{0x157E77A58_g}; - WEAK symbol hWnd{0x157E77A40_g}; - WEAK symbol hwndBuffer{0x157E77A48_g}; - WEAK symbol hwndInputLine{0x157E77A60_g}; - WEAK symbol windowHeight{0x157E7806C_g}; - WEAK symbol windowWidth{0x157E78068_g}; - WEAK symbol SysInputLineWndProc{0x157E78070_g}; + WEAK symbol codLogo{0x157E77A50}; + WEAK symbol hfBufferFont{0x157E77A58}; + WEAK symbol hWnd{0x157E77A40}; + WEAK symbol hwndBuffer{0x157E77A48}; + WEAK symbol hwndInputLine{0x157E77A60}; + WEAK symbol windowHeight{0x157E7806C}; + WEAK symbol windowWidth{0x157E78068}; + WEAK symbol SysInputLineWndProc{0x157E78070}; } } diff --git a/src/client/loader/component_loader.cpp b/src/client/loader/component_loader.cpp index fa4617d3..c163fd8e 100644 --- a/src/client/loader/component_loader.cpp +++ b/src/client/loader/component_loader.cpp @@ -143,12 +143,17 @@ size_t get_base() return base; } -size_t operator"" _g(const size_t val) +size_t get_game_address(const size_t val) { static auto base = get_base(); return base + (val - 0x140000000); } +size_t operator"" _g(const size_t val) +{ + return get_game_address(val); +} + size_t reverse_g(const size_t val) { static auto base = get_base(); diff --git a/src/client/loader/component_loader.hpp b/src/client/loader/component_loader.hpp index 1e4a97d0..01b55ae2 100644 --- a/src/client/loader/component_loader.hpp +++ b/src/client/loader/component_loader.hpp @@ -58,6 +58,7 @@ namespace \ } size_t get_base(); +size_t get_game_address(size_t val); size_t operator"" _g(size_t val); size_t reverse_g(size_t val); size_t reverse_g(const void* val);