[SDK:RTL] Add RtlInitUnicodeString() and RtlGUIDFromString()
This commit is contained in:
63
SDK/RTL/string.c
Normal file
63
SDK/RTL/string.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/*++
|
||||
|
||||
Copyright (c) 2024, Quinn Stephens.
|
||||
Provided under the BSD 3-Clause license.
|
||||
|
||||
Module Name:
|
||||
|
||||
string.c
|
||||
|
||||
Abstract:
|
||||
|
||||
Provides RTL string routines.
|
||||
|
||||
--*/
|
||||
|
||||
#include <ntrtl.h>
|
||||
#include <wchar.h>
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
RtlInitUnicodeString (
|
||||
OUT PUNICODE_STRING Destination,
|
||||
IN PCWSTR Source
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Initializes a unicode string structure with an existing string,
|
||||
which may be NULL to initialize an empty unicode string structure.
|
||||
|
||||
Arguments:
|
||||
|
||||
Destination - A pointer to the unicode string structure.
|
||||
|
||||
Source - Optionally, a pointer to a null-terminated string to initialize
|
||||
the unicode string structure with.
|
||||
|
||||
Return Value:
|
||||
|
||||
None.
|
||||
|
||||
--*/
|
||||
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
Destination->Buffer = (PWSTR)Source;
|
||||
if (Source == NULL) {
|
||||
Destination->Length = 0;
|
||||
Destination->MaximumLength = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Length = wcslen(Source) * sizeof(WCHAR);
|
||||
if (Length >= MAX_USTRING) {
|
||||
Length = MAX_USTRING - sizeof(UNICODE_NULL);
|
||||
}
|
||||
|
||||
Destination->Length = (USHORT)Length;
|
||||
Destination->MaximumLength = (USHORT)(Length + sizeof(UNICODE_NULL));
|
||||
}
|
Reference in New Issue
Block a user