-2
The thread that loads my DLL uses Loadlibrarya , I would like to recover the address (01145EA7) from the instruction that loads it or the PE (01C5B514) from the thread that loads it.
load dll assm:
01145EA2 PUSH 01FDE6B8 ; /FileName = "psHook.dll"
01145EA7 CALL DWORD PTR DS:[<&KERNEL32.LoadLibrar> ; \LoadLibraryA
01145EAD MOV DWORD PTR DS:[230E970],EAX
PE assm:
01C5B514 CALL 01C5BA38
My DLL:
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
(VOID)hInstDLL;
(VOID)lpvReserved;
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
hook_func();
(CreateThread(0,0,(LPTHREAD_START_ROUTINE)&UsedTimer,0,0,NULL));
break;
case DLL_PROCESS_DETACH:
FreeLibrary(hInstDLL);
break;
}
return TRUE;
}
use Getmainthreadid() to indent the IP of the thread I want to recover the PE or Address base.
DWORD GetMainThreadId() {
HANDLE hThreadSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hThreadSnapshot == INVALID_HANDLE_VALUE) {
WriteInConsole("Falha ao criar snapshot");
}
THREADENTRY32 tEntry;
tEntry.dwSize = sizeof(THREADENTRY32);
DWORD result = 0;
DWORD currentPID = GetCurrentProcessId();
for (BOOL success = Thread32First(hThreadSnapshot, &tEntry);
!result && success && GetLastError() != ERROR_NO_MORE_FILES;
success = Thread32Next(hThreadSnapshot, &tEntry))
{
if (tEntry.th32OwnerProcessID == currentPID) {
result = tEntry.th32ThreadID;
}
}
return result;
}
This is Assembly?
– Maury Developer
DLL is in C, the code to which Voce refers yes, the solution is just below.
– Victor Costa