From bcdf773db4e60566196085a68105f205a584ec6c Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 9 Feb 2018 23:40:11 +0100 Subject: [PATCH] Fixup (tested live) --- SilentPatch/MemoryMgr.h | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/SilentPatch/MemoryMgr.h b/SilentPatch/MemoryMgr.h index 6b5cb49..465a456 100644 --- a/SilentPatch/MemoryMgr.h +++ b/SilentPatch/MemoryMgr.h @@ -37,13 +37,18 @@ enum namespace Memory { - struct PatternAndRange + struct PatternAndOffset { + PatternAndOffset( std::string_view pattern, ptrdiff_t offset = 0 ) + : pattern(std::move(pattern)), offset(offset) + { + } + std::string_view pattern; ptrdiff_t offset; }; - using AddrVariant = std::variant; + using AddrVariant = std::variant; namespace internal { @@ -77,7 +82,7 @@ namespace Memory { namespace internal { - inline uintptr_t HandlePattern( const PatternAndRange& pattern ) + inline uintptr_t HandlePattern( const PatternAndOffset& pattern ) { void* addr = hook::get_pattern( pattern.pattern, pattern.offset ); return reinterpret_cast(addr); @@ -274,7 +279,7 @@ namespace Memory switch ( bVer ) { case 1: - if ( std::holds_alternative(address11) ) return HandlePattern( std::get(address11) ); + if ( std::holds_alternative(address11) ) return HandlePattern( std::get(address11) ); else { const uintptr_t addr = std::get(address11); @@ -290,7 +295,7 @@ namespace Memory return AdjustAddress_11(addr); } case 2: - if ( std::holds_alternative(addressSteam) ) return HandlePattern( std::get(addressSteam) ); + if ( std::holds_alternative(addressSteam) ) return HandlePattern( std::get(addressSteam) ); else { const uintptr_t addr = std::get(addressSteam); @@ -306,7 +311,7 @@ namespace Memory case 3: return GetDummy(); case 4: - if ( std::holds_alternative(addressNewsteamR2) ) return HandlePattern( std::get(addressNewsteamR2) ); + if ( std::holds_alternative(addressNewsteamR2) ) return HandlePattern( std::get(addressNewsteamR2) ); else { const uintptr_t addr = std::get(addressNewsteamR2); @@ -319,7 +324,7 @@ namespace Memory return DynBaseAddress(addr); } case 5: - if ( std::holds_alternative(addressNewsteamR2_LV) ) return HandlePattern( std::get(addressNewsteamR2_LV) ); + if ( std::holds_alternative(addressNewsteamR2_LV) ) return HandlePattern( std::get(addressNewsteamR2_LV) ); else { const uintptr_t addr = std::get(addressNewsteamR2_LV); @@ -332,7 +337,7 @@ namespace Memory return DynBaseAddress(addr); } default: - if ( std::holds_alternative(address10) ) return HandlePattern( std::get(address10) ); + if ( std::holds_alternative(address10) ) return HandlePattern( std::get(address10) ); else { const uintptr_t addr = std::get(address10); @@ -371,7 +376,7 @@ namespace Memory #if defined _GTA_III || defined _GTA_VC - inline uintptr_t AddressByVersion(Memory::AddrVariant address10, Memory::AddrVariant address11, Memory::AddrVariant addressSteam) + inline uintptr_t AddressByVersion(AddrVariant address10, AddrVariant address11, AddrVariant addressSteam) { InitializeVersions(); @@ -380,7 +385,7 @@ namespace Memory switch ( bVer ) { case 1: - if ( std::holds_alternative(address11) ) return HandlePattern( std::get(address11) ); + if ( std::holds_alternative(address11) ) return HandlePattern( std::get(address11) ); else { const uintptr_t addr = std::get(address11); @@ -390,7 +395,7 @@ namespace Memory return addr; } case 2: - if ( std::holds_alternative(addressSteam) ) return HandlePattern( std::get(addressSteam) ); + if ( std::holds_alternative(addressSteam) ) return HandlePattern( std::get(addressSteam) ); else { const uintptr_t addr = std::get(addressSteam); @@ -400,7 +405,7 @@ namespace Memory return addr; } default: - if ( std::holds_alternative(address10) ) return HandlePattern( std::get(address10) ); + if ( std::holds_alternative(address10) ) return HandlePattern( std::get(address10) ); else { const uintptr_t addr = std::get(address10);