#ifndef _NTSTRSAFE_H_INCLUDED_
#ifndef NTSTRSAFE_LIB_IMPL
#ifndef NTSTRSAFE_NO_UNICODE_STRING_FUNCTIONS
NTSTRSAFEDDI
RtlUnicodeStringCopyString(
_Inout_ PUNICODE_STRING DestinationString,
_In_ NTSTRSAFE_PCWSTR pszSrc)
{
NTSTATUS status;
wchar_t* pszDest;
size_t cchDest;
status = RtlUnicodeStringValidateDestWorker(DestinationString,
&pszDest,
&cchDest,
NULL,
NTSTRSAFE_UNICODE_STRING_MAX_CCH,
0);
if (NT_SUCCESS(status))
{
size_t cchNewDestLength = 0;
status = RtlWideCharArrayCopyStringWorker(pszDest,
cchDest,
&cchNewDestLength,
pszSrc,
NTSTRSAFE_UNICODE_STRING_MAX_CCH);
// safe to multiply cchNewDestLength * sizeof(wchar_t) since cchDest < NTSTRSAFE_UNICODE_STRING_MAX_CCH and sizeof(wchar_t) is 2
DestinationString->Length = (USHORT)(cchNewDestLength * sizeof(wchar_t));
}
return status;
}
View code on GitHub
No description available.