Implement GetDebuggedDLLBaseAddress

This commit is contained in:
Duncan Ogilvie 2020-11-13 11:13:06 +01:00
parent 5bc2e682e9
commit 0356726f20
1 changed files with 14 additions and 12 deletions

View File

@ -112,7 +112,7 @@ __declspec(dllexport) PROCESS_INFORMATION* TITCALL TitanGetProcessInformation()
return emu.TitanGetProcessInformation(); return emu.TitanGetProcessInformation();
} }
__declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteAPIAddressEx(const char* szDLLName, const char* szAPIName) static ULONG_PTR DbgValFromString(const char* expr)
{ {
#ifdef _WIN64 #ifdef _WIN64
#define X64DBG_DLL L"x64dbg.dll" #define X64DBG_DLL L"x64dbg.dll"
@ -121,18 +121,15 @@ __declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteAPIAddressEx(const char
#endif // _WIN64 #endif // _WIN64
static auto hModule = GetModuleHandleW(X64DBG_DLL); static auto hModule = GetModuleHandleW(X64DBG_DLL);
#undef X64DBG_DLL #undef X64DBG_DLL
static auto DbgValFromString = (ULONG_PTR(*)(const char*))GetProcAddress(hModule, "DbgValFromString");
return DbgValFromString ? DbgValFromString(expr) : 0;
}
if (hModule) __declspec(dllexport) ULONG_PTR TITCALL ImporterGetRemoteAPIAddressEx(const char* szDLLName, const char* szAPIName)
{ {
static auto DbgValFromString = (ULONG_PTR(*)(const char*))GetProcAddress(hModule, "DbgValFromString"); char expr[1024] = "";
if (DbgValFromString) _snprintf_s(expr, _TRUNCATE, "\"%s\":%s", szDLLName, szAPIName);
{ return DbgValFromString(expr);
char expr[1024] = "";
_snprintf_s(expr, _TRUNCATE, "\"%s\":%s", szDLLName, szAPIName);
return DbgValFromString(expr);
}
}
return 0;
} }
__declspec(dllexport) ULONG_PTR TITCALL GetDebuggedFileBaseAddress() __declspec(dllexport) ULONG_PTR TITCALL GetDebuggedFileBaseAddress()
@ -140,6 +137,11 @@ __declspec(dllexport) ULONG_PTR TITCALL GetDebuggedFileBaseAddress()
return emu.GetDebuggedFileBaseAddress(); return emu.GetDebuggedFileBaseAddress();
} }
__declspec(dllexport) ULONG_PTR TITCALL GetDebuggedDLLBaseAddress()
{
return DbgValFromString("mod.main()");
}
__declspec(dllexport) bool TITCALL DumpProcess(HANDLE hProcess, LPVOID ImageBase, const char* szDumpFileName, ULONG_PTR EntryPoint) __declspec(dllexport) bool TITCALL DumpProcess(HANDLE hProcess, LPVOID ImageBase, const char* szDumpFileName, ULONG_PTR EntryPoint)
{ {
// Just fails https://github.com/x64dbg/testplugin/blob/4ceae85ca8e8b63ff155495311c2c4b92febce99/test.cpp#L289, so not worth implementing // Just fails https://github.com/x64dbg/testplugin/blob/4ceae85ca8e8b63ff155495311c2c4b92febce99/test.cpp#L289, so not worth implementing