streamclass USB surprise removal problem: help please

Hello!

I know that this is Win98SE question, and that this is an NT based list, but my USB stream class MIDI driver is WDM, so I hope I’m not too far off topic.  While this driver has been made with DriverWorks (not by me- I’m the lucky debugger), I have been reading about stream class in the DDK, and take nothing for granted in the DriverWorks libraries (seen some questionable things in there!).  So let’s forget about DriveWorks, and talk in plain old WDM/streamclass language.  I’m away from my source and the DDK headers, so apologies if I have mispelled some DDK/streamclass constants.  As stated, this question concerns Win98SE, and it also has the WDM audio QFE installed.  The driver is MIDI in/out USB bulk driver.

My problem is this: my stream class MIDI driver freezes the system, or BSODs in _VWIN32_CloseVxDHandle on surprise removal.  Here’s the mystery: it does not do this with each MIDI app (but all except MIDIOX), AND it works fine with for surprise removal with ALL apps under WinXP SP1 (except that stream class BSODs under driver verifier when it completes some IRPs with STATUS_PENDING!).  In Win98SE, I do get a SRB_SURPRISE_REMOVAL associated with IRP_MN_REMOVE_DEVICE (naturally).  I do wait for all my own created IRPs to my device to come back up and I free them (I created them with IoCreate Irp).  This is done in accordance to Walter Oney’s cancel examples in his 2ed book (Great book!  Can’t survive without it!).  Then I complete all my queued SRBs with STATUS_CANCELLED.  Then, sometimes I get SRB_CLOSE_STREAM, but NEVER SRB_UNINITIALIZE_DEVICE.  I have noted two things:

a) I have my IRP stream class interception handlers which allow me to check what is going on before forwarding them to stream class.  I know, this is not for production driver, only for debugging. I have seen that I although I get 3 IRP_MJ_CREATE to stream class, I *never* get 3 IRP_MJ_CLEANUP/IRP_MJ_CLOSE, but only 2.  Why  is this?  Can I send these IRPs myself to ks.sys?  If so, how can I find its DEVICE_OBJECT?  Why do I even get IRP_MN_REMOVE_DEVICE in this circumstance, with references on my class DEVICE_OBJECT??

Sometimes, even though I received IRP_MN_REMOVE_DEVICE, I continue to find IRP_MJ_DEVICE_CONTROL IRPs being sent to stream.sys!!  If I have received remove IRP, I complete them with STATUS_DELETE_PENDING, but they keep on coming!  Why?

b) As I said, I do get SRB_SURPRISE_REMOVAL.  While I am stepping through this handler in SoftICE, I frequently get a freeze *before* I complete the SRB.  Later my timeout routine for this SRB is called, which confirms that I was never able to complete the SRB with the default timeout.  When I specify NO timeout, the system freezes.  So I reasoned I am preempted/interrupted.  So in my surprise removal handler, I did _asm cli, and balanced this with _asm sti after I completed the SRB (I know, never in a production driver…).  This time I *always* complete the SRB, but later freeze or BSOD in _VWIN32_CloseVxDHandle.  What would cause this?  Is this my interrupt on my device?  When in my IRP interception functions, should I send the IRP_MN_REMOVE_DEVICE right away down to the bus driver?  Any ideas on this??

Can anyone help me somewhat with my woes?  Thanks in advance.

Philip Lukidis


Add photos to your e-mail with MSN 8. Get 2 months FREE*.

Hi, Philip

If you need support on DriverWorks, the easiest thing to do is to send your
question to xxxxx@compuware.com
mailto:xxxxx . We’ll be there to help you. But more
to the point, if you see “questionable” thinks in DriverWorks, I’d be glad
to hear about them - we’re constantly improving the product, and we’d like
to hear about such issues !

Alberto.

-----Original Message-----
From: pagefault 0x0 [mailto:xxxxx@hotmail.com]
Sent: Sunday, April 13, 2003 1:43 PM
To: NT Developers Interest List
Subject: [ntdev] streamclass USB surprise removal problem: help please

Hello!

I know that this is Win98SE question, and that this is an NT based list, but
my USB stream class MIDI driver is WDM, so I hope I’m not too far off topic.
While this driver has been made with DriverWorks (not by me- I’m the lucky
debugger), I have been reading about stream class in the DDK, and take
nothing for granted in the DriverWorks libraries (seen some questionable
things in there!). So let’s forget about DriveWorks, and talk in plain old
WDM/streamclass language. I’m away from my source and the DDK headers, so
apologies if I have mispelled some DDK/streamclass constants. As stated,
this question concerns Win98SE, and it also has the WDM audio QFE installed.
The driver is MIDI in/out USB bulk driver.

My problem is this: my stream class MIDI driver freezes the system, or BSODs
in _VWIN32_CloseVxDHandle on surprise removal. Here’s the mystery: it does
not do this with each MIDI app (but all except MIDIOX), AND it works fine
with for surprise removal with ALL apps under WinXP SP1 (except that stream
class BSODs under driver verifier when it completes some IRPs with
STATUS_PENDING!). In Win98SE, I do get a SRB_SURPRISE_REMOVAL associated
with IRP_MN_REMOVE_DEVICE (naturally). I do wait for all my own created
IRPs to my device to come back up and I free them (I created them with
IoCreate Irp). This is done in accordance to Walter Oney’s cancel examples
in his 2ed book (Great book! Can’t survive without it!). Then I complete
all my queued SRBs with STATUS_CANCELLED. Then, sometimes I get
SRB_CLOSE_STREAM, but NEVER SRB_UNINITIALIZE_DEVICE. I have noted two
things:

a) I have my IRP stream class interception handlers which allow me to check
what is going on before forwarding them to stream class. I know, this is
not for production driver, only for debugging. I have seen that I although I
get 3 IRP_MJ_CREATE to stream class, I never get 3
IRP_MJ_CLEANUP/IRP_MJ_CLOSE, but only 2. Why is this? Can I send these
IRPs myself to ks.sys? If so, how can I find its DEVICE_OBJECT? Why do I
even get IRP_MN_REMOVE_DEVICE in this circumstance, with references on my
class DEVICE_OBJECT??

Sometimes, even though I received IRP_MN_REMOVE_DEVICE, I continue to find
IRP_MJ_DEVICE_CONTROL IRPs being sent to stream.sys!! If I have received
remove IRP, I complete them with STATUS_DELETE_PENDING, but they keep on
coming! Why?

b) As I said, I do get SRB_SURPRISE_REMOVAL. While I am stepping through
this handler in SoftICE, I frequently get a freeze before I complete the
SRB. Later my timeout routine for this SRB is called, which confirms that I
was never able to complete the SRB with the default timeout. When I specify
NO timeout, the system freezes. So I reasoned I am preempted/interrupted.
So in my surprise removal handler, I did _asm cli, and balanced this with
_asm sti after I completed the SRB (I know, never in a production
driver…). This time I always complete the SRB, but later freeze or BSOD
in _VWIN32_CloseVxDHandle. What would cause this? Is this my interrupt on
my device? When in my IRP interception functions, should I send the
IRP_MN_REMOVE_DEVICE right away down to the bus driver? Any ideas on this??

Can anyone help me somewhat with my woes? Thanks in advance.

Philip Lukidis

_____

Add photos to your e-mail with MSN 8. http: Get
2 months FREE*. —
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.</http:></mailto:xxxxx>

Mr. Moreira, I'd like to extend my apologies for that off topic comment on my part.

I did post a couple of points in the mailing list DriverWorksDev (the second one being much more important to me), but I got no response. It could very well be that what I objected to was not too important.

Again, please allow me to extend my sincere apologies for that comment. It was clearly out of place. Thank you for your understanding.

warm regards

Philip Lukidis
----- Original Message -----
From: Moreira, Alberto
To: NT Developers Interest List
Sent: Monday, April 14, 2003 9:48 AM
Subject: [ntdev] RE: streamclass USB surprise removal problem: help please

Hi, Philip

If you need support on DriverWorks, the easiest thing to do is to send your question to xxxxx@compuware.com. We'll be there to help you. But more to the point, if you see "questionable" thinks in DriverWorks, I'd be glad to hear about them - we're constantly improving the product, and we'd like to hear about such issues !

Alberto.

-----Original Message-----
From: pagefault 0x0 [mailto:xxxxx@hotmail.com]
Sent: Sunday, April 13, 2003 1:43 PM
To: NT Developers Interest List
Subject: [ntdev] streamclass USB surprise removal problem: help please

Hello!

I know that this is Win98SE question, and that this is an NT based list, but my USB stream class MIDI driver is WDM, so I hope I'm not too far off topic. While this driver has been made with DriverWorks (not by me- I'm the lucky debugger), I have been reading about stream class in the DDK, and take nothing for granted in the DriverWorks libraries (seen some questionable things in there!). So let's forget about DriveWorks, and talk in plain old WDM/streamclass language. I'm away from my source and the DDK headers, so apologies if I have mispelled some DDK/streamclass constants. As stated, this question concerns Win98SE, and it also has the WDM audio QFE installed. The driver is MIDI in/out USB bulk driver.

My problem is this: my stream class MIDI driver freezes the system, or BSODs in _VWIN32_CloseVxDHandle on surprise removal. Here's the mystery: it does not do this with each MIDI app (but all except MIDIOX), AND it works fine with for surprise removal with ALL apps under WinXP SP1 (except that stream class BSODs under driver verifier when it completes some IRPs with STATUS_PENDING!). In Win98SE, I do get a SRB_SURPRISE_REMOVAL associated with IRP_MN_REMOVE_DEVICE (naturally). I do wait for all my own created IRPs to my device to come back up and I free them (I created them with IoCreate Irp). This is done in accordance to Walter Oney's cancel examples in his 2ed book (Great book! Can't survive without it!). Then I complete all my queued SRBs with STATUS_CANCELLED. Then, sometimes I get SRB_CLOSE_STREAM, but NEVER SRB_UNINITIALIZE_DEVICE. I have noted two things:

a) I have my IRP stream class interception handlers which allow me to check what is going on before forwarding them to stream class. I know, this is not for production driver, only for debugging. I have seen that I although I get 3 IRP_MJ_CREATE to stream class, I *never* get 3 IRP_MJ_CLEANUP/IRP_MJ_CLOSE, but only 2. Why is this? Can I send these IRPs myself to ks.sys? If so, how can I find its DEVICE_OBJECT? Why do I even get IRP_MN_REMOVE_DEVICE in this circumstance, with references on my class DEVICE_OBJECT??

Sometimes, even though I received IRP_MN_REMOVE_DEVICE, I continue to find IRP_MJ_DEVICE_CONTROL IRPs being sent to stream.sys!! If I have received remove IRP, I complete them with STATUS_DELETE_PENDING, but they keep on coming! Why?

b) As I said, I do get SRB_SURPRISE_REMOVAL. While I am stepping through this handler in SoftICE, I frequently get a freeze *before* I complete the SRB. Later my timeout routine for this SRB is called, which confirms that I was never able to complete the SRB with the default timeout. When I specify NO timeout, the system freezes. So I reasoned I am preempted/interrupted. So in my surprise removal handler, I did _asm cli, and balanced this with _asm sti after I completed the SRB (I know, never in a production driver...). This time I *always* complete the SRB, but later freeze or BSOD in _VWIN32_CloseVxDHandle. What would cause this? Is this my interrupt on my device? When in my IRP interception functions, should I send the IRP_MN_REMOVE_DEVICE right away down to the bus driver? Any ideas on this??

Can anyone help me somewhat with my woes? Thanks in advance.

Philip Lukidis


Add photos to your e-mail with MSN 8. Get 2 months FREE*. ---
You are currently subscribed to ntdev as: xxxxx@compuware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

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

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.