[wdmaudiodev] streamclass USB surprise removal problem: help please

  • From: "pagefault 0x0" <pagefault0x0@xxxxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Sun, 13 Apr 2003 13:44:36 -0400

 

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
IRPsto 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
notfor 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. [1]Get 2 months FREE*. 

--- Links ---
   1 http://g.msn.com/8HMRENCA/2746
******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.de/

Other related posts: