RtlStringCbPrintfExA

INT64 __stdcall RtlStringCbPrintfExA(
        INT8 *pszDest,
        UINT64 cbDest,
        INT8 **ppszDestEnd,
        UINT64 *pcbRemaining,
        UINT64 dwFlags,
        INT8 *pszFormat){
  NTSTATUS v9; 
  INT8 *v10; 
  UINT64 v11; 
  const char *v12; 
  size_t v13; 
  UINT64 v15; 
  NTSTRSAFE_PSTR ppszDestEnda; 
  size_t pcchNewDestLength[2]; 
  char argList; 
  v9 = RtlStringExValidateDestA(pszDest, cbDest, (size_t)ppszDestEnd, dwFlags);
  if( v9 < 0 )
  {
    if( cbDest )
      *pszDest = 0;
    return(unsigned int)v9;
  }
  ppszDestEnda = pszDest;
  v10 = pszDest;
  pcchNewDestLength[0] = cbDest;
  v11 = cbDest;
  if( (dwFlags & 0x100) != 0 )
  {
    v12 = (const char *)File;
    if( pszFormat )
      v12 = pszFormat;
  }
  else
  {
    v12 = pszFormat;
  }
  v9 = 0;
  if( (dwFlags & 0xFFFFE000) == 0 )
  {
    if( cbDest )
    {
      pcchNewDestLength[0] = 0i64;
      v9 = RtlStringVPrintfWorkerA(pszDest, cbDest, pcchNewDestLength, 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(&pszDest[v13], 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(unsigned int)v9;
  }
  v9 = -1073741811;
  if( cbDest )
    *pszDest = 0;
LABEL_18:
  if( (dwFlags & 0x1C00) != 0 && cbDest )
  {
    LODWORD(v15) = dwFlags;
    RtlStringExHandleOtherFlagsA(pszDest, cbDest, 0i64, &ppszDestEnda, pcchNewDestLength, v15);
    v10 = ppszDestEnda;
    v11 = pcchNewDestLength[0];
  }
  if( (int)(v9 + 0x80000000) < 0 || v9 == -2147483643 )
    goto LABEL_23;
  return(unsigned int)v9;
}

Referenced by:

KiDisplayBlueScreen
Phase1InitializationDiscard