or learn the vld2.x version to see:
The Getprocessidofthread API is not available in Windows XP and previous operating systems, and an alternative implementation is given here:
Header file:
#if _WIN32_WINNT < 0x0600//Windows XP or earlier, no Getprocessidofthread ()
DWORD _getprocessidofthread (HANDLE thread);
#define Getprocessidofthread _getprocessidofthread
#endif
Source file:
Get through the Ntqueryinformationthread function:
DWORD _getprocessidofthread (HANDLE thread)
{
typedef struct _CLIENT_ID {
HANDLE uniqueprocess;
HANDLE Uniquethread;
} client_id, *pclient_id;
typedef LONG NTSTATUS;
typedef LONG Kpriority;
typedef struct _THREAD_BASIC_INFORMATION {
NTSTATUS Exitstatus;
PVOID tebbaseaddress;
client_id ClientId;
Kaffinity Affinitymask;
Kpriority priority;
Kpriority basepriority;
} thread_basic_information, *pthread_basic_information;
Const static Threadinfoclass threadbasicinformation = (threadinfoclass) 0;
typedef NTSTATUS (WINAPI *pntqueryinformationthread) (HANDLE thread,
Threadinfoclass Infoclass, PVOID buffer, ULONG buffersize,
Pulong used);
static Pntqueryinformationthread ntqueryinformationthread = NULL;
Thread_basic_information TBI;
NTSTATUS status;
if (Ntqueryinformationthread = = NULL) {
hmodule ntdll = Getmodulehandlew (L "Ntdll.dll");
if (ntdll)
{
Ntqueryinformationthread = (pntqueryinformationthread) GetProcAddress (Ntdll, "Ntqueryinformationthread");
}
if (Ntqueryinformationthread = = NULL) {
return 0;
}
}
Status =Ntqueryinformationthread(Thread, threadbasicinformation, &TBI, sizeof (TBI), NULL);
if (Status < 0) {
Shall we go through all the trouble for setting last error?
return 0;
}
Return(DWORD) TBI. Clientid.uniqueprocess;
}
Getprocessidofthread alternative implementations of WinXP and previous operating systems