RtlUnalignedStringCchLengthW - 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_CCH_FUNCTIONS
/*++
  NTSTATUS
  RtlUnalignedStringCchLength(
  _In_ LPCUTSTR    psz,
  _In_ _In_range_(1, NTSTRSAFE_MAX_CCH) size_t  cchMax,
  _Out_opt_ _Deref_out_range_(<, cchMax) size_t*     pcchLength  OPTIONAL
  );
  Routine Description:
  This routine is a version of RtlStringCchLength that accepts an unaligned string pointer.
  This function returns an NTSTATUS value, and not a pointer.  It returns
  STATUS_SUCCESS if the string is non-null and the length including the null
  terminator is less than or equal to cchMax characters.
Arguments:
psz         -   string to check the length of
cchMax      -   maximum number of characters including the null terminator
that psz is allowed to contain
pcch        -   if the function succeeds and pcch is non-null, the current length
in characters of psz excluding the null terminator will be returned.
This out parameter is equivalent to the return value of strlen(psz)
Notes:
psz can be null but the function will fail
cchMax should be greater than zero or the function will fail
Return Value:
STATUS_SUCCESS -   psz is non-null and the length including the null
terminator is less than or equal to cchMax characters
failure        -   you can use the macro NTSTATUS_CODE() to get a win32
error code for all hresult failure cases
It is strongly recommended to use the NT_SUCCESS() macro to test the
return value of this function.
--*/
#ifdef ALIGNMENT_MACHINE

_Must_inspect_result_
NTSTRSAFEDDI
    RtlUnalignedStringCchLengthW(
            _In_reads_or_z_(cchMax) STRSAFE_PCUNZWCH psz,
            _In_ _In_range_(1, NTSTRSAFE_MAX_CCH) size_t cchMax,
            _Out_opt_ _Deref_out_range_(<, cchMax) size_t* pcchLength)
{
    NTSTATUS status;

    if ((psz == NULL) || (cchMax > NTSTRSAFE_MAX_CCH))
    {
        status = STATUS_INVALID_PARAMETER;
    }
    else
    {
        status = RtlUnalignedStringLengthWorkerW(psz, cchMax, pcchLength);
    }

    if (!NT_SUCCESS(status) && pcchLength)
    {
        *pcchLength = 0;
    }

    return status;
}

#endif
#endif
#endif
#endif

View code on GitHub
#ifndef _NTSTRSAFE_H_INCLUDED_
#ifndef NTSTRSAFE_LIB_IMPL
#ifndef NTSTRSAFE_NO_CCH_FUNCTIONS
/*++
  NTSTATUS
  RtlUnalignedStringCchLength(
  _In_ LPCUTSTR    psz,
  _In_ _In_range_(1, NTSTRSAFE_MAX_CCH) size_t  cchMax,
  _Out_opt_ _Deref_out_range_(<, cchMax) size_t*     pcchLength  OPTIONAL
  );
  Routine Description:
  This routine is a version of RtlStringCchLength that accepts an unaligned string pointer.
  This function returns an NTSTATUS value, and not a pointer.  It returns
  STATUS_SUCCESS if the string is non-null and the length including the null
  terminator is less than or equal to cchMax characters.
Arguments:
psz         -   string to check the length of
cchMax      -   maximum number of characters including the null terminator
that psz is allowed to contain
pcch        -   if the function succeeds and pcch is non-null, the current length
in characters of psz excluding the null terminator will be returned.
This out parameter is equivalent to the return value of strlen(psz)
Notes:
psz can be null but the function will fail
cchMax should be greater than zero or the function will fail
Return Value:
STATUS_SUCCESS -   psz is non-null and the length including the null
terminator is less than or equal to cchMax characters
failure        -   you can use the macro NTSTATUS_CODE() to get a win32
error code for all hresult failure cases
It is strongly recommended to use the NT_SUCCESS() macro to test the
return value of this function.
--*/
#ifdef ALIGNMENT_MACHINE
// ...
#else

#define RtlUnalignedStringCchLengthW   RtlStringCchLengthW

#endif
#endif
#endif
#endif

View code on GitHub

No description available.