> > +
> > +_Use_decl_annotations_
> > +VOID
> > +virt2phys_device_EvtIoInCallerContext(
> > +   IN WDFDEVICE device, IN WDFREQUEST request)
> > +{
> > +   WDF_REQUEST_PARAMETERS params;
> > +   ULONG code;
> > +   PVOID *virt;  
> 
> Should this be PVOID virt; (instead of PVOID *virt)?
> If so, changes will be required to parameters passed in to
> WdfRequestRetrieveInputBuffer() call.

This should be PVOID *virt (pointer to an untyped pointer). User-mode passes
a virtual address as a PVOID value, WdfRequestRetrieveInputBuffer() fills
virt with the address of that parameter, so that *virt is the virtual address
user-mode wants to translate into a physical one.

> 
> > +   PHYSICAL_ADDRESS *phys;
> > +   size_t size;
> > +   NTSTATUS status;
> > +
[snip]
> > +
> > +   status = WdfRequestRetrieveOutputBuffer(
> > +           request, sizeof(*phys), &phys, &size);  
> 
> Better to put a (PVOID *)typecast for &phys here:
>       status = WdfRequestRetrieveOutputBuffer(
>               request, sizeof(*phys), (PVOID *)&phys, &size); 

What do you mean? Without a typecast the built-in static analyzer emits a
warning (and all warnings are treated as errors for a driver):

virt2phys.c(108,46): error C2220: the following warning is treated as an error
virt2phys.c(108,46): warning C4047: 'function': 'PVOID *' differs in levels of 
indirection from 'PVOID **'
virt2phys.c(108,46): warning C4022: 'WdfRequestRetrieveInputBuffer': pointer 
mismatch for actual parameter 3

> > +   if (!NT_SUCCESS(status)) {
> > +           KdPrint(("WdfRequestRetrieveOutputBuffer() failed, "
> > +                   "status=%08x\n", status));
> > +           WdfRequestComplete(request, status);
> > +           return;
> > +   }
> > +
> > +   *phys = MmGetPhysicalAddress(*virt);
> > +
> > +   WdfRequestCompleteWithInformation(
> > +           request, STATUS_SUCCESS, sizeof(*phys));
> > +}  
> 
> <Snip!>
> 
> Co-installers are no longer required (and discouraged) as per Microsoft. 
> So you can remove the lines indicated below from the .inf file.

Thanks, will remove in v2. They were generated by WDK solution template.

-- 
Dmitry Kozlyuk

Reply via email to