ddk samples crash in ntdll.dll

Hello,

I’ve been trying to track down the cause of a crash in NTDLL.dll when I run
one of the ddk samples (general\setup\enable).

The thing is that I can build the application using the provided shell and
BLD command and it runs fine. I then tried to move parts of the code into my
own dll that I’m developing using the VC6 IDE. James Antognini pointed out
to leave the /GZ flag out to make it compile. So now it compiles and links
but as soon as the program starts it crashes. To reduce the size of the
problem I let VC create a simple win32 console app and I stuck a single
bogus call:

// DLLHELL.cpp : Defines the entry point for the console application.
//

#include “stdafx.h”

#include <tchar.h> // Make program ansi AND unicode safe
#include <windows.h> // Most Windows functions
#include <commctrl.h> // Used for TreeView controls
#include <setupapi.h> // Used for SetupDiXxx functions
#include <cfgmgr32.h> // Used for CM_Xxxx functions
#include <regstr.h> // Extract Registry Strings

int main(int argc, char* argv)
{
DWORD Status, Problem;
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};

CM_Get_DevNode_Status(&Status, &Problem,
DeviceInfoData.DevInst,0);

printf(“Hello World!\n”);
return 0;
}

As soon as I run this I get a ‘user breakpoint called’ crash at the
following location:

NTDLL! 77f9eea9()
NTDLL! 77fcd942()
NTDLL! 77fb54c9()
NTDLL! 77fb4316()
NTDLL! 77fab4ab()
SETUPAPI! 778834e2()
SETUPAPI! 77883019()
SETUPAPI! 77882ce7()
SETUPAPI! 77882b69()
NTDLL! 77f8bfcc()
NTDLL! 77f8f5cb()
NTDLL! 77f8f56d()
NTDLL! 77f9f02f()

Can anyone help please? Looks like somehow things get misalligned or
something. Perhaps things got broken when I installed SP5 for VC6?

My link flags look like this:

cfgmgr32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib /nologo /subsystem:console /incremental:yes
/pdb:“Debug/DLLHELL.pdb” /debug /machine:I386 /out:“Debug/DLLHELL.exe”
/pdbtype:sept /libpath:“c:\ntddk\libchk\i386”

My compile flags like this:

/nologo /MLd /W3 /Gm /GX /ZI /Od /I “c:\ntddk\inc” /D “WIN32” /D “_DEBUG” /D
“_CONSOLE” /D “_MBCS” /Fp"Debug/DLLHELL.pch" /YX

I appreciate your time and assistance,

Sander


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</regstr.h></cfgmgr32.h></setupapi.h></commctrl.h></windows.h></tchar.h>

Per Dave Jones’ suggestion I ran my example in Windbg. I didn’t even bother
trying to add a dialog box or something because the application crashes
before it hits ‘main’. So I loaded my app and hit ‘F5’ and the following
appeared:

HEAP[RST_DC_Test.exe]: Heap block at 00134970 modified at 00134BD2 past
requested size of 25a
Hard coded breakpoint hit

This is repeatable and I’m sure it’s something I’m doing wrong during
compilation. In fact it seems related to the removal of the /GZ flag? Stack
and heap are not the same of course but I’m grasping for straws here :slight_smile:

This is with Windbg 5.00.2195.11 if it makes a difference.

Thanks,

Sander

-----Original Message-----
From: Dave Jones [mailto:xxxxx@digi.com]
Sent: Tuesday, June 12, 2001 2:21 PM
To: ‘Sander Pool’
Subject: FW: [ntdev] ddk samples crash in ntdll.dll

Sander:

The best way to find out what is going on is to use
windbg to debug this, because you don’t really have allot of
information here. To debug this you would start windbg and
use attach to process. An easy way to attach to the process
is to add some sort of user interaction such as a message box
or something that will give you time to set up the debugger.
Then once you crash you can get a stack trace and see what
the registers are doing. Also if you want to get more
information you can load the checked versions of the
offending dll, sys.

hope this helps

Dave Jones
Windows Software Engineer
Digi International

-----Original Message-----
From: Sander Pool [mailto:xxxxx@rhapsodynetworks.com]
Sent: Tuesday, June 12, 2001 4:04 PM
To: NT Developers Interest List
Subject: [ntdev] ddk samples crash in ntdll.dll

Hello,

I’ve been trying to track down the cause of a crash in
NTDLL.dll when I run
one of the ddk samples (general\setup\enable).

The thing is that I can build the application using the
provided shell and
BLD command and it runs fine. I then tried to move parts of
the code into my
own dll that I’m developing using the VC6 IDE. James
Antognini pointed out
to leave the /GZ flag out to make it compile. So now it
compiles and links
but as soon as the program starts it crashes. To reduce the
size of the
problem I let VC create a simple win32 console app and I
stuck a single
bogus call:

// DLLHELL.cpp : Defines the entry point for the console application.
//

#include “stdafx.h”

#include <tchar.h> // Make program ansi AND unicode safe
> #include <windows.h> // Most Windows functions
> #include <commctrl.h> // Used for TreeView controls
> #include <setupapi.h> // Used for SetupDiXxx functions
> #include <cfgmgr32.h> // Used for CM_Xxxx functions
> #include <regstr.h> // Extract Registry Strings
>
> int main(int argc, char* argv)
> {
> DWORD Status, Problem;
> SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
>
> CM_Get_DevNode_Status(&Status, &Problem,
> DeviceInfoData.DevInst,0);
>
> printf(“Hello World!\n”);
> return 0;
> }
>
> As soon as I run this I get a ‘user breakpoint called’ crash at the
> following location:
>
> NTDLL! 77f9eea9()
> NTDLL! 77fcd942()
> NTDLL! 77fb54c9()
> NTDLL! 77fb4316()
> NTDLL! 77fab4ab()
> SETUPAPI! 778834e2()
> SETUPAPI! 77883019()
> SETUPAPI! 77882ce7()
> SETUPAPI! 77882b69()
> NTDLL! 77f8bfcc()
> NTDLL! 77f8f5cb()
> NTDLL! 77f8f56d()
> NTDLL! 77f9f02f()
>
> Can anyone help please? Looks like somehow things get misalligned or
> something. Perhaps things got broken when I installed SP5 for VC6?
>
> My link flags look like this:
>
> cfgmgr32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.lib
> advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
> odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.lib
> advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
> odbccp32.lib /nologo /subsystem:console /incremental:yes
> /pdb:“Debug/DLLHELL.pdb” /debug /machine:I386 /out:“Debug/DLLHELL.exe”
> /pdbtype:sept /libpath:“c:\ntddk\libchk\i386”
>
> My compile flags like this:
>
> /nologo /MLd /W3 /Gm /GX /ZI /Od /I “c:\ntddk\inc” /D “WIN32”
> /D “_DEBUG” /D
> “_CONSOLE” /D “_MBCS” /Fp"Debug/DLLHELL.pch" /YX
>
>
> I appreciate your time and assistance,
>
> Sander
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@digi.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</regstr.h></cfgmgr32.h></setupapi.h></commctrl.h></windows.h></tchar.h>

You should go immediately to http://www.microsoft.com/ddk/debugging/ and
get the version of windbg found there abouts. Do not bother with
anything from either the NT4 or W2K ddk’s as they are bogus.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sander Pool
Sent: Tuesday, June 12, 2001 5:44 PM
To: NT Developers Interest List
Subject: [ntdev] RE: ddk samples crash in ntdll.dll

Per Dave Jones’ suggestion I ran my example in Windbg. I
didn’t even bother trying to add a dialog box or something
because the application crashes before it hits ‘main’. So I
loaded my app and hit ‘F5’ and the following
appeared:

HEAP[RST_DC_Test.exe]: Heap block at 00134970 modified at
00134BD2 past requested size of 25a Hard coded breakpoint hit

This is repeatable and I’m sure it’s something I’m doing
wrong during compilation. In fact it seems related to the
removal of the /GZ flag? Stack and heap are not the same of
course but I’m grasping for straws here :slight_smile:

This is with Windbg 5.00.2195.11 if it makes a difference.

Thanks,

Sander

> -----Original Message-----
> From: Dave Jones [mailto:xxxxx@digi.com]
> Sent: Tuesday, June 12, 2001 2:21 PM
> To: ‘Sander Pool’
> Subject: FW: [ntdev] ddk samples crash in ntdll.dll
>
>
> Sander:
>
> The best way to find out what is going on is to use
> windbg to debug this, because you don’t really have allot of
> information here. To debug this you would start windbg and
> use attach to process. An easy way to attach to the process
> is to add some sort of user interaction such as a message box
> or something that will give you time to set up the debugger.
> Then once you crash you can get a stack trace and see what
> the registers are doing. Also if you want to get more
> information you can load the checked versions of the
> offending dll, sys.
>
> hope this helps
>
> Dave Jones
> Windows Software Engineer
> Digi International
>
>
> -----Original Message-----
> From: Sander Pool [mailto:xxxxx@rhapsodynetworks.com]
> Sent: Tuesday, June 12, 2001 4:04 PM
> To: NT Developers Interest List
> Subject: [ntdev] ddk samples crash in ntdll.dll
>
>
>
> Hello,
>
> I’ve been trying to track down the cause of a crash in
> NTDLL.dll when I run
> one of the ddk samples (general\setup\enable).
>
> The thing is that I can build the application using the
> provided shell and
> BLD command and it runs fine. I then tried to move parts of
> the code into my
> own dll that I’m developing using the VC6 IDE. James
> Antognini pointed out
> to leave the /GZ flag out to make it compile. So now it
> compiles and links
> but as soon as the program starts it crashes. To reduce the
> size of the
> problem I let VC create a simple win32 console app and I
> stuck a single
> bogus call:
>
> // DLLHELL.cpp : Defines the entry point for the console
application.
> //
>
> #include “stdafx.h”
>
> #include <tchar.h> // Make program ansi AND unicode safe
> > #include <windows.h> // Most Windows functions
> > #include <commctrl.h> // Used for TreeView controls
> > #include <setupapi.h> // Used for SetupDiXxx functions #include
> > <cfgmgr32.h> // Used for CM_Xxxx functions
> > #include <regstr.h> // Extract Registry Strings
> >
> > int main(int argc, char* argv)
> > {
> > DWORD Status, Problem;
> > SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
> >
> > CM_Get_DevNode_Status(&Status, &Problem,
> > DeviceInfoData.DevInst,0);
> >
> > printf(“Hello World!\n”);
> > return 0;
> > }
> >
> > As soon as I run this I get a ‘user breakpoint called’ crash at the
> > following location:
> >
> > NTDLL! 77f9eea9()
> > NTDLL! 77fcd942()
> > NTDLL! 77fb54c9()
> > NTDLL! 77fb4316()
> > NTDLL! 77fab4ab()
> > SETUPAPI! 778834e2()
> > SETUPAPI! 77883019()
> > SETUPAPI! 77882ce7()
> > SETUPAPI! 77882b69()
> > NTDLL! 77f8bfcc()
> > NTDLL! 77f8f5cb()
> > NTDLL! 77f8f56d()
> > NTDLL! 77f9f02f()
> >
> > Can anyone help please? Looks like somehow things get
> misalligned or
> > something. Perhaps things got broken when I installed SP5 for VC6?
> >
> > My link flags look like this:
> >
> > cfgmgr32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> > comdlg32.lib
> > advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
> > odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> > comdlg32.lib
> > advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
> > odbccp32.lib /nologo /subsystem:console /incremental:yes
> > /pdb:“Debug/DLLHELL.pdb” /debug /machine:I386
> /out:“Debug/DLLHELL.exe”
> > /pdbtype:sept /libpath:“c:\ntddk\libchk\i386”
> >
> > My compile flags like this:
> >
> > /nologo /MLd /W3 /Gm /GX /ZI /Od /I “c:\ntddk\inc” /D “WIN32”
> > /D “_DEBUG” /D
> > “_CONSOLE” /D “_MBCS” /Fp"Debug/DLLHELL.pch" /YX
> >
> >
> > I appreciate your time and assistance,
> >
> > Sander
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@digi.com To
> > unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> >
>
> —
> You are currently subscribed to ntdev as: xxxxx@tellink.net
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</regstr.h></cfgmgr32.h></setupapi.h></commctrl.h></windows.h></tchar.h>

Looks like you want to get DevNodeStatus for Devinst==NULL.
Thats not so clever. Try to get a valid Devnode first and then get the
status for that one.

int main(int argc, char* argv)
{
DWORD Status, Problem;
SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
// ^-- this leaves (AFAIK)
// DeviceInfoData.DevInst==NULL
CM_Get_DevNode_Status(&Status, &Problem,
DeviceInfoData.DevInst,0);

printf(“Hello World!\n”);
return 0;
}


| Norbert Kawulski | mailto:xxxxx@stollmann.de |
| Stollmann T.P.GmbH, Development | http://www.stollmann.de |
–If it’s ISDN or Bluetooth, make sure it’s driven by Stollmann–

“That which does not kill us makes us stronger.”


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Norbert,

you are right, that wouldn’t be very smart for a real application. However,
this was the shortest example I could create that would crash *before* I
even hit that CM_* call.

Sander

-----Original Message-----
From: Norbert Kawulski [mailto:xxxxx@stollmann.de]

Looks like you want to get DevNodeStatus for Devinst==NULL.
Thats not so clever. Try to get a valid Devnode first and then get the
status for that one.
> int main(int argc, char* argv)
> {
> DWORD Status, Problem;
> SP_DEVINFO_DATA DeviceInfoData = {sizeof(SP_DEVINFO_DATA)};
// ^-- this leaves (AFAIK)
//
DeviceInfoData.DevInst==NULL
> CM_Get_DevNode_Status(&Status, &Problem,
> DeviceInfoData.DevInst,0);

> printf(“Hello World!\n”);
> return 0;
> }


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com