RtlStringCchPrintfExW

NTSTATUS __stdcall RtlStringCchPrintfExW(
        WCHAR *pszDest,
        UINT64 cchDest,
        WCHAR **ppszDestEnd,
        UINT64 *pcchRemaining,
        UINT64 dwFlags,
        WCHAR *pszFormat){
  NTSTATUS v9; 
  WCHAR *v10; 
  UINT64 v11; 
  WCHAR *v12; 
  NTSTATUS v13; 
  UINT64 v14; 
  UINT64 pcchRemaininga; 
  size_t pcchNewDestLength[2]; 
  char argList; 

  v9 = 0;
  if( (dwFlags & 0x100) != 0 )
  {
    if( !pszDest && cchDest || cchDest > 0x7FFFFFFF )
      v9 = -1073741811;
  }
  else if( cchDest - 1 > 0x7FFFFFFE )
  {
    v9 = -1073741811;
  }
  if( v9 < 0 )
  {
    if( cchDest )
      *pszDest = 0;
  }
  else
  {
    pcchRemaininga = (UINT64)pszDest;
    v10 = pszDest;
    *(_QWORD *)pcchNewDestLength = cchDest;
    v11 = cchDest;
    if( (dwFlags & 0x100) != 0 )
    {
      v12 = (WCHAR *)&::ppszDestEnd;
      if( pszFormat )
        v12 = pszFormat;
    }
    else
    {
      v12 = pszFormat;
    }
    v9 = 0;
    if( (dwFlags & 0xFFFFE000) != 0 )
    {
      v9 = -1073741811;
      if( cchDest )
        *pszDest = 0;
    }
    else if( cchDest )
    {
      *(_QWORD *)pcchNewDestLength = 0i64;
      v13 = RtlStringVPrintfWorkerW(
              (_NTSTRSAFE_PWSTR)pszDest,
              cchDest,
              pcchNewDestLength,
              (_NTSTRSAFE_PCWSTR)v12,
              &argList);
      v14 = *(_QWORD *)pcchNewDestLength;
      v9 = v13;
      v11 = cchDest - *(_QWORD *)pcchNewDestLength;
      *(_QWORD *)pcchNewDestLength = cchDest - *(_QWORD *)pcchNewDestLength;
      v10 = &pszDest[v14];
      pcchRemaininga = (UINT64)v10;
      if( v13 >= 0 )
      {
        if( (dwFlags & 0x200) != 0 && v11 > 1 )
          RtlStringExHandleFillBehindNullW((_DWORD)pszDest + 2 * v14, 2 * v11, dwFlags);
        goto LABEL_11;
      }
    }
    else
    {
      if( !*v12 )
      {
LABEL_11:
        if( ppszDestEnd )
          *ppszDestEnd = v10;
        if( pcchRemaining )
          *pcchRemaining = v11;
        return v9;
      }
      v9 = pszDest != 0i64 ? -2147483643 : -1073741811;
    }
    if( (dwFlags & 0x1C00) != 0 && cchDest )
    {
      StringExHandleOtherFlagsW(pszDest, 2 * cchDest, ppszDestEnd, &pcchRemaininga, (UINT64)pcchNewDestLength);
      v10 = (WCHAR *)pcchRemaininga;
      v11 = *(_QWORD *)pcchNewDestLength;
    }
    if( (int)(v9 + 0x80000000) < 0 || v9 == -2147483643 )
      goto LABEL_11;
  }
  return v9;
}

Referenced by:

CmBuildDevicePanelId
CmGetCommonClassRegKeyPath
CmGetDeviceContainerRegKeyPath
CmGetDeviceControlKeyPath
CmGetDeviceHardwareKeyPath
CmGetDeviceInstanceKeyPath
CmGetDeviceInterfaceRegKeyPath
CmGetDeviceLogConfKeyPath
CmGetDevicePanelRegKeyPath
CmGetDeviceSoftwareKey
CmGetDeviceSoftwareKeyPath
DrvDbBuildDeviceIdDriverInfMatch
DrvDbCreateDatabaseNode
IoReportDetectedDevice
IoReportRootDevice
IopCreateLegacyDeviceIds
IopInitializeBootDrivers
PiCMGenerateDeviceInstance
PiFindDevInstMatch
PiProcessDriverInstance
PiRearrangeDeviceInstances
PipMakeGloballyUniqueId
PnpDeletePropertyWorker
PnpDriverLoadingFailed
PnpGetGenericStoreProperty
PnpGetGenericStorePropertyLocales
PnpOpenPropertiesKey
PnpSetPropertyWorker
PnpStringFromGuid
PopDiagTraceProcessorThrottleDurationPerfTrack
PopDiagTraceProcessorThrottlePerfTrack
RtlFormatMessageEx