From 4093d0e16444ac272c554c5fc36e9ad792b6fa08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Bi=C8=99oc?= Date: Sun, 30 Jun 2024 20:56:29 +0200 Subject: [PATCH] [NTUSER] Estabilish power callouts and invoke the cleanup procedure when unloading Win32k --- win32ss/user/ntuser/main.c | 5 +++-- win32ss/user/ntuser/ntuser.c | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/win32ss/user/ntuser/main.c b/win32ss/user/ntuser/main.c index 84881a8831e..cb5dc019918 100644 --- a/win32ss/user/ntuser/main.c +++ b/win32ss/user/ntuser/main.c @@ -917,6 +917,7 @@ DriverUnload(IN PDRIVER_OBJECT DriverObject) FreeFontSupport(); ResetCsrApiPort(); ResetCsrProcess(); + IntWin32PowerManagementCleanup(); } // Return on failure @@ -984,8 +985,8 @@ DriverEntry( CalloutData.ProcessCallout = Win32kProcessCallback; CalloutData.ThreadCallout = Win32kThreadCallback; // CalloutData.GlobalAtomTableCallout = NULL; - // CalloutData.PowerEventCallout = NULL; - // CalloutData.PowerStateCallout = NULL; + CalloutData.PowerEventCallout = IntHandlePowerEvent; + CalloutData.PowerStateCallout = IntHandlePowerState; // CalloutData.JobCallout = NULL; CalloutData.BatchFlushRoutine = NtGdiFlushUserBatch; CalloutData.DesktopOpenProcedure = IntDesktopObjectOpen; diff --git a/win32ss/user/ntuser/ntuser.c b/win32ss/user/ntuser/ntuser.c index 6643495606d..d5a40085c37 100644 --- a/win32ss/user/ntuser/ntuser.c +++ b/win32ss/user/ntuser/ntuser.c @@ -195,7 +195,14 @@ NtUserInitialize( /* Save the EPROCESS of CSRSS */ InitCsrProcess(/*PsGetCurrentProcess()*/); -// Initialize Power Request List (use hPowerRequestEvent). + /* Initialize Power Request List */ + Status = IntInitWin32PowerManagement(hPowerRequestEvent); + if (!NT_SUCCESS(Status)) + { + UserLeave(); + return Status; + } + // Initialize Media Change (use hMediaRequestEvent). /* Initialize various GDI stuff (DirectX, fonts, language ID etc.) */