WdfRegistryAssignMemory function (wdfregistry.h)

[Applies to KMDF and UMDF]

The WdfRegistryAssignMemory method assigns data that is contained in a specified memory buffer to a specified value name in the registry.

Syntax

NTSTATUS WdfRegistryAssignMemory(
  [in]           WDFKEY            Key,
  [in]           PCUNICODE_STRING  ValueName,
  [in]           ULONG             ValueType,
  [in]           WDFMEMORY         Memory,
  [in, optional] PWDFMEMORY_OFFSET MemoryOffsets
);

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] ValueType

A value that identifies the data type. For a list of data type values, see the Type member of KEY_VALUE_BASIC_INFORMATION.

[in] Memory

A handle to a framework memory object. This object represents a buffer that contains data that will be assigned to the value name that ValueName points to.

[in, optional] MemoryOffsets

A pointer to a driver-supplied WDFMEMORY_OFFSET structure that identifies a subsection of the buffer that Memory specifies. This parameter is optional and can be NULL.

Return value

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

Return code Description
STATUS_INVALID_DEVICE_REQUEST

WdfRegistryAssignMemory was not called at IRQL = PASSIVE_LEVEL.

STATUS_INVALID_PARAMETER
An invalid parameter was specified.
STATUS_ACCESS_DENIED
The driver did not open the registry key with KEY_SET_VALUE access.
STATUS_INTEGER_OVERFLOW
The contents of the WDFMEMORY_OFFSET structure that the MemoryOffsets parameter specified were invalid.
 

This method also might return other NTSTATUS values.

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

Remarks

If the value name that the ValueName parameter specifies already exists, WdfRegistryAssignMemory updates the value's data.

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

Examples

The following code example creates a framework memory object, loads the object's buffer with fake data, and assigns the buffer's contents to a registry value.

PUCHAR pBuffer;
WDFMEMORY memory;
NTSTATUS status;
UCHAR i;
DECLARE_UNICODE_STRING_SIZE(valueName, L"MyValueName");

status = WdfMemoryCreate(
                         WDF_NO_OBJECT_ATTRIBUTES,
                         NonPagedPool,
                         0,
                         MEMORY_LENGTH,
                         &memory,
                         (PVOID*)&pBuffer
                         );
if (NT_SUCCESS(status)) {

    // Fill the buffer with fake data.
    for (i = 1; i <= MEMORY_LENGTH; i++) {
        pBuffer[i-1] = i;
    }

    status = WdfRegistryAssignMemory(
                                     Key,
                                     &valueName,
                                     REG_BINARY,
                                     memory,
                                     NULL
                                     );
}

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

UNICODE_STRING

WDFMEMORY_OFFSET

WdfMemoryCreate

WdfRegistryAssignMultiString

WdfRegistryAssignString

WdfRegistryAssignULong

WdfRegistryAssignUnicodeString

WdfRegistryAssignValue