ReactOS 0.4.15-dev-8093-g3285f69
Registry.c
Go to the documentation of this file.
1/*
2 * PROJECT: Filesystem Filter Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/filters/fltmgr/Misc.c
5 * PURPOSE: Uncataloged functions
6 * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "fltmgr.h"
12#include "fltmgrint.h"
13
14#define NDEBUG
15#include <debug.h>
16
17
18/* DATA *********************************************************************/
19
20#define REG_SERVICES_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"
21#define REG_PATH_LENGTH 512
22
23
24/* INTERNAL FUNCTIONS ******************************************************/
25
26
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}
65
72 _Out_opt_ PULONG BytesRequired)
73{
77
78 PAGED_CODE();
79
80 /* Get the size of the buffer required to hold the string */
81 Status = ZwQueryValueKey(KeyHandle,
84 NULL,
85 0,
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,
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
136Quit:
137
138 if (Value)
140
141 return Status;
142}
#define PAGED_CODE()
#define REG_SERVICES_KEY
Definition: Registry.c:20
NTSTATUS FltpOpenFilterServicesKey(_In_ PFLT_FILTER Filter, _In_ ACCESS_MASK DesiredAccess, _In_opt_ PUNICODE_STRING SubKey, _Out_ PHANDLE Handle)
Definition: Registry.c:28
#define REG_PATH_LENGTH
Definition: Registry.c:21
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: Registry.c:67
PRTL_UNICODE_STRING_BUFFER Path
Type
Definition: Type.h:7
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define PagedPool
Definition: env_spec_w32.h:308
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
#define FM_TAG_TEMP_REGISTRY
Definition: fltmgr.h:24
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define _Out_opt_
Definition: ms_sal.h:346
#define _Out_writes_bytes_(size)
Definition: ms_sal.h:350
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define L(x)
Definition: ntvdm.h:50
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
UNICODE_STRING Name
Definition: fltmgrint.h:100
uint32_t * PULONG
Definition: typedefs.h:59
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
__wchar_t WCHAR
Definition: xmlstorage.h:180