ArbShareDriverExclusive

char __fastcall ArbShareDriverExclusive(__int64 a1, __int64 a2){
  __int64 v3; 
  char v4; 
  int v6; 
  int v7; 
  __int64 v8; 
  int v9; 
  int v10; 
  PRTL_RANGE v11; 
  unsigned __int64 Start; 
  unsigned __int64 v13; 
  bool v14; 
  unsigned __int8 Attributes; 
  _DEVICE_OBJECT *Owner; 
  unsigned __int8 Flags; 
  __int64 v19; 
  __int64 v20; 
  bool v21; 
  ULONG ResultLength; 
  PRTL_RANGE Range; 
  struct _RANGE_LIST_ITERATOR Iterator; 
  __int16 PropertyBuffer[8]; 
  ResultLength = 0;
  Range = 0i64;
  v3 = *(_QWORD *)(a2 + 32);
  v4 = 0;
  memset(&Iterator, 0, sizeof(Iterator));
  v6 = *(_DWORD *)(v3 + 44);
  if( (v6 & 2) != 0 )
  {
    v4 = 1;
  }
  else if( (v6 & 4) == 0
         && IoGetDeviceProperty(
              *(PDEVICE_OBJECT *)(v3 + 32),
              DevicePropertyEnumeratorName,
              0xAu,
              PropertyBuffer,
              &ResultLength) >= 0 )
  {
    v7 = wcsicmp((const wchar_t *)PropertyBuffer, L"ROOT");
    v8 = *(_QWORD *)(a2 + 32);
    v9 = *(_DWORD *)(v8 + 44);
    if( v7 )
    {
      v10 = v9 | 4;
    }
    else
    {
      v10 = v9 | 2;
      v4 = 1;
    }
    *(_DWORD *)(v8 + 44) = v10;
  }
  RtlGetFirstRange(*(_RTL_RANGE_LIST **)(a1 + 48), &Iterator, &Range);
  while( 1 )
  {
    v11 = Range;
    if( !Range )
      return 0;
    Start = Range->Start;
    v13 = *(_QWORD *)(a2 + 16);
    v14 = v13 < Range->Start;
    if( v13 > Range->Start )
    {
      if( Range->End < v13 )
        goto LABEL_11;
      v14 = v13 < Start;
    }
    if( !v14 || *(_QWORD *)(a2 + 24) >= Start )
    {
      Attributes = Range->Attributes;
      if( (Attributes & *(_BYTE *)(a2 + 67)) == 0
        && (*(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a2 + 40) + 40i64) + 2i64) == 2 || (Attributes & 2) != 0) )
      {
        Owner = (_DEVICE_OBJECT *)Range->Owner;
        if( Owner )
        {
          if( v4 )
          {
            Flags = Range->Flags;
            if( (Flags & 0x40) == 0 )
            {
              if( (Flags & 0x20) != 0
                || IoGetDeviceProperty(Owner, DevicePropertyEnumeratorName, 0xAu, PropertyBuffer, &ResultLength) < 0 )
              {
                goto LABEL_37;
              }
              if( !wcsicmp((const wchar_t *)PropertyBuffer, L"ROOT") )
              {
                v11->Flags |= 0x20u;
LABEL_37:
                *(_QWORD *)a2 = *(_QWORD *)(a2 + 16);
                *(_QWORD *)(a2 + 8) = *(_QWORD *)(a2 + 24);
                v21 = *(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a2 + 40) + 40i64) + 2i64) == 2;
                goto LABEL_39;
              }
              v11->Flags |= 0x40u;
              Owner = (_DEVICE_OBJECT *)v11->Owner;
            }
            v4 = 0;
          }
          v19 = *((_QWORD *)Owner + 3);
          if( v19 )
            break;
        }
      }
    }
LABEL_11:
    RtlGetNextRange(&Iterator, &Range, 1u);
  }
  while( 1 )
  {
    v20 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a2 + 32) + 32i64) + 24i64);
    if( v20 )
      break;
LABEL_34:
    v19 = *(_QWORD *)(v19 + 24);
    if( !v19 )
      goto LABEL_11;
  }
  while( *(_QWORD *)(v19 + 8) != *(_QWORD *)(v20 + 8) )
  {
    v20 = *(_QWORD *)(v20 + 24);
    if( !v20 )
      goto LABEL_34;
  }
  *(_QWORD *)a2 = *(_QWORD *)(a2 + 16);
  *(_QWORD *)(a2 + 8) = *(_QWORD *)(a2 + 24);
  v21 = *(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a2 + 40) + 40i64) + 2i64) == 2;
LABEL_39:
  if( v21 )
    *(_BYTE *)(a2 + 66) |= 2u;
  return 1;
}

Referenced by:

ArbFindSuitableRange