RtlStringCbPrintfExA

NTSTATUS __stdcall RtlStringCbPrintfExA(
        INT8 *pszDest,
        UINT64 cbDest,
        INT8 **ppszDestEnd,
        UINT64 *pcbRemaining,
        UINT64 dwFlags,
        INT8 *pszFormat){
  int v9; 
  INT8 *v10; 
  UINT64 v11; 
  INT8 *v12; 
  __int64 v13; 
  UINT64 v15; 
  CHAR *ppszDestEnda; 
  __int64 pcchNewDestLength[2]; 
  char argList; 

  v9 = RtlStringExValidateDestA(pszDest, cbDest, (const size_t)ppszDestEnd, dwFlags);
  if( v9 < 0 )
  {
    if( cbDest )
      *pszDest = 0;
    return v9;
  }
  ppszDestEnda = pszDest;
  v10 = pszDest;
  pcchNewDestLength[0] = cbDest;
  v11 = cbDest;
  if( (dwFlags & 0x100) != 0 )
  {
    v12 = (INT8 *)&File;
    if( pszFormat )
      v12 = pszFormat;
  }
  else
  {
    v12 = pszFormat;
  }
  v9 = 0;
  if( (dwFlags & 0xFFFFE000) == 0 )
  {
    if( cbDest )
    {
      pcchNewDestLength[0] = 0i64;
      v9 = RtlStringVPrintfWorkerA(
             (_NTSTRSAFE_PSTR)pszDest,
             cbDest,
             (size_t *)pcchNewDestLength,
             (_NTSTRSAFE_PCSTR)v12,
             &argList);
      v13 = pcchNewDestLength[0];
      v11 = cbDest - pcchNewDestLength[0];
      pcchNewDestLength[0] = cbDest - pcchNewDestLength[0];
      v10 = &pszDest[v13];
      ppszDestEnda = &pszDest[v13];
      if( v9 < 0 )
        goto LABEL_18;
      if( (dwFlags & 0x200) != 0 && v11 > 1 )
        RtlStringExHandleFillBehindNullA(v13 + (_DWORD)pszDest, v11, dwFlags);
    }
    else
    {
      if( !*v12 )
        goto LABEL_23;
      v9 = pszDest != 0i64 ? -2147483643 : -1073741811;
    }
    if( v9 < 0 )
      goto LABEL_18;
LABEL_23:
    if( ppszDestEnd )
      *ppszDestEnd = v10;
    if( pcbRemaining )
      *pcbRemaining = v11;
    return v9;
  }
  v9 = -1073741811;
  if( cbDest )
    *pszDest = 0;
LABEL_18:
  if( (dwFlags & 0x1C00) != 0 && cbDest )
  {
    LODWORD(v15) = dwFlags;
    RtlStringExHandleOtherFlagsA(pszDest, cbDest, 0i64, &ppszDestEnda, (UINT64 *)pcchNewDestLength, v15);
    v10 = ppszDestEnda;
    v11 = pcchNewDestLength[0];
  }
  if( (int)(v9 + 0x80000000) < 0 || v9 == -2147483643 )
    goto LABEL_23;
  return v9;
}

Referenced by:

KiDisplayBlueScreen