ReactOS  0.4.13-dev-563-g0561610
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 281 of file registry.cpp.

291 {
292  HANDLE hHandle;
294  CRegistryKey * RegistryKey;
295  PPCLASS_DEVICE_EXTENSION DeviceExt;
296  PSUBDEVICE_DESCRIPTOR SubDeviceDescriptor;
297  ISubdevice * Device;
298  PSYMBOLICLINK_ENTRY SymEntry;
299  BOOL CanDelete = FALSE;
300 
301  DPRINT("PcNewRegistryKey entered\n");
302 
303  if (!OutRegistryKey)
305 
306  if (RegistryKeyType != GeneralRegistryKey &&
307  RegistryKeyType != DeviceRegistryKey &&
308  RegistryKeyType != DriverRegistryKey &&
309  RegistryKeyType != HwProfileRegistryKey &&
310  RegistryKeyType != DeviceInterfaceRegistryKey)
311  {
313  }
314 
315  // check for the key type
316  if (RegistryKeyType == GeneralRegistryKey)
317  {
318  // do we have the required object attributes
319  if (!ObjectAttributes)
320  {
321  // object attributes is mandatory
323  }
324  // try to create the key
325  Status = ZwCreateKey(&hHandle, DesiredAccess, ObjectAttributes, 0, NULL, CreateOptions, Disposition);
326 
327  // key can be deleted
328  CanDelete = TRUE;
329  }
330  else if (RegistryKeyType == DeviceRegistryKey ||
331  RegistryKeyType == DriverRegistryKey ||
332  RegistryKeyType == HwProfileRegistryKey)
333  {
334  // check for HwProfileRegistryKey case
335  if (RegistryKeyType == HwProfileRegistryKey)
336  {
337  // IoOpenDeviceRegistryKey used different constant
339  }
340 
341  // obtain the new device extension
342  DeviceExt = (PPCLASS_DEVICE_EXTENSION) ((PDEVICE_OBJECT)DeviceObject)->DeviceExtension;
343 
344  Status = IoOpenDeviceRegistryKey(DeviceExt->PhysicalDeviceObject, RegistryKeyType, DesiredAccess, &hHandle);
345  }
346  else if (RegistryKeyType == DeviceInterfaceRegistryKey)
347  {
348  if (SubDevice == NULL)
349  {
350  // invalid parameter
352  }
353 
354  // look up our undocumented interface
355  Status = ((PUNKNOWN)SubDevice)->QueryInterface(IID_ISubdevice, (LPVOID*)&Device);
356 
357  if (!NT_SUCCESS(Status))
358  {
359  DPRINT("No ISubdevice interface\n");
360  // invalid parameter
362  }
363 
364  // get the subdevice descriptor
365  Status = Device->GetDescriptor(&SubDeviceDescriptor);
366  if (!NT_SUCCESS(Status))
367  {
368  DPRINT("Failed to get subdevice descriptor %x\n", Status);
369  ((PUNKNOWN)SubDevice)->Release();
370  return STATUS_UNSUCCESSFUL;
371  }
372 
373  // is there an registered device interface
374  if (IsListEmpty(&SubDeviceDescriptor->SymbolicLinkList))
375  {
376  DPRINT("No device interface registered\n");
377  ((PUNKNOWN)SubDevice)->Release();
378  return STATUS_UNSUCCESSFUL;
379  }
380 
381  // get the first symbolic link
383 
384  // open device interface
386 
387  // release subdevice interface
388  ((PUNKNOWN)SubDevice)->Release();
389  }
390 
391  // check for success
392  if (!NT_SUCCESS(Status))
393  {
394  DPRINT1("PcNewRegistryKey failed with %lx\n", Status);
395  return Status;
396  }
397 
398  // allocate new registry key object
399  RegistryKey = new(NonPagedPool, TAG_PORTCLASS)CRegistryKey(OuterUnknown, hHandle, CanDelete);
400  if (!RegistryKey)
401  {
402  // not enough memory
403  ZwClose(hHandle);
405  }
406 
407  // query for interface
408  Status = RegistryKey->QueryInterface(IID_IRegistryKey, (PVOID*)OutRegistryKey);
409 
410  if (!NT_SUCCESS(Status))
411  {
412  // out of memory
413  delete RegistryKey;
414  }
415 
416  DPRINT("PcNewRegistryKey result %p\n", *OutRegistryKey);
417  return STATUS_SUCCESS;
418 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#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
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
struct PCLASS_DEVICE_EXTENSION * PPCLASS_DEVICE_EXTENSION
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2738
#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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PDEVICE_OBJECT PhysicalDeviceObject
Definition: private.hpp:402
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG CreateOptions
Definition: fltkernel.h:1230
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: registry.cpp:63
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4565
#define DPRINT1
Definition: precomp.h:8
UNICODE_STRING SymbolicLink
Definition: interfaces.hpp:176
return STATUS_SUCCESS
Definition: btrfs.c:2777
base of all file and directory entries
Definition: entries.h:82
#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE
Definition: iofuncs.h:2740
LIST_ENTRY SymbolicLinkList
Definition: interfaces.hpp:219

Referenced by CMiniportWaveCMI::loadChannelConfigFromRegistry(), and CMiniportWaveCMI::storeChannelConfigToRegistry().