#ifndef MEMSTD_H #define MEMSTD_H class IMemAlloc { public: template T* Alloc(size_t nSize) { const static int index = 0; return CallVFunc(index, this, nSize); } template T* Realloc(T* pMem, size_t nSize) { const static int index = 3; return CallVFunc(index, this, pMem, nSize); } template void Free(T* pMem) { const static int index = 5; CallVFunc(index, this, pMem); } template size_t GetSize(T* pMem) { const static int index = 6; return CallVFunc(index, this, pMem); } }; //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- class CStdMemAlloc : public IMemAlloc{}; inline CMemory p_CreateGlobalMemAlloc; inline auto v_CreateGlobalMemAlloc = p_CreateGlobalMemAlloc.RCast(); inline CStdMemAlloc** g_pMemAllocSingleton = nullptr; inline CStdMemAlloc* MemAllocSingleton() { if (!(*g_pMemAllocSingleton)) { (*g_pMemAllocSingleton) = v_CreateGlobalMemAlloc(); } return (*g_pMemAllocSingleton); } /////////////////////////////////////////////////////////////////////////////// class VMemStd : public IDetour { virtual void GetAdr(void) const { LogFunAdr("CreateGlobalMemAlloc", p_CreateGlobalMemAlloc.GetPtr()); LogVarAdr("g_pMemAllocSingleton", reinterpret_cast(g_pMemAllocSingleton)); } virtual void GetFun(void) const { p_CreateGlobalMemAlloc = g_GameDll.FindPatternSIMD("40 53 48 83 EC 20 BB ?? ?? ?? ?? 33 C0"); v_CreateGlobalMemAlloc = p_CreateGlobalMemAlloc.RCast(); /*40 53 48 83 EC 20 BB ?? ?? ?? ?? 33 C0*/ } virtual void GetVar(void) const { g_pMemAllocSingleton = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 41 8B D8").OffsetSelf(0x5A).FindPatternSelf("48 8B", CMemory::Direction::DOWN, 100).ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } virtual void Detach(void) const { } }; /////////////////////////////////////////////////////////////////////////////// #endif // MEMSTD_H