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

问题描述

我正在寻找在 Windows XP 下通过进程 ID 以编程方式暂停和恢复特定进程的不同方法.

I am looking for different ways to pause and resume programmatically a particular process via its process ID under Windows XP.

进程挂起/恢复工具使用 SuspendThread/ResumeThread 但警告多线程程序和死锁问题.

Process suspend/resume tool does it with SuspendThread / ResumeThread but warns about multi-threaded programs and deadlock problems.

PsSuspend 看起来不错,但我想知道它是否有什么特别之处关于死锁或使用其他方法?

PsSuspend looks okay, but I wonder if it does anything special about deadlocks or uses another method?

首选语言:C++/Python

Prefered languages : C++ / Python

推荐答案

如果您调试调试器"(例如,使用 logger.exe 跟踪由 windbg 进行的所有 API 调用.exe),看来调试器使用 SuspendThread()/ResumeThread() 来暂停正在调试的进程中的所有线程.

If you "debug the debugger" (for instance, using logger.exe to trace all API calls made by windbg.exe), it appears that the debugger uses SuspendThread()/ResumeThread() to suspend all of the threads in the process being debugged.

PsSuspend 可能使用不同的方式挂起进程(我不确定),但仍然可以挂起其他进程:如果您挂起的进程持有另一个进程需要的共享同步对象,您可以阻止其他进程取得任何进展.如果两个程序都写得很好,当你恢复你挂起的那个程序时,它们应该会恢复,但并不是所有的程序都写得很好.如果这导致正在执行挂起的程序挂起,那么您就会陷入死锁.

PsSuspend may use a different way of suspending processes (I'm not sure), but it is still possible to hang other processes: if the process you're suspending is holding a shared synchronization object that is needed by another process, you may block that other process from making any progress. If both programs are well-written, they should recover when you resume the one that you suspended, but not all programs are well-written. And if this causes your program that is doing the suspending to hang, then you have a deadlock.

这篇关于如何在 Windows 下暂停/恢复任何外部进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:25