From 99fe5b794a971f3ae97d0dfd2a22a6d739340d53 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Wed, 28 Jun 2023 20:00:38 +0200 Subject: [PATCH] Make memoverride a separate lib Else everything linked against tier0 will have to use the game's memalloc implementation, which requires it to run with the game process. Only limit this to DLL's that run with the game process. --- r5dev/core/CMakeLists.txt | 1 + r5dev/pluginsdk/CMakeLists.txt | 9 ++++++--- r5dev/tier0/CMakeLists.txt | 16 ++++++++++++++-- r5dev/tier0/memstd.cpp | 2 +- r5dev/tier0/memstd.h | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/r5dev/core/CMakeLists.txt b/r5dev/core/CMakeLists.txt index ddf87a36..45bf563b 100644 --- a/r5dev/core/CMakeLists.txt +++ b/r5dev/core/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE "Rpcrt4.lib" "vpc" + "memoverride" "tier0" "tier1" "tier2" diff --git a/r5dev/pluginsdk/CMakeLists.txt b/r5dev/pluginsdk/CMakeLists.txt index 44df544c..d72c3916 100644 --- a/r5dev/pluginsdk/CMakeLists.txt +++ b/r5dev/pluginsdk/CMakeLists.txt @@ -14,13 +14,16 @@ end_sources( "${BUILD_OUTPUT_DIR}/bin/x64_retail/plugins/" ) target_link_libraries( ${PROJECT_NAME} PRIVATE "tier0" + "memoverride" + "libdetours" "libprotobuf" "liblzham" "libspdlog" - "SigCache_PB" - "SV_RCon_PB" - "CL_RCon_PB" + + "SigCache_Pb" + "SV_RCon_Pb" + "CL_RCon_Pb" "Rpcrt4.lib" ) diff --git a/r5dev/tier0/CMakeLists.txt b/r5dev/tier0/CMakeLists.txt index fcbfe612..8bf1dd8b 100644 --- a/r5dev/tier0/CMakeLists.txt +++ b/r5dev/tier0/CMakeLists.txt @@ -1,4 +1,18 @@ cmake_minimum_required( VERSION 3.16 ) + +# Separate lib as we aren't implementing the memalloc system! +# This library mainly interfaces the program to the game's +# internal memalloc system. Only link if its getting used or +# is using the game module!!! +add_module( "lib" "memoverride" "vpc" ${FOLDER_CONTEXT} TRUE TRUE ) + +add_sources( SOURCE_GROUP "Runtime" + "memstd.cpp" + "memstd.h" +) + +end_sources() + add_module( "lib" "tier0" "vpc" ${FOLDER_CONTEXT} TRUE TRUE ) start_sources() @@ -22,8 +36,6 @@ add_sources( SOURCE_GROUP "Runtime" "frametask.cpp" "jobthread.cpp" "memaddr.cpp" - "memstd.cpp" - "memstd.h" "module.cpp" "platform.cpp" "sigcache.cpp" diff --git a/r5dev/tier0/memstd.cpp b/r5dev/tier0/memstd.cpp index b30fd6b0..964f6833 100644 --- a/r5dev/tier0/memstd.cpp +++ b/r5dev/tier0/memstd.cpp @@ -84,7 +84,7 @@ extern "C" InitAllocator(); MemAllocSingleton()->Free(pBlock); } - __declspec(noinline) size_t __cdecl _msize_base(void* const pBlock) + __declspec(noinline) size_t __cdecl _msize_base(void* const pBlock) noexcept { InitAllocator(); diff --git a/r5dev/tier0/memstd.h b/r5dev/tier0/memstd.h index f0b1e7ce..25442844 100644 --- a/r5dev/tier0/memstd.h +++ b/r5dev/tier0/memstd.h @@ -8,7 +8,7 @@ extern "C" __declspec(restrict) void* __cdecl _realloc_base(void* const pBlock, size_t const nSize); __declspec(restrict) void* __cdecl _recalloc_base(void* const pBlock, size_t const nCount, size_t const nSize); __declspec(noinline) void __cdecl _free_base(void* const pBlock); - __declspec(noinline) size_t __cdecl _msize_base(void* const pBlock); + __declspec(noinline) size_t __cdecl _msize_base(void* const pBlock) noexcept; char* __cdecl _strdup(const char* pString); void* __cdecl _expand(void* pBlock, size_t nSize); }