情報
要求されたトピックは次のとおりです。しかし、このトピックはこのライブラリには含まれていません。

WdfDeviceAllocAndQueryProperty メソッド

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

構文

NTSTATUS WdfDeviceAllocAndQueryProperty(
  [in]            WDFDEVICE Device,
  [in]            DEVICE_REGISTRY_PROPERTY DeviceProperty,
  [in]            POOL_TYPE PoolType,
  [in, optional]  PWDF_OBJECT_ATTRIBUTES PropertyMemoryAttributes,
  [out]           WDFMEMORY *PropertyMemory
);

パラメーター

Device [in]

A handle to a framework device object.

DeviceProperty [in]

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

PoolType [in]

A POOL_TYPE-typed enumerator 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 the function 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.

戻り値

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

リターン コード説明
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.

解説

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.

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;
}

要件

バージョン

Available in version 1.0 and later versions of KMDF.

ヘッダー

Wdfdevice.h (includeWdf.h)

ライブラリ

Wdf<MajorVersionNumber>000.sys (see Framework Library Versions.)

IRQL

PASSIVE_LEVEL

参照

WdfDeviceQueryProperty

 

 

コミュニティの追加

表示:
© 2014 Microsoft