PoFxRegisterDevice
INT64 __stdcall PoFxRegisterDevice(DEVICE_OBJECT *DeviceObject, PO_FX_DEVICE_V1 *Device, POHANDLE **Handle){
_PO_FX_COMPONENT_V2 *p_IdleStateCount;
PO_FX_DEVICE_V1 *v4;
ULONG Version;
void(__fastcall *v8)(void *, unsigned int);
void(__fastcall *v9)(void *, unsigned int);
UINT64 v10;
PO_FX_COMPONENT_V2 *v11;
ULONG v12;
PPO_FX_COMPONENT_ACTIVE_CONDITION_CALLBACK Flags;
PPO_FX_COMPONENT_IDLE_STATE DeviceContext;
char v15;
int v16;
int(__fastcall *v18)(void *, const _GUID *, void *, unsigned __int64, void *, unsigned __int64, unsigned __int64 *);
int IdleStateCount;
POHANDLE *v20;
PPO_FX_COMPONENT_ACTIVE_CONDITION_CALLBACK ComponentActiveConditionCallback;
_POP_FX_DRIVER_CALLBACKS Callbacks;
ULONG ComponentCount;
POHANDLE **v24;
_PO_FX_COMPONENT_IDLE_STATE *v25;
v24 = Handle;
p_IdleStateCount = 0i64;
v4 = 0i64;
if( !DeviceObject )
return(unsigned int)-1073741811;
Version = Device->Version;
v8 = 0i64;
v9 = 0i64;
memset(&Callbacks.ComponentCriticalTransition, 0, 32);
if( Version == 1 )
{
PopPrintEx(1ui64, (INT8 *)"Device using PO_FX_VERSION_V1: devobj 0x%p");
PopPrintEx(1ui64, (INT8 *)" - Driver: \"%wZ\"");
PopPrintEx(1ui64, (INT8 *)"\n");
v10 = Device->ComponentCount;
v25 = (_PO_FX_COMPONENT_IDLE_STATE *)Device->DeviceContext;
Callbacks.ComponentActive = (void(__fastcall *)(void *, unsigned int))Device->ComponentActiveConditionCallback;
Callbacks.ComponentIdle = (void(__fastcall *)(void *, unsigned int))Device->ComponentIdleConditionCallback;
Callbacks.ComponentIdleState = (void(__fastcall *)(void *, unsigned int, unsigned int))Device->ComponentIdleStateCallback;
Callbacks.DevicePowerRequired = (void(__fastcall *)(void *))Device->DevicePowerRequiredCallback;
Callbacks.DevicePowerNotRequired = (void(__fastcall *)(void *))Device->DevicePowerNotRequiredCallback;
Callbacks.PowerControl = (int(__fastcall *)(void *, const _GUID *, void *, unsigned __int64, void *, unsigned __int64, unsigned __int64 *))Device->PowerControlCallback;
ComponentCount = v10;
v11 = PopFxConvertV1Components(Device->Components, v10);
v12 = ComponentCount;
p_IdleStateCount = v11;
Flags = 0i64;
DeviceContext = v25;
Handle = v24;
}
else
{
if( Version == 2 )
{
p_IdleStateCount = (_PO_FX_COMPONENT_V2 *)&Device->Components[0].IdleStateCount;
v12 = *(_DWORD *)Device->Components[0].Id.Data4;
DeviceContext = *(PPO_FX_COMPONENT_IDLE_STATE *)&Device->Components[0].Id.Data1;
Callbacks.ComponentActive = (void(__fastcall *)(void *, unsigned int))Device->ComponentIdleConditionCallback;
Callbacks.ComponentIdle = (void(__fastcall *)(void *, unsigned int))Device->ComponentIdleStateCallback;
Callbacks.ComponentIdleState = (void(__fastcall *)(void *, unsigned int, unsigned int))Device->DevicePowerRequiredCallback;
Callbacks.DevicePowerRequired = (void(__fastcall *)(void *))Device->DevicePowerNotRequiredCallback;
Callbacks.DevicePowerNotRequired = (void(__fastcall *)(void *))Device->PowerControlCallback;
v18 = (int(__fastcall *)(void *, const _GUID *, void *, unsigned __int64, void *, unsigned __int64, unsigned __int64 *))Device->DeviceContext;
}
else
{
if( Version != 3 )
goto LABEL_36;
p_IdleStateCount = (_PO_FX_COMPONENT_V2 *)&Device[1].ComponentActiveConditionCallback;
v8 = *(void(__fastcall **)(void *, unsigned int))&Device->Components[0].Id.Data1;
v4 = Device;
v9 = *(void(__fastcall **)(void *, unsigned int))Device->Components[0].Id.Data4;
v12 = Device[1].Version;
Callbacks.ComponentActive = (void(__fastcall *)(void *, unsigned int))Device->ComponentIdleConditionCallback;
Callbacks.ComponentIdle = (void(__fastcall *)(void *, unsigned int))Device->ComponentIdleStateCallback;
Callbacks.ComponentIdleState = (void(__fastcall *)(void *, unsigned int, unsigned int))Device->DevicePowerRequiredCallback;
Callbacks.DevicePowerRequired = (void(__fastcall *)(void *))Device->DevicePowerNotRequiredCallback;
Callbacks.DevicePowerNotRequired = (void(__fastcall *)(void *))Device->PowerControlCallback;
v18 = (int(__fastcall *)(void *, const _GUID *, void *, unsigned __int64, void *, unsigned __int64, unsigned __int64 *))Device->DeviceContext;
DeviceContext = Device->Components[0].IdleStates;
Callbacks.DirectedPowerUpCallback = v8;
Callbacks.DirectedPowerDownCallback = v9;
}
Callbacks.PowerControl = v18;
Flags = Device->ComponentActiveConditionCallback;
}
v15 = 0;
if( v8 )
{
if( v9 )
{
v15 = 1;
goto LABEL_6;
}
}
else if( !v9 )
{
LABEL_6:
v16 = PopFxRegisterDevice(
DeviceObject,
&Callbacks,
p_IdleStateCount,
v12,
DeviceContext,
(UINT64)Flags,
(POHANDLE__ **)Handle);
if( v16 >= 0 && v15 )
{
IdleStateCount = v4->Components[0].IdleStateCount;
v20 = *v24;
if( IdleStateCount == -1 )
{
*((_DWORD *)v20 + 228) = 0;
}
else
{
if( !IdleStateCount )
IdleStateCount = PopFxDirectedFxDefaultTimeout;
*((_DWORD *)v20 + 228) = IdleStateCount;
}
ComponentActiveConditionCallback = v4->ComponentActiveConditionCallback;
if( ((unsigned __int8)ComponentActiveConditionCallback & 2) != 0 )
{
_InterlockedOr((volatile signed __int32 *)v20 + 206, 0x200u);
ComponentActiveConditionCallback = v4->ComponentActiveConditionCallback;
}
if( ((unsigned __int8)ComponentActiveConditionCallback & 4) != 0 )
_InterlockedOr((volatile signed __int32 *)v20 + 206, 0x400u);
_InterlockedOr((volatile signed __int32 *)v20 + 206, 0x20u);
if( !Callbacks.ComponentActive
&& !Callbacks.ComponentIdle
&& !Callbacks.ComponentIdleState
&& !Callbacks.DevicePowerRequired
&& !Callbacks.DevicePowerNotRequired )
{
_InterlockedOr((volatile signed __int32 *)v20 + 206, 1u);
}
}
goto LABEL_8;
}
LABEL_36:
v16 = -1073741811;
LABEL_8:
if( p_IdleStateCount && Device->Version == 1 )
ExFreePoolWithTag(p_IdleStateCount, 0x4D584650u);
return(unsigned int)v16;
}Referenced by:
No references.