AslEnvGetSystem32DirPathBuf

__int64 __fastcall AslEnvGetSystem32DirPathBuf(
        NTSTRSAFE_PWSTR pszDest,
        size_t cchDest,
        _WORD *a3,
        __int16 a4,
        __int64 a5){
  __int16 v9; 
  __int64 v10; 
  __int16 *i; 
  unsigned int v12; 
  int v14; 
  const CHAR *v15; 
  UINT64 v16; 
  wchar_t pszSrc[64]; 
  memset((INT64)pszSrc, 0i64);
  *pszDest = 0;
  if( a5 )
    v9 = *(_WORD *)a5;
  else
    v9 = a4;
  v10 = 0i64;
  for( i = word_140C04902; *(i - 1) != a4 || *i != v9; i += 8 )
  {
    if( (unsigned __int64)++v10 >= 7 )
      return(unsigned int)-1073741637;
  }
  v14 = AslPathToSystemPathBuf(pszSrc, 0x40ui64, (&off_140C04908)[2 * v10]);
  v12 = v14;
  if( v14 >= 0 )
  {
    if( a3 && *a3 )
    {
      v14 = AslPathCombine(pszSrc, (__int64)a3, pszDest, cchDest);
      v12 = v14;
      if( v14 < 0 )
      {
        v15 = "AslPathCombine failed [%x]";
        v16 = 1424i64;
        goto LABEL_12;
      }
    }
    else
    {
      v14 = RtlStringCchCopyW(pszDest, cchDest, pszSrc);
      v12 = v14;
      if( v14 < 0 )
      {
        v15 = "RtlStringCchCopyW failed [%x]";
        v16 = 1432i64;
        goto LABEL_12;
      }
    }
    return 0;
  }
  v15 = "AslPathToSystemPathBuf failed [%x]";
  v16 = 1414i64;
LABEL_12:
  AslLogCallPrintf(1ui64, "AslEnvGetSystem32DirPathBuf", v16, v15, v14);
  return v12;
}

Referenced by:

AslEnvGetSysNativeDirPathForGuestBuf
SdbpGetPathSystem