Export (0) Print
Expand All

RtlUnicodeStringInitEx function

The RtlUnicodeStringInitEx function initializes a UNICODE_STRING structure.

Syntax


NTSTATUS RtlUnicodeStringInitEx(
  _Out_     PUNICODE_STRING  DestinationString,
  _In_opt_  NTSTRSAFE_PCWSTR pszSrc,
  _In_      DWORD            dwFlags
);

Parameters

DestinationString [out]

Optional. A pointer to a UNICODE_STRING structure to be initialized. The pszSrc pointer is copied into the DestinationString parameter's UNICODE_STRING structure. The maximum number of characters in the string that pszSrc points to is NTSTRSAFE_UNICODE_STRING_MAX_CCH. DestinationString can be NULL, but only if STRSAFE_IGNORE_NULLS is set in dwFlags.

pszSrc [in, optional]

Optional. A pointer to a null-terminated string constant. This string pointer will be copied to the Buffer member of the UNICODE_STRING structure pointed to by the DestinationString parameter. This string pointer can be NULL.

dwFlags [in]

The following flag is defined:

STRSAFE_IGNORE_NULLS

If this flag is set, the source pointer can be NULL. RtlUnicodeStringInitEx treats NULL source buffer pointers like empty strings (TEXT("")), which can be copied.

Return value

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

This error status means that the function received an invalid input parameter. For more information, see the following list.

 

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

  • The length of the string that the pszSrc parameter points to is greater than NTSTRSAFE_UNICODE_STRING_MAX_CCH characters.
  • The DestinationString pointer is NULL, but the pszSrc pointer is not NULL.

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

Remarks

The RtlUnicodeStringInitEx function does the following:

  • Sets the Length member of the UNICODE_STRING structure to the length, in bytes, of the string that the pszSrc parameter points to.

  • Sets the MaximumLength member of the UNICODE_STRING structure to the length, in bytes, of the string that the pszSrc parameter points to plus 2 bytes.

  • Sets the Buffer member of the UNICODE_STRING structure to the address that the pszSrc parameter specifies.

The DestinationString pointer cannot be NULL unless the STRSAFE_IGNORE_NULLS flag is set.

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

Requirements

Target platform

Desktop

Version

Available starting with Windows XP with Service Pack 1 (SP1).

Header

Ntstrsafe.h (include Ntstrsafe.h)

Library

Ntstrsafe.lib

IRQL

PASSIVE_LEVEL

See also

RtlUnicodeStringInit
UNICODE_STRING

 

 

Send comments about this topic to Microsoft

Show:
© 2015 Microsoft