本文介绍了如何找到进程是否暂停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码进行暂停处理。我在这里找到

i am using this code for suspend process.i found it here http://www.codeproject.com/KB/threads/pausep.aspx

BOOL SuspendResumeThreadList(DWORD dwOwnerPID, bool bResumeThread) 
{ 
    HANDLE        hThreadSnap = NULL; 
    BOOL          bRet        = FALSE; 
    THREADENTRY32 te32        = {0}; 

    hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); 
    if (hThreadSnap == INVALID_HANDLE_VALUE) 
        return (FALSE); 

    te32.dwSize = sizeof(THREADENTRY32); 

    if (Thread32First(hThreadSnap, &te32)) 
    { 
        do 
        { 
            if (te32.th32OwnerProcessID == dwOwnerPID) 
            {
                HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te32.th32ThreadID);
                if (bResumeThread)
                {
                    //cout << _T("Resuming Thread 0x") << cout.setf( ios_base::hex ) << te32.th32ThreadID << '\n';
                    ResumeThread(hThread);
                }
                else
                {
                    //cout << _T("Suspending Thread 0x") << cout.setf( ios_base::hex ) << te32.th32ThreadID << '\n';
                    SuspendThread(hThread);
                }
                CloseHandle(hThread);
            } 
        }
        while (Thread32Next(hThreadSnap, &te32)); 
        bRet = TRUE; 
    } 
    else 
        bRet = FALSE;   
    CloseHandle (hThreadSnap); 
    return (bRet); 
} 



现在我想要一个方法来找到进程是否被暂停? ?

Now i want a way to find if the process is suspended or not ???please help me.

推荐答案

如果我记得正确,可以使用。使用 NtQuerySystemInformation ,您可以通过迭代 SYSTEM_PROCESS_INFORMATION SYSTEM_PROCESS_INFORMATION c>并查找目标进程的PID。您可以在Wine资源中找到 SYSTEM_PROCESS_INFORMATION 的详细说明。获得进程信息结构后,只需查看 SYSTEM_THREAD_INFORMATION ,您可以在其中检查线程的状态。有关结构和枚举的更多详细信息,请查看Wine源。

If I remember correct you can use NtQuerySystemInformation for this purpose. With NtQuerySystemInformation you can get SYSTEM_PROCESS_INFORMATION structure by iterating over array of SYSTEM_PROCESS_INFORMATION and looking for the PID of the target process. You can find detailed description of SYSTEM_PROCESS_INFORMATION in Wine sources here. After you get process information structure just look at SYSTEM_THREAD_INFORMATION where you can check state of thread. For more details about structures and enums look at Wine sources.

这篇关于如何找到进程是否暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 18:46