PnpIsDeviceInstanceEnabled

__int64 __fastcall PnpIsDeviceInstanceEnabled(VOID *a1, unsigned __int16 *a2, int a3){
  __int64 v3; 
  unsigned int v6; 
  int v7; 
  WCHAR *v8; 
  _QWORD *v9; 
  VOID *v10; 
  int v11; 
  VOID *v12; 
  __int64 v13; 
  char v14; 
  char v15; 
  int v17; 
  UINT64 *CmRegPropType; 
  UINT64 v19; 
  UINT64 PropertySize; 
  WCHAR *DeviceInstanceId; 
  VOID *BaseKeyHandle; 
  int PropertyBuffer; 

  BaseKeyHandle = a1;
  v3 = 0i64;
  PropertyBuffer = 0;
  PropertySize = 0i64;
  v6 = 1;
  DeviceInstanceId = 0i64;
  v7 = 0;
  v8 = 0i64;
  v9 = PnpDeviceObjectFromDeviceInstanceWithTag((__int64)a2, 0x55706E50u);
  v10 = v9;
  if( v9 )
    v3 = *(_QWORD *)(v9[39] + 40i64);
  if( v3 )
  {
    if( (*(_DWORD *)(v3 + 396) & 0x2000) != 0 )
    {
      v17 = *(_DWORD *)(v3 + 404);
      if( v17 == 22 || v17 == 29 )
        goto LABEL_20;
    }
  }
  v11 = PnpUnicodeStringToWstr((__int16 **)&DeviceInstanceId, 0i64, a2);
  v8 = DeviceInstanceId;
  if( v11 < 0 )
    goto LABEL_20;
  v12 = BaseKeyHandle;
  if( !BaseKeyHandle )
  {
    LODWORD(CmRegPropType) = 131097;
    if( CmOpenDeviceRegKey(
           *(&stru_140CF2E80 + 607),
           DeviceInstanceId,
           CM_KEY_TYPE_DEVICE_INSTANCE,
           0i64,
           (UINT64)CmRegPropType,
           0,
           &BaseKeyHandle,
           0i64) >= 0 )
    {
      v12 = BaseKeyHandle;
      v7 = 1;
      goto LABEL_7;
    }
LABEL_20:
    v6 = 0;
    goto LABEL_13;
  }
LABEL_7:
  LODWORD(v19) = 0;
  LODWORD(PropertySize) = 4;
  if( CmGetDeviceRegProp(
         *(&stru_140CF2E80 + 607),
         v8,
         v12,
         11i64,
         (UINT64 *)((char *)&PropertySize + 4),
         (UINT8 *)&PropertyBuffer,
         &PropertySize,
         v19) < 0
    || PropertySize == 0x400000004i64 )
  {
    v14 = PropertyBuffer;
  }
  else
  {
    v14 = 0;
    PropertyBuffer = 0;
  }
  if( (v14 & 1) != 0 )
  {
    v15 = 1;
    PropertyBuffer = 1;
  }
  else
  {
    PnpGetDeviceInstanceCsConfigFlags(a2, v13, &PropertyBuffer);
    v15 = PropertyBuffer;
  }
  if( (v15 & 7) != 0 )
  {
    v6 = 0;
    if( a3 )
    {
      if( v3 && *(_DWORD *)(v3 + 300) != 769 )
        PnpDisableDevice((_DEVICE_NODE *)v3, 0x16ui64);
    }
  }
LABEL_13:
  if( v10 )
    ObfDereferenceObjectWithTag(v10, 0x55706E50ui64);
  if( v7 )
    ZwClose((_HANDLE)BaseKeyHandle);
  if( v8 )
    PnpUnicodeStringToWstrFree(v8, (__int64)a2);
  return v6;
}

Referenced by:

IopInitializeDeviceInstanceKey
PiProcessNewDeviceNode
PiProfileUpdateDeviceTreeCallback