[wdmaudiodev] How can I open my virtual audio driver and send IOCTL to it?

  • From: hollychen(??源=研?) <hollychen@xxxxxxxxxxx>
  • To: "wdmaudiodev" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 10 Jun 2004 00:34:53 +0800

I'm a newbie in WDM. I wanna send IOCTL to my virtual audio driver,
but I failed to open my driver in user-mode application.
 
In audio driver side, I registers an interface,
 
AddDevice 
(
IN  PDRIVER_OBJECT          DriverObject,
IN  PDEVICE_OBJECT          PhysicalDeviceObject 
)
{
   ...
    ntStatus = 
        PcAddAdapterDevice
        ( 
            DriverObject,
            PhysicalDeviceObject,
            PCPFNSTARTDEVICE(StartDevice),
            MAX_MINIPORTS,
            0
        );
    ...
    ntStatus = IoRegisterDeviceInterface(PhysicalDeviceObject, 
&GUID_DEVINTERFACE_BT_AUDIO, NULL, &ifname);
    ...
   ntStatus = IoSetDeviceInterfaceState(&ifname, TRUE);
}

 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
In application side,
 
HDEVINFO info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_BT_AUDIO, 
  NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
 ... 
if (SetupDiEnumDeviceInterfaces(info, NULL, &GUID_DEVINTERFACE_BT_AUDIO, 0, 
&ifdata))
{   
  ...
  SetupDiGetDeviceInterfaceDetail(info, &ifdata, NULL, 0, &needed, NULL);  
  
  PSP_INTERFACE_DEVICE_DETAIL_DATA detail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) 
malloc(needed);  
  SP_DEVINFO_DATA did = {sizeof(SP_DEVINFO_DATA)};  
  detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
  
  if (!SetupDiGetDeviceInterfaceDetail(info, &ifdata, detail, needed, NULL, 
&did))   
  {  ...  }    
  ...
  strcpy(fileName, detail->DevicePath);
  ... 
 }  
 
 SetupDiDestroyDeviceInfoList(info);

  //////////////////////////////////////////////////// 
 
 HANDLE hdevice = CreateFile(fileName, GENERIC_READ | GENERIC_WRITE, 0, NULL, 
OPEN_EXISTING, 0, NULL);
 
The CreateFile() always return 2 (ERROR_FILE_NOT_FOUND).
 
What's the problem with my code?
Any suggestions/hints will be much appreciated!
 
Holly
 

Other related posts: