Header file for DebugBreak()

Using the Server 2003 DDK 3790,

I’m trying to write/debug a Native application, and I’ve placed a few calls to DebugBreak inside of NtProcessStartup().

The linker could not resolve _DebugBreak(), so I’ve grepped through all the headers and found a prototype in winbase.h.

When I include winbase.h, I get many errors.
What is the correct header to include for DebugBreak on XP, SP2?

1>Compiling - native.c for i386
1>c:\winddk\3790\inc\wnet\winbase.h(230) : error C2061: syntax error : identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2061: syntax error : identifie
r ‘OffsetHigh’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2059: syntax error : ‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(232) : error C2059: syntax error : ‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(235) : error C2059: syntax error : ‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(238) : error C2059: syntax error : ‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(241) : error C2061: syntax error : identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2061: syntax error : identifie
r ‘lpSecurityDescriptor’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2059: syntax error : ‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(243) : error C2061: syntax error : identifie
r ‘bInheritHandle’

You can’t call DebugBreak from a native application. Actually, it may
be possible as it is in kernel32.dll, but it is definitely not a good
idea, and kernel32.dll is the only system file that will work like this,
other than NTDLL, of course, which is the only thing you should be
using. I think you either want to write your own declaration for
DbgBreakPoint in ntdll (I don’t know what that would look like exactly),
or just write your own macro that expands under debug builds to __asm
{int 3}. DbgBreakPoint may do more than that; I do not know, and you
would have to disassemble it to find out, but the macro I describe
certainly won’t cause any problems.

mm

>> xxxxx@gmail.com 2007-05-15 14:01:16 >>>

Using the Server 2003 DDK 3790,

I’m trying to write/debug a Native application, and I’ve placed a few
calls to DebugBreak inside of NtProcessStartup().

The linker could not resolve _DebugBreak(), so I’ve grepped through all
the headers and found a prototype in winbase.h.

When I include winbase.h, I get many errors.
What is the correct header to include for DebugBreak on XP, SP2?

1>Compiling - native.c for i386
1>c:\winddk\3790\inc\wnet\winbase.h(230) : error C2061: syntax error :
identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2061: syntax error :
identifie
r ‘OffsetHigh’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2059: syntax error :
‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(232) : error C2059: syntax error :
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(235) : error C2059: syntax error :
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(238) : error C2059: syntax error :
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(241) : error C2061: syntax error :
identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2061: syntax error :
identifie
r ‘lpSecurityDescriptor’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2059: syntax error :
‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(243) : error C2061: syntax error :
identifie
r ‘bInheritHandle’


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

There would be a problem with x64 version. It is better to use __debugbreak() intrinsic, instead. Supported by VC compilers since version 13.00 (which is probably VS 7.0 or .NET 2002 or what the silly marketing name was). Works with all newer DDKs and WDKs.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Martin O’Brien[SMTP:xxxxx@evitechnology.com]
Reply To: Windows System Software Devs Interest List
Sent: Tuesday, May 15, 2007 8:29 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Header file for DebugBreak()

You can’t call DebugBreak from a native application. Actually, it may
be possible as it is in kernel32.dll, but it is definitely not a good
idea, and kernel32.dll is the only system file that will work like this,
other than NTDLL, of course, which is the only thing you should be
using. I think you either want to write your own declaration for
DbgBreakPoint in ntdll (I don’t know what that would look like exactly),
or just write your own macro that expands under debug builds to __asm
{int 3}. DbgBreakPoint may do more than that; I do not know, and you
would have to disassemble it to find out, but the macro I describe
certainly won’t cause any problems.

mm

>>> xxxxx@gmail.com 2007-05-15 14:01:16 >>>

Using the Server 2003 DDK 3790,

I’m trying to write/debug a Native application, and I’ve placed a few
calls to DebugBreak inside of NtProcessStartup().

The linker could not resolve _DebugBreak(), so I’ve grepped through all
the headers and found a prototype in winbase.h.

When I include winbase.h, I get many errors.
What is the correct header to include for DebugBreak on XP, SP2?

1>Compiling - native.c for i386
1>c:\winddk\3790\inc\wnet\winbase.h(230) : error C2061: syntax error :
identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2061: syntax error :
identifie
r ‘OffsetHigh’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2059: syntax error :
‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(232) : error C2059: syntax error :
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(235) : error C2059: syntax error :
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(238) : error C2059: syntax error :
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(241) : error C2061: syntax error :
identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2061: syntax error :
identifie
r ‘lpSecurityDescriptor’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2059: syntax error :
‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(243) : error C2061: syntax error :
identifie
r ‘bInheritHandle’


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

>>here would be a problem with x64 version. It is better to use __debugbreak() intrinsic, instead.

I’ve forgotten to mention that I’m building under the 32 bit checked build, not the 64-bit version.
But in either case, it appears debugbreak can’t be called from a Native application.

Definitely a better idea that I did not know about, but what is problem
on x64?

>> xxxxx@upek.com 2007-05-15 15:10:38 >>>
There would be a problem with x64 version. It is better to use
__debugbreak() intrinsic, instead. Supported by VC compilers since
version 13.00 (which is probably VS 7.0 or .NET 2002 or what the silly
marketing name was). Works with all newer DDKs and WDKs.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From:
xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com]
on behalf of Martin O’Brien[SMTP:xxxxx@evitechnology.com]
Reply To: Windows System Software Devs Interest List
Sent: Tuesday, May 15, 2007 8:29 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Header file for DebugBreak()

You can’t call DebugBreak from a native application. Actually, it
may
be possible as it is in kernel32.dll, but it is definitely not a
good
idea, and kernel32.dll is the only system file that will work like
this,
other than NTDLL, of course, which is the only thing you should be
using. I think you either want to write your own declaration for
DbgBreakPoint in ntdll (I don’t know what that would look like
exactly),
or just write your own macro that expands under debug builds to
__asm
{int 3}. DbgBreakPoint may do more than that; I do not know, and
you
would have to disassemble it to find out, but the macro I describe
certainly won’t cause any problems.

mm

>>> xxxxx@gmail.com 2007-05-15 14:01:16 >>>

Using the Server 2003 DDK 3790,

I’m trying to write/debug a Native application, and I’ve placed a
few
calls to DebugBreak inside of NtProcessStartup().

The linker could not resolve _DebugBreak(), so I’ve grepped through
all
the headers and found a prototype in winbase.h.

When I include winbase.h, I get many errors.
What is the correct header to include for DebugBreak on XP, SP2?

1>Compiling - native.c for i386
1>c:\winddk\3790\inc\wnet\winbase.h(230) : error C2061: syntax error
:
identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2061: syntax error
:
identifie
r ‘OffsetHigh’
1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2059: syntax error
:
‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(232) : error C2059: syntax error
:
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(235) : error C2059: syntax error
:
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(238) : error C2059: syntax error
:
‘}’
1>c:\winddk\3790\inc\wnet\winbase.h(241) : error C2061: syntax error
:
identifie
r ‘DWORD’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2061: syntax error
:
identifie
r ‘lpSecurityDescriptor’
1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2059: syntax error
:
‘;’
1>c:\winddk\3790\inc\wnet\winbase.h(243) : error C2061: syntax error
:
identifie
r ‘bInheritHandle’


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> ----------

From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com[SMTP:xxxxx@gmail.com]
Reply To: Windows System Software Devs Interest List
Sent: Tuesday, May 15, 2007 9:25 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Header file for DebugBreak()

>>here would be a problem with x64 version. It is better to use __debugbreak() intrinsic, instead.

I’ve forgotten to mention that I’m building under the 32 bit checked build, not the 64-bit version.
But in either case, it appears debugbreak can’t be called from a Native application.

__debugbreak() is compiler intrinsic and can be called from any code. Don’t forget two leading underscores.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

Inline assembly isn’t supported by compiler.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Martin O’Brien[SMTP:xxxxx@evitechnology.com]
Reply To: Windows System Software Devs Interest List
Sent: Tuesday, May 15, 2007 9:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Header file for DebugBreak()

Definitely a better idea that I did not know about, but what is problem
on x64?

>>> xxxxx@upek.com 2007-05-15 15:10:38 >>>
There would be a problem with x64 version. It is better to use
__debugbreak() intrinsic, instead. Supported by VC compilers since
version 13.00 (which is probably VS 7.0 or .NET 2002 or what the silly
marketing name was). Works with all newer DDKs and WDKs.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

> ----------
> From:
xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com]
on behalf of Martin O’Brien[SMTP:xxxxx@evitechnology.com]
> Reply To: Windows System Software Devs Interest List
> Sent: Tuesday, May 15, 2007 8:29 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Header file for DebugBreak()
>
> You can’t call DebugBreak from a native application. Actually, it
may
> be possible as it is in kernel32.dll, but it is definitely not a
good
> idea, and kernel32.dll is the only system file that will work like
this,
> other than NTDLL, of course, which is the only thing you should be
> using. I think you either want to write your own declaration for
> DbgBreakPoint in ntdll (I don’t know what that would look like
exactly),
> or just write your own macro that expands under debug builds to
__asm
> {int 3}. DbgBreakPoint may do more than that; I do not know, and
you
> would have to disassemble it to find out, but the macro I describe
> certainly won’t cause any problems.
>
> mm
>
> >>> xxxxx@gmail.com 2007-05-15 14:01:16 >>>
>
> Using the Server 2003 DDK 3790,
>
> I’m trying to write/debug a Native application, and I’ve placed a
few
> calls to DebugBreak inside of NtProcessStartup().
>
> The linker could not resolve _DebugBreak(), so I’ve grepped through
all
> the headers and found a prototype in winbase.h.
>
> When I include winbase.h, I get many errors.
> What is the correct header to include for DebugBreak on XP, SP2?
>
> 1>Compiling - native.c for i386
> 1>c:\winddk\3790\inc\wnet\winbase.h(230) : error C2061: syntax error
:
> identifie
> r ‘DWORD’
> 1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2061: syntax error
:
> identifie
> r ‘OffsetHigh’
> 1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2059: syntax error
:
> ‘;’
> 1>c:\winddk\3790\inc\wnet\winbase.h(232) : error C2059: syntax error
:
> ‘}’
> 1>c:\winddk\3790\inc\wnet\winbase.h(235) : error C2059: syntax error
:
> ‘}’
> 1>c:\winddk\3790\inc\wnet\winbase.h(238) : error C2059: syntax error
:
> ‘}’
> 1>c:\winddk\3790\inc\wnet\winbase.h(241) : error C2061: syntax error
:
> identifie
> r ‘DWORD’
> 1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2061: syntax error
:
> identifie
> r ‘lpSecurityDescriptor’
> 1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2059: syntax error
:
> ‘;’
> 1>c:\winddk\3790\inc\wnet\winbase.h(243) : error C2061: syntax error
:
> identifie
> r ‘bInheritHandle’
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256\>
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Definitely a better idea for IA64, at the very least.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien

Definitely a better idea that I did not know about, but what is problem
on x64?

>> xxxxx@upek.com 2007-05-15 15:10:38 >>>
There would be a problem with x64 version. It is better to use
__debugbreak() intrinsic, instead. Supported by VC compilers since
version 13.00 (which is probably VS 7.0 or .NET 2002 or what the silly
marketing name was). Works with all newer DDKs and WDKs.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

good point.

mm

>> xxxxx@upek.com 2007-05-15 15:48:20 >>>
Inline assembly isn’t supported by compiler.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]


From:
xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com]
on behalf of Martin O’Brien[SMTP:xxxxx@evitechnology.com]
Reply To: Windows System Software Devs Interest List
Sent: Tuesday, May 15, 2007 9:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Header file for DebugBreak()

Definitely a better idea that I did not know about, but what is
problem
on x64?

>>> xxxxx@upek.com 2007-05-15 15:10:38 >>>
There would be a problem with x64 version. It is better to use
__debugbreak() intrinsic, instead. Supported by VC compilers since
version 13.00 (which is probably VS 7.0 or .NET 2002 or what the
silly
marketing name was). Works with all newer DDKs and WDKs.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

> ----------
> From:

xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com]

on behalf of Martin O’Brien[SMTP:xxxxx@evitechnology.com]
> Reply To: Windows System Software Devs Interest List
> Sent: Tuesday, May 15, 2007 8:29 PM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] Header file for DebugBreak()
>
> You can’t call DebugBreak from a native application. Actually, it
may
> be possible as it is in kernel32.dll, but it is definitely not a
good
> idea, and kernel32.dll is the only system file that will work like
this,
> other than NTDLL, of course, which is the only thing you should be
> using. I think you either want to write your own declaration for
> DbgBreakPoint in ntdll (I don’t know what that would look like
exactly),
> or just write your own macro that expands under debug builds to
__asm
> {int 3}. DbgBreakPoint may do more than that; I do not know, and
you
> would have to disassemble it to find out, but the macro I describe
> certainly won’t cause any problems.
>
> mm
>
> >>> xxxxx@gmail.com 2007-05-15 14:01:16 >>>
>
> Using the Server 2003 DDK 3790,
>
> I’m trying to write/debug a Native application, and I’ve placed a
few
> calls to DebugBreak inside of NtProcessStartup().
>
> The linker could not resolve _DebugBreak(), so I’ve grepped
through
all
> the headers and found a prototype in winbase.h.
>
> When I include winbase.h, I get many errors.
> What is the correct header to include for DebugBreak on XP, SP2?
>
> 1>Compiling - native.c for i386
> 1>c:\winddk\3790\inc\wnet\winbase.h(230) : error C2061: syntax
error
:
> identifie
> r ‘DWORD’
> 1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2061: syntax
error
:
> identifie
> r ‘OffsetHigh’
> 1>c:\winddk\3790\inc\wnet\winbase.h(231) : error C2059: syntax
error
:
> ‘;’
> 1>c:\winddk\3790\inc\wnet\winbase.h(232) : error C2059: syntax
error
:
> ‘}’
> 1>c:\winddk\3790\inc\wnet\winbase.h(235) : error C2059: syntax
error
:
> ‘}’
> 1>c:\winddk\3790\inc\wnet\winbase.h(238) : error C2059: syntax
error
:
> ‘}’
> 1>c:\winddk\3790\inc\wnet\winbase.h(241) : error C2061: syntax
error
:
> identifie
> r ‘DWORD’
> 1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2061: syntax
error
:
> identifie
> r ‘lpSecurityDescriptor’
> 1>c:\winddk\3790\inc\wnet\winbase.h(242) : error C2059: syntax
error
:
> ‘;’
> 1>c:\winddk\3790\inc\wnet\winbase.h(243) : error C2061: syntax
error
:
> identifie
> r ‘bInheritHandle’
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256\>
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer