Did you also add a create handler, close handler, and ioctl handler to
your major function table in DriverEntry?
Matt
Mathieu Routhier wrote:
It looks like you're doing it the right way. Try calling CreateFile with the following parameters instead:
CreateFile( filename GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Mat
-----Original Message----- From: wdmaudiodev-bounce@xxxxxxxxxxxxx [mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of hollychen (ê?ø™Ô´=Ñаl) Sent: Wednesday, June 09, 2004 12:35 PM To: wdmaudiodev Subject: [wdmaudiodev] How can I open my virtual audio driver and send IOCTL to it?
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
******************
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/
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/