After calling DebugBreakProcess() - What does the event's dwThreadId represents?

Let's say some process debugs another process (by calling DebugActiveProcess()).

Then some other process/thread generates break-points exceptions at that debugged process (by calling DebugBreakProcess()). The debugger then receives this EXCEPTION_DEBUG_EVENT->EXCEPTION_BREAKPOINT event and in the DEBUG_EVENT structure the field dwThreadId will hold some ID.

My root question is - What does this dwThreadId represents? (MSDN says it is "The identifier of the thread in which the debugging event occurred").

My concerns are of the following:

  1. What does it mean "in which the debugging event occurred"? Isn't it that all the threads of the process are somehow signaled this way and therefor the process is entirely blocked?

  2. Moreover, from stuff I read, this mechanism works something like this:

    The DebugBreakProcess() API works by creating a thread in the target process that invokes a breakpoint instruction, which causes the normal SEH mechanism to take over.

    Which means there's a possibility that this dwThreadId is actually the ID of this newly created thread and not an ID of any of the original process' threads. Am i correct?

  3. What if the debugged process is multi-threaded (actually it is almost certain it is)? Is this the ID of the thread that was "in the processor" at the moment of calling the DebugBreakProcess() API?

UPDATE: all this block was answered. See the first answer.

  1. What about the case of a dual-core system and two threads of the same process are currently running in parallel? Which one will win and will be stated in this ID? Or maybe it will cause two different EXCEPTION_BREAKPOINT exceptions?

Thank you very much for any help that is provided.


You pretty much answered your own question, it would be the thread that called DebugBreak() which in turn is the new thread created by DebugBreakProcess().

Need Your Help

JavaFX: How can a Path be painted on a GraphicsContext?

path javafx graphicscontext

JavaFX provides both low-level path painting methods on a GraphicsContext and a high-level Path node.

Java client-server interaction with NIO

java nio

I want to use Java NIO for client-server communication. Several clients should connect to one server. The clients send a serialized object. The server deserializes the object and sends e.g. an inte...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.