OpenCBM
Functions
util-reg.c File Reference

Some utility functions for accessing the registry. More...

#include <wdm.h>
#include "cbm_driver.h"

Go to the source code of this file.

Functions

NTSTATUS cbm_registry_open_for_read (OUT PHANDLE HandleKey, IN PUNICODE_STRING Path)
 Open a registry path for reading. More...
 
NTSTATUS cbm_registry_open_hardwarekey (OUT PHANDLE HandleKey, OUT PDEVICE_OBJECT *Pdo, IN PDEVICE_EXTENSION Pdx)
 Open the hardware key for another driver. More...
 
NTSTATUS cbm_registry_close (IN HANDLE HandleKey)
 Close a registry key. More...
 
NTSTATUS cbm_registry_close_hardwarekey (IN HANDLE HandleKey, IN PDEVICE_OBJECT Pdo)
 Close a hardware registry key. More...
 
NTSTATUS cbm_registry_read_ulong (IN HANDLE HandleKey, IN PCWSTR KeyName, OUT PULONG Value)
 Read a ULONG value out of a registry key. More...
 
NTSTATUS cbm_registry_write_ulong (IN HANDLE HandleKey, IN PCWSTR KeyName, IN ULONG Value)
 Write a ULONG value out of a registry key. More...
 

Detailed Description

Some utility functions for accessing the registry.



Author
Spiro Trikaliotis

Definition in file util-reg.c.

Function Documentation

NTSTATUS cbm_registry_close ( IN HANDLE  HandleKey)

Close a registry key.

This function closes a registry key.

Parameters
HandleKeyThe HANDLE of the registry path.
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

If the registry key was obtained with a call to cbm_registry_open_hardwarekey(), you must not use this function, but use cbm_registry_close_hardwarekey() instead.

Definition at line 230 of file util-reg.c.

References FUNC_ENTER.

Referenced by cbm_init_registry(), and cbm_registry_close_hardwarekey().

NTSTATUS cbm_registry_close_hardwarekey ( IN HANDLE  HandleKey,
IN PDEVICE_OBJECT  Pdo 
)

Close a hardware registry key.

This function closes a registry key pointing to a hardware registry key.

Parameters
HandleKeyThe HANDLE of the registry path.
PdoPointer to the DEVICE_OBJECT for which we found the hardware key.
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

Definition at line 260 of file util-reg.c.

References cbm_registry_close(), and FUNC_ENTER.

Referenced by ParPortAllowInterruptIoctl().

NTSTATUS cbm_registry_open_for_read ( OUT PHANDLE  HandleKey,
IN PUNICODE_STRING  Path 
)

Open a registry path for reading.

This function opens a registry key ("path"). This way, its entries can be read afterwards.

Parameters
HandleKeyPointer to a HANDLE which will contain the handle to the registry key ("path") on exit
PathPointer to a UNICODE_STRING which points to the registry key to be opened.
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

A call to this function must be balanced with a call to cbm_registry_close().

Definition at line 43 of file util-reg.c.

References DBG_PREFIX, FUNC_ENTER, and FUNC_PARAM.

Referenced by cbm_init_registry().

NTSTATUS cbm_registry_open_hardwarekey ( OUT PHANDLE  HandleKey,
OUT PDEVICE_OBJECT *  Pdo,
IN PDEVICE_EXTENSION  Pdx 
)

Open the hardware key for another driver.

This function opens a the "hardware" registry key for the parallel port driver.

Parameters
HandleKeyPointer to a HANDLE which will contain the handle to the registry key ("path") on exit
PdoPointer to the DEVICE_OBJECT for which we found the hardware key.
PdxThe PDX of the driver which is calling this function
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

A call to this function must be balanced with a call to cbm_registry_close_hardwarekey().

Thanks to Doron Holan [MS] for pointing out how to do it (MsgId:O6weQ.nosp@m.L8qE.nosp@m.HA.34.nosp@m.28@T.nosp@m.K2MSF.nosp@m.TNGP.nosp@m.11.ph.nosp@m.x.gb.nosp@m.l on microsoft.public.development.device.drivers, http://groups.google.com/groups?selm=O6weQL8qEHA.3428%40TK2MSFTNGP11.phx.gbl

Definition at line 95 of file util-reg.c.

References CbmOpenDeviceRegistryKey(), DBG_ASSERT, and FUNC_ENTER.

Referenced by ParPortAllowInterruptIoctl().

NTSTATUS cbm_registry_read_ulong ( IN HANDLE  HandleKey,
IN PCWSTR  KeyName,
OUT PULONG  Value 
)

Read a ULONG value out of a registry key.

This function reads a ULONG value out of the registry.

Parameters
HandleKeyThe HANDLE of the registry path.
KeyNameA null-terminated wide char string which contains the name of the value to be read.
ValuePointer to a memory location which will hold the return value.
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

If the value cannot be read, the return value in *Value will not be changed.

Definition at line 299 of file util-reg.c.

References DBG_PREFIX, FUNC_ENTER, and FUNC_PARAM.

Referenced by cbm_init_registry(), and ParPortAllowInterruptIoctl().

NTSTATUS cbm_registry_write_ulong ( IN HANDLE  HandleKey,
IN PCWSTR  KeyName,
IN ULONG  Value 
)

Write a ULONG value out of a registry key.

This function writes a ULONG value to the registry.

Parameters
HandleKeyThe HANDLE of the registry path.
KeyNameA null-terminated wide char string which contains the name of the value to be read.
ValueThe value to be written to that memory entry.
Returns
If the routine succeeds, it returns STATUS_SUCCESS. Otherwise, it return one of the error status values.

Definition at line 356 of file util-reg.c.

References DBG_PREFIX, FUNC_ENTER, and FUNC_PARAM.

Referenced by ParPortAllowInterruptIoctl().