From: Cameron Gutman Date: Fri, 20 Aug 2010 02:27:05 +0000 (+0000) Subject: [NTOSKRNL] X-Git-Tag: ReactOS-0.3.12~158 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=62f520433c7d72854ff10255b7af41af8b3cf06e;ds=sidebyside [NTOSKRNL] - Shutdown the system if we receive a SYS_BUTTON_POWER event - Register for GUID_DEVICE_LID arrival events so we can receive lid events svn path=/trunk/; revision=48572 --- diff --git a/reactos/ntoskrnl/include/internal/po.h b/reactos/ntoskrnl/include/internal/po.h index 01ddf3b5c37..ef4ee1a5ff1 100644 --- a/reactos/ntoskrnl/include/internal/po.h +++ b/reactos/ntoskrnl/include/internal/po.h @@ -6,6 +6,7 @@ * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) */ +#include "initguid.h" #include // diff --git a/reactos/ntoskrnl/po/events.c b/reactos/ntoskrnl/po/events.c index 8417f2760cc..efbcc104d61 100644 --- a/reactos/ntoskrnl/po/events.c +++ b/reactos/ntoskrnl/po/events.c @@ -79,6 +79,15 @@ PopGetSysButtonCompletion( if (SysButton & SYS_BUTTON_LID) DbgPrint(" LID"); if (SysButton == 0) DbgPrint(" WAKE"); DbgPrint(" )\n"); + + if (SysButton & SYS_BUTTON_POWER) + { + /* FIXME: Read registry for the action we should perform here */ + DPRINT1("Initiating shutdown after power button event\n"); + + ZwShutdownSystem(ShutdownNoReboot); + } + } /* Allocate a new workitem to send the next IOCTL_GET_SYS_BUTTON_EVENT */ diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index e8d37b855fd..d745d76e777 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -136,7 +136,7 @@ PoInitSystem(IN ULONG BootPhase) /* Check if this is phase 1 init */ if (BootPhase == 1) { - /* Registry power button notification */ + /* Register power button notification */ IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, (PVOID)&GUID_DEVICE_SYS_BUTTON, @@ -145,6 +145,16 @@ PoInitSystem(IN ULONG BootPhase) PopAddRemoveSysCapsCallback, NULL, &NotificationEntry); + + /* Register lid notification */ + IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, + PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES, + (PVOID)&GUID_DEVICE_LID, + IopRootDeviceNode-> + PhysicalDeviceObject->DriverObject, + PopAddRemoveSysCapsCallback, + NULL, + &NotificationEntry); return TRUE; }