Get it from the server in NtPowerInformation(), and change it when NtSetThreadExecutionState() is called.
Signed-off-by: Chip Davis cdavis@codeweavers.com --- dlls/ntdll/nt.c | 25 ++++++++++++++++++++----- dlls/powrprof/tests/powrprof.c | 6 +++--- 2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index c1b0816a35e..a62c321883e 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -3069,7 +3069,18 @@ NTSTATUS WINAPI NtSetThreadExecutionState( EXECUTION_STATE new_state, EXECUTION_ WARN( "(0x%x, %p): stub, harmless.\n", new_state, old_state );
if (new_state & ES_CONTINUOUS) + { + NTSTATUS status; thread_data->exec_state = new_state; + SERVER_START_REQ( change_system_execution_state ) + { + req->old_state = *old_state; + req->new_state = new_state; + status = wine_server_call( req ); + } + SERVER_END_REQ; + return status; + } return STATUS_SUCCESS; }
@@ -3189,13 +3200,17 @@ NTSTATUS WINAPI NtPowerInformation( return STATUS_SUCCESS; } case SystemExecutionState: { - PULONG ExecutionState = lpOutputBuffer; - WARN("semi-stub: SystemExecutionState\n"); /* Needed for .NET Framework, but using a FIXME is really noisy. */ + EXECUTION_STATE *exec_state = lpOutputBuffer; + NTSTATUS status; if (lpInputBuffer != NULL) return STATUS_INVALID_PARAMETER; - /* FIXME: The actual state should be the value set by SetThreadExecutionState which is not currently implemented. */ - *ExecutionState = ES_USER_PRESENT; - return STATUS_SUCCESS; + SERVER_START_REQ( get_system_execution_state ) + { + status = wine_server_call( req ); + if (!status) *exec_state = reply->exec_state; + } + SERVER_END_REQ; + return status; } case ProcessorInformation: { const int cannedMHz = 1000; /* We fake a 1GHz processor if we can't conjure up real values */ diff --git a/dlls/powrprof/tests/powrprof.c b/dlls/powrprof/tests/powrprof.c index 67eea95d1fe..5a1ebfa813e 100644 --- a/dlls/powrprof/tests/powrprof.c +++ b/dlls/powrprof/tests/powrprof.c @@ -54,7 +54,7 @@ static void test_system_execution_state(void)
status = CallNtPowerInformation(SystemExecutionState, NULL, 0, &es, sizeof(es)); ok(status == STATUS_SUCCESS, "status %08x\n", status); - todo_wine ok(es & ES_DISPLAY_REQUIRED, "unexpected execution state 0x%08x\n", es); + ok(es & ES_DISPLAY_REQUIRED, "unexpected execution state 0x%08x\n", es);
old_es = SetThreadExecutionState(ES_CONTINUOUS); ok(old_es == (ES_CONTINUOUS|ES_DISPLAY_REQUIRED), "unexpected execution state 0x%08x\n", old_es); @@ -130,14 +130,14 @@ static void test_system_execution_state_other_thread(void)
status = CallNtPowerInformation(SystemExecutionState, NULL, 0, &es, sizeof(es)); ok(status == STATUS_SUCCESS, "status %08x\n", status); - todo_wine ok(es & ES_SYSTEM_REQUIRED, "unexpected execution state 0x%08x\n", es); + ok(es & ES_SYSTEM_REQUIRED, "unexpected execution state 0x%08x\n", es); es = SetThreadExecutionState(0); ok(es == ES_CONTINUOUS, "unexpected execution state 0x%08x\n", es); SignalObjectAndWait(events[1], events[0], INFINITE, FALSE);
status = CallNtPowerInformation(SystemExecutionState, NULL, 0, &es, sizeof(es)); ok(status == STATUS_SUCCESS, "status %08x\n", status); - todo_wine ok(es & ES_DISPLAY_REQUIRED, "unexpected execution state 0x%08x\n", es); + ok(es & ES_DISPLAY_REQUIRED, "unexpected execution state 0x%08x\n", es); es = SetThreadExecutionState(0); ok(es == ES_CONTINUOUS, "unexpected execution state 0x%08x\n", es); SignalObjectAndWait(events[1], thread, INFINITE, FALSE);