Thanks for the advice. I’ll stop trying to push everything into a round
hole, and just use WDF where it seems appropriate.
Here is my write handler. Look ok?
VOID FilterEvtRequestWriteComplete(WDFREQUEST Request, WDFIOTARGET Target,
PWDF_REQUEST_COMPLETION_PARAMS Params, WDFCONTEXT Context) {
NTSTATUS Status = WdfRequestGetStatus(Request);
ULONG_PTR Information = WdfRequestGetInformation(Request);
if (NT_SUCCESS(Status) && Information != 0) {
#pragma warning(push) // Save warning state.
#pragma warning(disable:4456) // Enable shadowing.
NTSTATUS Status;
WDFMEMORY MemoryHandle;
Status = WdfMemoryCreateFromLookaside(g_WriteEntryLookaside, &MemoryHandle);
if (NT_SUCCESS(Status)) {
PWRITE_ENTRY WriteEntry = WdfMemoryGetBuffer(MemoryHandle, NULL);
WriteEntry->Offset = Params->Parameters.Write.Offset;
// Should be the same?
// WriteEntry->Length = Params->IoStatus.Information;
WriteEntry->Length = Information;
PFILTER_CONTEXT FilterContext =
GetFilterContext(WdfIoQueueGetDevice(WdfRequestGetIoQueue(Request)));
ExInterlockedInsertTailList(&FilterContext->WriteListHead,
&WriteEntry->Entry, &FilterContext->WriteListLock);
}
#pragma warning(pop) // Restore warning state.
}
WdfRequestCompleteWithInformation(Request, Status, Information);
DBG_UNREFERENCED_PARAMETER(Target);
DBG_UNREFERENCED_PARAMETER(Context);
}
VOID FilterEvtWrite(WDFQUEUE Queue, WDFREQUEST Request, size_t Length) {
KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL,
“FilterEvtWrite()\n”));
WDFDEVICE FilterDevice = WdfIoQueueGetDevice(Queue);
PFILTER_CONTEXT FilterContext = GetFilterContext(FilterDevice);
WdfRequestFormatRequestUsingCurrentType(Request);
WdfRequestSetCompletionRoutine(Request, FilterEvtRequestWriteComplete,
NULL);
WdfRequestSend(Request, WdfDeviceGetIoTarget(FilterDevice), NULL);
DBG_UNREFERENCED_LOCAL_VARIABLE(FilterContext);
DBG_UNREFERENCED_PARAMETER(Length);
}
On Tue, Mar 20, 2018 at 10:29 AM xxxxx@osr.com
wrote:
>
>
> See… THIS is precisely the beauty of WDF.
>
> Use WDF where it adds value… and that is a LOT of places – But not
> everywhere; Drop down to WDM where that best fits your needs.
>
> In 10+ years of using WDF, I’ve been very pleased with it… with a few
> limited exceptions. I really wish MSFT would do a WDF V2 to advance
> things a bit, and smooth out some of the rougher edges, but I’m pretty good
> with what we have.
>
> I’m glad you’re into it Jamey… I think you’ll be pleased you’re putting
> in the effort. There is little that’s as cool as being able to whip-up a
> WDF filter driver in, like, ten minutes.
>
> Peter
> OSR
> @OSRDrivers
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: <
> http://www.osronline.com/showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer>
></http:>