#ifndef _NTSTRSAFE_H_INCLUDED_
#ifndef NTSTRSAFE_LIB_IMPL
#ifndef NTSTRSAFE_NO_CB_FUNCTIONS
_Must_inspect_result_
NTSTRSAFEDDI
RtlStringCbLengthA(
_In_reads_or_z_(cbMax) STRSAFE_PCNZCH psz,
_In_ _In_range_(1, NTSTRSAFE_MAX_CCH * sizeof(char)) size_t cbMax,
_Out_opt_ _Deref_out_range_(<, cbMax) size_t* pcbLength)
{
NTSTATUS status;
size_t cchMax = cbMax / sizeof(char);
size_t cchLength = 0;
if ((psz == NULL) || (cchMax > NTSTRSAFE_MAX_CCH))
{
status = STATUS_INVALID_PARAMETER;
}
else
{
status = RtlStringLengthWorkerA(psz, cchMax, &cchLength);
}
if (pcbLength)
{
if (NT_SUCCESS(status))
{
// safe to multiply cchLength * sizeof(char) since cchLength < NTSTRSAFE_MAX_CCH and sizeof(char) is 1
*pcbLength = cchLength * sizeof(char);
}
else
{
*pcbLength = 0;
}
}
return status;
}
View code on GitHub
No description available.