RtlUnicodeStringPrintf function (ntstrsafe.h)

The RtlUnicodeStringPrintf function creates a text string, with formatting that is based on supplied formatting information, and stores the string in a UNICODE_STRING structure.

Syntax

NTSTRSAFEDDI RtlUnicodeStringPrintf(
  [out] PUNICODE_STRING  DestinationString,
  [in]  NTSTRSAFE_PCWSTR pszFormat,
        ...              
);

Parameters

[out] DestinationString

A pointer to a UNICODE_STRING structure that receives a formatted string. RtlUnicodeStringPrintf creates this string from the formatting string that pszFormat specifies and the function's argument list. The maximum number of characters in the string is NTSTRSAFE_UNICODE_STRING_MAX_CCH.

[in] pszFormat

A pointer to a null-terminated text string that contains printf-styled formatting directives.

...

Optional. A list of arguments that the function interprets, based on formatting directives that the pszFormat string contains.

Return value

RtlUnicodeStringPrintf returns one of the following NTSTATUS values.

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

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

  • The contents of the UNICODE_STRING structure that the DestinationString parameter points to are invalid.
  • The destination buffer is already full.
  • A NULL pointer is present.
  • 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 RtlUnicodeStringPrintf function uses the destination buffer's size to ensure that the string formatting operation does not write past the end of the buffer. The function does not terminate the resultant string with a null character.

If the format string and destination string overlap, the behavior of the function is undefined.

The pszFormat and DestinationString pointers cannot be NULL. If you need to handle NULL pointer values, use the RtlUnicodeStringPrintfEx function.

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

Requirements

Requirement Value
Minimum supported client Available in Windows XP with Service Pack 1 (SP1) and later versions of Windows.
Target Platform Desktop
Header ntstrsafe.h (include Ntstrsafe.h)
Library Ntstrsafe.lib
IRQL Any if strings being manipulated are always resident in memory, otherwise PASSIVE_LEVEL

See also

RtlUnicodeStringPrintfEx

RtlUnicodeStringVPrintf

RtlUnicodeStringVPrintfEx

UNICODE_STRING