RtlStringCbPrintfExW

VOID RtlStringCbPrintfExW(
        WCHAR *pszDest,
        UINT64 cbDest,
        WCHAR **ppszDestEnd,
        UINT64 *pcbRemaining,
        UINT64 dwFlags,
        const WCHAR *pszFormat,
        ...){
  UINT64 v7; 
  int v10; 
  __int64 v11; 
  WCHAR *v12; 
  const WCHAR *v13; 
  NTSTATUS v14; 
  size_t v15; 
  int v16; 
  STRSAFE_LPWSTR ppszDestEnda; 
  size_t pcchNewDestLength[2]; 
  va_list va; 
  va_start(va, pszFormat);
  v7 = cbDest >> 1;
  v10 = 0;
  v11 = 3221225485i64;
  if( (dwFlags & 0x100) != 0 )
  {
    if( !pszDest && v7 || v7 > 0x7FFFFFFF )
      v10 = -1073741811;
  }
  else if( v7 - 1 > 0x7FFFFFFE )
  {
    v10 = -1073741811;
  }
  if( v10 < 0 )
  {
    if( v7 )
      *pszDest = 0;
    return;
  }
  ppszDestEnda = pszDest;
  v12 = pszDest;
  pcchNewDestLength[0] = cbDest >> 1;
  if( (dwFlags & 0x100) != 0 )
  {
    v13 = &::ppszDestEnd;
    if( pszFormat )
      v13 = pszFormat;
  }
  else
  {
    v13 = pszFormat;
  }
  if( (dwFlags & 0xFFFFE000) != 0 )
  {
    v16 = -1073741811;
    if( v7 )
      *pszDest = 0;
  }
  else
  {
    if( !v7 )
    {
      if( !*v13 )
        goto LABEL_13;
      v16 = pszDest != 0i64 ? -2147483643 : -1073741811;
LABEL_12:
      if( v16 >= 0 )
      {
LABEL_13:
        if( ppszDestEnd )
          *ppszDestEnd = v12;
        if( pcbRemaining )
          *pcbRemaining = (cbDest & 1) + 2 * v7;
        return;
      }
      goto LABEL_27;
    }
    pcchNewDestLength[0] = 0i64;
    v14 = RtlStringVPrintfWorkerW(pszDest, v7, pcchNewDestLength, v13, va);
    v15 = pcchNewDestLength[0];
    v16 = v14;
    v7 -= pcchNewDestLength[0];
    pcchNewDestLength[0] = v7;
    v12 = &pszDest[v15];
    ppszDestEnda = v12;
    if( v14 >= 0 )
    {
      if( (dwFlags & 0x200) != 0 )
        RtlStringExHandleFillBehindNullW(&pszDest[v15], (cbDest & 1) + 2 * v7, dwFlags);
      goto LABEL_12;
    }
  }
LABEL_27:
  if( (dwFlags & 0x1C00) != 0 && cbDest )
  {
    StringExHandleOtherFlagsW(pszDest, cbDest, (WCHAR **)v11, (UINT64 *)&ppszDestEnda, (UINT64)pcchNewDestLength);
    v12 = ppszDestEnda;
    v7 = pcchNewDestLength[0];
  }
  if( (int)(v16 + 0x80000000) < 0 || v16 == -2147483643 )
    goto LABEL_13;
}

Referenced by:

ConvertDevpropcompkeyToString
ConvertDevpropertyToString
EtwpQueryPsmKey
PiNormalizeDeviceText
PipCreateComputerId
RtlQueryPackageClaims
WmipGenerateBinaryMofNotification