WdfFdoInitAllocAndQueryProperty - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// wdffdo.h

NTSTATUS WdfFdoInitAllocAndQueryProperty(
  [in]           PWDFDEVICE_INIT          DeviceInit,
  [in]           DEVICE_REGISTRY_PROPERTY DeviceProperty,
  [in]           POOL_TYPE                PoolType,
  [in, optional] PWDF_OBJECT_ATTRIBUTES   PropertyMemoryAttributes,
  [out]          WDFMEMORY                *PropertyMemory
);

View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-wdffdo-wdffdoinitallocandqueryproperty)

WdfFdoInitAllocAndQueryProperty function

Description

[Applies to KMDF and UMDF]

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

Parameters

DeviceInit [in]

A pointer to a WDFDEVICE_INIT structure that the driver obtained from its EvtDriverDeviceAdd callback function.

DeviceProperty [in]

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

PoolType [in]

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

PropertyMemoryAttributes [in, optional]

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

PropertyMemory [out]

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

Return value

If the operation succeeds, the method 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 WDFDEVICE_INIT structure was not obtained from driver's EvtDriverDeviceAdd callback function.

The method might also return other NTSTATUS values.

Remarks

The driver must call WdfFdoInitAllocAndQueryProperty before calling WdfDeviceCreate. For more information about calling WdfDeviceCreate, see Creating a Framework Device Object.

After calling WdfDeviceCreate, a driver can obtain device property information by calling WdfDeviceAllocAndQueryProperty.

For more information about the WdfFdoInitAllocAndQueryProperty method, see Creating Device Objects in a Function Driver.

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

Examples

The following code example calls WdfFdoInitAllocAndQueryProperty to obtain a handle to a framework memory object that contains the name of a device's setup class. Then, the example calls WdfMemoryGetBuffer to obtain a pointer to the buffer that contains the setup class name's Unicode string.

NTSTATUS  status = STATUS_SUCCESS;
PVOID  pMemoryBuffer = NULL;
WDFMEMORY  memory = NULL;

status = WdfFdoInitAllocAndQueryProperty(
                                         DeviceInit,
                                         DevicePropertyClassName,
                                         NonPagedPool,
                                         WDF_NO_OBJECT_ATTRIBUTES,
                                         &memory
                                         );
if(NT_SUCCESS(status)){
 pMemoryBuffer = WdfMemoryGetBuffer(
                                    memory,
                                    NULL
                                    );
}

See also

WdfDeviceAllocAndQueryProperty

WdfFdoInitQueryProperty