AslpPathWildcardMakeLeaves

NTSTATUS __stdcall AslpPathWildcardMakeLeaves(PCWSTR SourceString){
  WCHAR v1; 
  WCHAR *v2; 
  wchar_t *Buffer; 
  unsigned __int16 v4; 
  int v5; 
  WCHAR v6; 
  int v7; 
  WCHAR *v8; 
  __int16 v9; 
  WCHAR v10; 
  _WORD *v11; 
  NTSTATUS v12; 
  struct _UNICODE_STRING v14; 
  v2 = (WCHAR *)SourceString;
  if( !SourceString || !*SourceString )
    return 0;
  v14 = 0i64;
  RtlInitUnicodeString(&v14, SourceString, v1);
  if( v14.Length < 2u || (Buffer = v14.Buffer, !*v14.Buffer) )
  {
    AslLogCallPrintf(1ui64, "AslpPathWildcardMakeLeaves", 0xBBEui64, "AslpPathGetFormatInfo failed [%x]", -1073741582);
    return 0;
  }
  v4 = v14.Length >> 1;
  if( (unsigned __int16)(v14.Length >> 1) < 8u || wcsnicmp(v14.Buffer, L"\\??\\UNC\\", 8ui64) )
  {
    if( v4 >= 4u )
    {
      if( !(unsigned int)wcsncmp(Buffer, L"\\??\\", 4ui64) )
      {
        v5 = 2;
        goto LABEL_17;
      }
      if( !(unsigned int)wcsncmp(Buffer, L"\\\\?\\", 4ui64) || !(unsigned int)wcsncmp(Buffer, L"\\\\.\\", 4ui64) )
      {
        v5 = 3;
        goto LABEL_17;
      }
    }
    if( v4 <= 2u || (v5 = 3, (unsigned int)wcsncmp(Buffer, L"\\\\", 2ui64)) )
      v5 = 0;
  }
  else
  {
    v5 = 4;
  }
LABEL_17:
  v6 = *v2;
  v7 = -v5;
  v8 = v2;
  while( v6 )
  {
    if( v6 == 92 )
    {
      if( v7 >= 0 )
        *v8 = 0;
      ++v7;
    }
    v6 = *++v8;
  }
  v8[1] = 0;
  v9 = *v2;
  if( *v2 )
  {
LABEL_25:
    if( v9 )
    {
      do
        ++v2;
      while( *v2 );
    }
    v10 = v2[1];
    if( v10 )
    {
      v11 = v2 + 1;
      while( v10 != 42 && v10 != 63 )
      {
        v10 = *++v11;
        if( !*v11 )
        {
          --v7;
          *v2 = 92;
          v9 = 92;
          if( v2[1] )
            goto LABEL_25;
          break;
        }
      }
    }
  }
  v12 = v7 + 1;
  if( v12 >= 0 )
    return v12;
  return 0;
}

Referenced by:

AslPathWildcardFindFirst