From ef28df4aa1d911ea850d9fa717b602d108f67240 Mon Sep 17 00:00:00 2001 From: PixieCore <41352111+IcePixelx@users.noreply.github.com> Date: Sun, 24 Jul 2022 15:09:45 +0200 Subject: [PATCH] CModule::GetVirtualMethodTable optimization --- r5dev/public/module.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/r5dev/public/module.cpp b/r5dev/public/module.cpp index a4c50aa2..657da6f0 100644 --- a/r5dev/public/module.cpp +++ b/r5dev/public/module.cpp @@ -264,7 +264,6 @@ CMemory CModule::GetVirtualMethodTable(const std::string& tableName) if (!rttiTypeDescriptor) return CMemory(); - vector rttiTDRef = {}; uintptr_t scanStart = m_ReadOnlyData.m_pSectionBase; // Get the start address of our scan. const uintptr_t scanEnd = (m_ReadOnlyData.m_pSectionBase + m_ReadOnlyData.m_nSectionSize) - 0x4; // Calculate the end of our scan. @@ -274,16 +273,13 @@ CMemory CModule::GetVirtualMethodTable(const std::string& tableName) CMemory reference = FindPatternSIMD(reinterpret_cast(&rttiTDRva), "xxxx", {".rdata", scanStart, m_ReadOnlyData.m_nSectionSize}); if (!reference) break; - - rttiTDRef.push_back(reference); - scanStart = reference.Offset(0x4).GetPtr(); // Set location to current reference + 0x4 so we avoid pushing it back again into the vector. - } - - for (const CMemory& ref : rttiTDRef) - { - CMemory referenceOffset = ref.Offset(-0xC); + + CMemory referenceOffset = reference.Offset(-0xC); if (referenceOffset.GetValue() != 1) // Check if we got a RTTI Object Locator for this reference by checking if -0xC is 1, which is the 'signature' field which is always 1 on x64. + { + scanStart = reference.Offset(0x4).GetPtr(); // Set location to current reference + 0x4 so we avoid pushing it back again into the vector. continue; + } return FindPatternSIMD(reinterpret_cast(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8); }