PiDevCfgProcessDeviceCallback

NTSTATUS __stdcall PiDevCfgProcessDeviceCallback(_DEVICE_NODE *DeviceNode, VOID *Context){
  VOID **v4; 
  bool v5; 
  wchar_t *Buffer; 
  unsigned int v7; 
  PI_DEVCFG_DEVICE_CONTEXT *v9; 
  unsigned int v10; 
  NTSTATUS v11; 
  PI_DEVCFG_DEVICE_CONTEXT *v12; 
  int v13; 
  VOID **PoolWithTag; 
  VOID **v15; 
  _DEVICE_OBJECT *PhysicalDeviceObject; 
  UINT64 DesiredAccess; 
  UINT64 *Disposition; 
  VOID *BaseKeyHandle; 
  _PI_DEVCFG_DEVICE_CONTEXT DeviceContext[32]; 
  unsigned int PropertyBuffer; 
  UINT64 PropertySize; 
  UINT64 CmRegPropType; 
  UINT64 ConfigFlagsUpdate; 

  v4 = 0i64;
  memset(DeviceContext, 0i64, 0x48u);
  v5 = (DeviceNode->StateFlags & 0x1000) == 0;
  BaseKeyHandle = 0i64;
  PropertyBuffer = 0;
  LODWORD(ConfigFlagsUpdate) = 0;
  LODWORD(CmRegPropType) = 1;
  LODWORD(PropertySize) = 0;
  if( v5 )
    goto LABEL_11;
  if( !DeviceNode->InstancePath.Buffer )
    goto LABEL_11;
  LODWORD(DesiredAccess) = 983103;
  if( CmOpenDeviceRegKey(
         *(&stru_140CF2E80 + 607),
         DeviceNode->InstancePath.Buffer,
         CM_KEY_TYPE_DEVICE_INSTANCE,
         0i64,
         DesiredAccess,
         0,
         &BaseKeyHandle,
         0i64) < 0 )
    goto LABEL_11;
  Buffer = DeviceNode->InstancePath.Buffer;
  LODWORD(Disposition) = 0;
  LODWORD(PropertySize) = 4;
  if( CmGetDeviceRegProp(
         *(&stru_140CF2E80 + 607),
         Buffer,
         BaseKeyHandle,
         11i64,
         &CmRegPropType,
         (UINT8 *)&PropertyBuffer,
         &PropertySize,
         (UINT64)Disposition) >= 0
    && (_DWORD)CmRegPropType == 4
    && (_DWORD)PropertySize == 4 )
  {
    v7 = PropertyBuffer;
  }
  else
  {
    v7 = 0;
    PropertyBuffer = 0;
  }
  if( (v7 & 0x40000) != 0 )
  {
    if( PiDevCfgInitDeviceContext(DeviceNode->InstancePath.Buffer, BaseKeyHandle, DeviceContext) < 0 )
      goto LABEL_11;
    LOBYTE(v9) = (PiDevCfgFlags & 2) != 0;
    if( ((unsigned __int8)v9 & ((PropertyBuffer & 0x400) != 0)) != 0 )
    {
      v10 = PropertyBuffer & 0xFFFFFFDF;
    }
    else
    {
      v11 = PiDevCfgCheckDeviceNeedsUpdate(DeviceContext, &ConfigFlagsUpdate);
      v10 = PropertyBuffer;
      if( v11 >= 0 )
        v10 = ConfigFlagsUpdate | PropertyBuffer;
    }
    PropertyBuffer = v10 & 0xFFFBFFFF;
    PiDevCfgSetDeviceRegProp(v9, (_CM_REG_PROP)DeviceContext, 0xBui64, (UINT8 *)4, (UINT64)&PropertyBuffer);
    LOBYTE(v7) = PropertyBuffer;
  }
  if( (v7 & 2) == 0 )
  {
    if( (v7 & 0x20) == 0 )
      goto LABEL_11;
    PhysicalDeviceObject = DeviceNode->PhysicalDeviceObject;
    if( (DeviceNode->Flags & 0x6000) != 0 )
    {
      PnpRequestDeviceAction(PhysicalDeviceObject, 1, 1, 0i64, 0i64, 0i64, 0i64);
      PnpRequestDeviceAction(DeviceNode->PhysicalDeviceObject, 16, 1, 0i64, 0i64, 0i64, 0i64);
      goto LABEL_11;
    }
    PnpSetTargetDeviceRemove(
      PhysicalDeviceObject,
      0,
      0,
      0,
      0,
      18,
      -1073740651,
      0i64,
      0i64,
      0i64,
      0i64,
      0i64,
      0i64,
      0i64);
    goto LABEL_31;
  }
  if( (unsigned int)PipAreDriversLoaded((__int64)DeviceNode) )
  {
    PropertyBuffer = v13 & 0xFFFFFFFD;
    PiDevCfgSetDeviceRegProp(v12, (_CM_REG_PROP)DeviceContext, 0xBui64, (UINT8 *)4, (UINT64)&PropertyBuffer);
    goto LABEL_11;
  }
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x20ui64, 1667526736i64);
  v4 = PoolWithTag;
  if( PoolWithTag )
  {
    *(_OWORD *)PoolWithTag = 0i64;
    *((_OWORD *)PoolWithTag + 1) = 0i64;
    if( !PnpDuplicateUnicodeString((__int64)(PoolWithTag + 2), (__int64)&DeviceNode->InstancePath) )
    {
LABEL_31:
      if( v4 )
        ExFreePoolWithTag(v4, 0);
      goto LABEL_11;
    }
    v15 = (VOID **)*((_QWORD *)Context + 1);
    if( *v15 != Context )
      __fastfail(3u);
    *v4 = Context;
    v4[1] = v15;
    *v15 = v4;
    *((_QWORD *)Context + 1) = v4;
  }
LABEL_11:
  PiDevCfgFreeDeviceContext(DeviceContext);
  if( BaseKeyHandle )
    ZwClose((_HANDLE)BaseKeyHandle);
  return 0;
}

Referenced by:

No references.