ReactOS  0.4.13-dev-241-g63286c6
shutdown.c File Reference
#include <advapi32.h>
Include dependency graph for shutdown.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (advapi)
 
BOOL WINAPI AbortSystemShutdownA (LPCSTR lpMachineName)
 
BOOL WINAPI AbortSystemShutdownW (LPCWSTR lpMachineName)
 
BOOL WINAPI InitiateSystemShutdownA (LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown)
 
BOOL WINAPI InitiateSystemShutdownW (LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown)
 
BOOL WINAPI InitiateSystemShutdownExA (LPSTR lpMachineName, LPSTR lpMessage, DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown, DWORD dwReason)
 
BOOL WINAPI InitiateSystemShutdownExW (LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown, DWORD dwReason)
 
DWORD WINAPI InitiateShutdownW (LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwGracePeriod, DWORD dwShutdownFlags, DWORD dwReason)
 
DWORD WINAPI InitiateShutdownA (LPSTR lpMachineName, LPSTR lpMessage, DWORD dwGracePeriod, DWORD dwShutdownFlags, DWORD dwReason)
 

Function Documentation

◆ AbortSystemShutdownA()

BOOL WINAPI AbortSystemShutdownA ( LPCSTR  lpMachineName)

Definition at line 20 of file shutdown.c.

21 {
22  ANSI_STRING MachineNameA;
23  UNICODE_STRING MachineNameW;
25  BOOL rv;
26 
27  RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
28  Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
29  if (STATUS_SUCCESS != Status)
30  {
32  return FALSE;
33  }
34 
35  rv = AbortSystemShutdownW(MachineNameW.Buffer);
36  RtlFreeUnicodeString(&MachineNameW);
38  return rv;
39 }
BOOL WINAPI AbortSystemShutdownW(LPCWSTR lpMachineName)
Definition: shutdown.c:48
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG NTSTATUS
Definition: precomp.h:26
char * LPSTR
Definition: xmlstorage.h:182
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ AbortSystemShutdownW()

BOOL WINAPI AbortSystemShutdownW ( LPCWSTR  lpMachineName)

Definition at line 48 of file shutdown.c.

49 {
50  DWORD dwError;
51 
53  {
54  dwError = BaseAbortSystemShutdown((PREGISTRY_SERVER_NAME)lpMachineName);
55  }
57  {
59  }
61 
62  if (dwError != ERROR_SUCCESS)
63  {
64  TRACE("BaseAbortSystemShutdown() failed (Error %lu)\n", dwError);
65  SetLastError(dwError);
66  return FALSE;
67  }
68 
69  return TRUE;
70 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
ULONG __stdcall BaseAbortSystemShutdown(PREGISTRY_SERVER_NAME ServerName)
Definition: rpcserver.c:429
PWCHAR PREGISTRY_SERVER_NAME
Definition: winreg.idl:10
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by AbortSystemShutdownA(), and wmain().

◆ InitiateShutdownA()

DWORD WINAPI InitiateShutdownA ( LPSTR  lpMachineName,
LPSTR  lpMessage,
DWORD  dwGracePeriod,
DWORD  dwShutdownFlags,
DWORD  dwReason 
)

Definition at line 314 of file shutdown.c.

319 {
320  ANSI_STRING MachineNameA, MessageA;
321  UNICODE_STRING MachineNameW, MessageW;
323  INT LastError;
324  DWORD rv;
325 
326  MachineNameW.Buffer = NULL;
327  MessageW.Buffer = NULL;
328 
329  if (lpMachineName)
330  {
331  RtlInitAnsiString(&MachineNameA, lpMachineName);
332  Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
333  if (STATUS_SUCCESS != Status)
334  {
335  if(MachineNameW.Buffer)
336  RtlFreeUnicodeString(&MachineNameW);
337 
339  return FALSE;
340  }
341  }
342 
343  if (lpMessage)
344  {
345  RtlInitAnsiString(&MessageA, lpMessage);
346  Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
347  if (STATUS_SUCCESS != Status)
348  {
349  if (MessageW.Buffer)
350  RtlFreeUnicodeString(&MessageW);
351 
353  return FALSE;
354  }
355  }
356 
357  rv = InitiateShutdownW(MachineNameW.Buffer,
358  MessageW.Buffer,
359  dwGracePeriod,
360  dwShutdownFlags,
361  dwReason);
362  LastError = GetLastError();
363 
364  /* Clear the values of both strings */
365  if (lpMachineName)
366  RtlFreeUnicodeString(&MachineNameW);
367 
368  if (lpMessage)
369  RtlFreeUnicodeString(&MessageW);
370 
371  SetLastError(LastError);
372  return rv;
373 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
DWORD dwReason
Definition: misc.cpp:154
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI InitiateShutdownW(LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwGracePeriod, DWORD dwShutdownFlags, DWORD dwReason)
Definition: shutdown.c:298
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ InitiateShutdownW()

DWORD WINAPI InitiateShutdownW ( LPWSTR  lpMachineName,
LPWSTR  lpMessage,
DWORD  dwGracePeriod,
DWORD  dwShutdownFlags,
DWORD  dwReason 
)

Definition at line 298 of file shutdown.c.

303 {
305  return ERROR_SUCCESS;
306 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by InitiateShutdownA().

◆ InitiateSystemShutdownA()

BOOL WINAPI InitiateSystemShutdownA ( LPSTR  lpMachineName,
LPSTR  lpMessage,
DWORD  dwTimeout,
BOOL  bForceAppsClosed,
BOOL  bRebootAfterShutdown 
)

Definition at line 80 of file shutdown.c.

85 {
86  ANSI_STRING MachineNameA, MessageA;
87  UNICODE_STRING MachineNameW, MessageW;
89  BOOL res;
90 
91  MachineNameW.Buffer = NULL;
92  MessageW.Buffer = NULL;
93 
94  if (lpMachineName)
95  {
96  RtlInitAnsiString(&MachineNameA, lpMachineName);
97  Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
98  if (STATUS_SUCCESS != Status)
99  {
100  if(MachineNameW.Buffer)
101  RtlFreeUnicodeString(&MachineNameW);
102 
104  return FALSE;
105  }
106  }
107 
108  if (lpMessage)
109  {
110  RtlInitAnsiString(&MessageA, lpMessage);
111  Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
112  if (STATUS_SUCCESS != Status)
113  {
114  if (MessageW.Buffer)
115  RtlFreeUnicodeString(&MessageW);
116 
118  return FALSE;
119  }
120  }
121 
122  res = InitiateSystemShutdownW(MachineNameW.Buffer,
123  MessageW.Buffer,
124  dwTimeout,
125  bForceAppsClosed,
126  bRebootAfterShutdown);
127 
128  /* Clear the values of both strings */
129  if (lpMachineName)
130  RtlFreeUnicodeString(&MachineNameW);
131 
132  if (lpMessage)
133  RtlFreeUnicodeString(&MessageW);
134 
135  return res;
136 }
BOOL WINAPI InitiateSystemShutdownW(LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown)
Definition: shutdown.c:145
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
GLuint res
Definition: glext.h:9613
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ InitiateSystemShutdownExA()

BOOL WINAPI InitiateSystemShutdownExA ( LPSTR  lpMachineName,
LPSTR  lpMessage,
DWORD  dwTimeout,
BOOL  bForceAppsClosed,
BOOL  bRebootAfterShutdown,
DWORD  dwReason 
)

Definition at line 187 of file shutdown.c.

193 {
194  ANSI_STRING MachineNameA, MessageA;
195  UNICODE_STRING MachineNameW, MessageW;
197  BOOL res;
198 
199  MachineNameW.Buffer = NULL;
200  MessageW.Buffer = NULL;
201 
202  if (lpMachineName)
203  {
204  RtlInitAnsiString(&MachineNameA, lpMachineName);
205  Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
206  if (STATUS_SUCCESS != Status)
207  {
208  if(MachineNameW.Buffer)
209  RtlFreeUnicodeString(&MachineNameW);
210 
212  return FALSE;
213  }
214  }
215 
216  if (lpMessage)
217  {
218  RtlInitAnsiString(&MessageA, lpMessage);
219  Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
220  if (STATUS_SUCCESS != Status)
221  {
222  if (MessageW.Buffer)
223  RtlFreeUnicodeString(&MessageW);
224 
226  return FALSE;
227  }
228  }
229 
230  res = InitiateSystemShutdownExW(MachineNameW.Buffer,
231  MessageW.Buffer,
232  dwTimeout,
233  bForceAppsClosed,
234  bRebootAfterShutdown,
235  dwReason);
236 
237  /* Clear the values of both strings */
238  if (lpMachineName)
239  RtlFreeUnicodeString(&MachineNameW);
240 
241  if (lpMessage)
242  RtlFreeUnicodeString(&MessageW);
243 
244  return res;
245 }
#define TRUE
Definition: types.h:120
BOOL WINAPI InitiateSystemShutdownExW(LPWSTR lpMachineName, LPWSTR lpMessage, DWORD dwTimeout, BOOL bForceAppsClosed, BOOL bRebootAfterShutdown, DWORD dwReason)
Definition: shutdown.c:254
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
DWORD dwReason
Definition: misc.cpp:154
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
GLuint res
Definition: glext.h:9613
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ InitiateSystemShutdownExW()

BOOL WINAPI InitiateSystemShutdownExW ( LPWSTR  lpMachineName,
LPWSTR  lpMessage,
DWORD  dwTimeout,
BOOL  bForceAppsClosed,
BOOL  bRebootAfterShutdown,
DWORD  dwReason 
)

Definition at line 254 of file shutdown.c.

260 {
262  DWORD dwError;
263 
264  RtlInitUnicodeString(&Message, lpMessage);
265 
267  {
268  dwError = BaseInitiateSystemShutdownEx((PREGISTRY_SERVER_NAME)lpMachineName,
270  dwTimeout,
271  bForceAppsClosed,
272  bRebootAfterShutdown,
273  dwReason);
274  }
276  {
277  dwError = RpcExceptionCode();
278  }
279  RpcEndExcept;
280 
281  if (dwError != ERROR_SUCCESS)
282  {
283  TRACE("BaseInitiateSystemShutdownEx() failed (Error %lu)\n", dwError);
284  SetLastError(dwError);
285  return FALSE;
286  }
287 
288  return TRUE;
289 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD dwReason
Definition: misc.cpp:154
PWCHAR PREGISTRY_SERVER_NAME
Definition: winreg.idl:10
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
ULONG __stdcall BaseInitiateSystemShutdownEx(PREGISTRY_SERVER_NAME ServerName, PRPC_UNICODE_STRING lpMessage, ULONG dwTimeout, BOOLEAN bForceAppsClosed, BOOLEAN bRebootAfterShutdown, ULONG dwReason)
Definition: rpcserver.c:494
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
CHAR Message[80]
Definition: alive.c:5
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by InitiateSystemShutdownExA(), and wmain().

◆ InitiateSystemShutdownW()

BOOL WINAPI InitiateSystemShutdownW ( LPWSTR  lpMachineName,
LPWSTR  lpMessage,
DWORD  dwTimeout,
BOOL  bForceAppsClosed,
BOOL  bRebootAfterShutdown 
)

Definition at line 145 of file shutdown.c.

150 {
152  DWORD dwError;
153 
154  RtlInitUnicodeString(&Message, lpMessage);
155 
157  {
158  dwError = BaseInitiateSystemShutdown((PREGISTRY_SERVER_NAME)lpMachineName,
160  dwTimeout,
161  bForceAppsClosed,
162  bRebootAfterShutdown);
163  }
165  {
167  }
168  RpcEndExcept;
169 
170  if (dwError != ERROR_SUCCESS)
171  {
172  TRACE("BaseInitiateSystemShutdown() failed (Error %lu)\n", dwError);
173  SetLastError(dwError);
174  return FALSE;
175  }
176 
177  return TRUE;
178 }
#define RpcEndExcept
Definition: rpc.h:128
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
ULONG __stdcall BaseInitiateSystemShutdown(PREGISTRY_SERVER_NAME ServerName, PRPC_UNICODE_STRING lpMessage, ULONG dwTimeout, BOOLEAN bForceAppsClosed, BOOLEAN bRebootAfterShutdown)
Definition: rpcserver.c:409
PWCHAR PREGISTRY_SERVER_NAME
Definition: winreg.idl:10
#define RpcTryExcept
Definition: rpc.h:126
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define RpcExceptionCode()
Definition: rpc.h:132
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
CHAR Message[80]
Definition: alive.c:5
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6081
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RpcExcept(expr)
Definition: rpc.h:127

Referenced by InitiateSystemShutdownA().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( advapi  )