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)
9 /* INCLUDES ******************************************************************/
12 #include "fltmgrint.h"
18 /* DATA *********************************************************************/
20 #define REG_SERVICES_KEY L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\"
21 #define REG_PATH_LENGTH 512
24 /* INTERNAL FUNCTIONS ******************************************************/
28 FltpOpenFilterServicesKey(
29 _In_ PFLT_FILTER Filter
,
30 _In_ ACCESS_MASK DesiredAccess
,
31 _In_opt_ PUNICODE_STRING SubKey
,
34 OBJECT_ATTRIBUTES ObjectAttributes
;
35 UNICODE_STRING ServicesKey
;
37 WCHAR Buffer
[REG_PATH_LENGTH
];
39 /* Setup a local buffer to hold the services key path */
41 Path
.MaximumLength
= REG_PATH_LENGTH
;
44 /* Build up the serices key name */
45 RtlInitUnicodeString(&ServicesKey
, REG_SERVICES_KEY
);
46 RtlCopyUnicodeString(&Path
, &ServicesKey
);
47 RtlAppendUnicodeStringToString(&Path
, &Filter
->Name
);
51 /* Tag on any child key */
52 RtlAppendUnicodeToString(&Path
, L
"\\");
53 RtlAppendUnicodeStringToString(&Path
, SubKey
);
56 InitializeObjectAttributes(&ObjectAttributes
,
58 OBJ_KERNEL_HANDLE
| OBJ_CASE_INSENSITIVE
,
62 /* Open and return the key handle param*/
63 return ZwOpenKey(Handle
, DesiredAccess
, &ObjectAttributes
);
67 FltpReadRegistryValue(_In_ HANDLE KeyHandle
,
68 _In_ PUNICODE_STRING ValueName
,
70 _Out_writes_bytes_(BufferSize
) PVOID Buffer
,
71 _In_ ULONG BufferSize
,
72 _Out_opt_ PULONG BytesRequired
)
74 PKEY_VALUE_PARTIAL_INFORMATION Value
= NULL
;
75 ULONG ValueLength
= 0;
80 /* Get the size of the buffer required to hold the string */
81 Status
= ZwQueryValueKey(KeyHandle
,
83 KeyValuePartialInformation
,
87 if (Status
!= STATUS_BUFFER_TOO_SMALL
&& Status
!= STATUS_BUFFER_OVERFLOW
)
92 /* Allocate the buffer */
93 Value
= (PKEY_VALUE_PARTIAL_INFORMATION
)ExAllocatePoolWithTag(PagedPool
,
95 FM_TAG_TEMP_REGISTRY
);
98 Status
= STATUS_INSUFFICIENT_RESOURCES
;
102 /* Now read in the value */
103 Status
= ZwQueryValueKey(KeyHandle
,
105 KeyValuePartialInformation
,
109 if (!NT_SUCCESS(Status
))
114 /* Make sure we got the type expected */
115 if (Value
->Type
!= Type
)
117 Status
= STATUS_INVALID_PARAMETER
;
123 *BytesRequired
= Value
->DataLength
;
126 /* Make sure the caller buffer is big enough to hold the data */
127 if (!BufferSize
|| BufferSize
< Value
->DataLength
)
129 Status
= STATUS_BUFFER_TOO_SMALL
;
133 /* Copy the data into the caller buffer */
134 RtlCopyMemory(Buffer
, Value
->Data
, Value
->DataLength
);
139 ExFreePoolWithTag(Value
, FM_TAG_TEMP_REGISTRY
);