RtlUnalignedStringCchLengthW function

The RtlUnalignedStringCchLengthW function is a version of the RtlStringCchLength function that accepts an unaligned pointer to a string of Unicode characters.

Syntax

NTSTRSAFEDDI RtlUnalignedStringCchLengthW(
  STRSAFE_PCUNZWCH psz,
  size_t           cchMax,
  size_t           *pcchLength
);

Parameters

psz

Supplies a pointer to a buffer that contains a null-terminated string whose length RtlUnalignedStringCchLengthW will check.

cchMax

Supplies the maximum number of characters that are allowed in the buffer that psz points to, including the terminating NULL character. This value cannot exceed NTSTRSAFE_MAX_CCH.

pcchLength

Optional. If the caller supplies a non-NULL address pointer, the function loads the address with the length, in characters, of the string that is contained in the buffer that psz points to. The length does not include the string's terminating NULL character.

Return Value

RtlUnalignedStringCchLengthW returns one of the following NTSTATUS values.

Return code Description
STATUS_SUCCESS
This success status means the string that the psz parameter was not NULL, and the length of the string (including the terminating NULL character) was less than or equal to cchMax characters.
STATUS_INVALID_PARAMETER
This error status means the value in psz is NULL, cchMax is larger than NTSTRSAFE_MAX_CCH, or psz is longer than cchMax.

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

Remarks

The RtlUnalignedStringCchLengthW function is available for processor architectures, such as Itanium-based and x64-based, that cause alignment exceptions when software attempts to access unaligned data. On those processors, you can use RtlUnalignedStringCchLengthW instead of RtlStringCchLength to avoid alignment exceptions. (For processors that do not cause alignment exceptions, RtlUnalignedStringCchLengthW is equivalent to RtlStringCchLength.)

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

Requirements

   
Windows version 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
IRQL PASSIVE_LEVEL

See Also

RtlStringCchLength