PopTransitionSystemPowerStateEx
VOID __fastcall PopTransitionSystemPowerStateEx(UINT64 *rcx0){
int v1;
UINT64 *v2;
_DWORD *v4;
int v5;
int v6;
INT8 v7;
_EJOB *CurrentServerSilo;
POWER_ACTION v9;
INT64 v10;
POWER_POLICY_DEVICE_TYPE v11;
bool v12;
int v13;
POWER_ACTION v14;
int v15;
UINT8 *v16;
unsigned int v17;
_SYSTEM_POWER_STATE *v18;
unsigned int v19;
int v20;
_DWORD *v21;
INT64 v22;
__int64 v23;
int v24;
_SYSTEM_POWER_STATE v25;
int v26;
UINT8 v27;
int HiberContext;
UINT64 v29;
INT64 v30;
NTSTATUS inited;
__int64 v32;
UINT64 v33;
UINT8 NextSystemPowerState;
__int64 v35;
UINT64 v36;
__int64 v37;
__int64 v38;
__int64 v39;
UINT64 v40;
UINT64 v41;
INT64 *v42;
UINT64 *v43;
_DWORD *v44;
__int64 *v45;
UINT64 v46;
CHAR v47;
UINT64 *v48;
UINT64 **v49;
bool NextWakeTime;
CHAR v51;
bool v52;
__int64 v53;
UINT64 v54;
INT64 v55;
INT64 v56;
INT64 v57;
INT64 v58;
INT64 v59;
_SYSTEM_POWER_STATE v60;
_SYSTEM_POWER_STATE v61;
_SYSTEM_POWER_STATE v62;
_DIAGNOSTIC_BUFFER *WakeInfoAc;
WCHAR v64;
__int64 v65;
struct EX_RUNDOWN_REF *v66;
INT64 *v67;
INT64 v68;
void *v69;
void *v70;
UINT8 v71;
__int64 v72;
_DWORD *v73;
PLARGE_INTEGER Timeout;
PLARGE_INTEGER Timeouta;
_DIAGNOSTIC_BUFFER *WakeInfoDc;
struct _UNICODE_STRING DestinationString;
INT64 a1[2];
int v79;
int v80;
__int64 v81;
int v82;
char v83;
_SYSTEM_POWER_STATE TargetState;
v1 = 0;
v2 = rcx0 + 29;
*((_BYTE *)rcx0 + 24) = 0;
v4 = (_DWORD *)rcx0 + 59;
*((_BYTE *)rcx0 + 36) = 0;
*((_DWORD *)rcx0 + 10) = 0;
rcx0[10] = 0i64;
*((_DWORD *)rcx0 + 37) = 1;
*((_DWORD *)rcx0 + 38) = 1;
*((_BYTE *)rcx0 + 256) = 1;
rcx0[47] = 1i64;
rcx0[7] = 0i64;
*((_DWORD *)rcx0 + 29) = 0;
rcx0[30] = 0i64;
rcx0[27] = 0i64;
rcx0[28] = 0i64;
rcx0[43] = 0i64;
*((_BYTE *)rcx0 + 384) = 0;
rcx0[45] = 0i64;
rcx0[46] = 0i64;
*((_DWORD *)rcx0 + 58) = 0;
*((_DWORD *)rcx0 + 59) = 0;
v5 = *(_DWORD *)PopSimulate & 0x10000;
*((_DWORD *)rcx0 + 26) = 0;
*((_DWORD *)rcx0 + 97) = v5 != 0 ? 300000000 : 600000000;
PopTransitionCheckpoint(8i64);
if( (unsigned int)(*((_DWORD *)rcx0 + 1) - 1) > 5 )
return;
v6 = *(_DWORD *)rcx0;
TargetState = PowerSystemShutdown;
if( (unsigned int)(v6 - 1) > 6 || (rcx0[1] & 0xCFFFFC0) != 0 || v6 < 4 && SleepReason >= PolicyDeviceMax )
return;
v7 = *((_BYTE *)KeGetCurrentThread() + 562);
*((_BYTE *)rcx0 + 72) = v7;
if( v7 )
{
if( SeSinglePrivilegeCheck(*(_QWORD *)&SeShutdownPrivilege, v7) )
ZwSetSystemPowerState(*(POWER_ACTION *)rcx0, *((_SYSTEM_POWER_STATE *)rcx0 + 1), *((unsigned int *)rcx0 + 2));
return;
}
CurrentServerSilo = PsGetCurrentServerSilo();
v9 = *(_DWORD *)rcx0;
rcx0[12] = (UINT64)CurrentServerSilo;
if( !PsIsHostSilo(CurrentServerSilo) )
{
if( (unsigned int)(v9 - 4) > 2 )
{
v1 = -1073741637;
}
else
{
v10 = 2147483697i64;
if( v9 != PowerActionShutdownReset )
v10 = 3221226219i64;
*((_DWORD *)rcx0 + 8) = v10;
PsTerminateServerSilo((_EJOB *)rcx0[12], v10);
}
*((_DWORD *)rcx0 + 26) = v1;
return;
}
if( v9 == PowerActionShutdown )
PopReadShutdownPolicy();
*((_DWORD *)rcx0 + 5) = 0;
*((_DWORD *)rcx0 + 3) = *(_DWORD *)rcx0;
*((_DWORD *)rcx0 + 4) = *((_DWORD *)rcx0 + 2);
*(_OWORD *)(rcx0 + 15) = 0i64;
rcx0[17] = 0i64;
v11 = SleepReason;
v12 = SleepReason < PolicyDeviceMax;
*((_DWORD *)rcx0 + 31) = 128;
if( !v12 )
v11 = PolicySetPowerStateAPI;
*((_DWORD *)rcx0 + 30) = v11;
PopAcquireTransitionLock();
MmLockPagableSectionByHandle(ExPageLockHandle);
PopRunMaximumIrpWorkers();
PopUnlockAfterSleepWorkItem.Parameter = 0i64;
PopUnlockAfterSleepWorkItem.WorkerRoutine = (void(__fastcall *)(void *))PopUnlockAfterSleepWorker;
PopUnlockAfterSleepWorkItem.List.Flink = 0i64;
CmSetLazyFlushState(0);
PopNotifyCallbacksPreSleep();
ExSwapinWorkerThreads(0);
v13 = PoInitializeBroadcast();
*((_DWORD *)rcx0 + 26) = v13;
if( v13 < 0 )
{
ExQueueWorkItem(&PopUnlockAfterSleepWorkItem, DelayedWorkQueue);
return;
}
PopCheckPowerSourceAfterRtcWakeCancel();
PopAcquirePolicyLock();
*((_BYTE *)rcx0 + 64) = 1;
PopFilterCapabilities((_SYSTEM_POWER_CAPABILITIES *)&PopCapabilities, &FilteredCapabilities);
if( byte_140C23261 )
{
if( byte_140C23261 != 2 )
{
PopReleasePolicyLock();
PoClearBroadcast();
ExQueueWorkItem(&PopUnlockAfterSleepWorkItem, DelayedWorkQueue);
return;
}
}
else
{
PopResetActionDefaults();
}
PopSetPowerActionState(3u);
qword_140C23298 = DevState;
LODWORD(Timeout) = 1;
PopExecutePowerAction((INT64)(rcx0 + 15), 0i64, (INT64)rcx0 + 12, *((unsigned int *)rcx0 + 1), (UINT64)Timeout);
PopIgnoreBatteryStatusChange();
PopCheckResiliencyScenarios();
PopEnforceResiliencyScenarios((PPOWER_IDLE_RESILIENCY)rcx0 + 31);
PopExecuteOnTargetProcessors((INT64)&KeActiveProcessors, (INT64)PpmStopIllegalProcessorThrottleLogging, 0i64, 0i64);
v14 = *(_DWORD *)rcx0;
if( *(_DWORD *)rcx0 == 6 )
{
Action = PowerActionShutdownOff;
v14 = *(_DWORD *)rcx0;
}
if( (unsigned int)(v14 - 4) <= 2 )
{
PoPowerDownActionInProgress = 1;
if( v14 == PowerActionShutdownReset )
PoPowerResetActionInProgress = 1;
if( *(_QWORD *)&PopHiberInfo )
{
if( *(_QWORD *)FileObject )
{
MmZeroPageFileAtShutdown();
if( v15 )
PopZeroHiberFile(*(PVOID *)&PopHiberInfo, (_FILE_OBJECT *)FileObject);
}
}
}
v16 = (UINT8 *)(rcx0 + 11);
v17 = *(_DWORD *)rcx0 - 2;
*((_BYTE *)rcx0 + 88) = 0;
v18 = (_SYSTEM_POWER_STATE *)rcx0 + 7;
*((_DWORD *)rcx0 + 7) = 0;
if( v17 <= 1 )
PoPowerDownActionInProgress = 1;
*((_BYTE *)rcx0 + 112) = 0;
LABEL_38:
*((_DWORD *)rcx0 + 26) = -1073741536;
LABEL_39:
while( 2 )
{
v19 = 0x80000000;
while( 1 )
{
while( 1 )
{
if( !*((_BYTE *)rcx0 + 64) )
{
PopAcquirePolicyLock();
v19 = 0x80000000;
*((_BYTE *)rcx0 + 64) = 1;
}
if( Action == PowerActionNone )
{
*((_DWORD *)rcx0 + 26) = 0;
goto LABEL_178;
}
*((_BYTE *)rcx0 + 144) = PopAction;
LOBYTE(PopAction) = 0;
v20 = *((_DWORD *)rcx0 + 26);
if( v20 == -1073741536 )
{
if( (rcx0[18] & 2) != 0 && (*(_DWORD *)Flags & v19) == 0 && (*(_BYTE *)Flags & 3) != 0 )
{
PopGetPolicyWorker(2ui64);
goto LABEL_178;
}
PopActionRetrieveInitialState(
(_SYSTEM_POWER_STATE *)&Action + 1,
(_SYSTEM_POWER_STATE *)rcx0 + 7,
&::TargetState,
(UINT8 *)rcx0 + 88);
if( (unsigned int)(Action - 4) <= 2 )
{
byte_140C23262 = 1;
*(_DWORD *)Flags = *((_DWORD *)rcx0 + 2);
}
*((_DWORD *)rcx0 + 26) = 0;
v20 = 0;
}
if( v20 < 0 )
goto LABEL_178;
PopReleasePolicyLock();
*((_BYTE *)rcx0 + 64) = 0;
*((_DWORD *)rcx0 + 94) = 1;
*((_DWORD *)rcx0 + 95) = 0;
PopQueryPowerSettingUlong(&GUID_ALLOW_RTC_WAKE, (_DWORD *)rcx0 + 94, (_DWORD *)rcx0 + 95);
v21 = (_DWORD *)rcx0 + 95;
if( (*(_DWORD *)Flags & 0x40000000) != 0 )
{
*((_DWORD *)rcx0 + 94) = 0;
*v21 = 0;
}
if( !FilteredCapabilities.SystemBatteriesPresent
&& !FilteredCapabilities.UpsPresent
&& !FilteredCapabilities.spare2[1] )
{
*v21 = 0;
}
PopInitializePowerPolicySimulate();
LODWORD(dword_140C23284) = ::TargetState;
v22 = (*(_DWORD *)Flags >> 27) & 2;
*((_DWORD *)rcx0 + 27) = v22;
PopAdvanceSystemPowerState(&dword_140C23284, v22, (unsigned int)*(&Action + 1), *(unsigned int *)v18);
if( (rcx0[1] & 8) != 0 )
{
byte_140C23480 = 1;
*((_BYTE *)rcx0 + 36) = 0;
EffectiveState = PowerSystemHibernate;
*((_DWORD *)rcx0 + 11) = 6;
v23 = ::TargetState;
LABEL_62:
v24 = PopPowerStateHandlerLookup[v23];
goto LABEL_63;
}
if( !(unsigned __int8)PopFastS4Check() )
{
EffectiveState = ::TargetState;
*((_DWORD *)rcx0 + 11) = ::TargetState;
v23 = ::TargetState;
*((_BYTE *)rcx0 + 36) = 0;
goto LABEL_62;
}
*((_DWORD *)rcx0 + 11) = ::TargetState;
v24 = 6;
EffectiveState = PowerSystemHibernate;
*((_BYTE *)rcx0 + 36) = 1;
LABEL_63:
*((_DWORD *)rcx0 + 17) = v24;
if( v24 < 0 || v24 >= 7 || !qword_140C23D88[3 * v24] )
{
NextSystemPowerState = PopFindNextSystemPowerState(*v18, *((_BYTE *)rcx0 + 36), (UINT8 *)rcx0 + 88);
*((_BYTE *)rcx0 + 48) = NextSystemPowerState;
if( NextSystemPowerState )
{
*((_DWORD *)rcx0 + 26) = 0;
goto LABEL_39;
}
LABEL_178:
if( byte_140C23480 )
{
stru_140C23940 = KeQueryPerformanceCounter(0i64);
dword_140C23464 = PopQpcTimeInMs(&stru_140C23938, &stru_140C23940);
}
if( *((int *)rcx0 + 26) >= 0 )
{
qword_140C232B0 = rcx0[43];
ExUpdateSystemTimeFromCmos(1u, 1ui64);
LOBYTE(v65) = 1;
if( ((unsigned __int8(__fastcall *)(__int64))off_140C00948[0])(v65) )
*((_BYTE *)rcx0 + 208) = 1;
stru_140C23768 = KeQueryPerformanceCounter(0i64);
PfPowerActionNotify(2i64, 0i64, 0i64);
qword_140C232A8 = *(_QWORD *)&KUSER_SHARED_DATA.InterruptTime.LowPart;
PopDiagComputeEarlyHiberStats();
if( *((_DWORD *)rcx0 + 10) == 4 )
PopDiagTraceFirmwareS3Stats();
}
byte_140C2327D = 1;
PoPowerDownActionInProgress = 0;
PoPowerResetActionInProgress = 0;
PsIumResumeAfterHibernate();
if( *((_BYTE *)rcx0 + 112) )
{
PfPowerActionNotify(3i64, 0i64, 0i64);
PopSetDevicesSystemState();
PfPowerActionNotify(3i64, 1i64, 0i64);
}
PpmCheckResumePpmEngineFromSx();
if( *((_BYTE *)rcx0 + 208) )
ZwUpdateWnfStateData();
if( !PopSleepReliabilityDetailedDiagEnabled )
{
LOBYTE(v67) = 1;
RtlBootStatusDisableFlushing(v67, v66, v68);
}
PopBootStatCheckpointAvailable = 1;
PopCheckpointSystemSleep(PopSleepCheckpointBootstatAvailable);
v70 = (void *)rcx0[30];
if( v70 )
{
ExFreePoolEx(v70, v69);
rcx0[30] = 0i64;
}
((void(__fastcall *)(_QWORD, _QWORD))off_140C005C0)(0i64, 0i64);
*((_DWORD *)rcx0 + 29) = PopNotifyTelemetryOsState(
Action,
::TargetState,
EffectiveState,
*((unsigned int *)rcx0 + 2),
0);
PopQueueBatteryStatusTimeout();
PopExecuteOnTargetProcessors(
(INT64)&KeActiveProcessors,
(INT64)PpmStartIllegalProcessorThrottleLogging,
0i64,
0i64);
if( *((_BYTE *)rcx0 + 64) )
{
PopReleasePolicyLock();
*((_BYTE *)rcx0 + 64) = 0;
}
PoClearBroadcast();
qword_140C23298 = 0i64;
PopEsExitSleep();
PopCurrentPowerStatePrecise((SYSTEM_BATTERY_STATE *)((char *)rcx0 + 156));
*((_DWORD *)rcx0 + 38) = dword_140C23D0C;
PopSpoilEstimatesOnPowerStateTransitionWorkItem.Parameter = 0i64;
PopSpoilEstimatesOnPowerStateTransitionWorkItem.WorkerRoutine = (void(__fastcall *)(void *))PopSpoilEstimatesOnPowerStateTransitionWorker;
PopSpoilEstimatesOnPowerStateTransitionWorkItem.List.Flink = 0i64;
ExQueueWorkItem(&PopSpoilEstimatesOnPowerStateTransitionWorkItem, DelayedWorkQueue);
PopThermalSxExit(v71);
if( !*((_BYTE *)rcx0 + 64) )
{
PopAcquirePolicyLock();
*((_BYTE *)rcx0 + 64) = 1;
}
if( *((int *)rcx0 + 26) >= 0 )
{
PopInitSIdle();
LOBYTE(PopAction) = 0;
if( (unsigned __int64)dword_140C232C0 < 3 )
{
qword_140C23318 = *(&ProgrammedWakeTimeAc + 3 * dword_140C232C0);
v72 = qword_140C232D8[3 * dword_140C232C0];
PopFullWake = 0;
PopPendingUserPresenceDuringSystemSleep = 0;
PopPendingUserPresenceMonitorOnReason = MonitorRequestReasonUnknown;
switch( v72 )
{
case -1i64:
if( PopDeferDoze(*((unsigned int *)rcx0 + 94), *((unsigned int *)rcx0 + 95), (BYTE *)rcx0 + 156) )
*(_QWORD *)&Action = *rcx0;
else
*(_QWORD *)&Action = 0x500000002i64;
LOBYTE(PopAction) = PopAction | 2;
LABEL_212:
*((_BYTE *)rcx0 + 256) = 0;
break;
case -2i64:
if( !qword_140C232B8 )
qword_140C232B8 = qword_140C232A8;
break;
case -3i64:
PopWakeAlarmTimeOverride = 0i64;
break;
default:
v73 = (_DWORD *)rcx0 + 95;
if( dword_140C23D0C == 1 )
{
if( !*v73 )
{
*(_QWORD *)&Action = *rcx0;
LOBYTE(PopAction) = 2;
goto LABEL_212;
}
}
else if( !*v73 && *((_DWORD *)rcx0 + 37) == *((_DWORD *)rcx0 + 38) )
{
PopCheckPowerSourceAfterRtcWakeSet();
}
break;
}
}
}
if( byte_140C23310 && *((_BYTE *)rcx0 + 256) )
{
ExWakeTimersResume();
byte_140C23310 = 0;
qword_140C23318 = 0i64;
}
if( PoResumeFromHibernate )
{
PopBootLoaderTraceProcess();
PoResumeFromHibernate = 0;
}
byte_140C23480 = 0;
PopResetActionDefaults();
PopSetPowerActionState(2u);
PopReleasePolicyLock();
if( PopPendingUserPresenceDuringSystemSleep )
PoSetUserPresent(PopPendingUserPresenceMonitorOnReason);
ExQueueWorkItem(&PopUnlockAfterSleepWorkItem, DelayedWorkQueue);
PopCheckForWork();
if( *((int *)rcx0 + 26) >= 0 )
PpmPerfReApplyStates();
SleepReason = PolicyDeviceMax;
qword_140C238D0 = PopCaptureTimeOnProcZero();
return;
}
if( (rcx0[1] & 8) != 0 )
{
v25 = PowerSystemShutdown;
LABEL_70:
PopSetSleepMarker(v25);
goto LABEL_72;
}
if( !byte_140C23262 )
{
v25 = ::TargetState;
goto LABEL_70;
}
PopSetShutdownMarker();
LABEL_72:
PopAcquirePolicyLock();
if( (PopAction & 6) != 0 )
{
*((_BYTE *)rcx0 + 64) = 1;
goto LABEL_38;
}
PopReleasePolicyLock();
PopCheckpointSystemSleep(PopSleepCheckpointSleepTransactionCommitted);
byte_140C2327C = 3;
PopDiagTraceKernelQueriesAllowed(*v16);
if( !*v16 )
break;
v26 = PopSetDevicesSystemState();
*((_DWORD *)rcx0 + 26) = v26;
if( (int)(v26 + 0x80000000) < 0 || v26 == -1073741536 )
{
if( !(unsigned int)Feature_Servicing_2207c_QxS0Irp__private_IsEnabled() )
break;
v19 = 0x80000000;
if( *((int *)rcx0 + 26) >= 0 )
{
*((_BYTE *)rcx0 + 112) = 1;
break;
}
}
else
{
v27 = PopFindNextSystemPowerState(*v18, *((_BYTE *)rcx0 + 36), (UINT8 *)rcx0 + 88);
*((_BYTE *)rcx0 + 48) = v27;
if( !v27 )
goto LABEL_178;
*((_DWORD *)rcx0 + 26) = 0;
}
}
v19 = 0x80000000;
if( *((int *)rcx0 + 26) >= 0 )
{
PopCheckpointSystemSleep(PopSleepCheckpointAllocatingHiberContext);
HiberContext = PopAllocateHiberContext();
*((_DWORD *)rcx0 + 26) = HiberContext;
v19 = 0x80000000;
if( HiberContext >= 0 )
break;
}
}
*((_DWORD *)rcx0 + 29) = PopNotifyTelemetryOsState(
Action,
::TargetState,
EffectiveState,
*((unsigned int *)rcx0 + 2),
1u);
PopTransitionCheckpoint(9i64);
if( !byte_140C23262 )
{
LODWORD(Timeouta) = *((_DWORD *)rcx0 + 29);
PopDiagTracePreSleepNotification(
*((_SYSTEM_POWER_STATE *)rcx0 + 11),
EffectiveState,
SleepReason,
(unsigned int)dword_140C23278,
(UINT64)Timeouta);
PopCheckpointSystemSleep(PopSleepCheckpointPreSleepNotification);
PopUmpoSendFlushSleepStudyLoggerNotification();
}
PopEsEnterSleepShutdown();
PopThermalSxEntry();
if( !*((_BYTE *)rcx0 + 24) )
{
if( byte_140C23262 )
{
v83 = 1;
LODWORD(a1[0]) = 5;
v79 = 1;
a1[1] = (INT64)&v83;
v80 = 11;
v81 = 0xFFFFF780000002C4ui64;
v82 = 4;
RtlSetSystemBootStatusEx((INT64)a1, 2ui64, 0i64);
}
*((_BYTE *)rcx0 + 24) = 1;
}
v29 = 5i64;
if( !*((_BYTE *)rcx0 + 36) )
v29 = (unsigned int)::TargetState;
PopFlushVolumes(v29);
if( EffectiveState < ::TargetState )
EffectiveState = ::TargetState;
byte_140C2327C = 2;
if( !byte_140C23262 )
{
v30 = *((unsigned int *)rcx0 + 17);
KeMtrrComparisonFailed = 0;
inited = PopInitSystemSleeperThread(v30, (_DWORD *)rcx0 + 66);
*((_DWORD *)rcx0 + 26) = inited;
if( inited < 0 )
continue;
if( !byte_140C23310 )
{
ExWakeTimersPause();
byte_140C23310 = 1;
}
rcx0[24] = *(_QWORD *)&KUSER_SHARED_DATA.InterruptTime.LowPart;
v32 = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
v33 = PopWakeAlarmTimeOverride;
rcx0[25] = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
rcx0[28] = 0i64;
if( v33 )
{
rcx0[27] = v33;
rcx0[28] = -3i64;
}
else if( !*((_DWORD *)PopPolicy + 22)
|| ::TargetState == PowerSystemHibernate
|| !PopIsDozeSupported(&PopCapabilities)
|| (*(_DWORD *)Flags & 0x40000000) != 0 )
{
if( byte_140C23E54
&& ::TargetState == PowerSystemHibernate
&& !byte_140C23480
&& qword_140C231C8
&& SleepReason == PolicyImmediateDozeS4Predicted )
{
v38 = qword_140C231C8 - v32;
rcx0[44] = qword_140C231C8 - v32;
v39 = -10000000i64 * (unsigned int)PopSmartUserPresenceWakeOffset;
rcx0[28] = -2i64;
v40 = v39 + v38;
v41 = rcx0[24];
rcx0[44] = v40;
rcx0[27] = v40 + v41;
}
}
else
{
v36 = rcx0[24];
rcx0[27] = v36;
v37 = *(unsigned int *)(v35 + 88);
rcx0[28] = -1i64;
rcx0[27] = v36 + 10000000 * v37;
if( !qword_140C23320 )
qword_140C23320 = v36;
}
v42 = &qword_140C232C8;
memset((INT64)&qword_140C232C8, 0i64);
dword_140C232C0 = 3;
if( rcx0[28] == -3i64 )
{
do
{
v42[2] = rcx0[28];
*v42 = rcx0[27];
v42 += 3;
}
while( (__int64)v42 < (__int64)qword_140C232F8 );
}
else if( !byte_140C23480 && SleepReason != PolicyImmediateDozeS4AdaptiveReserveNoWake )
{
v43 = rcx0 + 47;
v44 = (_DWORD *)rcx0 + 95;
if( ::TargetState == PowerSystemHibernate && *(_DWORD *)v43 != 1 && *v44 != 1 )
{
PopQueryPowerSettingUlong(&GUID_LEGACY_RTC_MITIGATION, v2, v4);
if( *(_DWORD *)v2 || *v4 )
{
v43 = rcx0 + 47;
*v44 = 0;
*((_DWORD *)rcx0 + 94) = 0;
}
else
{
v43 = rcx0 + 47;
}
}
if( rcx0[27] )
{
if( rcx0[28] == -2i64 )
{
if( *(_DWORD *)v43 )
{
qword_140C232C8 = rcx0[27];
qword_140C232D8[0] = rcx0[28];
}
if( *v44 )
{
qword_140C232E0 = rcx0[27];
qword_140C232F0 = rcx0[28];
}
}
else
{
do
{
*v42 = rcx0[27];
v42 += 3;
}
while( (__int64)v42 < (__int64)qword_140C232F8 );
v45 = qword_140C232D8;
do
{
*v45 = rcx0[28];
v45 += 3;
}
while( (__int64)v45 < (__int64)&qword_140C23308 );
}
}
v46 = qword_140C23318;
rcx0[10] = qword_140C23318;
if( v46 )
{
if( v46 < rcx0[24] + 20000000 )
v46 = rcx0[24] + 20000000;
rcx0[10] = v46;
}
if( *(_DWORD *)v43 )
{
if( *(_DWORD *)v43 != 2 || (v47 = 1, (*(_DWORD *)PopSimulate & 0x80000000) != 0) )
v47 = 0;
*((_BYTE *)rcx0 + 209) = v47;
v48 = rcx0 + 7;
v49 = (UINT64 **)(rcx0 + 30);
NextWakeTime = ExGetNextWakeTime(rcx0[10] + 1, rcx0[27], v47, rcx0 + 7, (UINT64 **)rcx0 + 30);
*((_BYTE *)rcx0 + 384) = NextWakeTime;
if( NextWakeTime )
{
qword_140C232C8 = *v48;
qword_140C232D8[0] = (__int64)*v49;
}
}
else
{
v48 = rcx0 + 7;
v49 = (UINT64 **)(rcx0 + 30);
}
if( *v44 )
{
if( *v44 != 2 || (v51 = 1, (*(_DWORD *)PopSimulate & 0x80000000) != 0) )
v51 = 0;
*((_BYTE *)rcx0 + 209) = v51;
v52 = ExGetNextWakeTime(rcx0[10] + 1, rcx0[27], v51, v48, v49);
*((_BYTE *)rcx0 + 384) = v52;
if( v52 )
{
qword_140C232E0 = *v48;
qword_140C232F0 = (__int64)*v49;
}
}
}
ProgrammedWakeTimeAc = qword_140C232C8;
if( qword_140C232C8 && qword_140C232C8 < rcx0[24] + *((unsigned int *)rcx0 + 97) )
ProgrammedWakeTimeAc = rcx0[24] + *((unsigned int *)rcx0 + 97);
ProgrammedWakeTimeDc = qword_140C232E0;
if( qword_140C232E0 && qword_140C232E0 < rcx0[24] + *((unsigned int *)rcx0 + 97) )
ProgrammedWakeTimeDc = rcx0[24] + *((unsigned int *)rcx0 + 97);
v53 = qword_140C232D8[0];
if( (unsigned __int64)(qword_140C232D8[0] - 1) <= 0xFFFFFFFFFFFFFFFBui64 )
v53 = *(int *)(qword_140C232D8[0] + 8);
rcx0[45] = v53;
v54 = qword_140C232F0;
if( (unsigned __int64)(qword_140C232F0 - 1) <= 0xFFFFFFFFFFFFFFFBui64 )
v54 = *(int *)(qword_140C232F0 + 8);
rcx0[46] = v54;
EndTime = KeQueryPerformanceCounter(0i64);
ExAcquireTimeRefreshLock(1u);
ExUpdateSystemTimeFromCmos(1u, 1ui64);
ExReleaseTimeRefreshLock();
((void(__fastcall *)(UINT64, INT64))off_140C005C0)(ProgrammedWakeTimeAc, ProgrammedWakeTimeDc);
PopBootStatCheckpointAvailable = 0;
PpmCheckPausePpmEngineForSx();
PopSetDevicesSystemState();
*((_BYTE *)rcx0 + 112) = 1;
PopNewWakeInfo(v56, v55, v57, v58);
rcx0[43] = *(_QWORD *)&KUSER_SHARED_DATA.InterruptTime.LowPart;
*((_DWORD *)rcx0 + 37) = dword_140C23D0C;
KeSetEvent((PRKEVENT)rcx0 + 12, 0);
KeWaitForSingleObject(rcx0 + 39, Executive, 0, 0, 0i64);
BugCheckParameter4 = 0i64;
*((_DWORD *)rcx0 + 26) = *((_DWORD *)rcx0 + 85);
PopSetPowerActionWatchdogState(2ui64, v59);
v60 = ::TargetState;
if( PoResumeFromHibernate )
v60 = EffectiveState;
WakeFromState = v60;
if( (rcx0[1] & 8) != 0 )
{
*((_DWORD *)rcx0 + 11) = 6;
}
else
{
*((_DWORD *)rcx0 + 11) = ::TargetState;
TargetState = ::TargetState;
}
v61 = WakeFromState;
v62 = TargetState;
WakeInfoDc = (_DIAGNOSTIC_BUFFER *)rcx0[46];
WakeInfoAc = (_DIAGNOSTIC_BUFFER *)rcx0[45];
*((_DWORD *)rcx0 + 10) = WakeFromState;
PopDiagTracePostSleepNotification(
v62,
EffectiveState,
v61,
ProgrammedWakeTimeAc,
ProgrammedWakeTimeDc,
WakeInfoAc,
WakeInfoDc);
if( KeMtrrComparisonFailed )
PopDiagTraceMtrrError();
if( *((int *)rcx0 + 26) < 0 && ::TargetState == PowerSystemHibernate )
{
DestinationString = 0i64;
StringCchPrintfW(&PopHibernationErrorSubstitutionString, 0x80ui64, (WCHAR *)L"0x%x");
RtlInitUnicodeString(&DestinationString, &PopHibernationErrorSubstitutionString, v64);
IoRaiseInformationalHardError((_VACB_ARRAY_HEADER *)0xC0000411i64);
PopDiagTraceHibernateErrorStatus(*((unsigned int *)rcx0 + 26));
}
goto LABEL_178;
}
break;
}
PopFxPrepareDevicesForShutdown();
IoFreePoDeviceNotifyList((_PO_DEVICE_NOTIFY_ORDER *)((char *)qword_140C23298 + 48));
if( SleepReason == PolicyDeviceBattery )
PopCriticalShutdownInProgress = 1;
PopTransitionCheckpoint(8i64);
if( (PEPROCESS)PsGetCurrentProcess() == PsInitialSystemProcess )
PopGracefulShutdown(0i64);
PopShutdownWorkItem.Parameter = 0i64;
PopShutdownWorkItem.WorkerRoutine = PopGracefulShutdown;
PopShutdownWorkItem.List.Flink = 0i64;
ExQueueWorkItem(&PopShutdownWorkItem, CriticalWorkQueue);
KeSuspendThread((__int64)KeGetCurrentThread());
}Referenced by:
NtSetSystemPowerState