AslPathCombine

__int64 __fastcall AslPathCombine(NTSTRSAFE_PCWSTR pszSrc, __int64 a2, wchar_t *a3, size_t a4){
  NTSTATUS v8; 
  const wchar_t *v9; 
  WCHAR *v10; 
  WCHAR *v11; 
  UINT64 v12; 
  WCHAR *v13; 
  unsigned int v14; 
  unsigned int v15; 
  __int64 pcchLength[7]; 
  size_t v17; 
  pcchLength[0] = 0i64;
  v17 = 0i64;
  if( !a4 )
    return 3221225507i64;
  v8 = RtlStringCchLengthW(pszSrc, 0x7FFFFFFFui64, (SIZE_T *)pcchLength);
  if( v8 < 0 )
    goto LABEL_23;
  v8 = RtlStringCchLengthW(v9, 0x7FFFFFFFui64, &v17);
  if( v8 < 0 )
    goto LABEL_23;
  if( pcchLength[0] )
  {
    v11 = (WCHAR *)pszSrc;
    v12 = a4;
    if( v17 )
    {
      v13 = v10 + 1;
      v14 = (pszSrc[pcchLength[0] - 1] == 92) + 1;
      if( *v10 != 92 )
        v14 = pszSrc[pcchLength[0] - 1] == 92;
      if( v14 <= 1 )
        v13 = v10;
      v8 = RtlStringCchCopyW(a3, a4, (PWCHAR)pszSrc);
      if( v8 < 0 )
        goto LABEL_23;
      v15 = v14 - 1;
      if( v14 <= 1 )
        v15 = v14;
      if( !v15 )
      {
        v8 = RtlStringCchCatW(a3, a4, (PWCHAR)L"\\");
        if( v8 < 0 )
          goto LABEL_23;
      }
      v8 = RtlStringCchCatW(a3, a4, v13);
      if( v8 < 0 )
        goto LABEL_23;
      v8 = 0;
LABEL_22:
      if( v8 >= 0 )
        return(unsigned int)v8;
LABEL_23:
      AslLogCallPrintf(1ui64, "AslPathCombine", 0x56Cui64, "An RtlString API failed [%x]", v8);
      return(unsigned int)v8;
    }
LABEL_9:
    v8 = RtlStringCchCopyW(a3, v12, v11);
    goto LABEL_22;
  }
  if( v17 )
  {
    v11 = v10;
    v12 = a4;
    goto LABEL_9;
  }
  *a3 = 0;
  return 0;
}

Referenced by:

AslEnvGetSysNativeDirPathForGuestBuf
AslEnvGetSystem32DirPathBuf
SdbpGetPathAppPatch
SdbpGetPathAppPatchPreRS3
SdbpGetPathAppraiser
SdbpGetPathCustomSdb
SdbpGetPathCustomSdbPreRS3