ReactOS 0.4.15-dev-8109-gd7be748
fxregkey.cpp
Go to the documentation of this file.
1//
2// Copyright (C) Microsoft. All rights reserved.
3//
4#include "fxsupportpch.hpp"
5
6extern "C" {
7#if defined(EVENT_TRACING)
8#include "FxRegKey.tmh"
9#endif
10}
11
15 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
16 __in PCUNICODE_STRING RegValueName,
17 __in_bcount(DataLength) PWCHAR DataString,
19 )
20/*++
21
22Routine Description:
23 This static function checks the input buffer to verify that it contains
24 a multi-sz string with a double-NULL termination at the end of the buffer.
25
26Arguments:
27 DataString - buffer containing multi-sz strings. If there are no strings
28 in the buffer, the buffer should at least contain two UNICODE_NULL
29 characters.
30
31 DataLength - the size in bytes of the input buffer.
32
33Return Value:
34 STATUS_OBJECT_TYPE_MISMATCH - if the the data buffer is off odd-length,
35 or it doesnt end with two UNICODE_NULL characters.
36
37 STATUS_SUCCESS - if the buffer contains valid multi-sz strings.
38
39 --*/
40{
42
43 if ((DataLength % 2) != 0) {
45 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGERROR,
46 "Reg value name %wZ, DataLength %d, Data buffer length is invalid, "
47 "STATUS_OBJECT_TYPE_MISMATCH",
48 RegValueName, DataLength);
50 }
51
52 numChars = DataLength / sizeof(WCHAR);
53 if (numChars < 2 ||
54 DataString[numChars-1] != UNICODE_NULL ||
55 DataString[numChars-2] != UNICODE_NULL) {
56
58 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGERROR,
59 "Read value name %wZ, DataLength %d, Data buffer from registry does not "
60 "have double NULL terminal chars, STATUS_OBJECT_TYPE_MISMATCH",
61 RegValueName, DataLength);
63 }
64
65 return STATUS_SUCCESS;
66}
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
static _Must_inspect_result_ NTSTATUS _VerifyMultiSzString(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PCUNICODE_STRING RegValueName, __in_bcount(DataLength) PWCHAR DataString, __in ULONG DataLength)
Definition: fxregkey.cpp:14
#define __in
Definition: dbghelp.h:35
#define __in_bcount(x)
Definition: dbghelp.h:41
#define TRACINGERROR
Definition: dbgtrace.h:63
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
USHORT numChars
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define UNICODE_NULL
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:273
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180