I am trying to get Win32StartAddress from a thread on x64 Win7. When I get a thread from PsLookupThreadByThreadId() or PsGetCurrentThread(), the following code returns NULL for Win32StartAddress:
*(PVOID*)((PCHAR)Thread + 0x410)
but when I walk through threads with the following code, it works fine
*(PVOID*)((PCHAR)Thread + 0x410)
but when I walk through threads with the following code, it works fine
Code: Select all
The ethread address returned by PsLookupThreadByThreadId/PsGetCurrentThread is always 8 bytes smaller than the address from my ThreadListEntry walker. Why do they differ? :?PETHREAD thread;
PLIST_ENTRY startListEntry;
PLIST_ENTRY listEntry;
startListEntry = *(PLIST_ENTRY*)((PCHAR)Process + 0x420);
listEntry = startListEntry;
do
{
thread = (PETHREAD)((PCHAR)listEntry - 0x420);
DbgPrint("ETHREAD: %016llX, Win32StartAddress: %016llX", thread, *(PVOID*)((PCHAR)thread + 0x410));
listEntry = listEntry->Flink;
}
while (listEntry != startListEntry);