mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Finish signature cache map implementation in CModule
This commit is contained in:
parent
c3eba48472
commit
81fbf9ded7
@ -149,6 +149,12 @@ CMemory CModule::FindStringReadOnly(const string& svString, bool bNullTerminator
|
||||
if (!m_ReadOnlyData.IsSectionValid())
|
||||
return CMemory();
|
||||
|
||||
uint64_t nRVA;
|
||||
if (g_SigCache.FindEntry(svString, nRVA))
|
||||
{
|
||||
return CMemory(nRVA + GetModuleBase());
|
||||
}
|
||||
|
||||
const vector<int> vBytes = StringToBytes(svString, bNullTerminator); // Convert our string to a byte array.
|
||||
const pair bytesInfo = std::make_pair(vBytes.size(), vBytes.data()); // Get the size and data of our bytes.
|
||||
|
||||
@ -171,7 +177,10 @@ CMemory CModule::FindStringReadOnly(const string& svString, bool bNullTerminator
|
||||
|
||||
if (bFound)
|
||||
{
|
||||
return CMemory(&pBase[i]);
|
||||
CMemory result = CMemory(&pBase[i]);
|
||||
g_SigCache.AddEntry(svString, GetRVA(result.GetPtr()));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,8 +243,8 @@ CMemory CModule::FindString(const string& svString, const ptrdiff_t nOccurrence,
|
||||
}
|
||||
|
||||
resultAddress = CMemory(pLatestOccurrence);
|
||||
|
||||
g_SigCache.AddEntry(svPackedString, GetRVA(resultAddress.GetPtr()));
|
||||
|
||||
return resultAddress;
|
||||
}
|
||||
|
||||
@ -330,9 +339,9 @@ CMemory CModule::GetVirtualMethodTable(const string& svTableName, const uint32_t
|
||||
}
|
||||
|
||||
CMemory vfTable = FindPatternSIMD(reinterpret_cast<rsig_t>(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8);
|
||||
|
||||
g_SigCache.AddEntry(svPackedTableName, GetRVA(vfTable.GetPtr()));
|
||||
return FindPatternSIMD(reinterpret_cast<rsig_t>(&referenceOffset), "xxxxxxxx", { ".rdata", m_ReadOnlyData.m_pSectionBase, m_ReadOnlyData.m_nSectionSize }).OffsetSelf(0x8);
|
||||
|
||||
return vfTable;
|
||||
}
|
||||
|
||||
return CMemory();
|
||||
|
@ -22,7 +22,6 @@ public:
|
||||
|
||||
CModule(void) = default;
|
||||
CModule(const string& moduleName);
|
||||
CMemory FindPatternSIMD(const uint8_t* szPattern, const char* szMask, const ModuleSections_t& moduleSection = {}, const uint32_t nOccurrence = 0) const;
|
||||
CMemory FindPatternSIMD(const string& svPattern, const ModuleSections_t& moduleSection = {}) const;
|
||||
CMemory FindString(const string& string, const ptrdiff_t occurrence = 1, bool nullTerminator = false) const;
|
||||
CMemory FindStringReadOnly(const string& svString, bool nullTerminator) const;
|
||||
@ -41,6 +40,8 @@ public:
|
||||
ModuleSections_t m_ReadOnlyData;
|
||||
|
||||
private:
|
||||
CMemory FindPatternSIMD(const uint8_t* szPattern, const char* szMask, const ModuleSections_t& moduleSection = {}, const uint32_t nOccurrence = 0) const;
|
||||
|
||||
string m_svModuleName;
|
||||
uintptr_t m_pModuleBase{};
|
||||
DWORD m_nModuleSize{};
|
||||
|
Loading…
x
Reference in New Issue
Block a user