ReactOS  0.4.15-dev-4603-gb922b6d
registry.cpp File Reference
#include "private.hpp"
#include <debug.h>
Include dependency graph for registry.cpp:

Go to the source code of this file.

Classes

class  CRegistryKey
 

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI PcNewRegistryKey (OUT PREGISTRYKEY *OutRegistryKey, IN PUNKNOWN OuterUnknown OPTIONAL, IN ULONG RegistryKeyType, IN ACCESS_MASK DesiredAccess, IN PVOID DeviceObject OPTIONAL, IN PVOID SubDevice OPTIONAL, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN ULONG CreateOptions OPTIONAL, OUT PULONG Disposition OPTIONAL)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file registry.cpp.

Function Documentation

◆ PcNewRegistryKey()

NTSTATUS NTAPI PcNewRegistryKey ( OUT PREGISTRYKEY OutRegistryKey,
IN PUNKNOWN OuterUnknown  OPTIONAL,
IN ULONG  RegistryKeyType,
IN ACCESS_MASK  DesiredAccess,
IN PVOID DeviceObject  OPTIONAL,
IN PVOID SubDevice  OPTIONAL,
IN POBJECT_ATTRIBUTES ObjectAttributes  OPTIONAL,
IN ULONG CreateOptions  OPTIONAL,
OUT PULONG Disposition  OPTIONAL 
)

Definition at line 268 of file registry.cpp.

278 {
279  HANDLE hHandle;
281  CRegistryKey * RegistryKey;
282  PPCLASS_DEVICE_EXTENSION DeviceExt;
283  PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
284  ISubdevice * Device;
285  PSYMBOLICLINK_ENTRY SymEntry;
286  BOOL CanDelete = FALSE;
287 
288  DPRINT("PcNewRegistryKey entered\n");
289 
290  if (!OutRegistryKey)
292 
293  if (RegistryKeyType != GeneralRegistryKey &&
294  RegistryKeyType != DeviceRegistryKey &&
295  RegistryKeyType != DriverRegistryKey &&
296  RegistryKeyType != HwProfileRegistryKey &&
297  RegistryKeyType != DeviceInterfaceRegistryKey)
298  {
300  }
301 
302  // check for the key type
303  if (RegistryKeyType == GeneralRegistryKey)
304  {
305  // do we have the required object attributes
306  if (!ObjectAttributes)
307  {
308  // object attributes is mandatory
310  }
311  // try to create the key
312  Status = ZwCreateKey(&hHandle, DesiredAccess, ObjectAttributes, 0, NULL, CreateOptions, Disposition);
313 
314  // key can be deleted
315  CanDelete = TRUE;
316  }
317  else if (RegistryKeyType == DeviceRegistryKey ||
318  RegistryKeyType == DriverRegistryKey ||
319  RegistryKeyType == HwProfileRegistryKey)
320  {
321  // check for HwProfileRegistryKey case
322  if (RegistryKeyType == HwProfileRegistryKey)
323  {
324  // IoOpenDeviceRegistryKey used different constant
326  }
327 
328  // obtain the new device extension
329  DeviceExt = (PPCLASS_DEVICE_EXTENSION) ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
330 
331  Status = IoOpenDeviceRegistryKey(DeviceExt->PhysicalDeviceObject, RegistryKeyType, DesiredAccess, &hHandle);
332  }
333  else if (RegistryKeyType == DeviceInterfaceRegistryKey)
334  {
335  if (SubDevice == NULL)
336  {
337  // invalid parameter
339  }
340 
341  // look up our undocumented interface
342  Status = ((PUNKNOWN)SubDevice)->QueryInterface(IID_ISubdevice, (LPVOID*)&Device);
343 
344  if (!NT_SUCCESS(Status))
345  {
346  DPRINT("No ISubdevice interface\n");
347  // invalid parameter
349  }
350 
351  // get the subdevice descriptor
352  Status = Device->GetDescriptor(&SubDeviceDescriptor);
353  if (!NT_SUCCESS(Status))
354  {
355  DPRINT("Failed to get subdevice descriptor %x\n", Status);
356  ((PUNKNOWN)SubDevice)->Release();
357  return STATUS_UNSUCCESSFUL;
358  }
359 
360  // is there an registered device interface
361  if (IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
362  {
363  DPRINT("No device interface registered\n");
364  ((PUNKNOWN)SubDevice)->Release();
365  return STATUS_UNSUCCESSFUL;
366  }
367 
368  // get the first symbolic link
370 
371  // open device interface
373 
374  // release subdevice interface
375  ((PUNKNOWN)SubDevice)->Release();
376  }
377 
378  // check for success
379  if (!NT_SUCCESS(Status))
380  {
381  DPRINT1("PcNewRegistryKey failed with %lx\n", Status);
382  return Status;
383  }
384 
385  // allocate new registry key object
386  RegistryKey = new(NonPagedPool, TAG_PORTCLASS)CRegistryKey(OuterUnknown, hHandle, CanDelete);
387  if (!RegistryKey)
388  {
389  // not enough memory
390  ZwClose(hHandle);
392  }
393 
394  // query for interface
395  Status = RegistryKey->QueryInterface(IID_IRegistryKey, (PVOID*)OutRegistryKey);
396 
397  if (!NT_SUCCESS(Status))
398  {
399  // out of memory
400  delete RegistryKey;
401  }
402 
403  DPRINT("PcNewRegistryKey result %p\n", *OutRegistryKey);
404  return STATUS_SUCCESS;
405 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey(IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey)
Definition: deviface.c:241
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2786
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
IUnknown * PUNKNOWN
Definition: com_apitest.h:45
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define TAG_PORTCLASS
Definition: private.hpp:24
LONG NTSTATUS
Definition: precomp.h:26
struct SYMBOLICLINK_ENTRY * PSYMBOLICLINK_ENTRY
Definition: interfaces.hpp:173
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PDEVICE_OBJECT PhysicalDeviceObject
Definition: private.hpp:402
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: registry.cpp:50
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG CreateOptions
Definition: wdfregistry.h:112
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:2191
#define DPRINT1
Definition: precomp.h:8
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:82
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE
Definition: iofuncs.h:2788
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219

Referenced by CAC97AdapterCommon::DisableAC97Pin(), CMiniportWaveCMI::loadChannelConfigFromRegistry(), CAC97AdapterCommon::SetAC97Default(), and CMiniportWaveCMI::storeChannelConfigToRegistry().