Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

RtlStringCchCopyUnicodeString function

The RtlStringCchCopyUnicodeString function copies the contents of a UNICODE_STRING structure to a specified destination.

Syntax


NTSTATUS RtlStringCchCopyUnicodeString(
  _Out_ NTSTRSAFE_PWSTR  pszDest,
  _In_  size_t           cchDest,
  _In_  PCUNICODE_STRING SourceString
);

Parameters

pszDest [out]

A pointer to a buffer that receives the copied string. The string that the SourceString parameter's UNICODE_STRING structure points to is copied to the buffer at pszDest and terminated with a null character.

cchDest [in]

The size, in characters, of the destination buffer. The buffer must be large enough for the string and the terminating null character. The maximum number of characters is NTSTRSAFE_MAX_CCH.

SourceString [in]

A pointer to a UNICODE_STRING structure that contains the string to be copied. The maximum number of characters in the string is NTSTRSAFE_UNICODE_STRING_MAX_CCH.

Return value

RtlStringCchCopyUnicodeString returns one of the following NTSTATUS values.

Return codeDescription
STATUS_SUCCESS

This success status means that source data was present, the string was copied without truncation, and the resultant destination buffer is null-terminated.

STATUS_BUFFER_OVERFLOW

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.

STATUS_INVALID_PARAMETER

This error status means that the function received an invalid input parameter. For more information, see the following list.

 

RtlStringCchCopyUnicodeString returns the STATUS_INVALID_PARAMETER value when one of the following occurs:

  • The contents of the UNICODE_STRING structure are invalid.
  • The value in cbDest is larger than the maximum buffer size.
  • The destination buffer (which pszDest points to) is already full.
  • A buffer pointer is NULL.
  • The destination buffer's length is zero, but a nonzero length source string is present.

For information about how to test NTSTATUS values, see Using NTSTATUS Values.

Remarks

The RtlStringCchCopyUnicodeString function uses the destination buffer's size (which cchDest specifies) to ensure that the copy operation does not write past the end of the buffer.

If the source and destination strings overlap, the behavior of the function is undefined.

The SourceString and pszDest pointers cannot be NULL. If you need to handle NULL pointer values, use the RtlStringCchCopyUnicodeStringEx function.

For more information about the safe string functions, see Using Safe String Functions.

Requirements

Target platform

Desktop

Version

Available in Windows XP with Service Pack 1 (SP1) and later versions of Windows.

Header

Ntstrsafe.h (include Ntstrsafe.h)

Library

Ntstrsafe.lib

IRQL

PASSIVE_LEVEL

See also

RtlStringCbCopyUnicodeString
RtlStringCchCopyUnicodeStringEx
UNICODE_STRING

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft