ReactOS  0.4.12-dev-57-g7050ac4
shutdown.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VOID ShutDown_StandBy (VOID)
 
VOID ShutDown_Hibernate (VOID)
 
VOID ShutDown_PowerOff (VOID)
 
VOID ShutDown_Reboot (VOID)
 
VOID ShutDown_LogOffUser (VOID)
 
VOID ShutDown_SwitchUser (VOID)
 
VOID ShutDown_LockComputer (VOID)
 
VOID ShutDown_Disconnect (VOID)
 
VOID ShutDown_EjectComputer (VOID)
 

Function Documentation

◆ ShutDown_Disconnect()

VOID ShutDown_Disconnect ( VOID  )

Definition at line 189 of file shutdown.c.

Referenced by TaskManagerWndProc().

190 {
191 }

◆ ShutDown_EjectComputer()

VOID ShutDown_EjectComputer ( VOID  )

Definition at line 194 of file shutdown.c.

Referenced by TaskManagerWndProc().

195 {
196 }

◆ ShutDown_Hibernate()

VOID ShutDown_Hibernate ( VOID  )

Definition at line 88 of file shutdown.c.

Referenced by TaskManagerWndProc().

89 {
91 
93  {
95  return;
96  }
97 
98 #ifdef NT_INITIATE_POWERACTION_IMPLEMENTED
101  0, FALSE);
102 #else
105  0);
106 #endif
107 
108  if (!NT_SUCCESS(Status))
110 
112 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSTATUS NTAPI NtInitiatePowerAction(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags, IN BOOLEAN Asynchronous)
Definition: power.c:639
NTSTATUS NTAPI NtSetSystemPowerState(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags)
Definition: power.c:861
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:383
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:157
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: shutdown.c:34

◆ ShutDown_LockComputer()

VOID ShutDown_LockComputer ( VOID  )

Definition at line 182 of file shutdown.c.

Referenced by TaskManagerWndProc().

183 {
184  if (!LockWorkStation())
186 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
EXTINLINE BOOL WINAPI LockWorkStation(VOID)
Definition: ntwrapper.h:82
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:157

◆ ShutDown_LogOffUser()

VOID ShutDown_LogOffUser ( VOID  )

Definition at line 170 of file shutdown.c.

Referenced by TaskManagerWndProc().

171 {
172  if (!ExitWindowsEx(EWX_LOGOFF, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER))
174 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define EWX_LOGOFF
Definition: winuser.h:631
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:157

◆ ShutDown_PowerOff()

VOID ShutDown_PowerOff ( VOID  )

Definition at line 115 of file shutdown.c.

Referenced by TaskManagerWndProc().

116 {
117  /* Trick: on Windows, pressing the CTRL key forces shutdown via NT API */
118  BOOL ForceShutdown = !!(GetKeyState(VK_CONTROL) & 0x8000);
119 
121  {
123  return;
124  }
125 
126  if (ForceShutdown)
127  {
129  if (!NT_SUCCESS(Status))
131  }
132  else
133  {
134  // The choice of EWX_SHUTDOWN or EWX_POWEROFF may be done with NtPowerInformation
135  if (!ExitWindowsEx(EWX_POWEROFF /* EWX_SHUTDOWN */, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER))
137  }
138 
140 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define EWX_POWEROFF
Definition: winuser.h:632
SHORT WINAPI GetKeyState(_In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define VK_CONTROL
Definition: winuser.h:2157
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:383
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:157
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: shutdown.c:34

◆ ShutDown_Reboot()

VOID ShutDown_Reboot ( VOID  )

Definition at line 143 of file shutdown.c.

Referenced by TaskManagerWndProc().

144 {
145  /* Trick: on Windows, pressing the CTRL key forces reboot via NT API */
146  BOOL ForceReboot = !!(GetKeyState(VK_CONTROL) & 0x8000);
147 
149  {
151  return;
152  }
153 
154  if (ForceReboot)
155  {
157  if (!NT_SUCCESS(Status))
159  }
160  else
161  {
162  if (!ExitWindowsEx(EWX_REBOOT, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER))
164  }
165 
167 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define EWX_REBOOT
Definition: winuser.h:633
SHORT WINAPI GetKeyState(_In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define VK_CONTROL
Definition: winuser.h:2157
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:383
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:157
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: shutdown.c:34

◆ ShutDown_StandBy()

VOID ShutDown_StandBy ( VOID  )

Definition at line 61 of file shutdown.c.

Referenced by TaskManagerWndProc().

62 {
64 
66  {
68  return;
69  }
70 
71 #ifdef NT_INITIATE_POWERACTION_IMPLEMENTED
74  0, FALSE);
75 #else
78  0);
79 #endif
80 
81  if (!NT_SUCCESS(Status))
83 
85 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSTATUS NTAPI NtInitiatePowerAction(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags, IN BOOLEAN Asynchronous)
Definition: power.c:639
NTSTATUS NTAPI NtSetSystemPowerState(IN POWER_ACTION SystemAction, IN SYSTEM_POWER_STATE MinSystemState, IN ULONG Flags)
Definition: power.c:861
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:383
VOID ShowWin32Error(IN DWORD dwError)
Definition: eventvwr.c:157
static BOOL EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege)
Definition: shutdown.c:34

◆ ShutDown_SwitchUser()

VOID ShutDown_SwitchUser ( VOID  )

Definition at line 177 of file shutdown.c.

Referenced by TaskManagerWndProc().

178 {
179 }