RtlUnicodeStringValidateEx function (ntstrsafe.h)

The RtlUnicodeStringValidateEx function validates the contents of a UNICODE_STRING structure.


NTSTRSAFEDDI RtlUnicodeStringValidateEx(
  [in] PCUNICODE_STRING SourceString,
  [in] DWORD            dwFlags


[in] SourceString

Optional. A pointer to a UNICODE_STRING structure to be validated. This pointer can be NULL, but only if STRSAFE_IGNORE_NULLS is set in dwFlags.

[in] dwFlags

The following flag is defined:


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

Return value

RtlUnicodeStringValidateEx returns one of the following NTSTATUS values.

Return code Description
This success status means that the function completed successfully.
This error status means that the function received an invalid input parameter. For more information, see the following list.

If STRSAFE_IGNORE_NULLS is not set in dwFlags, RtlUnicodeStringValidateEx returns the STATUS_INVALID_PARAMETER value when one of the following occurs:

  • SourceString->Length % sizeof(WCHAR) does not equal zero.
  • SourceString->MaximumLength % sizeof(WCHAR) does not equal zero.
  • SourceString->Length is greater than SourceString->MaximumLength.
  • SourceString->MaximumLength is greater than NTSTRSAFE_UNICODE_STRING_MAX_CCH * sizeof(WCHAR).
  • SourceString->Buffer equals NULL but SourceString->Length or SourceString->MaximumLength does not equal zero.
  • An invalid flag is specified for dwFlags.
For information about how to test NTSTATUS values, see Using NTSTATUS Values.


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


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

See also