PopSleepstudyStartNextSession
VOID __fastcall PopSleepstudyStartNextSession(INT64 a1, INT64 a2){
unsigned int v2;
int v3;
__int64 *v4;
__int64 v5;
__int64 *v6;
UINT64 InterruptTimePrecise;
UINT64 v8;
int v9;
unsigned int MonitorReasonFromPowerEventId;
int v11;
int v12;
unsigned int v13;
UINT64 *v14;
__int64 v15;
CHAR Version;
int v17;
__int64 v18;
POWER_POLICY_DEVICE_TYPE v19;
INT64 v20;
__int64 *v21;
INT64 *v22;
__int128 v23;
__int128 v24;
__int128 v25;
__int128 v26;
__int128 v27;
__int128 v28;
__int128 v29;
__int128 v30;
__int128 v31;
__int128 v32;
__int128 v33;
__int64 v34;
INT64 v35;
UNICODE_STRING *v36;
INT64 v37;
_EXT_SET_PARAMETERS_V0 QpcTimeStamp;
__int64 v39;
__int64 PowerState;
__int128 PowerState_8;
__int128 PowerState_24;
__int128 v43;
__int128 v44;
INT64 result[42];
v2 = a2;
LODWORD(v39) = a2;
v3 = a1;
memset((INT64)result, 0i64);
PowerState_8 = 0i64;
PowerState_24 = 0i64;
v43 = 0i64;
v44 = 0i64;
PopAcquireRwLockExclusive(&PopSleepstudySessionLock);
v4 = &qword_140C1E338[12 * (unsigned int)dword_140C1E330];
v5 = ((_BYTE)dword_140C1E330 + 1) & 7;
dword_140C1E330 = ((_BYTE)dword_140C1E330 + 1) & 7;
v6 = &qword_140C1E338[12 * v5];
InterruptTimePrecise = KeQueryInterruptTimePrecise((UINT64 *)&QpcTimeStamp.Version);
PowerState = -2500000i64;
v8 = InterruptTimePrecise;
PopCurrentPowerStatePrecise((SYSTEM_BATTERY_STATE *)&PowerState_8);
QpcTimeStamp.Version = v9 != 258;
MonitorReasonFromPowerEventId = PopGetMonitorReasonFromPowerEventId(v2);
v11 = HIDWORD(PowerState_8);
*((_DWORD *)v4 + 9) = v2;
v12 = DWORD2(PowerState_8);
v13 = MonitorReasonFromPowerEventId;
v4[3] = v8;
*((_DWORD *)v4 + 11) = v11;
*((_DWORD *)v4 + 13) = v12;
memset((INT64)v6 + 4, 0i64);
*(_DWORD *)v6 = v3;
v15 = v4[1] + 1;
v6[2] = v8;
v6[1] = v15;
*((_DWORD *)v6 + 10) = v11;
*((_DWORD *)v6 + 12) = v12;
if( *(_DWORD *)v4 == 1 )
{
Version = QpcTimeStamp.Version;
}
else
{
if( *(_DWORD *)v4 != 2 )
{
Version = QpcTimeStamp.Version;
goto LABEL_4;
}
PopSleepstudySendWnfNotification();
Version = QpcTimeStamp.Version;
PopSleepstudyCaptureResiliencyStatistics(v4, (INT64)&PowerState_8, QpcTimeStamp.Version, 0);
}
v18 = 2i64;
if( v3 != 2 )
{
if( *(_DWORD *)v4 == 1 )
++v6[1];
if( ((v3 - 1) & 0xFFFFFFFD) != 0 || (byte_140C4FD0C = 1, v3 != 3) )
{
v19 = PolicyDeviceMax|PolicyDeviceThermalZone;
if( (_DWORD)v39 == 45 )
v19 = PolicyDeviceBattery;
}
else
{
v19 = SleepReason;
}
LODWORD(PopSleepstudyStopReason) = v19;
PopSetModernStandbyTransitionReason(0, v13);
PopSleepstudyCaptureSessionStatistics(v20, &NullGuid, v6[1], (INT64)result);
if( !PopSleepstudySessionContext[0] )
{
v21 = &PopWdiScenarioStopEventData;
v22 = result;
do
{
v23 = *((_OWORD *)v22 + 1);
*(_OWORD *)v21 = *(_OWORD *)v22;
v24 = *((_OWORD *)v22 + 2);
*((_OWORD *)v21 + 1) = v23;
v25 = *((_OWORD *)v22 + 3);
*((_OWORD *)v21 + 2) = v24;
v26 = *((_OWORD *)v22 + 4);
*((_OWORD *)v21 + 3) = v25;
v27 = *((_OWORD *)v22 + 5);
*((_OWORD *)v21 + 4) = v26;
v28 = *((_OWORD *)v22 + 6);
*((_OWORD *)v21 + 5) = v27;
v29 = *((_OWORD *)v22 + 7);
v22 += 16;
*((_OWORD *)v21 + 6) = v28;
v21 += 16;
*((_OWORD *)v21 - 1) = v29;
--v18;
}
while( v18 );
v30 = *(_OWORD *)v22;
*(_QWORD *)&QpcTimeStamp.Version = 0i64;
v31 = *((_OWORD *)v22 + 1);
QpcTimeStamp.NoWakeTolerance = -1i64;
*(_OWORD *)v21 = v30;
v32 = *((_OWORD *)v22 + 2);
*((_OWORD *)v21 + 1) = v31;
v33 = *((_OWORD *)v22 + 3);
v34 = v22[8];
*((_OWORD *)v21 + 2) = v32;
*((_OWORD *)v21 + 3) = v33;
v21[8] = v34;
KeSetTimer2(&stru_140C1E288, -50000000i64, 0i64, &QpcTimeStamp);
PopSleepstudySessionContext[0] = 1;
}
PopSleepstudySendWnfNotification();
}
LABEL_4:
v17 = v3 - 1;
if( !v17 )
{
PopSetModernStandbyTransitionReason(1, v13);
PopSleepstudyCaptureSessionStatistics(v35, &GUID_SPM_LOW_POWER_CS, v6[1], (INT64)result);
if( !PopSleepstudySessionContext[0] )
PopDiagTraceSleepStudyStart(v37, v36);
goto LABEL_25;
}
if( v17 == 1 )
{
PopCalculateIdleInformation((INT64)&v43, v14);
v6[7] = v44;
v6[10] = *((_QWORD *)&v43 + 1);
PopSleepstudyCaptureResiliencyStatistics(v6, (INT64)&PowerState_8, Version, 1);
LABEL_25:
PopSleepstudySendWnfNotification();
}
PopReleaseRwLock((UINT64)&PopSleepstudySessionLock);
}Referenced by:
PopPowerAggregatorDisengageModernStandby
PopPowerAggregatorStartNextSession