I will ask one by one on what was done on my driver…
-
is this OK to declare this three variable globally?
//
// Collection object is used to store all the FilterDevice objects so
// that any event callback routine can easily walk thru the list and pick a
// specific instance of the device for filtering.
//
WDFCOLLECTION FilterDeviceCollection;
WDFWAITLOCK FilterDeviceCollectionLock;
WDFDEVICE ControlDevice;
-
On my driver entry, is it correct to make a collection of filter device? i just follow the filter.c in TOASTER. here’s the codes…
//
// Since there is only one control-device for all the instances
// of the physical device, we need an ability to get to particular instance
// of the device in our FilterEvtIoDeviceControlForControl. For that we
// will create a collection object and store filter device objects.
//
WDF_OBJECT_ATTRIBUTES_INIT(&colAttributes);
colAttributes.ParentObject = hDriver;
status = WdfCollectionCreate(&colAttributes,
&FilterDeviceCollection);
///locks
WDF_OBJECT_ATTRIBUTES_INIT(&colAttributes);
colAttributes.ParentObject = hDriver;
status = WdfWaitLockCreate(&colAttributes,
&FilterDeviceCollectionLock);
- Codes internally FOR my FOR_SECOND_EVENT IOCTL…is this ok, refer below? i just converted it from wdm to wdf…here’s the code…
//for wdm:
KeInitializeEvent(&eventSendDone, NotificationEvent, FALSE);
InternalIrp = IoBuildDeviceIoControlRequest
( IOCTL_INTERNAL_I8042_MOUSE_WRITE_BUFFER,
devExt->TopOfStack,
&devExt->Byteholder,
sizeof(devExt->Byteholder),
NULL,
0,
TRUE,
&eventSendDone,
&AppIrp->IoStatus
);
if (!InternalIrp) {
KeAcquireSpinLock(pSpinLock, ¤tIrql);
devExt->StartedWrite = FALSE;
KeReleaseSpinLock(pSpinLock, currentIrql);
AppIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
AppIrp->IoStatus.Information = 0;
IoCompleteRequest(AppIrp, IO_NO_INCREMENT);
return STATUS_UNSUCCESSFUL;
}
status = IoCallDriver(devExt->TopOfStack, InternalIrp);
for WDF CODES:…
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(
&attributes,SET_EVENT_REQUEST_COMPLETION_CONTEXT);
status = WdfRequestCreate(&attributes,
WdfDeviceGetIoTarget(devExt->WdfDevice),
&InternalRequest);
setEventContext = GetSetEventContext(InternalRequest);
WdfRequestSetCompletionRoutine(InternalRequest,
SetEventRequestCompletionRoutine,
setEventContext);
KeInitializeEvent(&setEventContext->eventSendDone, NotificationEvent, FALSE);
status = WdfMemoryCreatePreallocated(WDF_NO_OBJECT_ATTRIBUTES,
&devExt->SendContext.FirstByte,
sizeof(devExt->SendContext.FirstByte),
&memory);
status = WdfIoTargetFormatRequestForInternalIoctl(
WdfDeviceGetIoTarget(devExt->WdfDevice),
InternalRequest,
IOCTL_INTERNAL_I8042_MOUSE_WRITE_BUFFER,
memory, NULL, WDF_NO_HANDLE,NULL);
if (!NT_SUCCESS(status)) {
WdfSpinLockAcquire(devExt->WdfISRSpinLock);
devExt->StartedWrite = FALSE;
WdfSpinLockRelease(devExt->WdfISRSpinLock);
AppIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
AppIrp->IoStatus.Information = 0;
IoCompleteRequest(AppIrp, IO_NO_INCREMENT);
return STATUS_UNSUCCESSFUL;
}
status = WdfRequestSend(InternalRequest,
WdfDeviceGetIoTarget(devExt->WdfDevice),
NULL);
does my conversion correct?
I am still using some of the WDM function in wdf, like for example the IoCompleteRequest(… is it ok?
sorry if I have lots of question… I know I must read some of the msdn reference but I don’t have time…komattana…