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

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

The RtlUnicodeStringCatStringEx function concatenates two strings when the destination string is contained in a UNICODE_STRING structure.

NTSTATUS
  RtlUnicodeStringCatStringEx(
    IN OUT PUNICODE_STRING  DestinationString OPTIONAL,
    IN LPCTSTR  pszSrc OPTIONAL,
    OUT PUNICODE_STRING  RemainingString OPTIONAL,
    IN DWORD  dwFlags
    );

Parameters

DestinationString
Optional. 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 (excluding the terminating NULL) is added to the end of the destination string. The maximum number of bytes in the structure's string buffer is NTSTRSAFE_UNICODE_STRING_MAX_CCH * sizeof(WCHAR). DestinationString can be NULL, but only if STRSAFE_IGNORE_NULLS is set in dwFlags.
pszSrc
Optional. A caller-supplied pointer to a NULL-terminated source string. This string will be concatenated to the end of the string that is contained in the UNICODE_STRING structure that DestinationString specifies. pszSrc can be NULL, but only if STRSAFE_IGNORE_NULLS is set in dwFlags.
RemainingString
Optional. If the caller supplies a non-NULL pointer to a UNICODE_STRING structure, the function sets this structure's Buffer member to the end of the concatenated string, sets the structure's Length member to zero, and sets the structure's MaximumLength member to the number of bytes that are remaining in the destination buffer. This pointer can be NULL, but only if STRSAFE_IGNORE_NULLS is set in dwFlags.
dwFlags
One or more flags and, optionally, a fill byte. The flags are defined as follows:
STRSAFE_FILL_BEHIND_NULL
If this flag is set and the function succeeds, the low byte of dwFlags is used to fill the portion of the destination buffer that follows the terminating NULL character.
STRSAFE_IGNORE_NULLS
If this flag is set, the source or destination pointer, or both, can be NULL. RtlUnicodeStringCatStringEx treats NULL source buffer pointers like empty strings (TEXT("")), which can be copied. NULL destination buffer pointers cannot receive nonempty strings.
STRSAFE_FILL_ON_FAILURE
If this flag is set and the function fails, the low byte of dwFlags is used to fill the entire destination buffer, and the buffer is null-terminated. This operation overwrites any preexisting buffer contents.
STRSAFE_NULL_ON_FAILURE
If this flag is set and the function fails, the destination buffer is set to an empty string (TEXT("")). This operation overwrites any preexisting buffer contents.
STRSAFE_NO_TRUNCATION
If this flag is set and the function returns STATUS_BUFFER_OVERFLOW, the contents of the destination buffer are not modified.

Return Value

RtlUnicodeStringCatStringEx 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 copy operation did not complete because of insufficient space in the destination buffer. If STRSAFE_NO_TRUNCATION is set in dwFlags, the destination buffer is not modified. If the flag is not set, the destination buffer contains a truncated 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.

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

  • The contents of a UNICODE_STRING structure are invalid.
  • An invalid flag is specified in dwFlags.
  • The destination buffer is already full.
  • A buffer pointer is NULL and the STRSAFE_IGNORE_NULLS flag is not specified in dwFlags.
  • The destination buffer pointer is NULL, but the buffer size is not zero.
  • The destination buffer pointer is NULL, or its length is zero, but a nonzero length source string is present.

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

Comments

The RtlUnicodeStringCatStringEx 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.

RtlUnicodeStringCatStringEx adds to the functionality of the RtlUnicodeStringCatString function by returning a UNICODE_STRING structure that identifies the end of the destination string and the number of bytes that are left unused in that string. You can pass flags to RtlUnicodeStringCatStringEx for additional control.

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

The pszSrc and DestinationString pointers cannot be NULL unless the STRSAFE_IGNORE_NULLS flag is set in dwFlags. If STRSAFE_IGNORE_NULLS is set, one or both of these pointers can be NULL. If the DestinationString pointer is NULL, the pszSrc pointer must either be NULL or point to an empty string.

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

RtlUnicodeStringCatString, 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