Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Driver Kit
Reference
 RtlUnicodeStringCchCatN

  Switch on low bandwidth view
Windows Driver Kit: Kernel-Mode Driver Architecture
RtlUnicodeStringCchCatN

The RtlUnicodeStringCchCatN function concatenates two strings that are contained in UNICODE_STRING structures while limiting the size of the copied string.

NTSTATUS
  RtlUnicodeStringCchCatN(
    IN OUT PUNICODE_STRING  DestinationString,
    IN PCUNICODE_STRING  SourceString,
    IN size_t  cchToAppend
    );

Parameters

DestinationString
A pointer to a UNICODE_STRING structure. This structure includes a buffer that, on input, contains a destination string to which the source string will be concatenated. On output, this buffer is the destination buffer that contains the entire resultant string. The source string is added to the end of the destination string. The maximum number of characters in the structure's string buffer is NTSTRSAFE_UNICODE_STRING_MAX_CCH.
SourceString
A pointer to a UNICODE_STRING structure. This structure includes a buffer that contains the source string. This string will be added to the end of the destination string. The maximum number of characters in the structure's string buffer is NTSTRSAFE_UNICODE_STRING_MAX_CCH.
cchToAppend
The maximum number of characters to append to the string that the DestinationString parameter describes.

Return Value

RtlUnicodeStringCchCatN returns one of the following NTSTATUS values.

Return valueMeaning
STATUS_SUCCESSThis success status means that source data was present, the strings were concatenated without truncation, and the resultant destination buffer is null-terminated.
STATUS_BUFFER_OVERFLOWThis warning status means that the concatenated operation did not complete because of insufficient buffer space. The destination buffer contains a truncated, null-terminated version of the intended result.
STATUS_INVALID_PARAMETERThis error status means that the function received an invalid input parameter. For more information, see the following list.

RtlUnicodeStringCchCatN 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 cchToAppend parameter's value is greater than NTSTRSAFE_UNICODE_STRING_MAX_CCH.

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

Comments

The RtlUnicodeStringCchCatN function uses the destination buffer's size to ensure that the concatenation 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 RtlUnicodeStringCchCatNEx function.

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

Requirements

IRQL: PASSIVE_LEVEL

Headers: Declared in Ntstrsafe.h. Include Ntstrsafe.h. Link to Ntstrsafe.lib.

See Also

RtlUnicodeStringCbCatN, RtlUnicodeStringCchCatNEx, UNICODE_STRING


Send feedback on this topic
Built on May 20, 2009
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker