ReactOS 0.4.15-dev-8096-ga0eec98
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 11 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 264 of file registry.cpp.

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

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