IoOpenDriverRegistryKey function (wdm.h)

The IoOpenDriverRegistryKey routine returns a handle to a driver-specific registry key for a particular driver.

Syntax

NTSTATUS IoOpenDriverRegistryKey(
  [in]  PDRIVER_OBJECT     DriverObject,
  [in]  DRIVER_REGKEY_TYPE RegKeyType,
  [in]  ACCESS_MASK        DesiredAccess,
  [in]  ULONG              Flags,
  [out] PHANDLE            DriverRegKey
);

Parameters

[in] DriverObject

A pointer to a DRIVER_OBJECT structure. This structure must be the driver object for the calling driver.

[in] RegKeyType

An enumeration of type DRIVER_REGKEY_TYPE that indicates the type of the requested registry key.

[in] DesiredAccess

Specifies the ACCESS_MASK value that represents the access rights needed for the key. See ZwCreateKey for a description of each KEY_XXX access right.

[in] Flags

Set to zero.

[out] DriverRegKey

A pointer to the HANDLE variable that, on successful return, contains a handle to the requested registry key.

Return value

IoOpenDriverRegistryKey returns STATUS_SUCCESS if the call successfully opened a handle to the requested registry key.

Remarks

The driver must call ZwClose to close the handle returned from this routine when access is no longer needed.

The registry keys opened by this routine are nonvolatile.

To provision keys and values under the immutable DriverRegKeyParameters registry key, use an AddReg directive from a service-install-section to reference an add-registry-section section that contains entries with a reg-root of HKR and a subkey of Parameters.

Callers of IoOpenDriverRegistryKey must be running at IRQL = PASSIVE_LEVEL in the context of a system thread.

Requirements

Requirement Value
Minimum supported client Windows 10, version 1803
Header wdm.h (include wdm.h, ntddk.h, or ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL PASSIVE_LEVEL

See also

ZwClose

ACCESS_MASK

DRIVER_REGKEY_TYPE