[wdmaudiodev] Re: Need to write a lower filter to USBAudio.sys

  • From: "Jerry Trantow" <Jerry.Trantow@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Tue, 2 Jan 2007 14:56:25 -0600

A few years ago, I wrote such a lower filter for the SoundDevices USBPre.  I
haven't looked at Vista. In previous OS versions, I modified four URBs.  If
you are lucky it might be as simple as patching
URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE.

/*

      This file contains lower filter functions for modifying several of the
URBs to 

      support multiple capture sample rates.  The sample rates are modified
by the PIC and since the 

      Philips firmware doesn't have a clue about the digital input sample
rate we need this lower filter to

      add functionality.

 

      There are several URBs which must be patched by this filter.

 

      1)    URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE sent to get the
configuration.  We return a 

            different configuration which describes capture support for
32,44.1,48khz sample rates.

 

      2)    URB_FUNCTION_CLASS_ENDPOINT sent to the sample rate control of
the endpoint.  We send a message

            to the PIC and complete the command.

      

      3)    URB_FUNCTION_ISOCH_TRANSFER this URB may be converted from PCM
to PCM8 or unpacked into 32 bit

            frames.  Packet values can also be displayed in _DEBUG.

 

      4)    URB_FUNCTION_SELECT_INTERFACE this URB is monitored to keep
track of alternate interfaces.

            32 bit interfaces are spoofed.

 

*/

In NTSTATUS DispatchInternalControl(PDEVICE_OBJECT fdo, PIRP Irp), 

switch(urb_ptr->UrbHeader.Function)

/*

      Display descriptors according to the _URB_CONTROL_DESCRIPTOR_REQUEST
structure.

*/

case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE://     0x000B

      if (2==urb_ptr->UrbControlDescriptorRequest.DescriptorType) //
CONFIGURATION==2.

      {

            #if defined(DESCRIPTOR_SUBSTITUTE)

                  /*

                        Copy our modified configuration descriptor into the
urb and complete the Irp.

                  */

 
RtlCopyBytes(urb_ptr->UrbControlDescriptorRequest.TransferBuffer,Configurati
on_Descriptor_Replacement,

 
min(sizeof(Configuration_Descriptor_Replacement),urb_ptr->UrbControlDescript
orRequest.TransferBufferLength));

                  #if defined(_DEBUG)

                        display_urb(&urb_ptr->UrbControlDescriptorRequest);

                  #endif

                  /*

                        Complete this Irp without sending it on.

                  */

                  urb_ptr->UrbHeader.Status=USBD_STATUS_SUCCESS;

                  ntStatus=CompleteRequest(Irp,STATUS_SUCCESS,0);

                  IoReleaseRemoveLock(&pdx->RemoveLock, Irp);

                  return(ntStatus);

            #else

                  #if (0)

                        /*

                              Let's take a look at what gets returned.

                              Copy arguments to the next stack level.

                        */

                        IoCopyCurrentIrpStackLocationToNext(Irp);

 
IoSetCompletionRoutine(Irp,CompletionRoutine_Descriptor,NULL,TRUE,TRUE,TRUE)
;

                        ntStatus=IoCallDriver(pdx->LowerDeviceObject,Irp);

                        IoReleaseRemoveLock(&pdx->RemoveLock, Irp);

                        return(ntStatus);

                  #endif

            #endif      //    defined(DESCRIPTOR_SUBSTITUTE)

      }else // Not a configuration descriptor, so simply pass it down.

      {

            ;

      }

      break;

 

Jerry Trantow

jtrantow@xxxxxxxx

 

 

-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Steve Thorpe
Sent: Tuesday, January 02, 2007 2:25 PM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Need to write a lower filter to USBAudio.sys

 

I urgently need to write a lower filter to USBAudio.sys to correct a Feature
Unit 
Descriptor flaw which causes our existing USB Audio Class device to fail in 
Vista (the flaw it was ignored by all earlier versions of Windows and hence
went
unnoticed until now) I have looked in Walter Oney's book (2nd Ed.) but not
found 
the information I need there. Could anyone point me to some detailed
information  
(or better yet, sample source) on how to write such a filter which
manipulates
descriptors?

Steve Thorpe
Empia Technology, Inc.

Other related posts: