RtlStringCbPrintfExW

NTSTATUS __stdcall RtlStringCbPrintfExW(
        WCHAR *pszDest,
        UINT64 cbDest,
        WCHAR **ppszDestEnd,
        UINT64 *pcbRemaining,
        UINT64 dwFlags,
        WCHAR *pszFormat){
  UINT64 v7; 
  NTSTATUS v10; 
  __int64 v11; 
  WCHAR *v12; 
  WCHAR *v13; 
  NTSTATUS v14; 
  UINT64 v15; 
  UINT64 pcchRemaining; 
  size_t pcchNewDestLength[2]; 
  char argList; 

  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 v10;
  }
  pcchRemaining = (UINT64)pszDest;
  v12 = pszDest;
  *(_QWORD *)pcchNewDestLength = cbDest >> 1;
  if( (dwFlags & 0x100) != 0 )
  {
    v13 = (WCHAR *)&::ppszDestEnd;
    if( pszFormat )
      v13 = pszFormat;
  }
  else
  {
    v13 = pszFormat;
  }
  v10 = 0;
  if( (dwFlags & 0xFFFFE000) != 0 )
  {
    v10 = -1073741811;
    if( v7 )
      *pszDest = 0;
  }
  else
  {
    if( !v7 )
    {
      if( !*v13 )
        goto LABEL_13;
      v10 = pszDest != 0i64 ? -2147483643 : -1073741811;
LABEL_12:
      if( v10 >= 0 )
      {
LABEL_13:
        if( ppszDestEnd )
          *ppszDestEnd = v12;
        if( pcbRemaining )
          *pcbRemaining = (cbDest & 1) + 2 * v7;
        return v10;
      }
      goto LABEL_27;
    }
    *(_QWORD *)pcchNewDestLength = 0i64;
    v14 = RtlStringVPrintfWorkerW((_NTSTRSAFE_PWSTR)pszDest, v7, pcchNewDestLength, (_NTSTRSAFE_PCWSTR)v13, &argList);
    v15 = *(_QWORD *)pcchNewDestLength;
    v10 = v14;
    v7 -= *(_QWORD *)pcchNewDestLength;
    *(_QWORD *)pcchNewDestLength = v7;
    v12 = &pszDest[v15];
    pcchRemaining = (UINT64)v12;
    if( v14 >= 0 )
    {
      if( (dwFlags & 0x200) != 0 )
        RtlStringExHandleFillBehindNullW((_DWORD)pszDest + 2 * v15, (cbDest & 1) + 2 * v7, dwFlags);
      goto LABEL_12;
    }
  }
LABEL_27:
  if( (dwFlags & 0x1C00) != 0 && cbDest )
  {
    StringExHandleOtherFlagsW(pszDest, cbDest, (WCHAR **)v11, &pcchRemaining, (UINT64)pcchNewDestLength);
    v12 = (WCHAR *)pcchRemaining;
    v7 = *(_QWORD *)pcchNewDestLength;
  }
  if( (int)(v10 + 0x80000000) < 0 || v10 == -2147483643 )
    goto LABEL_13;
  return v10;
}

Referenced by:

ConvertDevpropcompkeyToString
ConvertDevpropertyToString
EtwpQueryPsmKey
PipCreateComputerId
RtlQueryPackageClaims
WmipGenerateBinaryMofNotification