From 513705e33f59273c5b463c0da874a0066e8d0589 Mon Sep 17 00:00:00 2001 From: F1F7Y <64418963+F1F7Y@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:28:35 +0200 Subject: Memory class renaming (#469) - Renames `MemoryAddress` to `CMemoryAddress` - Renames `CMemoryAddress::As` to `CMemoryAddress::RCast` --- NorthstarDLL/client/audio.cpp | 2 +- NorthstarDLL/client/chatcommand.cpp | 3 +- NorthstarDLL/client/clientauthhooks.cpp | 2 +- NorthstarDLL/client/debugoverlay.cpp | 8 +- NorthstarDLL/client/localchatwriter.cpp | 10 +- NorthstarDLL/client/r2client.cpp | 6 +- NorthstarDLL/core/convar/concommand.cpp | 2 +- NorthstarDLL/core/convar/convar.cpp | 4 +- NorthstarDLL/core/filesystem/rpakfilesystem.cpp | 4 +- NorthstarDLL/core/memory.cpp | 68 +++++----- NorthstarDLL/core/memory.h | 36 +++--- NorthstarDLL/core/tier0.cpp | 8 +- NorthstarDLL/dedicated/dedicated.cpp | 4 +- NorthstarDLL/dedicated/dedicatedlogtoclient.cpp | 2 +- NorthstarDLL/engine/hoststate.cpp | 2 +- NorthstarDLL/engine/r2engine.cpp | 18 +-- NorthstarDLL/logging/loghooks.cpp | 2 +- NorthstarDLL/scripts/client/scriptbrowserhooks.cpp | 2 +- NorthstarDLL/scripts/scriptdatatables.cpp | 4 +- NorthstarDLL/server/alltalk.cpp | 2 +- NorthstarDLL/server/auth/serverauthentication.cpp | 2 +- NorthstarDLL/server/buildainfile.cpp | 8 +- NorthstarDLL/server/r2server.cpp | 4 +- NorthstarDLL/server/serverchathooks.cpp | 26 ++-- NorthstarDLL/server/serverpresence.cpp | 2 +- NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp | 8 +- .../exploit_fixes/exploitfixes_utf8parser.cpp | 4 +- NorthstarDLL/shared/exploit_fixes/ns_limits.cpp | 2 +- NorthstarDLL/shared/keyvalues.cpp | 6 +- NorthstarDLL/shared/maxplayers.cpp | 18 +-- NorthstarDLL/shared/misccommands.cpp | 2 +- NorthstarDLL/squirrel/squirrel.cpp | 142 ++++++++++----------- NorthstarDLL/util/wininfo.cpp | 2 +- 33 files changed, 208 insertions(+), 207 deletions(-) diff --git a/NorthstarDLL/client/audio.cpp b/NorthstarDLL/client/audio.cpp index ea1f6416..9fcac982 100644 --- a/NorthstarDLL/client/audio.cpp +++ b/NorthstarDLL/client/audio.cpp @@ -502,5 +502,5 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", AudioHooks, ConVar, (CModule module)) AUTOHOOK_DISPATCH() Cvar_ns_print_played_sounds = new ConVar("ns_print_played_sounds", "0", FCVAR_NONE, ""); - MilesStopAll = module.Offset(0x580850).As(); + MilesStopAll = module.Offset(0x580850).RCast(); } diff --git a/NorthstarDLL/client/chatcommand.cpp b/NorthstarDLL/client/chatcommand.cpp index c1ad1b3b..9cf34e43 100644 --- a/NorthstarDLL/client/chatcommand.cpp +++ b/NorthstarDLL/client/chatcommand.cpp @@ -28,7 +28,8 @@ void ConCommand_log(const CCommand& args) ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", ClientChatCommand, ConCommand, (CModule module)) { - ClientSayText = module.Offset(0x54780).As(); + ClientSayText = + module.Offset(0x54780).RCast(); RegisterConCommand("say", ConCommand_say, "Enters a message in public chat", FCVAR_CLIENTDLL); RegisterConCommand("say_team", ConCommand_say_team, "Enters a message in team chat", FCVAR_CLIENTDLL); RegisterConCommand("log", ConCommand_log, "Log a message to the local chat window", FCVAR_CLIENTDLL); diff --git a/NorthstarDLL/client/clientauthhooks.cpp b/NorthstarDLL/client/clientauthhooks.cpp index 7fca9581..e66da6c8 100644 --- a/NorthstarDLL/client/clientauthhooks.cpp +++ b/NorthstarDLL/client/clientauthhooks.cpp @@ -52,7 +52,7 @@ ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", ClientAuthHooks, ConVar, (CModule modu { AUTOHOOK_DISPATCH() - p3PToken = module.Offset(0x13979D80).As(); + p3PToken = module.Offset(0x13979D80).RCast(); // this cvar will save to cfg once initially agreed with Cvar_ns_has_agreed_to_send_token = new ConVar( diff --git a/NorthstarDLL/client/debugoverlay.cpp b/NorthstarDLL/client/debugoverlay.cpp index e3a9292d..cdb14693 100644 --- a/NorthstarDLL/client/debugoverlay.cpp +++ b/NorthstarDLL/client/debugoverlay.cpp @@ -127,13 +127,13 @@ ON_DLL_LOAD_CLIENT_RELIESON("engine.dll", DebugOverlay, ConVar, (CModule module) { AUTOHOOK_DISPATCH() - RenderLine = module.Offset(0x192A70).As(); - RenderBox = module.Offset(0x192520).As(); - RenderWireframeBox = module.Offset(0x193DA0).As(); + RenderLine = module.Offset(0x192A70).RCast(); + RenderBox = module.Offset(0x192520).RCast(); + RenderWireframeBox = module.Offset(0x193DA0).RCast(); sEngineModule = reinterpret_cast(module.m_nAddress); // not in g_pCVar->FindVar by this point for whatever reason, so have to get from memory - ConVar* Cvar_enable_debug_overlays = module.Offset(0x10DB0990).As(); + ConVar* Cvar_enable_debug_overlays = module.Offset(0x10DB0990).RCast(); Cvar_enable_debug_overlays->SetValue(false); Cvar_enable_debug_overlays->m_pszDefaultValue = (char*)"0"; Cvar_enable_debug_overlays->AddFlags(FCVAR_CHEAT); diff --git a/NorthstarDLL/client/localchatwriter.cpp b/NorthstarDLL/client/localchatwriter.cpp index 57fe98a2..848d898f 100644 --- a/NorthstarDLL/client/localchatwriter.cpp +++ b/NorthstarDLL/client/localchatwriter.cpp @@ -440,10 +440,10 @@ void LocalChatWriter::InsertDefaultFade() ON_DLL_LOAD_CLIENT("client.dll", LocalChatWriter, (CModule module)) { - gGameSettings = module.Offset(0x11BAA48).As(); - gChatFadeLength = module.Offset(0x11BAB78).As(); - gChatFadeSustain = module.Offset(0x11BAC08).As(); - CHudChat::allHuds = module.Offset(0x11BA9E8).As(); + gGameSettings = module.Offset(0x11BAA48).RCast(); + gChatFadeLength = module.Offset(0x11BAB78).RCast(); + gChatFadeSustain = module.Offset(0x11BAC08).RCast(); + CHudChat::allHuds = module.Offset(0x11BA9E8).RCast(); - ConvertANSIToUnicode = module.Offset(0x7339A0).As(); + ConvertANSIToUnicode = module.Offset(0x7339A0).RCast(); } diff --git a/NorthstarDLL/client/r2client.cpp b/NorthstarDLL/client/r2client.cpp index fabc0dc6..fea97d8e 100644 --- a/NorthstarDLL/client/r2client.cpp +++ b/NorthstarDLL/client/r2client.cpp @@ -12,8 +12,8 @@ namespace R2 ON_DLL_LOAD("engine.dll", R2EngineClient, (CModule module)) { - g_pLocalPlayerUserID = module.Offset(0x13F8E688).As(); - g_pLocalPlayerOriginToken = module.Offset(0x13979C80).As(); + g_pLocalPlayerUserID = module.Offset(0x13F8E688).RCast(); + g_pLocalPlayerOriginToken = module.Offset(0x13979C80).RCast(); - GetBaseLocalClient = module.Offset(0x78200).As(); + GetBaseLocalClient = module.Offset(0x78200).RCast(); } diff --git a/NorthstarDLL/core/convar/concommand.cpp b/NorthstarDLL/core/convar/concommand.cpp index ce198159..732e0d1f 100644 --- a/NorthstarDLL/core/convar/concommand.cpp +++ b/NorthstarDLL/core/convar/concommand.cpp @@ -148,7 +148,7 @@ void RegisterConCommand( ON_DLL_LOAD("engine.dll", ConCommand, (CModule module)) { - ConCommandConstructor = module.Offset(0x415F60).As(); + ConCommandConstructor = module.Offset(0x415F60).RCast(); AddMiscConCommands(); g_pPluginCommunicationhandler->m_sEngineData.ConCommandConstructor = (void*)ConCommandConstructor; diff --git a/NorthstarDLL/core/convar/convar.cpp b/NorthstarDLL/core/convar/convar.cpp index 5069192e..9aaaca66 100644 --- a/NorthstarDLL/core/convar/convar.cpp +++ b/NorthstarDLL/core/convar/convar.cpp @@ -31,8 +31,8 @@ void* g_pIConVar_Vtable = nullptr; //----------------------------------------------------------------------------- ON_DLL_LOAD("engine.dll", ConVar, (CModule module)) { - conVarMalloc = module.Offset(0x415C20).As(); - conVarRegister = module.Offset(0x417230).As(); + conVarMalloc = module.Offset(0x415C20).RCast(); + conVarRegister = module.Offset(0x417230).RCast(); g_pConVar_Vtable = module.Offset(0x67FD28); g_pIConVar_Vtable = module.Offset(0x67FDC8); diff --git a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp index e42d6826..8d50b07a 100644 --- a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp +++ b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp @@ -338,8 +338,8 @@ ON_DLL_LOAD("engine.dll", RpakFilesystem, (CModule module)) g_pPakLoadManager = new PakLoadManager; - g_pakLoadApi = module.Offset(0x5BED78).Deref().As(); - pUnknownPakLoadSingleton = module.Offset(0x7C5E20).As(); + g_pakLoadApi = module.Offset(0x5BED78).Deref().RCast(); + pUnknownPakLoadSingleton = module.Offset(0x7C5E20).RCast(); LoadPakAsyncHook.Dispatch((LPVOID*)g_pakLoadApi->LoadPakAsync); UnloadPakHook.Dispatch((LPVOID*)g_pakLoadApi->UnloadPak); diff --git a/NorthstarDLL/core/memory.cpp b/NorthstarDLL/core/memory.cpp index 7bd87d70..3770586f 100644 --- a/NorthstarDLL/core/memory.cpp +++ b/NorthstarDLL/core/memory.cpp @@ -1,93 +1,93 @@ #include "memory.h" -MemoryAddress::MemoryAddress() : m_nAddress(0) {} -MemoryAddress::MemoryAddress(const uintptr_t nAddress) : m_nAddress(nAddress) {} -MemoryAddress::MemoryAddress(const void* pAddress) : m_nAddress(reinterpret_cast(pAddress)) {} +CMemoryAddress::CMemoryAddress() : m_nAddress(0) {} +CMemoryAddress::CMemoryAddress(const uintptr_t nAddress) : m_nAddress(nAddress) {} +CMemoryAddress::CMemoryAddress(const void* pAddress) : m_nAddress(reinterpret_cast(pAddress)) {} // operators -MemoryAddress::operator uintptr_t() const +CMemoryAddress::operator uintptr_t() const { return m_nAddress; } -MemoryAddress::operator void*() const +CMemoryAddress::operator void*() const { return reinterpret_cast(m_nAddress); } -MemoryAddress::operator bool() const +CMemoryAddress::operator bool() const { return m_nAddress != 0; } -bool MemoryAddress::operator==(const MemoryAddress& other) const +bool CMemoryAddress::operator==(const CMemoryAddress& other) const { return m_nAddress == other.m_nAddress; } -bool MemoryAddress::operator!=(const MemoryAddress& other) const +bool CMemoryAddress::operator!=(const CMemoryAddress& other) const { return m_nAddress != other.m_nAddress; } -bool MemoryAddress::operator==(const uintptr_t& addr) const +bool CMemoryAddress::operator==(const uintptr_t& addr) const { return m_nAddress == addr; } -bool MemoryAddress::operator!=(const uintptr_t& addr) const +bool CMemoryAddress::operator!=(const uintptr_t& addr) const { return m_nAddress != addr; } -MemoryAddress MemoryAddress::operator+(const MemoryAddress& other) const +CMemoryAddress CMemoryAddress::operator+(const CMemoryAddress& other) const { return Offset(other.m_nAddress); } -MemoryAddress MemoryAddress::operator-(const MemoryAddress& other) const +CMemoryAddress CMemoryAddress::operator-(const CMemoryAddress& other) const { - return MemoryAddress(m_nAddress - other.m_nAddress); + return CMemoryAddress(m_nAddress - other.m_nAddress); } -MemoryAddress MemoryAddress::operator+(const uintptr_t& addr) const +CMemoryAddress CMemoryAddress::operator+(const uintptr_t& addr) const { return Offset(addr); } -MemoryAddress MemoryAddress::operator-(const uintptr_t& addr) const +CMemoryAddress CMemoryAddress::operator-(const uintptr_t& addr) const { - return MemoryAddress(m_nAddress - addr); + return CMemoryAddress(m_nAddress - addr); } -MemoryAddress MemoryAddress::operator*() const +CMemoryAddress CMemoryAddress::operator*() const { return Deref(); } // traversal -MemoryAddress MemoryAddress::Offset(const uintptr_t nOffset) const +CMemoryAddress CMemoryAddress::Offset(const uintptr_t nOffset) const { - return MemoryAddress(m_nAddress + nOffset); + return CMemoryAddress(m_nAddress + nOffset); } -MemoryAddress MemoryAddress::Deref(const int nNumDerefs) const +CMemoryAddress CMemoryAddress::Deref(const int nNumDerefs) const { uintptr_t ret = m_nAddress; for (int i = 0; i < nNumDerefs; i++) ret = *reinterpret_cast(ret); - return MemoryAddress(ret); + return CMemoryAddress(ret); } // patching -void MemoryAddress::Patch(const uint8_t* pBytes, const size_t nSize) +void CMemoryAddress::Patch(const uint8_t* pBytes, const size_t nSize) { if (nSize) WriteProcessMemory(GetCurrentProcess(), reinterpret_cast(m_nAddress), pBytes, nSize, NULL); } -void MemoryAddress::Patch(const std::initializer_list bytes) +void CMemoryAddress::Patch(const std::initializer_list bytes) { uint8_t* pBytes = new uint8_t[bytes.size()]; @@ -146,13 +146,13 @@ inline std::vector HexBytesToString(const char* pHexString) return ret; } -void MemoryAddress::Patch(const char* pBytes) +void CMemoryAddress::Patch(const char* pBytes) { std::vector vBytes = HexBytesToString(pBytes); Patch(vBytes.data(), vBytes.size()); } -void MemoryAddress::NOP(const size_t nSize) +void CMemoryAddress::NOP(const size_t nSize) { uint8_t* pBytes = new uint8_t[nSize]; @@ -162,7 +162,7 @@ void MemoryAddress::NOP(const size_t nSize) delete[] pBytes; } -bool MemoryAddress::IsMemoryReadable(const size_t nSize) +bool CMemoryAddress::IsMemoryReadable(const size_t nSize) { static SYSTEM_INFO sysInfo; if (!sysInfo.dwPageSize) @@ -218,15 +218,15 @@ CModule::CModule(const HMODULE pModule) CModule::CModule(const char* pModuleName) : CModule(GetModuleHandleA(pModuleName)) {} -MemoryAddress CModule::GetExport(const char* pExportName) +CMemoryAddress CModule::GetExport(const char* pExportName) { - return MemoryAddress(reinterpret_cast(GetProcAddress(reinterpret_cast(m_nAddress), pExportName))); + return CMemoryAddress(reinterpret_cast(GetProcAddress(reinterpret_cast(m_nAddress), pExportName))); } -MemoryAddress CModule::FindPattern(const uint8_t* pPattern, const char* pMask) +CMemoryAddress CModule::FindPattern(const uint8_t* pPattern, const char* pMask) { if (!m_ExecutableCode.IsSectionValid()) - return MemoryAddress(); + return CMemoryAddress(); uint64_t nBase = static_cast(m_ExecutableCode.m_pSectionBase); uint64_t nSize = static_cast(m_ExecutableCode.m_nSectionSize); @@ -267,21 +267,21 @@ MemoryAddress CModule::FindPattern(const uint8_t* pPattern, const char* pMask) { if ((i + 1) == iNumMasks) { - return MemoryAddress(const_cast(pData)); + return CMemoryAddress(const_cast(pData)); } } else goto CONTINUE; } - return MemoryAddress((&*(const_cast(pData)))); + return CMemoryAddress((&*(const_cast(pData)))); } } CONTINUE:; } - return MemoryAddress(); + return CMemoryAddress(); } inline std::pair, std::string> MaskedBytesFromPattern(const char* pPatternString) @@ -340,7 +340,7 @@ inline std::pair, std::string> MaskedBytesFromPattern(const return std::make_pair(vRet, sMask); } -MemoryAddress CModule::FindPattern(const char* pPattern) +CMemoryAddress CModule::FindPattern(const char* pPattern) { const auto pattern = MaskedBytesFromPattern(pPattern); return FindPattern(pattern.first.data(), pattern.second.c_str()); diff --git a/NorthstarDLL/core/memory.h b/NorthstarDLL/core/memory.h index 38c76cb3..db0a38b3 100644 --- a/NorthstarDLL/core/memory.h +++ b/NorthstarDLL/core/memory.h @@ -1,39 +1,39 @@ #pragma once -class MemoryAddress +class CMemoryAddress { public: uintptr_t m_nAddress; public: - MemoryAddress(); - MemoryAddress(const uintptr_t nAddress); - MemoryAddress(const void* pAddress); + CMemoryAddress(); + CMemoryAddress(const uintptr_t nAddress); + CMemoryAddress(const void* pAddress); // operators operator uintptr_t() const; operator void*() const; operator bool() const; - bool operator==(const MemoryAddress& other) const; - bool operator!=(const MemoryAddress& other) const; + bool operator==(const CMemoryAddress& other) const; + bool operator!=(const CMemoryAddress& other) const; bool operator==(const uintptr_t& addr) const; bool operator!=(const uintptr_t& addr) const; - MemoryAddress operator+(const MemoryAddress& other) const; - MemoryAddress operator-(const MemoryAddress& other) const; - MemoryAddress operator+(const uintptr_t& other) const; - MemoryAddress operator-(const uintptr_t& other) const; - MemoryAddress operator*() const; + CMemoryAddress operator+(const CMemoryAddress& other) const; + CMemoryAddress operator-(const CMemoryAddress& other) const; + CMemoryAddress operator+(const uintptr_t& other) const; + CMemoryAddress operator-(const uintptr_t& other) const; + CMemoryAddress operator*() const; - template T As() + template T RCast() { return reinterpret_cast(m_nAddress); } // traversal - MemoryAddress Offset(const uintptr_t nOffset) const; - MemoryAddress Deref(const int nNumDerefs = 1) const; + CMemoryAddress Offset(const uintptr_t nOffset) const; + CMemoryAddress Deref(const int nNumDerefs = 1) const; // patching void Patch(const uint8_t* pBytes, const size_t nSize); @@ -45,7 +45,7 @@ class MemoryAddress }; // based on https://github.com/Mauler125/r5sdk/blob/master/r5dev/public/include/module.h -class CModule : public MemoryAddress +class CModule : public CMemoryAddress { public: struct ModuleSections_t @@ -84,7 +84,7 @@ class CModule : public MemoryAddress CModule(const HMODULE pModule); CModule(const char* pModuleName); - MemoryAddress GetExport(const char* pExportName); - MemoryAddress FindPattern(const uint8_t* pPattern, const char* pMask); - MemoryAddress FindPattern(const char* pPattern); + CMemoryAddress GetExport(const char* pExportName); + CMemoryAddress FindPattern(const uint8_t* pPattern, const char* pMask); + CMemoryAddress FindPattern(const char* pPattern); }; diff --git a/NorthstarDLL/core/tier0.cpp b/NorthstarDLL/core/tier0.cpp index cbad3ec0..3b9996a1 100644 --- a/NorthstarDLL/core/tier0.cpp +++ b/NorthstarDLL/core/tier0.cpp @@ -29,8 +29,8 @@ ON_DLL_LOAD("tier0.dll", Tier0GameFuncs, (CModule module)) TryCreateGlobalMemAlloc(); // setup tier0 funcs - Tier0::Error = module.GetExport("Error").As(); - Tier0::CommandLine = module.GetExport("CommandLine").As(); - Tier0::Plat_FloatTime = module.GetExport("Plat_FloatTime").As(); - Tier0::ThreadInServerFrameThread = module.GetExport("ThreadInServerFrameThread").As(); + Tier0::Error = module.GetExport("Error").RCast(); + Tier0::CommandLine = module.GetExport("CommandLine").RCast(); + Tier0::Plat_FloatTime = module.GetExport("Plat_FloatTime").RCast(); + Tier0::ThreadInServerFrameThread = module.GetExport("ThreadInServerFrameThread").RCast(); } diff --git a/NorthstarDLL/dedicated/dedicated.cpp b/NorthstarDLL/dedicated/dedicated.cpp index a28de0ec..34282f51 100644 --- a/NorthstarDLL/dedicated/dedicated.cpp +++ b/NorthstarDLL/dedicated/dedicated.cpp @@ -137,7 +137,7 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul { // CModAppSystemGroup::Create // force the engine into dedicated mode by changing the first comparison to IsServerOnly to an assignment - MemoryAddress base = module.Offset(0x1C4EBD); + CMemoryAddress base = module.Offset(0x1C4EBD); // cmp => mov base.Offset(1).Patch("C6 87"); @@ -203,7 +203,7 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul dedicatedExports->Sys_Printf = Sys_Printf; dedicatedExports->RunServer = RunServer; - *module.Offset(0x13F0B668).As() = dedicatedExports; + *module.Offset(0x13F0B668).RCast() = dedicatedExports; // extra potential patches: // nop engine.dll+1c67d1 and +1c67d8 to skip videomode creategamewindow diff --git a/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp b/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp index bb62cb36..8d19372f 100644 --- a/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp +++ b/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp @@ -45,5 +45,5 @@ void DedicatedServerLogToClientSink::flush_() {} ON_DLL_LOAD_DEDI("engine.dll", DedicatedServerLogToClient, (CModule module)) { - CGameClient__ClientPrintf = module.Offset(0x1016A0).As(); + CGameClient__ClientPrintf = module.Offset(0x1016A0).RCast(); } diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp index 50862e99..2ad21fcf 100644 --- a/NorthstarDLL/engine/hoststate.cpp +++ b/NorthstarDLL/engine/hoststate.cpp @@ -194,5 +194,5 @@ ON_DLL_LOAD_RELIESON("engine.dll", HostState, ConVar, (CModule module)) { AUTOHOOK_DISPATCH() - g_pHostState = module.Offset(0x7CF180).As(); + g_pHostState = module.Offset(0x7CF180).RCast(); } diff --git a/NorthstarDLL/engine/r2engine.cpp b/NorthstarDLL/engine/r2engine.cpp index 303cfaf8..67a628fd 100644 --- a/NorthstarDLL/engine/r2engine.cpp +++ b/NorthstarDLL/engine/r2engine.cpp @@ -26,18 +26,18 @@ namespace R2 ON_DLL_LOAD("engine.dll", R2Engine, (CModule module)) { - Cbuf_GetCurrentPlayer = module.Offset(0x120630).As(); - Cbuf_AddText = module.Offset(0x1203B0).As(); - Cbuf_Execute = module.Offset(0x1204B0).As(); + Cbuf_GetCurrentPlayer = module.Offset(0x120630).RCast(); + Cbuf_AddText = module.Offset(0x1203B0).RCast(); + Cbuf_Execute = module.Offset(0x1204B0).RCast(); - CCommand__Tokenize = module.Offset(0x418380).As(); + CCommand__Tokenize = module.Offset(0x418380).RCast(); - g_pEngine = module.Offset(0x7D70C8).Deref().As(); + g_pEngine = module.Offset(0x7D70C8).Deref().RCast(); - CBaseClient__Disconnect = module.Offset(0x1012C0).As(); - g_pClientArray = module.Offset(0x12A53F90).As(); + CBaseClient__Disconnect = module.Offset(0x1012C0).RCast(); + g_pClientArray = module.Offset(0x12A53F90).RCast(); - g_pServerState = module.Offset(0x12A53D48).As(); + g_pServerState = module.Offset(0x12A53D48).RCast(); - g_pGlobals = module.Offset(0x7C6F70).As(); + g_pGlobals = module.Offset(0x7C6F70).RCast(); } diff --git a/NorthstarDLL/logging/loghooks.cpp b/NorthstarDLL/logging/loghooks.cpp index 805a5125..53a85c1b 100644 --- a/NorthstarDLL/logging/loghooks.cpp +++ b/NorthstarDLL/logging/loghooks.cpp @@ -257,5 +257,5 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientPrintHooks, ConVar, (CModule mod AUTOHOOK_DISPATCH_MODULE(client.dll) Cvar_cl_showtextmsg = new ConVar("cl_showtextmsg", "1", FCVAR_NONE, "Enable/disable text messages printing on the screen."); - pInternalCenterPrint = module.Offset(0x216E940).As(); + pInternalCenterPrint = module.Offset(0x216E940).RCast(); } diff --git a/NorthstarDLL/scripts/client/scriptbrowserhooks.cpp b/NorthstarDLL/scripts/client/scriptbrowserhooks.cpp index 1462e57f..86b4a356 100644 --- a/NorthstarDLL/scripts/client/scriptbrowserhooks.cpp +++ b/NorthstarDLL/scripts/client/scriptbrowserhooks.cpp @@ -20,5 +20,5 @@ ON_DLL_LOAD_CLIENT("engine.dll", ScriptExternalBrowserHooks, (CModule module)) { AUTOHOOK_DISPATCH() - bIsOriginOverlayEnabled = module.Offset(0x13978255).As(); + bIsOriginOverlayEnabled = module.Offset(0x13978255).RCast(); } diff --git a/NorthstarDLL/scripts/scriptdatatables.cpp b/NorthstarDLL/scripts/scriptdatatables.cpp index 8a2935c2..8aa52fdb 100644 --- a/NorthstarDLL/scripts/scriptdatatables.cpp +++ b/NorthstarDLL/scripts/scriptdatatables.cpp @@ -887,12 +887,12 @@ void ConCommand_dump_datatables(const CCommand& args) ON_DLL_LOAD_RELIESON("server.dll", ServerScriptDatatables, ServerSquirrel, (CModule module)) { - SQ_GetDatatableInternal = module.Offset(0x1250f0).As(); + SQ_GetDatatableInternal = module.Offset(0x1250f0).RCast(); } ON_DLL_LOAD_RELIESON("client.dll", ClientScriptDatatables, ClientSquirrel, (CModule module)) { - SQ_GetDatatableInternal = module.Offset(0x1C9070).As(); + SQ_GetDatatableInternal = module.Offset(0x1C9070).RCast(); SQ_GetDatatableInternal = SQ_GetDatatableInternal; } diff --git a/NorthstarDLL/server/alltalk.cpp b/NorthstarDLL/server/alltalk.cpp index 6283a1a2..d71b0bae 100644 --- a/NorthstarDLL/server/alltalk.cpp +++ b/NorthstarDLL/server/alltalk.cpp @@ -15,7 +15,7 @@ size_t __fastcall ShouldAllowAlltalk() ON_DLL_LOAD_RELIESON("engine.dll", ServerAllTalk, ConVar, (CModule module)) { // replace strcmp function called in CClient::ProcessVoiceData with our own code that calls ShouldAllowAllTalk - MemoryAddress base = module.Offset(0x1085FA); + CMemoryAddress base = module.Offset(0x1085FA); base.Patch("48 B8"); // mov rax, 64 bit int // (uint8_t*)&ShouldAllowAlltalk doesn't work for some reason? need to make it a uint64 first diff --git a/NorthstarDLL/server/auth/serverauthentication.cpp b/NorthstarDLL/server/auth/serverauthentication.cpp index 8f62e1dd..d5653dcc 100644 --- a/NorthstarDLL/server/auth/serverauthentication.cpp +++ b/NorthstarDLL/server/auth/serverauthentication.cpp @@ -368,7 +368,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", ServerAuthentication, (ConCommand, ConVar), ( // patch to disable fairfight marking players as cheaters and kicking them module.Offset(0x101012).Patch("E9 90 00"); - CBaseServer__RejectConnection = module.Offset(0x1182E0).As(); + CBaseServer__RejectConnection = module.Offset(0x1182E0).RCast(); if (Tier0::CommandLine()->CheckParm("-allowdupeaccounts")) { diff --git a/NorthstarDLL/server/buildainfile.cpp b/NorthstarDLL/server/buildainfile.cpp index 848d8569..d0143295 100644 --- a/NorthstarDLL/server/buildainfile.cpp +++ b/NorthstarDLL/server/buildainfile.cpp @@ -388,8 +388,8 @@ ON_DLL_LOAD("server.dll", BuildAINFile, (CModule module)) Cvar_ns_ai_dumpAINfileFromLoad = new ConVar( "ns_ai_dumpAINfileFromLoad", "0", FCVAR_NONE, "For debugging: whether we should dump ain data for ains loaded from disk"); - pUnkStruct0Count = module.Offset(0x1063BF8).As(); - pppUnkNodeStruct0s = module.Offset(0x1063BE0).As(); - pUnkLinkStruct1Count = module.Offset(0x1063AA8).As(); - pppUnkStruct1s = module.Offset(0x1063A90).As(); + pUnkStruct0Count = module.Offset(0x1063BF8).RCast(); + pppUnkNodeStruct0s = module.Offset(0x1063BE0).RCast(); + pUnkLinkStruct1Count = module.Offset(0x1063AA8).RCast(); + pppUnkStruct1s = module.Offset(0x1063A90).RCast(); } diff --git a/NorthstarDLL/server/r2server.cpp b/NorthstarDLL/server/r2server.cpp index a8aa84ce..cf7add0d 100644 --- a/NorthstarDLL/server/r2server.cpp +++ b/NorthstarDLL/server/r2server.cpp @@ -11,6 +11,6 @@ namespace R2 ON_DLL_LOAD("server.dll", R2GameServer, (CModule module)) { - Server_GetEntityByIndex = module.Offset(0xFB820).As(); - UTIL_PlayerByIndex = module.Offset(0x26AA10).As(); + Server_GetEntityByIndex = module.Offset(0xFB820).RCast(); + UTIL_PlayerByIndex = module.Offset(0x26AA10).RCast(); } diff --git a/NorthstarDLL/server/serverchathooks.cpp b/NorthstarDLL/server/serverchathooks.cpp index 96765697..cb3af244 100644 --- a/NorthstarDLL/server/serverchathooks.cpp +++ b/NorthstarDLL/server/serverchathooks.cpp @@ -151,7 +151,7 @@ ADD_SQFUNC( ON_DLL_LOAD("engine.dll", EngineServerChatHooks, (CModule module)) { - g_pServerGameDLL = module.Offset(0x13F0AA98).As(); + g_pServerGameDLL = module.Offset(0x13F0AA98).RCast(); } ON_DLL_LOAD_RELIESON("server.dll", ServerChatHooks, ServerSquirrel, (CModule module)) @@ -159,16 +159,16 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerChatHooks, ServerSquirrel, (CModule mod AUTOHOOK_DISPATCH_MODULE(server.dll) CServerGameDLL__OnReceivedSayTextMessage = - module.Offset(0x1595C0).As(); - CRecipientFilter__Construct = module.Offset(0x1E9440).As(); - CRecipientFilter__Destruct = module.Offset(0x1E9700).As(); - CRecipientFilter__AddAllPlayers = module.Offset(0x1E9940).As(); - CRecipientFilter__AddRecipient = module.Offset(0x1E9B30).As(); - CRecipientFilter__MakeReliable = module.Offset(0x1EA4E0).As(); - - UserMessageBegin = module.Offset(0x15C520).As(); - MessageEnd = module.Offset(0x158880).As(); - MessageWriteByte = module.Offset(0x158A90).As(); - MessageWriteString = module.Offset(0x158D00).As(); - MessageWriteBool = module.Offset(0x158A00).As(); + module.Offset(0x1595C0).RCast(); + CRecipientFilter__Construct = module.Offset(0x1E9440).RCast(); + CRecipientFilter__Destruct = module.Offset(0x1E9700).RCast(); + CRecipientFilter__AddAllPlayers = module.Offset(0x1E9940).RCast(); + CRecipientFilter__AddRecipient = module.Offset(0x1E9B30).RCast(); + CRecipientFilter__MakeReliable = module.Offset(0x1EA4E0).RCast(); + + UserMessageBegin = module.Offset(0x15C520).RCast(); + MessageEnd = module.Offset(0x158880).RCast(); + MessageWriteByte = module.Offset(0x158A90).RCast(); + MessageWriteString = module.Offset(0x158D00).RCast(); + MessageWriteBool = module.Offset(0x158A00).RCast(); } diff --git a/NorthstarDLL/server/serverpresence.cpp b/NorthstarDLL/server/serverpresence.cpp index 945f5810..ed9185c1 100644 --- a/NorthstarDLL/server/serverpresence.cpp +++ b/NorthstarDLL/server/serverpresence.cpp @@ -224,5 +224,5 @@ void ServerPresenceManager::SetPlayerCount(const int iPlayerCount) ON_DLL_LOAD_RELIESON("engine.dll", ServerPresence, ConVar, (CModule module)) { g_pServerPresence->CreateConVars(); - Cvar_hostname = module.Offset(0x1315BAE8).Deref().As(); + Cvar_hostname = module.Offset(0x1315BAE8).Deref().RCast(); } diff --git a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp index 338de306..2a0a9c2c 100644 --- a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp +++ b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp @@ -98,7 +98,7 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10 auto entry = msg->m_ConVars + i; // Safety check for memory access - if (MemoryAddress(entry).IsMemoryReadable(sizeof(*entry))) + if (CMemoryAddress(entry).IsMemoryReadable(sizeof(*entry))) { // Find null terminators bool nameValid = false, valValid = false; @@ -405,9 +405,9 @@ ON_DLL_LOAD("engine.dll", EngineExploitFixes, (CModule module)) // patch to set bWasWritingStringTableSuccessful in CNetworkStringTableContainer::WriteBaselines if it fails { - MemoryAddress writeAddress(&bWasWritingStringTableSuccessful - module.Offset(0x234EDC).m_nAddress); + CMemoryAddress writeAddress(&bWasWritingStringTableSuccessful - module.Offset(0x234EDC).m_nAddress); - MemoryAddress addr = module.Offset(0x234ED2); + CMemoryAddress addr = module.Offset(0x234ED2); addr.Patch("C7 05"); addr.Offset(2).Patch((BYTE*)&writeAddress, sizeof(writeAddress)); @@ -435,7 +435,7 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerExploitFixes, ConVar, (CModule module)) // Prevent these from actually doing anything for (auto exportName : ANTITAMPER_EXPORTS) { - MemoryAddress exportAddr = module.GetExport(exportName); + CMemoryAddress exportAddr = module.GetExport(exportName); if (exportAddr) { // Just return, none of them have any args or are userpurge diff --git a/NorthstarDLL/shared/exploit_fixes/exploitfixes_utf8parser.cpp b/NorthstarDLL/shared/exploit_fixes/exploitfixes_utf8parser.cpp index de0b0f21..3d97f750 100644 --- a/NorthstarDLL/shared/exploit_fixes/exploitfixes_utf8parser.cpp +++ b/NorthstarDLL/shared/exploit_fixes/exploitfixes_utf8parser.cpp @@ -67,7 +67,7 @@ bool __fastcall CheckUTF8Valid(INT64* a1, DWORD* a2, char* strData) { while (1) { - if (!MemoryAddress(v4).IsMemoryReadable(1)) + if (!CMemoryAddress(v4).IsMemoryReadable(1)) return false; // INVALID v11 = *v4++; // crash potential @@ -195,5 +195,5 @@ ON_DLL_LOAD("engine.dll", EngineExploitFixes_UTF8Parser, (CModule module)) { AUTOHOOK_DISPATCH() - sub_F1320 = module.FindPattern("83 F9 7F 77 08 88 0A").As(); + sub_F1320 = module.FindPattern("83 F9 7F 77 08 88 0A").RCast(); } diff --git a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp index e69ef41c..c9085cb0 100644 --- a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp +++ b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp @@ -289,7 +289,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", ServerLimits, ConVar, (CModule module)) FCVAR_GAMEDLL, "Increase usercmd processing budget by tickinterval * value per tick"); - CEngineServer__GetTimescale = module.Offset(0x240840).As(); + CEngineServer__GetTimescale = module.Offset(0x240840).RCast(); } ON_DLL_LOAD("server.dll", ServerLimitsServer, (CModule module)) diff --git a/NorthstarDLL/shared/keyvalues.cpp b/NorthstarDLL/shared/keyvalues.cpp index 06ed8d68..aa22ca65 100644 --- a/NorthstarDLL/shared/keyvalues.cpp +++ b/NorthstarDLL/shared/keyvalues.cpp @@ -1289,9 +1289,9 @@ KeyValues* KeyValues::MakeCopy(void) const ON_DLL_LOAD("vstdlib.dll", KeyValues, (CModule module)) { - V_UTF8ToUnicode = module.GetExport("V_UTF8ToUnicode").As(); - V_UnicodeToUTF8 = module.GetExport("V_UnicodeToUTF8").As(); - KeyValuesSystem = module.GetExport("KeyValuesSystem").As(); + V_UTF8ToUnicode = module.GetExport("V_UTF8ToUnicode").RCast(); + V_UnicodeToUTF8 = module.GetExport("V_UnicodeToUTF8").RCast(); + KeyValuesSystem = module.GetExport("KeyValuesSystem").RCast(); } AUTOHOOK_INIT() diff --git a/NorthstarDLL/shared/maxplayers.cpp b/NorthstarDLL/shared/maxplayers.cpp index dcf4044e..b2a09578 100644 --- a/NorthstarDLL/shared/maxplayers.cpp +++ b/NorthstarDLL/shared/maxplayers.cpp @@ -64,7 +64,7 @@ namespace R2 // use R2 namespace for game funcs } } // namespace R2 -template void ChangeOffset(MemoryAddress addr, unsigned int offset) +template void ChangeOffset(CMemoryAddress addr, unsigned int offset) { addr.Patch((BYTE*)&offset, sizeof(T)); } @@ -432,8 +432,8 @@ ON_DLL_LOAD("server.dll", MaxPlayersOverride_Server, (CModule module)) ChangeOffset(module.Offset(0x5C6654 + 3), CPlayerResource_OriginalSize + PlayerResource_KillStats_Start); ChangeOffset(module.Offset(0x5C665B + 3), CPlayerResource_OriginalSize + PlayerResource_KillStats_Start); - *module.Offset(0x14E7390).As() = 0; - auto DT_PlayerResource_Construct = module.Offset(0x5C4FE0).As<__int64(__fastcall*)()>(); + *module.Offset(0x14E7390).RCast() = 0; + auto DT_PlayerResource_Construct = module.Offset(0x5C4FE0).RCast<__int64(__fastcall*)()>(); DT_PlayerResource_Construct(); constexpr int CTeam_OriginalSize = 3336; @@ -446,8 +446,8 @@ ON_DLL_LOAD("server.dll", MaxPlayersOverride_Server, (CModule module)) // CTeam::CTeam - increase memset length to clean newly allocated data ChangeOffset(module.Offset(0x2395AE + 2), 256 + CTeam_AddedSize); - *module.Offset(0xC945A0).As() = 0; - auto DT_Team_Construct = module.Offset(0x238F50).As<__int64(__fastcall*)()>(); + *module.Offset(0xC945A0).RCast() = 0; + auto DT_Team_Construct = module.Offset(0x238F50).RCast<__int64(__fastcall*)()>(); DT_Team_Construct(); } @@ -621,8 +621,8 @@ ON_DLL_LOAD("client.dll", MaxPlayersOverride_Client, (CModule module)) // Some other get name func 2 (that seems to be unused too) - change m_bConnected address ChangeOffset(module.Offset(0x164834 + 3), C_PlayerResource_OriginalSize + PlayerResource_Connected_Start); - *module.Offset(0xC35068).As() = 0; - auto DT_PlayerResource_Construct = module.Offset(0x163400).As<__int64(__fastcall*)()>(); + *module.Offset(0xC35068).RCast() = 0; + auto DT_PlayerResource_Construct = module.Offset(0x163400).RCast<__int64(__fastcall*)()>(); DT_PlayerResource_Construct(); constexpr int C_Team_OriginalSize = 3200; @@ -638,7 +638,7 @@ ON_DLL_LOAD("client.dll", MaxPlayersOverride_Client, (CModule module)) // DT_Team size ChangeOffset(module.Offset(0xC3AA0C), C_Team_ModifiedSize); - *module.Offset(0xC3AFF8).As() = 0; - auto DT_Team_Construct = module.Offset(0x17F950).As<__int64(__fastcall*)()>(); + *module.Offset(0xC3AFF8).RCast() = 0; + auto DT_Team_Construct = module.Offset(0x17F950).RCast<__int64(__fastcall*)()>(); DT_Team_Construct(); } diff --git a/NorthstarDLL/shared/misccommands.cpp b/NorthstarDLL/shared/misccommands.cpp index 15e12720..5d9ced99 100644 --- a/NorthstarDLL/shared/misccommands.cpp +++ b/NorthstarDLL/shared/misccommands.cpp @@ -172,7 +172,7 @@ void FixupCvarFlags() // make all engine client commands FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS // these are usually checked through CGameClient::IsEngineClientCommand, but we get more control over this if we just do it through // cvar flags - const char** ppEngineClientCommands = CModule("engine.dll").Offset(0x7C5EF0).As(); + const char** ppEngineClientCommands = CModule("engine.dll").Offset(0x7C5EF0).RCast(); int i = 0; do diff --git a/NorthstarDLL/squirrel/squirrel.cpp b/NorthstarDLL/squirrel/squirrel.cpp index 3bb5c154..0dd23cd7 100644 --- a/NorthstarDLL/squirrel/squirrel.cpp +++ b/NorthstarDLL/squirrel/squirrel.cpp @@ -701,37 +701,37 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) { AUTOHOOK_DISPATCH_MODULE(client.dll) - g_pSquirrel->__sq_defconst = module.Offset(0x12120).As(); + g_pSquirrel->__sq_defconst = module.Offset(0x12120).RCast(); g_pSquirrel->__sq_defconst = g_pSquirrel->__sq_defconst; - g_pSquirrel->__sq_compilebuffer = module.Offset(0x3110).As(); - g_pSquirrel->__sq_pushroottable = module.Offset(0x5860).As(); - g_pSquirrel->__sq_compilefile = module.Offset(0xF950).As(); + g_pSquirrel->__sq_compilebuffer = module.Offset(0x3110).RCast(); + g_pSquirrel->__sq_pushroottable = module.Offset(0x5860).RCast(); + g_pSquirrel->__sq_compilefile = module.Offset(0xF950).RCast(); g_pSquirrel->__sq_compilebuffer = g_pSquirrel->__sq_compilebuffer; g_pSquirrel->__sq_pushroottable = g_pSquirrel->__sq_pushroottable; g_pSquirrel->__sq_compilefile = g_pSquirrel->__sq_compilefile; - g_pSquirrel->__sq_call = module.Offset(0x8650).As(); + g_pSquirrel->__sq_call = module.Offset(0x8650).RCast(); g_pSquirrel->__sq_call = g_pSquirrel->__sq_call; - g_pSquirrel->__sq_newarray = module.Offset(0x39F0).As(); - g_pSquirrel->__sq_arrayappend = module.Offset(0x3C70).As(); + g_pSquirrel->__sq_newarray = module.Offset(0x39F0).RCast(); + g_pSquirrel->__sq_arrayappend = module.Offset(0x3C70).RCast(); g_pSquirrel->__sq_newarray = g_pSquirrel->__sq_newarray; g_pSquirrel->__sq_arrayappend = g_pSquirrel->__sq_arrayappend; - g_pSquirrel->__sq_newtable = module.Offset(0x3960).As(); - g_pSquirrel->__sq_newslot = module.Offset(0x70B0).As(); + g_pSquirrel->__sq_newtable = module.Offset(0x3960).RCast(); + g_pSquirrel->__sq_newslot = module.Offset(0x70B0).RCast(); g_pSquirrel->__sq_newtable = g_pSquirrel->__sq_newtable; g_pSquirrel->__sq_newslot = g_pSquirrel->__sq_newslot; - g_pSquirrel->__sq_pushstring = module.Offset(0x3440).As(); - g_pSquirrel->__sq_pushinteger = module.Offset(0x36A0).As(); - g_pSquirrel->__sq_pushfloat = module.Offset(0x3800).As(); - g_pSquirrel->__sq_pushbool = module.Offset(0x3710).As(); - g_pSquirrel->__sq_pushasset = module.Offset(0x3560).As(); - g_pSquirrel->__sq_pushvector = module.Offset(0x3780).As(); - g_pSquirrel->__sq_pushobject = module.Offset(0x83D0).As(); - g_pSquirrel->__sq_raiseerror = module.Offset(0x8470).As(); + g_pSquirrel->__sq_pushstring = module.Offset(0x3440).RCast(); + g_pSquirrel->__sq_pushinteger = module.Offset(0x36A0).RCast(); + g_pSquirrel->__sq_pushfloat = module.Offset(0x3800).RCast(); + g_pSquirrel->__sq_pushbool = module.Offset(0x3710).RCast(); + g_pSquirrel->__sq_pushasset = module.Offset(0x3560).RCast(); + g_pSquirrel->__sq_pushvector = module.Offset(0x3780).RCast(); + g_pSquirrel->__sq_pushobject = module.Offset(0x83D0).RCast(); + g_pSquirrel->__sq_raiseerror = module.Offset(0x8470).RCast(); g_pSquirrel->__sq_pushstring = g_pSquirrel->__sq_pushstring; g_pSquirrel->__sq_pushinteger = g_pSquirrel->__sq_pushinteger; g_pSquirrel->__sq_pushfloat = g_pSquirrel->__sq_pushfloat; @@ -741,16 +741,16 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel->__sq_pushobject = g_pSquirrel->__sq_pushobject; g_pSquirrel->__sq_raiseerror = g_pSquirrel->__sq_raiseerror; - g_pSquirrel->__sq_getstring = module.Offset(0x60C0).As(); - g_pSquirrel->__sq_getinteger = module.Offset(0x60E0).As(); - g_pSquirrel->__sq_getfloat = module.Offset(0x6100).As(); - g_pSquirrel->__sq_getbool = module.Offset(0x6130).As(); - g_pSquirrel->__sq_get = module.Offset(0x7C30).As(); - g_pSquirrel->__sq_getasset = module.Offset(0x6010).As(); - g_pSquirrel->__sq_getuserdata = module.Offset(0x63D0).As(); - g_pSquirrel->__sq_getvector = module.Offset(0x6140).As(); - g_pSquirrel->__sq_getthisentity = module.Offset(0x12F80).As(); - g_pSquirrel->__sq_getobject = module.Offset(0x6160).As(); + g_pSquirrel->__sq_getstring = module.Offset(0x60C0).RCast(); + g_pSquirrel->__sq_getinteger = module.Offset(0x60E0).RCast(); + g_pSquirrel->__sq_getfloat = module.Offset(0x6100).RCast(); + g_pSquirrel->__sq_getbool = module.Offset(0x6130).RCast(); + g_pSquirrel->__sq_get = module.Offset(0x7C30).RCast(); + g_pSquirrel->__sq_getasset = module.Offset(0x6010).RCast(); + g_pSquirrel->__sq_getuserdata = module.Offset(0x63D0).RCast(); + g_pSquirrel->__sq_getvector = module.Offset(0x6140).RCast(); + g_pSquirrel->__sq_getthisentity = module.Offset(0x12F80).RCast(); + g_pSquirrel->__sq_getobject = module.Offset(0x6160).RCast(); g_pSquirrel->__sq_getstring = g_pSquirrel->__sq_getstring; g_pSquirrel->__sq_getinteger = g_pSquirrel->__sq_getinteger; g_pSquirrel->__sq_getfloat = g_pSquirrel->__sq_getfloat; @@ -762,27 +762,27 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) g_pSquirrel->__sq_getthisentity = g_pSquirrel->__sq_getthisentity; g_pSquirrel->__sq_getobject = g_pSquirrel->__sq_getobject; - g_pSquirrel->__sq_createuserdata = module.Offset(0x38D0).As(); - g_pSquirrel->__sq_setuserdatatypeid = module.Offset(0x6490).As(); + g_pSquirrel->__sq_createuserdata = module.Offset(0x38D0).RCast(); + g_pSquirrel->__sq_setuserdatatypeid = module.Offset(0x6490).RCast(); g_pSquirrel->__sq_createuserdata = g_pSquirrel->__sq_createuserdata; g_pSquirrel->__sq_setuserdatatypeid = g_pSquirrel->__sq_setuserdatatypeid; - g_pSquirrel->__sq_GetEntityConstant_CBaseEntity = module.Offset(0x3E49B0).As(); - g_pSquirrel->__sq_getentityfrominstance = module.Offset(0x114F0).As(); + g_pSquirrel->__sq_GetEntityConstant_CBaseEntity = module.Offset(0x3E49B0).RCast(); + g_pSquirrel->__sq_getentityfrominstance = module.Offset(0x114F0).RCast(); g_pSquirrel->__sq_GetEntityConstant_CBaseEntity = g_pSquirrel->__sq_GetEntityConstant_CBaseEntity; g_pSquirrel->__sq_getentityfrominstance = g_pSquirrel->__sq_getentityfrominstance; // Message buffer stuff g_pSquirrel->messageBuffer = g_pSquirrel->messageBuffer; - g_pSquirrel->__sq_getfunction = module.Offset(0x572FB0).As(); + g_pSquirrel->__sq_getfunction = module.Offset(0x572FB0).RCast(); g_pSquirrel->__sq_getfunction = g_pSquirrel->__sq_getfunction; - g_pSquirrel->__sq_stackinfos = module.Offset(0x35970).As(); + g_pSquirrel->__sq_stackinfos = module.Offset(0x35970).RCast(); g_pSquirrel->__sq_stackinfos = g_pSquirrel->__sq_stackinfos; // Structs - g_pSquirrel->__sq_pushnewstructinstance = module.Offset(0x5400).As(); - g_pSquirrel->__sq_sealstructslot = module.Offset(0x5530).As(); + g_pSquirrel->__sq_pushnewstructinstance = module.Offset(0x5400).RCast(); + g_pSquirrel->__sq_sealstructslot = module.Offset(0x5530).RCast(); g_pSquirrel->__sq_pushnewstructinstance = g_pSquirrel->__sq_pushnewstructinstance; g_pSquirrel->__sq_sealstructslot = g_pSquirrel->__sq_sealstructslot; @@ -817,7 +817,7 @@ ON_DLL_LOAD_RELIESON("client.dll", ClientSquirrel, ConCommand, (CModule module)) StubUnsafeSQFuncs(); StubUnsafeSQFuncs(); - g_pSquirrel->__sq_getfunction = module.Offset(0x6CB0).As(); + g_pSquirrel->__sq_getfunction = module.Offset(0x6CB0).RCast(); g_pSquirrel->__sq_getfunction = g_pSquirrel->__sq_getfunction; SquirrelFunctions s = {}; @@ -829,55 +829,55 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerSquirrel, ConCommand, (CModule module)) { AUTOHOOK_DISPATCH_MODULE(server.dll) - g_pSquirrel->__sq_defconst = module.Offset(0x1F550).As(); + g_pSquirrel->__sq_defconst = module.Offset(0x1F550).RCast(); - g_pSquirrel->__sq_compilebuffer = module.Offset(0x3110).As(); - g_pSquirrel->__sq_pushroottable = module.Offset(0x5840).As(); - g_pSquirrel->__sq_call = module.Offset(0x8620).As(); - g_pSquirrel->__sq_compilefile = module.Offset(0x1CD80).As(); + g_pSquirrel->__sq_compilebuffer = module.Offset(0x3110).RCast(); + g_pSquirrel->__sq_pushroottable = module.Offset(0x5840).RCast(); + g_pSquirrel->__sq_call = module.Offset(0x8620).RCast(); + g_pSquirrel->__sq_compilefile = module.Offset(0x1CD80).RCast(); - g_pSquirrel->__sq_newarray = module.Offset(0x39F0).As(); - g_pSquirrel->__sq_arrayappend = module.Offset(0x3C70).As(); + g_pSquirrel->__sq_newarray = module.Offset(0x39F0).RCast(); + g_pSquirrel->__sq_arrayappend = module.Offset(0x3C70).RCast(); - g_pSquirrel->__sq_newtable = module.Offset(0x3960).As(); - g_pSquirrel->__sq_newslot = module.Offset(0x7080).As(); + g_pSquirrel->__sq_newtable = module.Offset(0x3960).RCast(); + g_pSquirrel->__sq_newslot = module.Offset(0x7080).RCast(); - g_pSquirrel->__sq_pushstring = module.Offset(0x3440).As(); - g_pSquirrel->__sq_pushinteger = module.Offset(0x36A0).As(); - g_pSquirrel->__sq_pushfloat = module.Offset(0x3800).As(); - g_pSquirrel->__sq_pushbool = module.Offset(0x3710).As(); - g_pSquirrel->__sq_pushasset = module.Offset(0x3560).As(); - g_pSquirrel->__sq_pushvector = module.Offset(0x3780).As(); - g_pSquirrel->__sq_pushobject = module.Offset(0x83A0).As(); + g_pSquirrel->__sq_pushstring = module.Offset(0x3440).RCast(); + g_pSquirrel->__sq_pushinteger = module.Offset(0x36A0).RCast(); + g_pSquirrel->__sq_pushfloat = module.Offset(0x3800).RCast(); + g_pSquirrel->__sq_pushbool = module.Offset(0x3710).RCast(); + g_pSquirrel->__sq_pushasset = module.Offset(0x3560).RCast(); + g_pSquirrel->__sq_pushvector = module.Offset(0x3780).RCast(); + g_pSquirrel->__sq_pushobject = module.Offset(0x83A0).RCast(); - g_pSquirrel->__sq_raiseerror = module.Offset(0x8440).As(); + g_pSquirrel->__sq_raiseerror = module.Offset(0x8440).RCast(); - g_pSquirrel->__sq_getstring = module.Offset(0x60A0).As(); - g_pSquirrel->__sq_getinteger = module.Offset(0x60C0).As(); - g_pSquirrel->__sq_getfloat = module.Offset(0x60E0).As(); - g_pSquirrel->__sq_getbool = module.Offset(0x6110).As(); - g_pSquirrel->__sq_getasset = module.Offset(0x5FF0).As(); - g_pSquirrel->__sq_getuserdata = module.Offset(0x63B0).As(); - g_pSquirrel->__sq_getvector = module.Offset(0x6120).As(); - g_pSquirrel->__sq_get = module.Offset(0x7C00).As(); + g_pSquirrel->__sq_getstring = module.Offset(0x60A0).RCast(); + g_pSquirrel->__sq_getinteger = module.Offset(0x60C0).RCast(); + g_pSquirrel->__sq_getfloat = module.Offset(0x60E0).RCast(); + g_pSquirrel->__sq_getbool = module.Offset(0x6110).RCast(); + g_pSquirrel->__sq_getasset = module.Offset(0x5FF0).RCast(); + g_pSquirrel->__sq_getuserdata = module.Offset(0x63B0).RCast(); + g_pSquirrel->__sq_getvector = module.Offset(0x6120).RCast(); + g_pSquirrel->__sq_get = module.Offset(0x7C00).RCast(); - g_pSquirrel->__sq_getthisentity = module.Offset(0x203B0).As(); - g_pSquirrel->__sq_getobject = module.Offset(0x6140).As(); + g_pSquirrel->__sq_getthisentity = module.Offset(0x203B0).RCast(); + g_pSquirrel->__sq_getobject = module.Offset(0x6140).RCast(); - g_pSquirrel->__sq_createuserdata = module.Offset(0x38D0).As(); - g_pSquirrel->__sq_setuserdatatypeid = module.Offset(0x6470).As(); + g_pSquirrel->__sq_createuserdata = module.Offset(0x38D0).RCast(); + g_pSquirrel->__sq_setuserdatatypeid = module.Offset(0x6470).RCast(); - g_pSquirrel->__sq_GetEntityConstant_CBaseEntity = module.Offset(0x418AF0).As(); - g_pSquirrel->__sq_getentityfrominstance = module.Offset(0x1E920).As(); + g_pSquirrel->__sq_GetEntityConstant_CBaseEntity = module.Offset(0x418AF0).RCast(); + g_pSquirrel->__sq_getentityfrominstance = module.Offset(0x1E920).RCast(); g_pSquirrel->logger = NS::log::SCRIPT_SV; // Message buffer stuff - g_pSquirrel->__sq_getfunction = module.Offset(0x6C85).As(); - g_pSquirrel->__sq_stackinfos = module.Offset(0x35920).As(); + g_pSquirrel->__sq_getfunction = module.Offset(0x6C85).RCast(); + g_pSquirrel->__sq_stackinfos = module.Offset(0x35920).RCast(); // Structs - g_pSquirrel->__sq_pushnewstructinstance = module.Offset(0x53e0).As(); - g_pSquirrel->__sq_sealstructslot = module.Offset(0x5510).As(); + g_pSquirrel->__sq_pushnewstructinstance = module.Offset(0x53e0).RCast(); + g_pSquirrel->__sq_sealstructslot = module.Offset(0x5510).RCast(); MAKEHOOK( module.Offset(0x1DD10), diff --git a/NorthstarDLL/util/wininfo.cpp b/NorthstarDLL/util/wininfo.cpp index b0b77749..4fd64369 100644 --- a/NorthstarDLL/util/wininfo.cpp +++ b/NorthstarDLL/util/wininfo.cpp @@ -5,5 +5,5 @@ HMODULE g_NorthstarModule = 0; ON_DLL_LOAD("engine.dll", WinInfo, (CModule module)) { - g_gameHWND = module.Offset(0x7d88a0).As(); + g_gameHWND = module.Offset(0x7d88a0).RCast(); } -- cgit v1.2.3