Skip to content

Latest commit

 

History

History
144 lines (109 loc) · 5.05 KB

nf-ntstrsafe-rtlunicodestringcchcopystringn.md

File metadata and controls

144 lines (109 loc) · 5.05 KB
UID title description old-location tech.root ms.date keywords ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames f1_keywords topic_type api_type api_location api_name
NF:ntstrsafe.RtlUnicodeStringCchCopyStringN
RtlUnicodeStringCchCopyStringN function (ntstrsafe.h)
The RtlUnicodeStringCchCopyStringN function copies a string into a UNICODE_STRING structure while limiting the size of the copied string.
kernel\rtlunicodestringcchcopystringn.htm
kernel
04/30/2018
RtlUnicodeStringCchCopyStringN function
RtlUnicodeStringCchCopyStringN, RtlUnicodeStringCchCopyStringN function [Kernel-Mode Driver Architecture], kernel.rtlunicodestringcchcopystringn, ntstrsafe/RtlUnicodeStringCchCopyStringN, safestrings_d48eb8f3-535f-4829-aed4-6bde1b4733e3.xml
ntstrsafe.h
Ntstrsafe.h
Desktop
Available in Windows XP with Service Pack 1 (SP1) and later versions of Windows.
Ntstrsafe.lib
Any if strings being manipulated are always resident in memory, otherwise PASSIVE_LEVEL
Windows
RtlUnicodeStringCchCopyStringN
ntstrsafe/RtlUnicodeStringCchCopyStringN
APIRef
kbSyntax
LibDef
Ntstrsafe.lib
Ntstrsafe.dll
RtlUnicodeStringCchCopyStringN

RtlUnicodeStringCchCopyStringN function

-description

The RtlUnicodeStringCchCopyStringN function copies a string into a UNICODE_STRING structure while limiting the size of the copied string.

-parameters

-param DestinationString [out]

A pointer to a UNICODE_STRING structure that receives the copied string. The string that the pszSrc parameter points to (excluding the terminating NULL) is copied into the buffer that the DestinationString parameter's UNICODE_STRING structure points to. The maximum number of characters in the string is NTSTRSAFE_UNICODE_STRING_MAX_CCH.

-param pszSrc [in]

A pointer to the string to be copied.

-param cchToCopy [in]

The number of characters to be copied from the source to the destination.

-returns

RtlUnicodeStringCchCopyStringN returns one of the following NTSTATUS.

Return code Description
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.
 

RtlUnicodeStringCchCopyStringN 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.
For information about how to test NTSTATUS values, see Using NTSTATUS Values.

-remarks

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 pszSrc 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.

-see-also

RtlUnicodeStringCchCopyN

RtlUnicodeStringCchCopyNEx

UNICODE_STRING