The RtlUnicodeStringCchCopyN function copies a string from one UNICODE_STRING structure to another while limiting the size of the copied string.
NTSTATUS RtlUnicodeStringCchCopyN( _Out_ PUNICODE_STRING DestinationString, _In_ PCUNICODE_STRING SourceString, _In_ size_t cchToCopy );
A pointer to a UNICODE_STRING structure that receives the copied string. The string that the SourceString parameter's UNICODE_STRING structure points to is copied to the buffer that the DestinationString parameter's UNICODE_STRING structure points to. The maximum number of characters in the structure's string buffer is NTSTRSAFE_UNICODE_STRING_MAX_CCH.
A pointer to a UNICODE_STRING structure that contains the string to be copied. The maximum number of characters in the structure's string buffer is NTSTRSAFE_UNICODE_STRING_MAX_CCH.
The number of characters to be copied from the source to the destination.
RtlUnicodeStringCchCopyN returns one of the following NTSTATUS values.
||This success status means that source data was present, the string was copied without truncation, and the resultant destination buffer is null-terminated.|
||This warning status means that the copy operation did not complete because of insufficient buffer space. The destination buffer contains a truncated, null-terminated version of the intended result.|
||This error status means that the function received an invalid input parameter. For more information, see the following list.|
RtlUnicodeStringCchCopyN returns the STATUS_INVALID_PARAMETER value when one of the following occurs:
- The contents of the UNICODE_STRING structure are invalid.
- The destination buffer is already full.
- A buffer pointer is NULL.
- The destination buffer's length is zero, but a nonzero length source string is present.
- The cchToCopy parameter's value is greater than NTSTRSAFE_UNICODE_STRING_MAX_CCH.
The RtlUnicodeStringCchCopyN function uses the destination buffer's size to ensure that the copy operation does not write past the end of the buffer. The function does not terminate the resultant string with a null character.
If the source and destination strings overlap, the behavior of the function is undefined.
The SourceString and DestinationString pointers cannot be NULL. If you need to handle NULL pointer values, use the RtlUnicodeStringCchCopyNEx function.
For more information about the safe string functions, see Using Safe String Functions.
|Windows version||Available in Windows XP with Service Pack 1 (SP1) and later versions of Windows.|
|Header||ntstrsafe.h (include Ntstrsafe.h)|