I'm writing thread finder in module. My goal is find all threads in process and find threads currently working address locations. Like image on below. I do this goal with NtQueryInformationThread API.
I'm search all web, and I find little bit code pieces. I compile and run my program, but thread start address is always being 0x00000 or 0xccccc. Where I do mistake? My Thread Start Address Finder function is here:
#define ThreadQuerySetWin32StartAddress 9
typedef NTSTATUS(WINAPI* NTQUERYINFOMATIONTHREAD)(HANDLE, LONG, PVOID, ULONG, PULONG);
DWORD WINAPI GetThreadStartAddress(__in HANDLE hThread)
{
NTSTATUS ntStatus;
DWORD dwThreadStartAddr = 0;
NTQUERYINFOMATIONTHREAD NtQueryInformationThread;
if ((NtQueryInformationThread = (NTQUERYINFOMATIONTHREAD)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtQueryInformationThread"))) {
ntStatus = NtQueryInformationThread(hThread, ThreadQuerySetWin32StartAddress, &dwThreadStartAddr, sizeof(DWORD), NULL);
}
return dwThreadStartAddr;
}