Export (0) Print
Expand All

RtlUnicodeStringPrintf function

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


NTSTATUS RtlUnicodeStringPrintf(
  _Out_ PUNICODE_STRING  DestinationString,
  _In_  NTSTRSAFE_PCWSTR pszFormat,
                         ...
);

Parameters

DestinationString [out]

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.

pszFormat [in]

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

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

RtlUnicodeStringPrintfEx
RtlUnicodeStringVPrintf
RtlUnicodeStringVPrintfEx
UNICODE_STRING

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft