NtSetThreadExecutionState
NTSTATUS __stdcall NtSetThreadExecutionState(
_EXECUTION_STATE NewFlags,
_EXECUTION_STATE *PreviousFlags,
INT64 a3,
INT64 a4,
INT64 a5,
INT64 a6,
INT64 a7,
INT64 a8){
char PreviousMode;
_ETHREAD *CurrentThread;
__int64 v12;
VOID *LegacyPowerObject;
int v14;
_DIAGNOSTIC_CONTEXT *v15;
unsigned int LegacyPowerRequestFlags;
bool v18;
unsigned int SessionId;
UINT8 v20;
VOID *PowerRequest;
UINT64 OldFlags;
_DIAGNOSTIC_CONTEXT *Context;
LODWORD(OldFlags) = 0;
Context = 0i64;
PreviousMode = KeGetCurrentThread()->PreviousMode;
if( !PreviousMode )
return -1073741637;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
if( (NewFlags & 0x7FFFFFBC) != 0 || (NewFlags & 0x40) != 0 && NewFlags >= 0 )
return -1073741811;
v12 = 0x7FFFFFFF0000i64;
if( (unsigned __int64)PreviousFlags < 0x7FFFFFFF0000i64 )
v12 = (__int64)PreviousFlags;
*(_DWORD *)v12 = *(_DWORD *)v12;
LegacyPowerObject = CurrentThread->LegacyPowerObject;
PowerRequest = LegacyPowerObject;
if( LegacyPowerObject || NewFlags >= 0 )
goto LABEL_11;
v14 = PoCaptureReasonContext(0i64, PreviousMode, 0i64, 1u, 0i64, &Context);
if( v14 < 0 )
return v14;
v15 = Context;
v14 = PopCreateUserPowerRequest(&PowerRequest, 0, Context);
if( v14 >= 0 )
{
LegacyPowerObject = PowerRequest;
CurrentThread->LegacyPowerObject = PowerRequest;
LABEL_11:
LegacyPowerRequestFlags = PopGetLegacyPowerRequestFlags(LegacyPowerObject, (unsigned int)NewFlags, &OldFlags);
*PreviousFlags = OldFlags;
if( NewFlags >= 0 )
{
PopDiagTraceSetThreadExecutionState(CurrentThread, (unsigned int)NewFlags);
if( (NewFlags & 1) != 0 )
{
PopAcquirePolicyLock();
PopSystemRequiredSet();
PopReleasePolicyLock();
}
if( (NewFlags & 2) != 0 )
{
PoEnergyContextUpdateComponentPower(KeGetCurrentThread()->ApcState.Process, 12i64, 3i64);
PopAcquirePolicyLock();
v18 = 0;
if( PopPlatformAoAc && !PopLidOpened )
v18 = (_BYTE)PopConsoleExternalDisplayConnected == 0;
PopReleasePolicyLock();
SessionId = MmGetSessionIdEx(KeGetCurrentThread()->ApcState.Process);
if( SessionIsInteractive(SessionId) && !v18 )
PopNotifyConsoleUserPresent(1u, v20, MonitorRequestReasonSetThreadExecutionState);
}
}
else
{
PopApplyLegacyPowerRequestFlags(LegacyPowerObject, (unsigned int)NewFlags, LegacyPowerRequestFlags);
}
return 0;
}
if( v15 )
PoDestroyReasonContext(v15);
return v14;
}Referenced by:
No references.