PnpIsDeviceInstanceEnabled

UINT64 __stdcall PnpIsDeviceInstanceEnabled(PVOID DeviceInstanceHandle, UNICODE_STRING *DeviceInstance, UINT64 Disable){
  _DWORD *v3; 
  int v5; 
  unsigned int v6; 
  int v7; 
  WCHAR *v8; 
  _QWORD *v9; 
  void *v10; 
  int v11; 
  HANDLE v12; 
  UINT64 *v13; 
  INT64 v14; 
  char v15; 
  char v16; 
  int v18; 
  int v19; 
  int v20; 
  WCHAR *OutString; 
  HANDLE Handle; 
  int v23; 
  Handle = DeviceInstanceHandle;
  v3 = 0i64;
  v23 = 0;
  v19 = 0;
  v5 = Disable;
  v20 = 0;
  v6 = 1;
  OutString = 0i64;
  v7 = 0;
  v8 = 0i64;
  v9 = PnpDeviceObjectFromDeviceInstanceWithTag((INT64)DeviceInstance, 0x55706E50ui64);
  v10 = v9;
  if( v9 )
    v3 = *(_DWORD **)(v9[39] + 40i64);
  if( v3 )
  {
    if( (v3[99] & 0x2000) != 0 )
    {
      v18 = v3[101];
      if( v18 == 22 || v18 == 29 )
        goto LABEL_21;
    }
  }
  v11 = PnpUnicodeStringToWstr(&OutString, 0i64, DeviceInstance);
  v8 = OutString;
  if( v11 < 0 )
    goto LABEL_21;
  v12 = Handle;
  if( !Handle )
  {
    if( (int)CmOpenDeviceRegKey(PiPnpRtlCtx, OutString, 16, 0, 131097, 0, (__int64)&Handle, 0i64) >= 0 )
    {
      v12 = Handle;
      v7 = 1;
      goto LABEL_7;
    }
LABEL_21:
    v6 = 0;
    goto LABEL_14;
  }
LABEL_7:
  v19 = 4;
  if( (int)CmGetDeviceRegProp(PiPnpRtlCtx, v8, (__int64)v12, 11, (__int64)&v20, (__int64)&v23, (__int64)&v19, 0) < 0
    || v20 == 4 && v19 == 4 )
  {
    v15 = v23;
  }
  else
  {
    v15 = 0;
    v23 = 0;
  }
  if( (v15 & 1) != 0 )
  {
    v16 = 1;
    v23 = 1;
  }
  else
  {
    PnpGetDeviceInstanceCsConfigFlags(DeviceInstance, v13);
    v16 = v23;
  }
  if( (v16 & 7) != 0 )
  {
    v6 = 0;
    if( v5 )
    {
      if( v3 && v3[75] != 769 )
        PnpDisableDevice((__int64)v3, (const WCHAR *)0x16, v14);
    }
  }
LABEL_14:
  if( v10 )
    ObfDereferenceObjectWithTag(v10, 0x55706E50ui64);
  if( v7 )
    ZwClose(Handle);
  if( v8 )
    PnpUnicodeStringToWstrFree(v8, DeviceInstance);
  return v6;
}

Referenced by:

IopInitializeDeviceInstanceKey
PiProcessNewDeviceNode
PiProfileUpdateDeviceTreeCallback