Skip to content

Latest commit

 

History

History
154 lines (114 loc) · 5.37 KB

nf-wdfdevice-wdfdeviceallocandqueryproperty.md

File metadata and controls

154 lines (114 loc) · 5.37 KB
UID title description old-location tech.root ms.date keywords ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames f1_keywords topic_type api_type api_location api_name
NF:wdfdevice.WdfDeviceAllocAndQueryProperty
WdfDeviceAllocAndQueryProperty function (wdfdevice.h)
The WdfDeviceAllocAndQueryProperty method allocates a buffer and retrieves a specified device property.
wdf\wdfdeviceallocandqueryproperty.htm
wdf
02/26/2018
WdfDeviceAllocAndQueryProperty function
DFDeviceObjectGeneralRef_d093b9da-de6b-467d-a6bd-c25d7a4145f8.xml, WdfDeviceAllocAndQueryProperty, WdfDeviceAllocAndQueryProperty method, kmdf.wdfdeviceallocandqueryproperty, wdf.wdfdeviceallocandqueryproperty, wdfdevice/WdfDeviceAllocAndQueryProperty
wdfdevice.h
Wdf.h
Universal
1.0
2.0
DriverCreate, KmdfIrql, KmdfIrql2
Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
PASSIVE_LEVEL
Windows
WdfDeviceAllocAndQueryProperty
wdfdevice/WdfDeviceAllocAndQueryProperty
APIRef
kbSyntax
LibDef
Wdf01000.sys
Wdf01000.sys.dll
WUDFx02000.dll
WUDFx02000.dll.dll
WdfDeviceAllocAndQueryProperty

WdfDeviceAllocAndQueryProperty function

-description

[Applies to KMDF and UMDF]

The WdfDeviceAllocAndQueryProperty method allocates a buffer and retrieves a specified device property.

-parameters

-param Device [in]

A handle to a framework device object.

-param DeviceProperty [in]

A DEVICE_REGISTRY_PROPERTY-typed enumerator that identifies the device property to be retrieved.

-param PoolType [in]

A POOL_TYPE-typed enumerator that specifies the type of memory to be allocated.

-param PropertyMemoryAttributes [in, optional]

A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure that describes object attributes for the memory object that the function will allocate. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

-param PropertyMemory [out]

A pointer to a WDFMEMORY-typed location that receives a handle to a framework memory object.

-returns

If the operation succeeds, WdfDeviceAllocAndQueryProperty returns STATUS_SUCCESS. Additional return values include:

Return code Description
STATUS_INVALID_PARAMETER or STATUS_INVALID_PARAMETER_2
The specified DeviceProperty value is invalid.
STATUS_INVALID_DEVICE_REQUEST
The device's drivers have not yet reported the device's properties.
 

The method might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.

-remarks

The WdfDeviceAllocAndQueryProperty method determines the amount of memory that is necessary to hold the requested device property. It allocates enough memory to hold the data, and returns a handle to a framework memory object that describes the allocated memory. To access the data, your driver can call WdfMemoryGetBuffer.

Alternatively, you can use WdfDeviceAllocAndQueryPropertyEx to access device properties that are exposed through the Unified Property Model.

Examples

The following code example initializes a WDF_OBJECT_ATTRIBUTES structure with attributes for the framework memory object that the framework will create for the requested property. Then, the example calls WdfDeviceAllocAndQueryProperty to obtain the DevicePropertyPhysicalDeviceObjectName property. After WdfDeviceAllocAndQueryProperty returns, the driver can call WdfMemoryGetBuffer to obtain a pointer to the buffer that contains the name string.

WDF_OBJECT_ATTRIBUTES  attributes;
NTSTATUS  status;
WDFDEVICE  device;
WDFMEMORY  memory;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
attributes.ParentObject = device;

status = WdfDeviceAllocAndQueryProperty(device,
                                        DevicePropertyPhysicalDeviceObjectName,
                                        NonPagedPool,
                                        &attributes,
                                        &memory
                                        );
if (!NT_SUCCESS(status)) {
    return STATUS_UNSUCCESSFUL;
}

-see-also

WdfDeviceQueryProperty