Win32 debugging under Windows XP

Win32 debugging under Windows XP

Post by pat blond » Fri, 01 Feb 2002 00:22:58

Hi all,

I've coded a tool using the win32 debugging API (WaitForDebugEvent,
ContinueDebugEvent,...) that is working fine under windows 98/2K/NT.

It's been a bad surprise to see that it is not working properly under
Windows XP.

The wrong behavior comes from the mechanism of setting the trap flag
and handling the ensuing "single-step exception". I'm using the
sequence to set the trap flag:

    if( !GetThreadContext( hThread, &ctx ) )
      throw( __LINE__ );

    ctx.EFlags |= 0x0100;

    if( !SetThreadContext( hThread, &ctx ) )
      throw( __LINE__ );

(This code is inspired by MSDN articles and samples, e.g. "Points to
Remember When Writing a De* for Win32s" ).

The sequence correctly sets the trap flag (I checked it by calling
GetThreadContext) but under XP, I never get the "single-step
exception" that
the next call to WaitForDebugEvent() should return.

I tried a few things that did not work better:
1. SuspendThread before GetThreadContext and ResumeThread after
2. CreateProcess with DEBUG_PROCESS flag alone
3. CreateProcess with DEBUG_ONLY_THIS_PROCESS flag alone

Besides, the "break-point" exception event is correctly caught and
as well as the CREATE_PROCESS / CREATE_THREAD / LOAD_DLL / ... debug
Really, only single-step mode seems to be a problem under XP.

Any clue?


PS. I'll keep trying things and post an answer if I find one.


1. Windows XP crash after try to debug Winlogon.exe

On Windows XP profesional I made the changes like described in
Platform SDK from January 2001 in the topic "testing and debuging gina
dll". So I edited the win.ini file and made a new key under
HKLM\.....winlogon\...Image "Something dont remeber" and a REG_SZ
entry with name Debugger with value ntsd -d. I rebooted and somewhere
probably at the moment when winlogon should start runing the system
starts reboting again. How can I get my system running again? I found
out that there is a tool called BlueCon but which is not shareware.
Any other tools allowing me to boot up and undo the HKLM registry
changes and the win.ini file changes (probably the registry one are
Any additional sugestion are welcomed.


2. New Stuff in System Folder

3. debug version of Oleaut32.dll of Windows XP

4. Drives won't connect after "reinstalling" W/95

5. Debug Registers & Windows 2000/XP

6. The Network Side of Cellular Mobile Radio

7. Debugging, Visual C++ 4 and Windows XP

8. The 7th Guest finished file? Please????

9. Win32's GetFileVersionInfoSize() on 16-bit EXE = 0xC0000005 in debug window...

10. Please help, problem with FMTID_SummaryInformation on Windows XP (and ONLY windows xp)

11. Windows XP Home (Korean) and Windows XP Professional (German) Volume License Version

12. Win32 app and Windows XP themes

13. Printing to Debug Message window without the debug kernel?