PiRestartRemovalRelations

BOOL __fastcall PiRestartRemovalRelations(INT64 a1, UINT64 **rdx0, DEVICE_OBJECT *a3){
  BOOL result; 
  const WCHAR *v7; 
  INT64 v8; 
  DEVICE_OBJECT *v9; 
  _DWORD *v10; 
  UINT64 DeviceState; 
  int a2[2]; 
  void *DeviceObject[3]; 
  int a4; 
  DeviceObject[0] = 0i64;
  a4 = 0;
  a2[1] = 0;
  a2[0] = 1;
  while( 1 )
  {
    LOBYTE(result) = IopEnumerateRelations((unsigned int **)rdx0, a2, DeviceObject, &a4, 0i64);
    if( !result )
      return result;
    v9 = (DEVICE_OBJECT *)DeviceObject[0];
    if( DeviceObject[0] )
      v10 = *(_DWORD **)(*((_QWORD *)DeviceObject[0] + 39) + 40i64);
    else
      v10 = 0i64;
    if( *(_DWORD *)(a1 + 16) != 54 || a4 == 1 )
    {
      if( DeviceObject[0] == a3 )
      {
        if( (*(_DWORD *)(a1 + 144) & 2) == 0 && v10[75] == 786 && (v10[99] & 0x2000) != 0 && v10[101] == 21 )
        {
          PipClearDevNodeProblem((INT64)v10, v7, v8);
          goto LABEL_20;
        }
      }
      else if( (v10[99] & 0x6000) == 0 && v10[75] == 786 )
      {
LABEL_20:
        PnpRestartDeviceNode((__int64)v10);
      }
    }
    else if( v10[75] != 788 )
    {
      *((_DWORD *)DeviceObject[0] + 12) |= 0x4000000u;
      IopQueryDeviceState(v9, &DeviceState);
    }
  }
}

Referenced by:

PnpProcessQueryRemoveAndEject