blue screen after standby device removal

Hi All,

If i attach the OSR-USB-FX2 board to my computer, the driver gets loaded
correctly. then i put my system (a laptop) in standby and remove the board.
then i wake my system again, causing it to bugcheck. the message indicates a
problem in usbhub.sys.

I have removed all code from my driver until only the DriverEntry and the
DeviceAdd routines contain some code. Is this a bug in my code, or is this a
bug in the USB hub driver?

kind regards,
Bruno.

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;

KdPrint((__DRIVER_NAME “–> DriverEntry\n”));

WDF_DRIVER_CONFIG_INIT(&config, EvtDeviceAdd);

status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME “WdfDriverCreate failed with status 0x%08x\n”,
status));
}

KdPrint((__DRIVER_NAME “<– DriverEntry\n”));

return status;
}

#pragma alloc_text(PAGE, EvtDevicePrepareHardware)
#pragma alloc_text(PAGE, EvtDeviceAdd)

NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;

UNREFERENCED_PARAMETER(Driver);

KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));

/*set the callback functions that will be executed on PNP and Power
events*/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);

WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);

/*initialize storage for the device context*/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

/*create a device instance.*/
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}

devCtx = GetDeviceContext(device);

/*create the default IO queue. this one will be used for ioctl requests*/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}

status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC, NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”,
status));
return status;
}

KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}

What OS (and SP level)? What is the call stack when the bugcheck
occurs?

The code looks fine (but you didn’t post any of the other functions like
D0Entry/Exit)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Friday, January 27, 2006 12:33 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] blue screen after standby device removal

Hi All,

If i attach the OSR-USB-FX2 board to my computer, the driver gets loaded

correctly. then i put my system (a laptop) in standby and remove the
board.
then i wake my system again, causing it to bugcheck. the message
indicates a
problem in usbhub.sys.

I have removed all code from my driver until only the DriverEntry and
the
DeviceAdd routines contain some code. Is this a bug in my code, or is
this a
bug in the USB hub driver?

kind regards,
Bruno.

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;

KdPrint((__DRIVER_NAME “–> DriverEntry\n”));

WDF_DRIVER_CONFIG_INIT(&config, EvtDeviceAdd);

status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME “WdfDriverCreate failed with status
0x%08x\n”,
status));
}

KdPrint((__DRIVER_NAME “<– DriverEntry\n”));

return status;
}

#pragma alloc_text(PAGE, EvtDevicePrepareHardware)
#pragma alloc_text(PAGE, EvtDeviceAdd)

NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;

UNREFERENCED_PARAMETER(Driver);

KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));

/*set the callback functions that will be executed on PNP and Power
events*/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit,
&pnpPowerCallbacks);

WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);

/*initialize storage for the device context*/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

/*create a device instance.*/
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}

devCtx = GetDeviceContext(device);

/*create the default IO queue. this one will be used for ioctl
requests*/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}

status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC,
NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”,
status));
return status;
}

KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hello Doron,

i am testing this on WinXP SP2 with all latest updates.
the other functions like PrepareHardware, D0Entry and D0Exit do not have any
code in them. they are just empty function bodies with KdPrint statements in
them to show that they got executed.

nothing USB specific is configured or done. The code I posted is all that is
left to compile.

as for the Call stack, how can i see that? the Blue screen showed only the
name of the file that caused the error usbhub.sys, and a number of hex
values.
can i get the call stack from the dump file? if so, which file should i
configure to be generated? I can choose kernel dump, mini dump or complete
memory dump.

kind regards,
Bruno.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
What OS (and SP level)? What is the call stack when the bugcheck
occurs?

The code looks fine (but you didn’t post any of the other functions like
D0Entry/Exit)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Friday, January 27, 2006 12:33 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] blue screen after standby device removal

Hi All,

If i attach the OSR-USB-FX2 board to my computer, the driver gets loaded

correctly. then i put my system (a laptop) in standby and remove the
board.
then i wake my system again, causing it to bugcheck. the message
indicates a
problem in usbhub.sys.

I have removed all code from my driver until only the DriverEntry and
the
DeviceAdd routines contain some code. Is this a bug in my code, or is
this a
bug in the USB hub driver?

kind regards,
Bruno.

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;

KdPrint((__DRIVER_NAME “–> DriverEntry\n”));

WDF_DRIVER_CONFIG_INIT(&config, EvtDeviceAdd);

status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME “WdfDriverCreate failed with status
0x%08x\n”,
status));
}

KdPrint((__DRIVER_NAME “<– DriverEntry\n”));

return status;
}

#pragma alloc_text(PAGE, EvtDevicePrepareHardware)
#pragma alloc_text(PAGE, EvtDeviceAdd)

NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;

UNREFERENCED_PARAMETER(Driver);

KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));

/set the callback functions that will be executed on PNP and Power
events
/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit,
&pnpPowerCallbacks);

WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);

/initialize storage for the device context/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

/create a device instance./
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}

devCtx = GetDeviceContext(device);

/create the default IO queue. this one will be used for ioctl
requests
/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}

status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC,
NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”,
status));
return status;
}

KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

A kernel dump would be best, although a minidump also works. It is
eaiser still to have a kernel debugger attached at the point of the
crash. Once in the debugger, execute the “kb” command and that will
give the callstack. Also, “!analyze -v” will also give you some good
details of what went wrong.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Saturday, January 28, 2006 11:11 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] blue screen after standby device removal

Hello Doron,

i am testing this on WinXP SP2 with all latest updates.
the other functions like PrepareHardware, D0Entry and D0Exit do not have
any
code in them. they are just empty function bodies with KdPrint
statements in
them to show that they got executed.

nothing USB specific is configured or done. The code I posted is all
that is
left to compile.

as for the Call stack, how can i see that? the Blue screen showed only
the
name of the file that caused the error usbhub.sys, and a number of hex
values.
can i get the call stack from the dump file? if so, which file should i
configure to be generated? I can choose kernel dump, mini dump or
complete
memory dump.

kind regards,
Bruno.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
What OS (and SP level)? What is the call stack when the bugcheck
occurs?

The code looks fine (but you didn’t post any of the other functions like
D0Entry/Exit)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Friday, January 27, 2006 12:33 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] blue screen after standby device removal

Hi All,

If i attach the OSR-USB-FX2 board to my computer, the driver gets loaded

correctly. then i put my system (a laptop) in standby and remove the
board.
then i wake my system again, causing it to bugcheck. the message
indicates a
problem in usbhub.sys.

I have removed all code from my driver until only the DriverEntry and
the
DeviceAdd routines contain some code. Is this a bug in my code, or is
this a
bug in the USB hub driver?

kind regards,
Bruno.

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;

KdPrint((__DRIVER_NAME “–> DriverEntry\n”));

WDF_DRIVER_CONFIG_INIT(&config, EvtDeviceAdd);

status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME “WdfDriverCreate failed with status
0x%08x\n”,
status));
}

KdPrint((__DRIVER_NAME “<– DriverEntry\n”));

return status;
}

#pragma alloc_text(PAGE, EvtDevicePrepareHardware)
#pragma alloc_text(PAGE, EvtDeviceAdd)

NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;

UNREFERENCED_PARAMETER(Driver);

KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));

/set the callback functions that will be executed on PNP and Power
events
/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit,
&pnpPowerCallbacks);

WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);

/initialize storage for the device context/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

/create a device instance./
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}

devCtx = GetDeviceContext(device);

/create the default IO queue. this one will be used for ioctl
requests
/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}

status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC,
NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”,
status));
return status;
}

KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I will try to do this tomorrow. i have a spare machine with XP checked build
on.

just to be sure:

  • will the debugger automatically break into the debugged system if that
    bugchecks?
  • should that machine not have the problem, can i attach the debugger to my
    laptop which runs the release build?

kind regards,
Bruno.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
A kernel dump would be best, although a minidump also works. It is
eaiser still to have a kernel debugger attached at the point of the
crash. Once in the debugger, execute the “kb” command and that will
give the callstack. Also, “!analyze -v” will also give you some good
details of what went wrong.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Saturday, January 28, 2006 11:11 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] blue screen after standby device removal

Hello Doron,

i am testing this on WinXP SP2 with all latest updates.
the other functions like PrepareHardware, D0Entry and D0Exit do not have
any
code in them. they are just empty function bodies with KdPrint
statements in
them to show that they got executed.

nothing USB specific is configured or done. The code I posted is all
that is
left to compile.

as for the Call stack, how can i see that? the Blue screen showed only
the
name of the file that caused the error usbhub.sys, and a number of hex
values.
can i get the call stack from the dump file? if so, which file should i
configure to be generated? I can choose kernel dump, mini dump or
complete
memory dump.

kind regards,
Bruno.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
What OS (and SP level)? What is the call stack when the bugcheck
occurs?

The code looks fine (but you didn’t post any of the other functions like
D0Entry/Exit)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Friday, January 27, 2006 12:33 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] blue screen after standby device removal

Hi All,

If i attach the OSR-USB-FX2 board to my computer, the driver gets loaded

correctly. then i put my system (a laptop) in standby and remove the
board.
then i wake my system again, causing it to bugcheck. the message
indicates a
problem in usbhub.sys.

I have removed all code from my driver until only the DriverEntry and
the
DeviceAdd routines contain some code. Is this a bug in my code, or is
this a
bug in the USB hub driver?

kind regards,
Bruno.

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;

KdPrint((__DRIVER_NAME “–> DriverEntry\n”));

WDF_DRIVER_CONFIG_INIT(&config, EvtDeviceAdd);

status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME “WdfDriverCreate failed with status
0x%08x\n”,
status));
}

KdPrint((__DRIVER_NAME “<– DriverEntry\n”));

return status;
}

#pragma alloc_text(PAGE, EvtDevicePrepareHardware)
#pragma alloc_text(PAGE, EvtDeviceAdd)

NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;

UNREFERENCED_PARAMETER(Driver);

KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));

/set the callback functions that will be executed on PNP and Power
events
/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit,
&pnpPowerCallbacks);

WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);

/initialize storage for the device context/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

/create a device instance./
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}

devCtx = GetDeviceContext(device);

/create the default IO queue. this one will be used for ioctl
requests
/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}

status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC,
NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”,
status));
return status;
}

KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

You don’t need a chk build, but it sometimes helps in diagnosing the
problem. Yes, the debugger will break in when the bugcheck occurs.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Saturday, January 28, 2006 12:20 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] blue screen after standby device removal

I will try to do this tomorrow. i have a spare machine with XP checked
build
on.

just to be sure:

  • will the debugger automatically break into the debugged system if that

bugchecks?

  • should that machine not have the problem, can i attach the debugger to
    my
    laptop which runs the release build?

kind regards,
Bruno.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
A kernel dump would be best, although a minidump also works. It is
eaiser still to have a kernel debugger attached at the point of the
crash. Once in the debugger, execute the “kb” command and that will
give the callstack. Also, “!analyze -v” will also give you some good
details of what went wrong.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Saturday, January 28, 2006 11:11 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] blue screen after standby device removal

Hello Doron,

i am testing this on WinXP SP2 with all latest updates.
the other functions like PrepareHardware, D0Entry and D0Exit do not have
any
code in them. they are just empty function bodies with KdPrint
statements in
them to show that they got executed.

nothing USB specific is configured or done. The code I posted is all
that is
left to compile.

as for the Call stack, how can i see that? the Blue screen showed only
the
name of the file that caused the error usbhub.sys, and a number of hex
values.
can i get the call stack from the dump file? if so, which file should i
configure to be generated? I can choose kernel dump, mini dump or
complete
memory dump.

kind regards,
Bruno.

“Doron Holan” wrote in message
news:xxxxx@ntdev…
What OS (and SP level)? What is the call stack when the bugcheck
occurs?

The code looks fine (but you didn’t post any of the other functions like
D0Entry/Exit)

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Bruno van Dooren
Sent: Friday, January 27, 2006 12:33 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] blue screen after standby device removal

Hi All,

If i attach the OSR-USB-FX2 board to my computer, the driver gets loaded

correctly. then i put my system (a laptop) in standby and remove the
board.
then i wake my system again, causing it to bugcheck. the message
indicates a
problem in usbhub.sys.

I have removed all code from my driver until only the DriverEntry and
the
DeviceAdd routines contain some code. Is this a bug in my code, or is
this a
bug in the USB hub driver?

kind regards,
Bruno.

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
WDF_DRIVER_CONFIG config;
NTSTATUS status;

KdPrint((__DRIVER_NAME “–> DriverEntry\n”));

WDF_DRIVER_CONFIG_INIT(&config, EvtDeviceAdd);

status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME “WdfDriverCreate failed with status
0x%08x\n”,
status));
}

KdPrint((__DRIVER_NAME “<– DriverEntry\n”));

return status;
}

#pragma alloc_text(PAGE, EvtDevicePrepareHardware)
#pragma alloc_text(PAGE, EvtDeviceAdd)

NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;

UNREFERENCED_PARAMETER(Driver);

KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));

/set the callback functions that will be executed on PNP and Power
events
/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit,
&pnpPowerCallbacks);

WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);

/initialize storage for the device context/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);

/create a device instance./
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}

devCtx = GetDeviceContext(device);

/create the default IO queue. this one will be used for ioctl
requests
/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}

status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC,
NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”,
status));
return status;
}

KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


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

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com