我用HOOK将Dll注入了一个进程内
怎么枚举进程内的线程 并暂停 我不想要的他运行的线程
谢谢

解决方案 »

  1.   

    HANDLE hThreadSnap = NULL; 
    THREADENTRY32 threadEntry = {0};
    hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); 
    if (hThreadSnap != INVALID_HANDLE_VALUE) 
    {

    threadEntry.dwSize = sizeof(THREADENTRY32); 
    Thread32First(hThreadSnap, &threadEntry);
    do
    {.......
    }
    while(Thread32Next(hThreadSnap, &threadEntry));

    }
      

  2.   

    CreateToolhelp32Snapshot、Thread32First、Thread32Next。
      

  3.   

    CreateToolhelp32Snapshot
    THREADENTRY32
    Thread32First
    Thread32Next
    ...
      

  4.   

    HANDLE        hThreadSnap = NULL;
    BOOL          bRet        = FALSE;
    THREADENTRY32 te32        = {0}; // Take a snapshot of all threads currently in the system. hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
    if (hThreadSnap == INVALID_HANDLE_VALUE)
    return (FALSE); // Fill in the size of the structure before using it. te32.dwSize = sizeof(THREADENTRY32); // Walk the thread snapshot to find all threads of the process.
    // If the thread belongs to the process, add its information
    // to the display list. if (Thread32First(hThreadSnap, &te32))
    {
    do
    {
    if (te32.th32OwnerProcessID == dwOwnerPID)
    {
    CString str;
    str.Format(_T("TID\t\t%d\nOwner PID\t%d\nDelta Priority\t%d\nBase Priority\t%d\n"), te32.th32ThreadID, te32.th32OwnerProcessID, te32.tpDeltaPri, te32.tpBasePri);
    AfxMessageBox(str);
    }
    }
    while (Thread32Next(hThreadSnap, &te32));
    bRet = TRUE;
    }
    else
    bRet = FALSE;          // could not walk the list of threads // Do not forget to clean up the snapshot object. CloseHandle (hThreadSnap); return (bRet);搞定 谢谢