ArbQueryConflict

__int64 __fastcall ArbQueryConflict(__int64 a1, __int64 a2){
  unsigned int v4; 
  UINT8 *PoolWithTag; 
  __int64 v6; 
  __int64 v7; 
  struct _RTL_RANGE_LIST *v8; 
  struct _RTL_RANGE_LIST *v9; 
  int v10; 
  PDEVICE_OBJECT v11; 
  NTSTATUS DeviceProperty; 
  int v13; 
  NTSTATUS v14; 
  int v15; 
  unsigned __int8(__fastcall *v16)(__int64, INT64 *); 
  UINT8 *v17; 
  __int64 v18; 
  __int64 v19; 
  __int64 v21; 
  __int64 v22; 
  ULONG ResultLength; 
  __int64 v24; 
  INT64 Minimum; 
  unsigned __int64 Maximum; 
  unsigned __int64 v27; 
  unsigned __int64 v28; 
  INT64 *v29; 
  _ARBITER_ALTERNATIVE *v30; 
  __int64 v31; 
  _ARBITER_ALTERNATIVE *v32; 
  __int64 v33; 
  PVOID v34; 
  INT64 result[5]; 
  int v36; 
  int PropertyBuffer; 
  int v38[8]; 
  _ARBITER_ALTERNATIVE v39; 
  memset((INT64)result, 0i64);
  memset((INT64)&v39, 0i64);
  v21 = 0i64;
  v4 = 0;
  ResultLength = 0;
  PoolWithTag = 0i64;
  LODWORD(v6) = 10;
  memset((INT64)&Minimum, 0i64);
  v7 = *(_QWORD *)(a1 + 336);
  v8 = *(struct _RTL_RANGE_LIST **)(a1 + 40);
  v22 = *(_QWORD *)(a1 + 328);
  *(_QWORD *)(a1 + 336) = ArbpQueryConflictCallback;
  v9 = *(struct _RTL_RANGE_LIST **)(a1 + 48);
  *(_QWORD *)(a1 + 328) = &v21;
  v24 = v7;
  v10 = RtlCopyRangeList(v9, v8);
  if( v10 < 0 )
    goto LABEL_18;
  v10 = ArbpBuildAlternative((_ARBITER_INSTANCE *)a1, *(_IO_RESOURCE_DESCRIPTOR **)(a2 + 8), &v39);
  if( v10 < 0 )
    goto LABEL_18;
  Maximum = v39.Maximum;
  v28 = v39.Maximum;
  Minimum = v39.Minimum;
  v30 = &v39;
  v32 = &v39;
  v29 = result;
  v27 = v39.Minimum;
  v11 = *(PDEVICE_OBJECT *)a2;
  v31 = 1i64;
  LOWORD(v34) = 0;
  *(_DWORD *)((char *)&v34 + 2) = 0;
  HIWORD(v34) = 0;
  v33 = 4i64;
  v36 = 4;
  result[4] = (INT64)v11;
  DeviceProperty = IoGetDeviceProperty(v11, DevicePropertyLegacyBusType, 4u, &PropertyBuffer, &ResultLength);
  v13 = PropertyBuffer;
  if( DeviceProperty < 0 )
    v13 = 1;
  PropertyBuffer = v13;
  v14 = IoGetDeviceProperty(*(PDEVICE_OBJECT *)a2, DevicePropertyBusNumber, 4u, v38, &ResultLength);
  v15 = v38[0];
  if( v14 < 0 )
    v15 = 0;
  v38[0] = v15;
  PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, 0xF0ui64, 0x43627241ui64);
  if( !PoolWithTag )
  {
    v10 = -1073741670;
LABEL_18:
    v19 = v22;
    goto LABEL_19;
  }
  v10 = (*(__int64(__fastcall **)(__int64, INT64 *))(a1 + 224))(a1, &Minimum);
  if( v10 < 0 )
    goto LABEL_18;
  RtlDeleteOwnersRanges(*(PRTL_RANGE_LIST *)(a1 + 48), (PVOID)v29[4]);
  while( 1 )
  {
    v27 = Minimum;
    v10 = 0;
    v28 = Maximum;
    v16 = *(unsigned __int8(__fastcall **)(__int64, INT64 *))(a1 + 248);
    v21 = 0i64;
    if( v16(a1, &Minimum) )
      break;
    if( v4 == (_DWORD)v6 )
    {
      v6 = (unsigned int)(v6 + 5);
      v17 = PoolWithTag;
      PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, 24 * v6, 0x43627241ui64);
      if( !PoolWithTag )
      {
        v10 = -1073741670;
        PoolWithTag = v17;
LABEL_17:
        v7 = v24;
        goto LABEL_18;
      }
      memmove(PoolWithTag, v17, 24i64 * v4);
      ExFreePoolWithTag(v17, 0);
    }
    v18 = v4++;
    if( !v21 )
    {
      *(_QWORD *)&PoolWithTag[24 * v18 + 16] = -1i64;
      *(_QWORD *)&PoolWithTag[24 * v18] = 0i64;
      *(_QWORD *)&PoolWithTag[24 * v18 + 8] = 0i64;
      break;
    }
    *(_QWORD *)&PoolWithTag[24 * v18] = *(_QWORD *)(v21 + 24);
    *(_QWORD *)&PoolWithTag[24 * v18 + 8] = *(_QWORD *)v21;
    *(_QWORD *)&PoolWithTag[24 * v18 + 16] = *(_QWORD *)(v21 + 8);
    v10 = RtlDeleteOwnersRanges(*(PRTL_RANGE_LIST *)(a1 + 48), *(PVOID *)(v21 + 24));
    if( v10 < 0 )
      goto LABEL_17;
  }
  RtlFreeRangeList(*(_QWORD *)(a1 + 48));
  v7 = v24;
  v19 = v22;
  *(_QWORD *)(a1 + 336) = v24;
  *(_QWORD *)(a1 + 328) = v19;
  **(_QWORD **)(a2 + 24) = PoolWithTag;
  **(_DWORD **)(a2 + 16) = v4;
LABEL_19:
  if( (v33 & 0x10) != 0 )
  {
    ExFreePoolWithTag(v34, 0);
    LOWORD(v33) = v33 & 0xFFEF;
  }
  if( v10 < 0 )
  {
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0);
    RtlFreeRangeList(*(_QWORD *)(a1 + 48));
    *(_QWORD *)(a1 + 336) = v7;
    *(_QWORD *)(a1 + 328) = v19;
    **(_QWORD **)(a2 + 24) = 0i64;
  }
  return(unsigned int)v10;
}

Referenced by:

IopMemQueryConflict