DmrValidateDeviceScope

NTSTATUS __stdcall DmrValidateDeviceScope(UINT64 a1, UINT64 a2){
  NTSTATUS v2; 
  unsigned __int8 v5; 
  UINT64 i; 
  _BYTE *NextDrhdDeviceScope; 
  INT64 j; 
  UINT64 k; 
  UINT64 m; 
  char v11; 
  INT64 v12; 
  INT64 v13; 
  INT64 v14; 
  INT64 v15; 
  UINT64 NextRemappingStructure; 
  UINT64 v17; 

  v2 = 0;
  if( *(_WORD *)a2 )
    return -1073741823;
  v5 = *(_BYTE *)(a2 + 4);
  if( (v5 & 1) != 0 )
  {
    for( i = 0i64; ; i = (UINT64)NextDrhdDeviceScope )
    {
      NextDrhdDeviceScope = (_BYTE *)DmrGetNextDrhdDeviceScope(a2, i);
      if( !NextDrhdDeviceScope )
        break;
      if( (unsigned __int8)(*NextDrhdDeviceScope - 1) <= 1u )
        return -1073741823;
    }
  }
  for( j = 0i64; ; j = v17 )
  {
    NextRemappingStructure = DmrGetNextRemappingStructure(a1, j);
    v17 = NextRemappingStructure;
    if( !NextRemappingStructure )
      break;
    if( !*(_WORD *)NextRemappingStructure
      && NextRemappingStructure != a2
      && *(_WORD *)(NextRemappingStructure + 6) == *(_WORD *)(a2 + 6) )
    {
      if( (v5 & *(_BYTE *)(NextRemappingStructure + 4) & 1) != 0 )
        return -1073741823;
      for( k = 0i64; ; k = v15 )
      {
        v15 = DmrGetNextDrhdDeviceScope(a2, k);
        if( !v15 )
          break;
        for( m = 0i64; ; m = v14 )
        {
          v12 = DmrGetNextDrhdDeviceScope(v17, m);
          v14 = v12;
          if( !v12 )
            break;
          DmrCheckPathMatch(v15, v12, v13);
          if( v11 )
            return -1073741823;
        }
      }
    }
  }
  return v2;
}

Referenced by:

HalpIvtProcessDrhdEntry