ReactOS  0.4.13-dev-922-g2fbff73
Registry.c File Reference
#include "fltmgr.h"
#include "fltmgrint.h"
#include <debug.h>
Include dependency graph for Registry.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define REG_SERVICES_KEY   L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"
 
#define REG_PATH_LENGTH   512
 

Functions

NTSTATUS FltpOpenFilterServicesKey (_In_ PFLT_FILTER Filter, _In_ ACCESS_MASK DesiredAccess, _In_opt_ PUNICODE_STRING SubKey, _Out_ PHANDLE Handle)
 
NTSTATUS FltpReadRegistryValue (_In_ HANDLE KeyHandle, _In_ PUNICODE_STRING ValueName, _In_opt_ ULONG Type, _Out_writes_bytes_(BufferSize) PVOID Buffer, _In_ ULONG BufferSize, _Out_opt_ PULONG BytesRequired)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file Registry.c.

◆ REG_PATH_LENGTH

#define REG_PATH_LENGTH   512

Definition at line 21 of file Registry.c.

◆ REG_SERVICES_KEY

#define REG_SERVICES_KEY   L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"

Definition at line 20 of file Registry.c.

Function Documentation

◆ FltpOpenFilterServicesKey()

NTSTATUS FltpOpenFilterServicesKey ( _In_ PFLT_FILTER  Filter,
_In_ ACCESS_MASK  DesiredAccess,
_In_opt_ PUNICODE_STRING  SubKey,
_Out_ PHANDLE  Handle 
)

Definition at line 28 of file Registry.c.

33 {
35  UNICODE_STRING ServicesKey;
38 
39  /* Setup a local buffer to hold the services key path */
40  Path.Length = 0;
41  Path.MaximumLength = REG_PATH_LENGTH;
42  Path.Buffer = Buffer;
43 
44  /* Build up the serices key name */
46  RtlCopyUnicodeString(&Path, &ServicesKey);
48 
49  if (SubKey)
50  {
51  /* Tag on any child key */
54  }
55 
57  &Path,
59  NULL,
60  NULL);
61 
62  /* Open and return the key handle param*/
63  return ZwOpenKey(Handle, DesiredAccess, &ObjectAttributes);
64 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
_In_ HANDLE Handle
Definition: extypes.h:390
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
UNICODE_STRING Name
Definition: fltmgrint.h:100
PRTL_UNICODE_STRING_BUFFER Path
_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
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define REG_SERVICES_KEY
Definition: Registry.c:20
#define REG_PATH_LENGTH
Definition: Registry.c:21

Referenced by GetFilterAltitude().

◆ FltpReadRegistryValue()

NTSTATUS FltpReadRegistryValue ( _In_ HANDLE  KeyHandle,
_In_ PUNICODE_STRING  ValueName,
_In_opt_ ULONG  Type,
_Out_writes_bytes_(BufferSize) PVOID  Buffer,
_In_ ULONG  BufferSize,
_Out_opt_ PULONG  BytesRequired 
)

Definition at line 67 of file Registry.c.

73 {
75  ULONG ValueLength = 0;
77 
78  PAGED_CODE();
79 
80  /* Get the size of the buffer required to hold the string */
81  Status = ZwQueryValueKey(KeyHandle,
82  ValueName,
84  NULL,
85  0,
86  &ValueLength);
88  {
89  return Status;
90  }
91 
92  /* Allocate the buffer */
96  if (Value == NULL)
97  {
99  goto Quit;
100  }
101 
102  /* Now read in the value */
103  Status = ZwQueryValueKey(KeyHandle,
104  ValueName,
106  Value,
107  ValueLength,
108  &ValueLength);
109  if (!NT_SUCCESS(Status))
110  {
111  goto Quit;
112  }
113 
114  /* Make sure we got the type expected */
115  if (Value->Type != Type)
116  {
118  goto Quit;
119  }
120 
121  if (BytesRequired)
122  {
123  *BytesRequired = Value->DataLength;
124  }
125 
126  /* Make sure the caller buffer is big enough to hold the data */
127  if (!BufferSize || BufferSize < Value->DataLength)
128  {
130  goto Quit;
131  }
132 
133  /* Copy the data into the caller buffer */
134  RtlCopyMemory(Buffer, Value->Data, Value->DataLength);
135 
136 Quit:
137 
138  if (Value)
140 
141  return Status;
142 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Type
Definition: Type.h:6
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
#define FM_TAG_TEMP_REGISTRY
Definition: fltmgr.h:22
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
#define BufferSize
Definition: classpnp.h:419
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333

Referenced by GetFilterAltitude().