diff --git a/r5dev/client/cdll_engine_int.cpp b/r5dev/client/cdll_engine_int.cpp index e6120eea..efab29b8 100644 --- a/r5dev/client/cdll_engine_int.cpp +++ b/r5dev/client/cdll_engine_int.cpp @@ -37,10 +37,10 @@ ClientClass* CHLClient::GetAllClasses() /////////////////////////////////////////////////////////////////////////////// void CHLClient_Attach() { - DetourAttach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); + //DetourAttach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); } void CHLClient_Detach() { - DetourDetach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); + //DetourDetach((LPVOID*)&CHLClient_FrameStageNotify, &CHLClient::FrameStageNotify); } diff --git a/r5dev/common/netmessages.cpp b/r5dev/common/netmessages.cpp index 614e4448..77c4a5da 100644 --- a/r5dev/common/netmessages.cpp +++ b/r5dev/common/netmessages.cpp @@ -43,13 +43,13 @@ void CNetMessages_Attach() { auto SVCPrint = &SVC_Print::Process; auto SVCUserMessage = &SVC_UserMessage::Process; - CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID&)SVCPrint, (LPVOID*)&SVC_Print_Process, 3); - CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID&)SVCUserMessage, (LPVOID*)&SVC_UserMessage_Process, 3); + CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID&)SVCPrint, 3, (LPVOID*)&SVC_Print_Process); + CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID&)SVCUserMessage, 3, (LPVOID*)&SVC_UserMessage_Process); } void CNetMessages_Detach() { void* hkRestore = nullptr; - CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID)SVC_Print_Process, (LPVOID*)&hkRestore, 3); - CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID)SVC_UserMessage_Process, (LPVOID*)&hkRestore, 3); + CMemory::HookVirtualMethod((uintptr_t)g_pSVC_Print_VTable, (LPVOID)SVC_Print_Process, 3, (LPVOID*)&hkRestore); + CMemory::HookVirtualMethod((uintptr_t)g_pSVC_UserMessage_VTable, (LPVOID)SVC_UserMessage_Process, 3, (LPVOID*)&hkRestore); } \ No newline at end of file diff --git a/r5dev/public/include/memaddr.h b/r5dev/public/include/memaddr.h index 680db972..b145f6e8 100644 --- a/r5dev/public/include/memaddr.h +++ b/r5dev/public/include/memaddr.h @@ -116,15 +116,15 @@ public: } bool CheckOpCodes(const vector vOpcodeArray) const; - void Patch(vector vOpcodes) const; + void Patch(const vector vOpcodeArray) const; void PatchString(const string& svString) const; CMemory FindPattern(const string& svPattern, const Direction searchDirect = Direction::DOWN, const int opCodesToScan = 512, const ptrdiff_t occurence = 1) const; CMemory FindPatternSelf(const string& svPattern, const Direction searchDirect = Direction::DOWN, const int opCodesToScan = 512, const ptrdiff_t occurence = 1); - CMemory FollowNearCall(ptrdiff_t opcodeOffset = 0x1, ptrdiff_t nextInstructionOffset = 0x5) const; - CMemory FollowNearCallSelf(ptrdiff_t opcodeOffset = 0x1, ptrdiff_t nextInstructionOffset = 0x5); - CMemory ResolveRelativeAddress(ptrdiff_t registerOffset = 0x0, ptrdiff_t nextInstructionOffset = 0x4) const; - CMemory ResolveRelativeAddressSelf(ptrdiff_t registerOffset = 0x0, ptrdiff_t nextInstructionOffset = 0x4); - static void HookVirtualMethod(uintptr_t virtualTable, void* pHookMethod, void** ppOriginalMethod, ptrdiff_t methodIndex); + CMemory FollowNearCall(const ptrdiff_t opcodeOffset = 0x1, const ptrdiff_t nextInstructionOffset = 0x5) const; + CMemory FollowNearCallSelf(const ptrdiff_t opcodeOffset = 0x1, const ptrdiff_t nextInstructionOffset = 0x5); + CMemory ResolveRelativeAddress(const ptrdiff_t registerOffset = 0x0, const ptrdiff_t nextInstructionOffset = 0x4) const; + CMemory ResolveRelativeAddressSelf(const ptrdiff_t registerOffset = 0x0, const ptrdiff_t nextInstructionOffset = 0x4); + static void HookVirtualMethod(const uintptr_t virtualTable, const void* pHookMethod, const ptrdiff_t methodIndex, void** ppOriginalMethod); private: uintptr_t ptr = 0; diff --git a/r5dev/public/memaddr.cpp b/r5dev/public/memaddr.cpp index 9eca8f15..61994681 100644 --- a/r5dev/public/memaddr.cpp +++ b/r5dev/public/memaddr.cpp @@ -33,19 +33,19 @@ bool CMemory::CheckOpCodes(const vector vOpcodeArray) const // Purpose: patch array of opcodes starting from current address // Input : vOpcodeArray - //----------------------------------------------------------------------------- -void CMemory::Patch(vector vOpcodes) const +void CMemory::Patch(const vector vOpcodeArray) const { DWORD oldProt = NULL; - SIZE_T dwSize = vOpcodes.size(); + SIZE_T dwSize = vOpcodeArray.size(); VirtualProtect(reinterpret_cast(ptr), dwSize, PAGE_EXECUTE_READWRITE, &oldProt); // Patch page to be able to read and write to it. - for (int i = 0; i < vOpcodes.size(); i++) + for (int i = 0; i < vOpcodeArray.size(); i++) { - *reinterpret_cast(ptr + i) = vOpcodes[i]; // Write opcodes to Address. + *reinterpret_cast(ptr + i) = vOpcodeArray[i]; // Write opcodes to Address. } - dwSize = vOpcodes.size(); + dwSize = vOpcodeArray.size(); VirtualProtect(reinterpret_cast(ptr), dwSize, oldProt, &oldProt); // Restore protection. } @@ -173,7 +173,7 @@ CMemory CMemory::FindPatternSelf(const string& svPattern, const Direction search // nextInstructionOffset - // Output : CMemory //----------------------------------------------------------------------------- -CMemory CMemory::FollowNearCall(ptrdiff_t opcodeOffset, ptrdiff_t nextInstructionOffset) const +CMemory CMemory::FollowNearCall(const ptrdiff_t opcodeOffset, const ptrdiff_t nextInstructionOffset) const { return ResolveRelativeAddress(opcodeOffset, nextInstructionOffset); } @@ -184,7 +184,7 @@ CMemory CMemory::FollowNearCall(ptrdiff_t opcodeOffset, ptrdiff_t nextInstructio // nextInstructionOffset - // Output : CMemory //----------------------------------------------------------------------------- -CMemory CMemory::FollowNearCallSelf(ptrdiff_t opcodeOffset, ptrdiff_t nextInstructionOffset) +CMemory CMemory::FollowNearCallSelf(const ptrdiff_t opcodeOffset, const ptrdiff_t nextInstructionOffset) { return ResolveRelativeAddressSelf(opcodeOffset, nextInstructionOffset); } @@ -195,7 +195,7 @@ CMemory CMemory::FollowNearCallSelf(ptrdiff_t opcodeOffset, ptrdiff_t nextInstru // nextInstructionOffset - // Output : CMemory //----------------------------------------------------------------------------- -CMemory CMemory::ResolveRelativeAddress(ptrdiff_t registerOffset, ptrdiff_t nextInstructionOffset) const +CMemory CMemory::ResolveRelativeAddress(const ptrdiff_t registerOffset, const ptrdiff_t nextInstructionOffset) const { // Skip register. uintptr_t skipRegister = ptr + registerOffset; @@ -216,7 +216,7 @@ CMemory CMemory::ResolveRelativeAddress(ptrdiff_t registerOffset, ptrdiff_t next // nextInstructionOffset - // Output : CMemory //----------------------------------------------------------------------------- -CMemory CMemory::ResolveRelativeAddressSelf(ptrdiff_t registerOffset, ptrdiff_t nextInstructionOffset) +CMemory CMemory::ResolveRelativeAddressSelf(const ptrdiff_t registerOffset, const ptrdiff_t nextInstructionOffset) { // Skip register. uintptr_t skipRegister = ptr + registerOffset; @@ -240,7 +240,7 @@ CMemory CMemory::ResolveRelativeAddressSelf(ptrdiff_t registerOffset, ptrdiff_t // pOriginalMethod - // Output : void** via pOriginalMethod //----------------------------------------------------------------------------- -void CMemory::HookVirtualMethod(uintptr_t virtualTable, void* pHookMethod, void** ppOriginalMethod, ptrdiff_t methodIndex) +void CMemory::HookVirtualMethod(const uintptr_t virtualTable, const void* pHookMethod, const ptrdiff_t methodIndex, void** ppOriginalMethod) { DWORD oldProt = NULL; diff --git a/r5dev/squirrel/sqapi.cpp b/r5dev/squirrel/sqapi.cpp index c4a3bb52..3b19ab71 100644 --- a/r5dev/squirrel/sqapi.cpp +++ b/r5dev/squirrel/sqapi.cpp @@ -11,7 +11,7 @@ //--------------------------------------------------------------------------------- SQChar* sq_getstring(HSQUIRRELVM v, SQInteger i) { - return *reinterpret_cast(*reinterpret_cast(&v->_stackbase) + 0x10i64 * i + 0x8) + 0x40; + return *reinterpret_cast(*reinterpret_cast(&v->_stackbase) + 0x10i64 * i + 0x8) + 0x40; } //--------------------------------------------------------------------------------- diff --git a/r5dev/thirdparty/imgui/src/imgui_logger.cpp b/r5dev/thirdparty/imgui/src/imgui_logger.cpp index a0063f49..a484b9d1 100644 --- a/r5dev/thirdparty/imgui/src/imgui_logger.cpp +++ b/r5dev/thirdparty/imgui/src/imgui_logger.cpp @@ -58,7 +58,7 @@ std::string CTextLogger::GetText(const Coordinates & aStart, const Coordinates & int iend = GetCharacterIndex(aEnd); size_t s = 0; - for (size_t i = lstart; i < lend; i++) + for (int i = lstart; i < lend; i++) s += m_Lines[i].size(); result.reserve(s + s / 8); diff --git a/r5dev/tier0/basetypes.h b/r5dev/tier0/basetypes.h index fe0e77f9..c2819055 100644 --- a/r5dev/tier0/basetypes.h +++ b/r5dev/tier0/basetypes.h @@ -135,6 +135,7 @@ #define MAX_MAP_NAME 64 #define SDK_VERSION "VGameSDK001" // Increment this with every /breaking/ SDK change (i.e. security/backend changes breaking compatibility). +#define SDK_ARRAYSIZE(arr) ((int)(sizeof(arr) / sizeof(*arr))) // Name due to IMGUI implementation and NT implementation that we shouldn't share across everywhere. #ifndef DEDICATED #define SDK_DEFAULT_CFG "platform\\cfg\\startup_default.cfg" diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index 18d89adc..8e380b3c 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -31,11 +31,6 @@ ConVar::ConVar(const char* pszName, const char* pszDefaultValue, int nFlags, con //----------------------------------------------------------------------------- ConVar::~ConVar(void) { - if (m_Value.m_pszString) - { - delete[] m_Value.m_pszString; - m_Value.m_pszString = NULL; - } } //----------------------------------------------------------------------------- @@ -202,7 +197,7 @@ void ConVar::PurgeShipped(void) const "voice_enabled", }; - for (int i = 0; i < (&pszToPurge)[1] - pszToPurge; i++) + for (int i = 0; i < SDK_ARRAYSIZE(pszToPurge); i++) { ConVar* pCVar = g_pCVar->FindVar(pszToPurge[i]); @@ -239,7 +234,7 @@ void ConVar::PurgeHostNames(void) const "users_hostname" }; - for (int i = 0; i < (&pszHostNames)[1] - pszHostNames; i++) + for (int i = 0; i < SDK_ARRAYSIZE(pszHostNames); i++) { ConVar* pCVar = g_pCVar->FindVar(pszHostNames[i]); diff --git a/r5dev/tier1/cmd.cpp b/r5dev/tier1/cmd.cpp index 042aa096..bf729b1f 100644 --- a/r5dev/tier1/cmd.cpp +++ b/r5dev/tier1/cmd.cpp @@ -21,7 +21,7 @@ int CCommand::MaxCommandLength(void) //----------------------------------------------------------------------------- // Purpose: returns argument count //----------------------------------------------------------------------------- -std::int64_t CCommand::ArgC(void) const +int64_t CCommand::ArgC(void) const { return m_nArgc; } diff --git a/r5dev/vpc/interfaces.h b/r5dev/vpc/interfaces.h index 33aafbbf..db6f09e2 100644 --- a/r5dev/vpc/interfaces.h +++ b/r5dev/vpc/interfaces.h @@ -77,11 +77,11 @@ struct FactoryInfo class CFactory { public: - void AddFactory(const string& svFactoryName, void* pFactory); - void AddFactory(FactoryInfo factoryInfo); - size_t GetVersionIndex(const string& svInterfaceName) const; - void GetFactoriesFromRegister(void); - CMemory GetFactoryPtr(const string& factoryName, bool versionLess = true) const; + virtual void AddFactory(const string& svFactoryName, void* pFactory); + virtual void AddFactory(FactoryInfo factoryInfo); + virtual size_t GetVersionIndex(const string& svInterfaceName) const; + virtual void GetFactoriesFromRegister(void); + virtual CMemory GetFactoryPtr(const string& svFactoryName, bool versionLess = true) const; private: vector m_vFactories;