aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-09-22 21:16:54 +0200
committerToni Uhlig <matzeton@googlemail.com>2019-09-22 21:16:54 +0200
commit7dfd4eaf40541f30a8089fd35893524238944148 (patch)
tree08a3deaad89ea5c8b7384256da6dd3e34f093063
parent19b860efd3b00a164979234f85d8884a3e5e6cf1 (diff)
fixed bug during import table function resolving, added public getter function for EntryPoint and BaseAddress
-rw-r--r--MemDriverLib/DLLHelper.cpp4
-rw-r--r--include/DLLHelper.h9
2 files changed, 11 insertions, 2 deletions
diff --git a/MemDriverLib/DLLHelper.cpp b/MemDriverLib/DLLHelper.cpp
index 279fc58..723d63d 100644
--- a/MemDriverLib/DLLHelper.cpp
+++ b/MemDriverLib/DLLHelper.cpp
@@ -16,7 +16,7 @@ static FARPROC GetRemoteProcAddress(HMODULE localMod, HMODULE remoteMod, char *f
* Account for potential differences in base address
* of modules in different processes.
*/
- unsigned long delta = MakeDelta(unsigned long, remoteMod, localMod);
+ ULONGLONG delta = MakeDelta(ULONGLONG, remoteMod, localMod);
return MakePtr(FARPROC, GetProcAddress(localMod, func_name), delta);
}
@@ -228,7 +228,7 @@ bool DLLHelper::FixImports()
iibn = (IMAGE_IMPORT_BY_NAME *)GetPtrFromRVA((DWORD)(itd->u1.AddressOfData),
m_NTHeader, (PBYTE)m_DLLPtr);
- itd->u1.Function = MakePtr(DWORD, GetRemoteProcAddress(localMod,
+ itd->u1.Function = MakePtr(ULONGLONG, GetRemoteProcAddress(localMod,
remoteMod, (char *)iibn->Name), 0);
itd++;
diff --git a/include/DLLHelper.h b/include/DLLHelper.h
index cc61572..fc17711 100644
--- a/include/DLLHelper.h
+++ b/include/DLLHelper.h
@@ -39,6 +39,15 @@ public:
}
bool FixRelocs();
bool CopyHeaderAndSections();
+ UINT64 GetEntryPoint() {
+ if (!m_NTHeader) {
+ return 0;
+ }
+ return (UINT64)m_TargetBaseAddress + m_NTHeader->OptionalHeader.AddressOfEntryPoint;
+ }
+ UINT64 GetBaseAddress() {
+ return (UINT64)m_TargetBaseAddress;
+ }
private:
HANDLE m_TargetPID = 0;