[wdmaudiodev] Re: 回复: Re: for help in implementation virtual audio driver

  • From: "Vargheese Baby" <vargheese.baby@xxxxxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 20 Jul 2006 14:44:08 +0530

Hi Weiji,

It should be like this:

 

//######################################

#define MY_DEVICE_NAME    L"\\Device\\myDevice"           // Device Name

#define MY_DOSDEVICE_NAME L"\\DosDevices\\ myDevice " // Dos Device Name

 

extern "C" NTSTATUS

AddDevice

(

   IN  PDRIVER_OBJECT   DriverObject,

   IN  PDEVICE_OBJECT   PhysicalDeviceObject

)

{

   PAGED_CODE();

 

   NTSTATUS ntStatus = STATUS_UNSUCCESSFUL;

   NTSTATUS addAdDeviceStatus = STATUS_UNSUCCESSFUL;

   PDEVICE_OBJECT deviceObject;

   UNICODE_STRING usDeviceName;

   UNICODE_STRING usDosDeviceName;

 

   DPF(D_TERSE, ("[AddDevice]"));

 

   // Tell the class driver to add the device.

   ntStatus =  PcAddAdapterDevice

               (

                  DriverObject,

                  PhysicalDeviceObject,

                  PCPFNSTARTDEVICE(StartDevice),

                  MAX_MINIPORTS,

                  0

               );

 

   if (!NT_SUCCESS(ntStatus))

   {

      return ntStatus;

   }

 

   addAdDeviceStatus = ntStatus;

   DPF(D_TERSE, ("[Added Adapter driver]"));

   RtlInitUnicodeString(&usDeviceName, MY_DEVICE_NAME);

   RtlInitUnicodeString(&usDosDeviceName, MY_DOSDEVICE_NAME);

 

   // Create the device

   ntStatus = IoCreateDevice

               (

                  DriverObject,

                  0,

                  &usDeviceName,

                  FILE_DEVICE_UNKNOWN,

                  0,

                  FALSE,

                  &deviceObject

               );

   if(!NT_SUCCESS(ntStatus))

   {

      DPF(D_TERSE, ("[Failed IoCreateDevice...]"));

      return addAdDeviceStatus;

   }

   DPF(D_TERSE, ("[Device Created]"));

 

 

   // Create the symbolic link

   ntStatus = IoCreateSymbolicLink

               (

                  &usDosDeviceName,

                  &usDeviceName

               );

   if (!NT_SUCCESS(ntStatus))  //try to delete the symbolic link first

   {

      DPF(D_TERSE,("[Failed IoCreateSymbolicLink...]"));

      IoDeleteDevice(DriverObject->DeviceObject);

      return addAdDeviceStatus;

   }

   DPF(D_TERSE, ("[SymbolicLink Created]"));

 

   // Initialize device object flags

   deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

 

 

   return ntStatus;

} // AddDevice

 

You can use a pointer “deviceObject” to distinguish the IRPs from your
application and kernel.

 

You will get audio stream to mini port through the method
“CMiniportWaveCyclicStreamMSVAD::CopyTo” method. You have to create your
own buffer and fill this data. A pointer to your buffer from adapter driver
will serve your purpose.

 

Best of luck

Regards

Vargheese

 

  _____  

From: wdmaudiodev-bounce@xxxxxxxxxxxxx [mailto:wdmaudiodev-bounce@freelists.
org] On Behalf Of Weiji Zheng
Sent: Thursday, July 20, 2006 11:39 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] 回复: Re: for help in implementation virtual audio
driver

 

Hi, Vargheese

 

firstly, thanks for your so warm help. but I have some a little puzzle, and
what do you mean as following:

 

in adddevice:

    // Tell the class driver to add the device.
    //
    ntStatus = 
        PcAddAdapterDevice
        ( 
            DriverObject,
            PhysicalDeviceObject,
            PCPFNSTARTDEVICE(StartDevice),
            MAX_MINIPORTS,
            0 );

.....................

    ntStatus = IoCreateDevice(
                    DriverObject,                   // our driver object
                    sizeof(DEVICE_EXTENSION),       // extension size for us
                    NULL,                           // name for this device
                    FILE_DEVICE_UNKNOWN,
                    FILE_AUTOGENERATED_DEVICE_NAME, 
                    FALSE,                          // Not exclusive
                    &deviceObject);                 // Our device object

..............

IoAttachDeviceToDeviceStack(deviceObject,
                                            PhysicalDeviceObject);

................

IoCreateSymbolicLink();

................

 

 

but can I call simultaneously both PcAddAdapterDevice and IoCreateDevice?

if the answer is YES, but how do I distinguish IRP in IRP_MAJOR_CREATE?
actaully both the kernel and my own application call this function.

 

aside, another question, how does adapter driver get the buffer pointer of
miniport driver? I will use IOCTL to transfer PCM data from/to
miniportstream.

 

thanks again.

 

--weiji zheng

 



Vargheese Baby <vargheese.baby@xxxxxxxxxxxxxxx> 写道:

Hi Weiji,

I tried “IoRegisterDeviceInterface()” with MSVAD. Its not working for me.
The following method will help you.

In DriverEntry

First call PcInitializeAdapterDriver

Then assign your dispatch routines

 

In AddDevice

IoCreateDevice

IoCreateSymbolicLink

 

In Application

Open the handle by CreateFile()

 

Regards

Vargheese

 


  _____  


From: wdmaudiodev-bounce@xxxxxxxxxxxxx [mailto:wdmaudiodev-bounce@freelists.
org] On Behalf Of Weiji Zheng
Sent: Thursday, July 20, 2006 10:19 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] for help in implementation virtual audio driver

 

Hi

 

I am developing one project, that is, PCM data is transfered into MSVAD by
usr mode, and MSVAD then put these PCM data into another application based
on DirectSound, such as Skype, that means MSVAD will be open simultaneously
both the applications.

 

Actaully, I encounter the same question as following: 

1. how can I get the handle of the MSVAD(Simple)? 
2. I tried to use IoRegisterDeviceInterface() in AddDevice() of
MSVAD(Simple), and then in my user mode application I use
SetupDiGetDeviceInterfaceDetail() and CreateFile() to get the handle of the
MSVAD device. It seems that I can get the handle of the MSVAD(Simple), but
the Graph Edit con not find any device about MSVAD, Do you have any idea
about this? 

 

Maybe the implementation in IRP_MAJOR_CREATE is one key.

 

//dispatch function
extern "C"
NTSTATUS
PCP_Create
(
    IN      PDEVICE_OBJECT  pDeviceObject,
    IN      PIRP            pIrp
)
{
 PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(pIrp);
 //PDEVICE_EXTENSION pDevExt =
(PDEVICE_EXTENSION)pDeviceObject->DeviceExtension;
 NTSTATUS ntStatus = STATUS_SUCCESS;
    
 DPF(D_TERSE, ("[enter PCP_Create]"));
 
 
 DbgPrint("the Flags is 0x%x\n", pIrp->Flags);
 DbgPrint("the RequestorMode is 0x%x\n", pIrp->RequestorMode);

 if(pIrp->RequestorMode == 0x1) //my own application
 {// Complete successfully
  pIrp->IoStatus.Status = STATUS_SUCCESS;
  pIrp->IoStatus.Information = 0;
  IoCompleteRequest(pIrp, IO_NO_INCREMENT);
  return STATUS_SUCCESS;
 }
 else //Graph Edit
 {
   //
   // Pass the IRPs on to PortCls
   //
   ntStatus = PcDispatchIrp( pDeviceObject, pIrp );
  if(NT_SUCCESS(ntStatus))
   DbgPrint("success to open device\n");
  else
   DbgPrint("fail to open device\n");
  return ntStatus;
 }
 
 
}

 

But when I run own application(not Graph Edit), the system crash!

 

so would you please give me some advice.

 

thanks for any help.

 

best regards

 

--weiji zheng

  


  _____  


 <http://cn.mail.yahoo.com/> 雅虎免费邮箱-3.5G容量,20M附件 

 

  

  _____  

Mp3 <http://music.yahoo.com.cn/?source=mail_mailbox_footer> 疯狂搜-新歌热歌
高速下 

Other related posts: