aboutsummaryrefslogtreecommitdiff
path: root/primedev/thirdparty/silver-bun
diff options
context:
space:
mode:
Diffstat (limited to 'primedev/thirdparty/silver-bun')
-rw-r--r--primedev/thirdparty/silver-bun/module.cpp15
-rw-r--r--primedev/thirdparty/silver-bun/module.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/primedev/thirdparty/silver-bun/module.cpp b/primedev/thirdparty/silver-bun/module.cpp
index 84f4da9e..dceb602a 100644
--- a/primedev/thirdparty/silver-bun/module.cpp
+++ b/primedev/thirdparty/silver-bun/module.cpp
@@ -66,6 +66,21 @@ void CModule::Init()
m_ModuleSections.push_back(ModuleSections_t(reinterpret_cast<const char*>(hCurrentSection.Name),
static_cast<uintptr_t>(m_pModuleBase + hCurrentSection.VirtualAddress), hCurrentSection.SizeOfRawData)); // Push back a struct with the section data.
}
+
+ // Get the location of IMAGE_IMPORT_DESCRIPTOR for this module by adding the IMAGE_DIRECTORY_ENTRY_IMPORT relative virtual address onto our
+ // module base address.
+ IMAGE_IMPORT_DESCRIPTOR* pImageImportDescriptors = reinterpret_cast<IMAGE_IMPORT_DESCRIPTOR*>(
+ m_pModuleBase + m_pNTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
+ if (!pImageImportDescriptors)
+ return;
+
+ for (IMAGE_IMPORT_DESCRIPTOR* pIID = pImageImportDescriptors; pIID->Name != 0; pIID++)
+ {
+ // Get virtual relative Address of the imported module name. Then add module base Address to get the actual location.
+ const char* szImportedModuleName = reinterpret_cast<char*>(reinterpret_cast<DWORD*>(m_pModuleBase + pIID->Name));
+
+ m_vImportedModules.push_back(szImportedModuleName);
+ }
}
//-----------------------------------------------------------------------------
diff --git a/primedev/thirdparty/silver-bun/module.h b/primedev/thirdparty/silver-bun/module.h
index 5683ee14..cc513086 100644
--- a/primedev/thirdparty/silver-bun/module.h
+++ b/primedev/thirdparty/silver-bun/module.h
@@ -52,6 +52,7 @@ public:
ModuleSections_t GetSectionByName(const char* szSectionName) const;
inline const std::vector<CModule::ModuleSections_t>& GetSections() const { return m_ModuleSections; }
+ inline const std::vector<std::string>& GetImportedModules() const { return m_vImportedModules; }
inline uintptr_t GetModuleBase(void) const { return m_pModuleBase; }
inline DWORD GetModuleSize(void) const { return m_nModuleSize; }
inline const std::string& GetModuleName(void) const { return m_ModuleName; }
@@ -73,4 +74,5 @@ private:
uintptr_t m_pModuleBase;
DWORD m_nModuleSize;
std::vector<ModuleSections_t> m_ModuleSections;
+ std::vector<std::string> m_vImportedModules;
};