mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 07:02:56 +00:00
[WDF] Add Windows Driver Framework files
Takern from Microsoft GitHub repo:
d9c6040fe9
Licensed under MIT
This commit is contained in:
parent
545df81502
commit
8a978a179f
475 changed files with 285099 additions and 0 deletions
66
sdk/lib/drivers/wdf/shared/support/fxregkey.cpp
Normal file
66
sdk/lib/drivers/wdf/shared/support/fxregkey.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// Copyright (C) Microsoft. All rights reserved.
|
||||
//
|
||||
#include "FxSupportPch.hpp"
|
||||
|
||||
extern "C" {
|
||||
#if defined(EVENT_TRACING)
|
||||
#include "FxRegKey.tmh"
|
||||
#endif
|
||||
}
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
FxRegKey::_VerifyMultiSzString(
|
||||
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
|
||||
__in PCUNICODE_STRING RegValueName,
|
||||
__in_bcount(DataLength) PWCHAR DataString,
|
||||
__in ULONG DataLength
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
This static function checks the input buffer to verify that it contains
|
||||
a multi-sz string with a double-NULL termination at the end of the buffer.
|
||||
|
||||
Arguments:
|
||||
DataString - buffer containing multi-sz strings. If there are no strings
|
||||
in the buffer, the buffer should at least contain two UNICODE_NULL
|
||||
characters.
|
||||
|
||||
DataLength - the size in bytes of the input buffer.
|
||||
|
||||
Return Value:
|
||||
STATUS_OBJECT_TYPE_MISMATCH - if the the data buffer is off odd-length,
|
||||
or it doesnt end with two UNICODE_NULL characters.
|
||||
|
||||
STATUS_SUCCESS - if the buffer contains valid multi-sz strings.
|
||||
|
||||
--*/
|
||||
{
|
||||
ULONG numChars;
|
||||
|
||||
if ((DataLength % 2) != 0) {
|
||||
DoTraceLevelMessage(
|
||||
FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGERROR,
|
||||
"Reg value name %wZ, DataLength %d, Data buffer length is invalid, "
|
||||
"STATUS_OBJECT_TYPE_MISMATCH",
|
||||
RegValueName, DataLength);
|
||||
return STATUS_OBJECT_TYPE_MISMATCH;
|
||||
}
|
||||
|
||||
numChars = DataLength / sizeof(WCHAR);
|
||||
if (numChars < 2 ||
|
||||
DataString[numChars-1] != UNICODE_NULL ||
|
||||
DataString[numChars-2] != UNICODE_NULL) {
|
||||
|
||||
DoTraceLevelMessage(
|
||||
FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGERROR,
|
||||
"Read value name %wZ, DataLength %d, Data buffer from registry does not "
|
||||
"have double NULL terminal chars, STATUS_OBJECT_TYPE_MISMATCH",
|
||||
RegValueName, DataLength);
|
||||
return STATUS_OBJECT_TYPE_MISMATCH;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue