Hi All,
I have a user mode application and a kernel mode component and both use the same driver. This driver interacts with two DSPs. Lets say usermode application interacts with DSP1 and kernel mode component with DSP2. Initially my driver only had to interact with one DSP (I had only 1 app). I have made some changes to support 2 DSPs and I am facing some problems.
In the usermode application I am saying:
Createfile(TEXT(“\\.\DSP1”, …)
and in the kernel mode I am saying
ZwCreatefile()
In kernel mode I am initializing a UNICODE string:
RtlInitUnicodeString(&DeviceName,L"DSP2")
InitializeObjectAttributes(&attr,&DeviceName)
With the attr I am creating a device using Zwcreatefile.
Coming to my driver:
In the devicadd callback I am performing some initializations like:
DECLARE_CONST_UNICODE_STRING(ntdevicename,L"\Device\DSP1");
DECLARE_CONST_UNICODE_STRING(udevicename1,L"\DosDevices\DSP1");
DECLARE_CONST_UNICODE_STRING(udevicename2,L"\DosDevices\DSP1");
WdfDeviceInitAssignName -> I am assigning ntdevicname to device using this. Then I am creating the device using WdfDeviceCreate. Then WdfDeviceCreateSymbolicLink(Device, &udevicename1) and WdfDeviceCreateSymbolicLink(Device, &udevicename2). Calling create symbolic link twice failed for me. So I removed WdfDeviceCreateSymbolicLink and tried using WdfDeviceCreateDeviceInterface. I called it twice like this:
WdfDeviceCreateDeviceInterface(Device,&GUID,&utdevicename1);
WdfDeviceCreateDeviceInterface(Device,&GUID,&utdevicename2);
The first WdfDeviceCreateDeviceInterface is failing returning c0000010. I have a few questions regarding my approach:
- when do I need to use WdfDeviceInitAssignName ? is it necessary?
- when do I need to use WdfDeviceCreateSymbolicLink? is it necessary in my case?
- Why is WdfDeviceCreateDeviceInterface failing?
- In order to use WdfDeviceCreateDeviceInterface do I need to make any changes in my user mode app or kernel mode component. Any example code in user mode level or kernel mode level will be helpful.
Based on the utdevicename1 and utdevicename2 (reference strings) in EvtDeviceFileCreate callback I will either communicate with DSP1 or DSP2. Say in usermode app I make a createfile for DSP1, the EvtDeviceFileCreate in driver will be called .Since I am calling Createfile(TEXT(“\\.\DSP1”, …) I am expecting that when I do a WdfFileObjectGetFileName in EvtDeviceFileCreate , I can compare the filename with the reference string (udevicename1->L"\DosDevices\DSP1). Is my approach right? When I call WdfFileObjectGetFileName will I get DSP1 as the name?In order to use device interface class what are the required changes to be made in my application?