Bewerken

Delen via


WdfRegistryQueryMemory function (wdfregistry.h)

[Applies to KMDF and UMDF]

The WdfRegistryQueryMemory method retrieves the data that is currently assigned to a specified registry value, stores the data in a framework-allocated buffer, and creates a framework memory object to represent the buffer.

Syntax

NTSTATUS WdfRegistryQueryMemory(
  [in]            WDFKEY                 Key,
  [in]            PCUNICODE_STRING       ValueName,
  [in]            POOL_TYPE              PoolType,
  [in, optional]  PWDF_OBJECT_ATTRIBUTES MemoryAttributes,
  [out]           WDFMEMORY              *Memory,
  [out, optional] PULONG                 ValueType
);

Parameters

[in] Key

A handle to a registry-key object that represents an opened registry key.

[in] ValueName

A pointer to a UNICODE_STRING structure that contains a value name.

[in] PoolType

A POOL_TYPE-typed value that specifies the type of memory to be allocated for the data buffer.

[in, optional] MemoryAttributes

A pointer to a WDF_OBJECT_ATTRIBUTES structure that contains object attributes for the new memory object. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

[out] Memory

A pointer to a location that receives a handle to the new memory object.

[out, optional] ValueType

A pointer to a location that receives the data type. For a list of data type values, see the Type member of KEY_VALUE_BASIC_INFORMATION. This pointer is optional and can be NULL.

Return value

WdfRegistryQueryMemory returns STATUS_SUCCESS if the operation succeeds. Otherwise, the method might return one of the following values:

Return code Description
STATUS_INVALID_DEVICE_REQUEST

WdfRegistryQueryMemory was not called at IRQL = PASSIVE_LEVEL.

STATUS_INVALID_PARAMETER
An invalid parameter was specified.
STATUS_INSUFFICIENT_RESOURCES
A memory object could not be allocated.
STATUS_ACCESS_DENIED
The driver did not open the registry key with KEY_QUERY_VALUE, KEY_READ, or KEY_ALL_ACCESS access.
STATUS_OBJECT_NAME_NOT_FOUND
The registry value was not available.
STATUS_RESOURCE_DATA_NOT_FOUND
The registry value exists under the specified key, but is empty.
 

For a list of other return values that the WdfRegistryQueryMemory method might return, see Framework Object Creation Errors.

This method also might return other NTSTATUS values.

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

Remarks

When a driver calls WdfRegistryQueryMemory, the framework allocates a buffer that is large enough to hold the specified registry value's data. After WdfRegistryQueryMemory returns, the driver can call WdfMemoryGetBuffer to obtain a pointer to the buffer and the buffer's size.

For more information about registry-key objects, see Using the Registry in Framework-Based Drivers.

Examples

The following code example retrieves the data that is assigned to the MyValueName value and then obtains the data's address and size.

WDFMEMORY memory;
size_t size;
PUCHAR pBuf;
NTSTATUS status;
ULONG type;
DECLARE_CONST_UNICODE_STRING(valueName1, L"MyValueName");

status = WdfRegistryQueryMemory(
                                Key,
                                &valueName1,
                                PagedPool,
                                NULL,
                                &memory,
                                &type
                                );
pBuf = (PUCHAR)WdfMemoryGetBuffer(
                                   memory,
                                   &size
                                   );

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Minimum UMDF version 2.0
Header wdfregistry.h (include Wdf.h)
Library Wdf01000.sys (KMDF); WUDFx02000.dll (UMDF)
IRQL PASSIVE_LEVEL
DDI compliance rules DriverCreate(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf)

See also

KEY_VALUE_BASIC_INFORMATION

POOL_TYPE

UNICODE_STRING

WDF_OBJECT_ATTRIBUTES

WdfMemoryGetBuffer

WdfRegistryQueryMultiString

WdfRegistryQueryString

WdfRegistryQueryULong

WdfRegistryQueryUnicodeString

WdfRegistryQueryValue