#ifndef _NTSTRSAFE_H_INCLUDED_
_Success_(1) // always succeeds, no exit tests needed
NTSTRSAFEWORKERDDI
RtlStringExHandleOtherFlagsA(
_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest,
_In_ _In_range_(1, NTSTRSAFE_MAX_CCH * sizeof(char)) size_t cbDest,
_In_ _In_range_(0, cbDest>sizeof(char)?(cbDest / sizeof(char)) - 1:0) size_t cchOriginalDestLength,
_Outptr_result_buffer_(*pcchRemaining) NTSTRSAFE_PSTR* ppszDestEnd,
_Out_ _Deref_out_range_(0, cbDest / sizeof(char)) size_t* pcchRemaining,
_In_ DWORD dwFlags);
View code on GitHub
#ifndef _NTSTRSAFE_H_INCLUDED_
// Below here are the worker functions that actually do the work
#if defined(NTSTRSAFE_LIB_IMPL) || !defined(NTSTRSAFE_LIB)
_Success_(1) // always succeeds, no exit tests needed
NTSTRSAFEWORKERDDI
RtlStringExHandleOtherFlagsA(
_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest,
_In_ _In_range_(1, NTSTRSAFE_MAX_CCH * sizeof(char)) size_t cbDest,
_In_ _In_range_(0, cbDest>sizeof(char)?(cbDest / sizeof(char)) - 1:0) size_t cchOriginalDestLength,
_Outptr_result_buffer_(*pcchRemaining) NTSTRSAFE_PSTR* ppszDestEnd,
_Out_ _Deref_out_range_(0, cbDest / sizeof(char)) size_t* pcchRemaining,
_In_ DWORD dwFlags)
{
size_t cchDest = cbDest / sizeof(char);
_Analysis_assume_(dwFlags & (STRSAFE_NO_TRUNCATION | STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE));
if ((cchDest > 0) && (dwFlags & STRSAFE_NO_TRUNCATION))
{
char* pszOriginalDestEnd;
pszOriginalDestEnd = pszDest + cchOriginalDestLength;
*ppszDestEnd = pszOriginalDestEnd;
*pcchRemaining = cchDest - cchOriginalDestLength;
// null terminate the end of the original string
*pszOriginalDestEnd = '\0';
}
if (dwFlags & STRSAFE_FILL_ON_FAILURE)
{
memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
{
*ppszDestEnd = pszDest;
*pcchRemaining = cchDest;
_Analysis_assume_(*pszDest == '\0');
}
else if (cchDest > 0)
{
char* pszDestEnd;
pszDestEnd = pszDest + cchDest - 1;
*ppszDestEnd = pszDestEnd;
*pcchRemaining = 1;
// null terminate the end of the string
*pszDestEnd = L'\0';
}
}
if ((cchDest > 0) && (dwFlags & STRSAFE_NULL_ON_FAILURE))
{
*ppszDestEnd = pszDest;
*pcchRemaining = cchDest;
// null terminate the beginning of the string
*pszDest = '\0';
}
return STATUS_SUCCESS;
}
View code on GitHub
#ifndef _NTSTRSAFE_H_INCLUDED_
// Do not call these functions, they are worker functions for internal use within this file
#ifdef DEPRECATE_SUPPORTED
// ...
#else
#define RtlStringExHandleOtherFlagsA RtlStringExHandleOtherFlagsA_do_not_call_this_function
View code on GitHub
No description available.