#ifndef _NTSTRSAFE_H_INCLUDED_
#ifndef NTSTRSAFE_NO_UNICODE_STRING_FUNCTIONS
_At_(DestinationString->Buffer, _Post_equal_to_(pszSrc))
_At_(DestinationString->Length, _Post_equal_to_(_String_length_(pszSrc) * sizeof(WCHAR)))
_At_(DestinationString->MaximumLength, _Post_equal_to_((_String_length_(pszSrc)+1) * sizeof(WCHAR)))
NTSTRSAFEWORKERDDI
RtlUnicodeStringInitWorker(
_Out_ PUNICODE_STRING DestinationString,
_In_opt_ NTSTRSAFE_PCWSTR pszSrc,
_In_ const size_t cchMax,
_In_ DWORD dwFlags);
View code on GitHub
#ifndef _NTSTRSAFE_H_INCLUDED_
// Below here are the worker functions that actually do the work
#if defined(NTSTRSAFE_LIB_IMPL) || !defined(NTSTRSAFE_LIB)
#ifndef NTSTRSAFE_NO_UNICODE_STRING_FUNCTIONS
_Use_decl_annotations_
NTSTRSAFEWORKERDDI
RtlUnicodeStringInitWorker(
PUNICODE_STRING DestinationString,
NTSTRSAFE_PCWSTR pszSrc,
const size_t cchMax,
DWORD dwFlags)
{
NTSTATUS status = STATUS_SUCCESS;
if (DestinationString || !(dwFlags & STRSAFE_IGNORE_NULLS))
{
memset(DestinationString, 0, sizeof(*DestinationString));
}
if (pszSrc)
{
size_t cchSrcLength;
status = RtlStringLengthWorkerW(pszSrc, cchMax, &cchSrcLength);
if (NT_SUCCESS(status))
{
if (DestinationString)
{
size_t cbLength;
// safe to multiply cchSrcLength * sizeof(wchar_t) since cchSrcLength < NTSTRSAFE_UNICODE_STRING_MAX_CCH and sizeof(wchar_t) is 2
cbLength = cchSrcLength * sizeof(wchar_t);
DestinationString->Length = (USHORT)cbLength;
// safe to add cbLength + sizeof(wchar_t) since cchSrcLength < NTSTRSAFE_UNICODE_STRING_MAX_CCH
DestinationString->MaximumLength = (USHORT)(cbLength + sizeof(wchar_t));
DestinationString->Buffer = (PWSTR)pszSrc;
}
else
{
status = STATUS_INVALID_PARAMETER;
}
}
}
return status;
}
View code on GitHub
#ifndef _NTSTRSAFE_H_INCLUDED_
// Do not call these functions, they are worker functions for internal use within this file
#ifdef DEPRECATE_SUPPORTED
// ...
#else
#define RtlUnicodeStringInitWorker RtlUnicodeStringInitWorker_instead_use_RtlUnicodeStringInit_or_RtlUnicodeStringInitEx
View code on GitHub
No description available.