RtlUnicodeStringValidateEx - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTSTRSAFE_H_INCLUDED_
#ifndef NTSTRSAFE_LIB_IMPL
#ifndef NTSTRSAFE_NO_UNICODE_STRING_FUNCTIONS

/*++

  NTSTATUS
  RtlUnicodeStringValidateEx(
  _In_ PCUNICODE_STRING    SourceString     OPTIONAL,
  _In_ DWORD               dwFlags
  );

  Routine Description:

  In addition to functionality provided by RtlUnicodeStringValidate, this routine
  includes the flags parameter allows additional controls.

  This function returns an NTSTATUS value.  It returns STATUS_SUCCESS if the
  counted unicode string is valid.

Arguments:

SourceString   - pointer to the counted unicode string to be checked

dwFlags        - controls some details of the validation:

STRSAFE_IGNORE_NULLS
allows SourceString to be NULL (will return STATUS_SUCCESS for this case).

Return Value:

STATUS_SUCCESS -   SourceString is a valid counted unicode string

failure        -   the operation did not succeed

STATUS_INVALID_PARAMETER
-   this return value is an indication that the source string
is not a valid counted unicode string given the flags passed.

It is strongly recommended to use the NT_SUCCESS() macro to test the
return value of this function.

--*/

NTSTRSAFEDDI
RtlUnicodeStringValidateEx(
        _In_ PCUNICODE_STRING SourceString,
        _In_ DWORD dwFlags)
{
    NTSTATUS status;

    if (dwFlags & (~STRSAFE_UNICODE_STRING_VALID_FLAGS))
    {
        status = STATUS_INVALID_PARAMETER;
    }
    else
    {
        status = RtlUnicodeStringValidateWorker(SourceString, NTSTRSAFE_UNICODE_STRING_MAX_CCH, dwFlags);
    }

    return status;
}

#endif
#endif
#endif

View code on GitHub
// ntstrsafe.h

NTSTRSAFEDDI RtlUnicodeStringValidateEx(
  [in] PCUNICODE_STRING SourceString,
  [in] DWORD            dwFlags
);
View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nf-ntstrsafe-rtlunicodestringvalidateex)

RtlUnicodeStringValidateEx function

Description

The RtlUnicodeStringValidateEx function validates the contents of a UNICODE_STRING structure.

Parameters

SourceString [in]

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.

dwFlags [in]

The following flag is defined:

STRSAFE_IGNORE_NULLS

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
STATUS_SUCCESS This success status means that the function completed successfully.
STATUS_INVALID_PARAMETER 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:

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

Remarks

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.

See also

RtlUnicodeStringValidate

UNICODE_STRING