Hello Everybody,
In First, HAPPY NEW YEAR 2011 (^_^)
I have already posted a thread for understand how to proceed for develop a smartcard reader driver multislot ( multi interface ).
I have already developped an USB smartcard reader driver with one interface ( mono slot).
Now last step is to rewrite this driver for work with multi interface.
I have added a fileObject and executed this code :
RtlInitUnicodeString(&DeviceName0, L"VIRTUAL_SM_0");
RtlInitUnicodeString(&DeviceName1, L"VIRTUAL_SM_1");
WDF_FILEOBJECT_CONFIG_INIT(
&fileobjectConfig,
virtualSM_DeviceFileCreate, // Create
virtualSM_DeviceEvtFileClose, // Close
virtualSM_EvtFileCleanup // Cleanup
);
WdfDeviceInitSetFileObjectConfig(
DeviceInit,
&fileobjectConfig,
WDF_NO_OBJECT_ATTRIBUTES
);
…
…
status = WdfDeviceCreateDeviceInterface(
device,
&SmartCardReaderGuid_0,
&DeviceName0 // VIRTUAL_SM_0
);
status = WdfDeviceCreateDeviceInterface(
device,
&SmartCardReaderGuid_1,
&DeviceName1 // VIRTUAL_SM_1
);
both evtAddDevice and evtPrepareHW are called successfully.
Driver is correctly installed, and evtIoDeviceControl process fine.
Now When I try to list smartcardreader, DeviceFileCreate function is called two times.
(thanks to Doron’s link,then thank you, http://blogs.msdn.com/b/doronh/archive/2006/08/18/706717.aspx)
VOID
virtualSM_DeviceFileCreate (
IN WDFDEVICE Device,
IN WDFREQUEST Request,
IN WDFFILEOBJECT FileObject
)
/*++
Routine Description:
The framework calls a driver’s EvtDeviceFileCreate callback
when the framework receives an IRP_MJ_CREATE request.
The system sends this request when a user application opens the
device to perform an I/O operation, such as reading or writing to a device.
This callback is called in the context of the thread
that created the IRP_MJ_CREATE request.
Arguments:
Device - Handle to a framework device object.
FileObject - Pointer to fileobject that represents the open handle.
CreateParams - Parameters for create
Return Value:
NT status code
–*/
{
PDEVICE_CONTEXT fdoData;
PUNICODE_STRING deviceName;
//UNREFERENCED_PARAMETER(FileObject);
KdPrint( (“virtualSM_DeviceFileCreate %p\n”, Device));
PAGED_CODE ();
//
// Get the device context given the device handle.
//
fdoData = GetDeviceContext(Device);
//deviceName = WdfFileObjectGetFileName(FileObject);
deviceName = WdfFileObjectGetFileName(WdfRequestGetFileObject(Request));
WdfRequestComplete(Request, STATUS_SUCCESS);
return;
}
and return good deviceName (“VIRTUAL_SM_0” and “VIRTUAL_SM_1”)
Now I have a problem for understand clearly how to proceed for visualize both device interface ( Slot0 and Slot1 ),
Clearly :
_ If I need to create 2 FDO (If it’s possible, call 2 times “SmartcardInitialize”) .
_ If I need to use 2 different DEVICE_CONTEXT Structure.
_ How dispatch IOCTL and IRP for communicate with one device interface.
_ If it’s possible to instantiate entirely the FDO in the fileDeviceCreate function,
Thanks in advance,
Best regard,
Kamel