1#include <windows.h>2#include <tlhelp32.h>3#include"iostream"4 using namespacestd;5 voidPass_tpthread (WCHAR processname[]);6 typedef LONG NTSTATUS;7typedef NTSTATUS (WINAPI *ntqueryinformationthread) (8 HANDLE Threadhandle,9 ULONG Threadinformationclass,Ten PVOID threadinformation, One ULONG Threadinformationlength, A Pulong returnlength); -typedefenum_threadinfoclass - { the Threadbasicinformation, - Threadtimes, - ThreadPriority, - threadbasepriority, + Threadaffinitymask, - Threadimpersonationtoken, + Threaddescriptortableentry, A Threadenablealignmentfaultfixup, at threadeventpair_reusable, - threadquerysetwin32startaddress, - Threadzerotlscell, - Threadperformancecount, - Threadamilastthread, - Threadidealprocessor, in Threadpriorityboost, -Threadsettlsarrayaddress,//Obsolete to threadisiopending, + Threadhidefromdebugger, - Threadbreakontermination, the Threadswitchlegacystate, * threadisterminated, $ Threadlastsystemcall,Panax Notoginseng threadiopriority, - Threadcycletime, the threadpagepriority, + threadactualbasepriority, A Threadtebinformation, theThreadcswitchmon,//Obsolete + THREADCSWITCHPMU, - Threadwow64context, $ Threadgroupinformation, $Threadumsinformation,//UMS - threadcounterprofiling, - Threadidealprocessorex, the Maxthreadinfoclass - } threadinfoclass;Wuyi DWORD getprocess (WCHAR processname[]) the { -DWORD ProcessID =NULL; WuGetWindowThreadProcessId (Findwindoww (NULL, ProcessName), &ProcessID); - returnProcessID; About } $ voidPass_tpthread (WCHAR processname[]) - { -DWORD dwstaaddr =NULL; -DWORD dwreturnlength =NULL; AHANDLE Threadhwnd =NULL; + THREADENTRY32 te32; theTe32.dwsize =sizeof(TE32); -Hmodule Hntdll = Loadlibraryw (L"Ntdll.dll"); $Ntqueryinformationthread Ntqueryinformationthread =NULL; theNtqueryinformationthread =(Ntqueryinformationthread) theGetProcAddress (Hntdll,"Ntqueryinformationthread"); the theHANDLE Snapshot =CreateToolhelp32Snapshot (Th32cs_snapthread, NULL); - if(Thread32first (Snapshot, &te32)) in { the Do the { AboutThreadhwnd =Openthread (thread_all_access, FALSE, te32.th32threadid); the Ntqueryinformationthread (Threadhwnd, threadquerysetwin32startaddress, the&DWSTAADDR,sizeof(DWSTAADDR), &dwreturnlength); theDWORD PID =getprocess (ProcessName); + - if(GetProcess (ProcessName) = =Getprocessidofthread (Threadhwnd)) the {BayiCOUT.SETF (Ios::showbase |ios::uppercase); thecout<<dec<<"game thread ID:"<<Te32.th32threadid; thecout << Hex <<"Thread entry Address:"<< dwstaaddr <<Endl; - } - the} while(Thread32next (Snapshot, &te32)); the } the } the - intMain () the { thePass_tpthread (L"QQ"); thecout <<"Main thread id="<< GetWindowThreadProcessId (Findwindoww (NULL, L"QQ"), NULL) <<Endl;94 GetChar (); the}
Get the thread ID and entry address of a process