Author: fireball
Date: Thu Aug 16 22:14:49 2012
New Revision: 57089
URL:
http://svn.reactos.org/svn/reactos?rev=57089&view=rev
Log:
[ADVAPI32]
Patch by milawynsrealm:
* Implemented the beginnings of InitiateShutdownA/W (nothing works yet, and it's not
exported).
* Running InitiateSystemShutdownA/W invokes InitiateSystemShutdownExA/W while
using "Other (Planned)" as the reason code.
- The "Other (Planned)" reason code seemed to be the best default
option so far.
Let me know if you feel otherwise.
* Added the shutdown flags that are used for InitiateShutdownA/W inside of
winreg.h.
* Include the reason.h header inside the winreg.h header so that the reason
codes can be
properly called. This conforms to the VC2010 method of adding this support.
* Added the declarations for InitiateSystemShutdownExA/W and InitiateShutdownA/W inside of
winreg.h.
* In winuser.h, change the definitions for EWX_* to conform to MSDN
documentation
-
http://msdn.microsoft.com/en-us/library/windows/desktop/aa376868%28v=vs.85%…
* Added definition support for EWX_HYBRID_SHUTDOWN which is found in Windows 8.
* Calling InitiateSystemShutdownExA will convert strings to UNICODE and send it
over to InitiateSystemShutdownExW. The same is also for InitiateShutdownA.
See issue #7245 for more details.
Modified:
trunk/reactos/dll/win32/advapi32/misc/shutdown.c
trunk/reactos/include/psdk/winreg.h
trunk/reactos/include/psdk/winuser.h
Modified: trunk/reactos/dll/win32/advapi32/misc/shutdown.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/misc/sh…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/misc/shutdown.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/misc/shutdown.c [iso-8859-1] Thu Aug 16 22:14:49
2012
@@ -55,11 +55,10 @@
return rv;
}
-
/**********************************************************************
* InitiateSystemShutdownW
*
- * @unimplemented
+ * @implemented
*/
BOOL WINAPI
InitiateSystemShutdownW(LPWSTR lpMachineName,
@@ -68,30 +67,20 @@
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown)
{
- SHUTDOWN_ACTION Action = ShutdownNoReboot;
- NTSTATUS Status;
-
- if (lpMachineName)
- {
- /* FIXME: remote machine shutdown not supported yet */
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
- }
-
- if (dwTimeout)
- {
- }
-
- Status = NtShutdownSystem(Action);
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
-}
-
+ return InitiateSystemShutdownExW(lpMachineName,
+ lpMessage,
+ dwTimeout,
+ bForceAppsClosed,
+ bRebootAfterShutdown,
+ SHTDN_REASON_MAJOR_OTHER |
+ SHTDN_REASON_MINOR_OTHER |
+ SHTDN_REASON_FLAG_PLANNED);
+}
/**********************************************************************
* InitiateSystemShutdownA
*
- * @unimplemented
+ * @implemented
*/
BOOL
WINAPI
@@ -101,68 +90,20 @@
BOOL bForceAppsClosed,
BOOL bRebootAfterShutdown)
{
- ANSI_STRING MachineNameA;
- ANSI_STRING MessageA;
- UNICODE_STRING MachineNameW;
- UNICODE_STRING MessageW;
- NTSTATUS Status;
- INT LastError;
- BOOL rv;
-
- MachineNameW.Buffer = NULL;
- MessageW.Buffer = NULL;
-
- if (lpMachineName)
- {
- RtlInitAnsiString(&MachineNameA, lpMachineName);
- Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA,
TRUE);
- if (STATUS_SUCCESS != Status)
- {
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
- }
-
- if (lpMessage)
- {
- RtlInitAnsiString(&MessageA, lpMessage);
- Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
- if (STATUS_SUCCESS != Status)
- {
- if (MachineNameW.Buffer)
- {
- RtlFreeUnicodeString(&MachineNameW);
- }
-
- SetLastError(RtlNtStatusToDosError(Status));
- return FALSE;
- }
- }
-
- rv = InitiateSystemShutdownW(MachineNameW.Buffer,
- MessageW.Buffer,
- dwTimeout,
- bForceAppsClosed,
- bRebootAfterShutdown);
- LastError = GetLastError();
- if (lpMachineName)
- {
- RtlFreeUnicodeString(&MachineNameW);
- }
-
- if (lpMessage)
- {
- RtlFreeUnicodeString(&MessageW);
- }
-
- SetLastError(LastError);
- return rv;
+ return InitiateSystemShutdownExA(lpMachineName,
+ lpMessage,
+ dwTimeout,
+ bForceAppsClosed,
+ bRebootAfterShutdown,
+ SHTDN_REASON_MAJOR_OTHER |
+ SHTDN_REASON_MINOR_OTHER |
+ SHTDN_REASON_FLAG_PLANNED);
}
/******************************************************************************
* InitiateSystemShutdownExW [ADVAPI32.@]
*
- * see InitiateSystemShutdownExA
+ * @unimplemented
*/
BOOL WINAPI
InitiateSystemShutdownExW(LPWSTR lpMachineName,
@@ -172,10 +113,30 @@
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
- UNIMPLEMENTED;
- return TRUE;
-}
-
+ SHUTDOWN_ACTION Action = ShutdownNoReboot;
+ NTSTATUS Status;
+
+ if (lpMachineName)
+ {
+ /* FIXME: remote machine shutdown not supported yet */
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return FALSE;
+ }
+
+ if (dwTimeout)
+ {
+ }
+
+ Status = NtShutdownSystem(Action);
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+}
+
+/******************************************************************************
+ * InitiateSystemShutdownExA [ADVAPI32.@]
+ *
+ * see InitiateSystemShutdownExW
+ */
BOOL WINAPI
InitiateSystemShutdownExA(LPSTR lpMachineName,
LPSTR lpMessage,
@@ -184,8 +145,139 @@
BOOL bRebootAfterShutdown,
DWORD dwReason)
{
- UNIMPLEMENTED;
- return TRUE;
+ ANSI_STRING MachineNameA, MessageA;
+ UNICODE_STRING MachineNameW, MessageW;
+ NTSTATUS Status;
+ INT LastError;
+ BOOL rv;
+
+ MachineNameW.Buffer = NULL;
+ MessageW.Buffer = NULL;
+
+ if (lpMachineName)
+ {
+ RtlInitAnsiString(&MachineNameA, lpMachineName);
+ Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA,
TRUE);
+ if (STATUS_SUCCESS != Status)
+ {
+ if(MachineNameW.Buffer)
+ RtlFreeUnicodeString(&MachineNameW);
+
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ }
+
+ if (lpMessage)
+ {
+ RtlInitAnsiString(&MessageA, lpMessage);
+ Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
+ if (STATUS_SUCCESS != Status)
+ {
+ if (MessageW.Buffer)
+ RtlFreeUnicodeString(&MessageW);
+
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ }
+
+ rv = InitiateSystemShutdownExW(MachineNameW.Buffer,
+ MessageW.Buffer,
+ dwTimeout,
+ bForceAppsClosed,
+ bRebootAfterShutdown,
+ dwReason);
+ LastError = GetLastError();
+ if (lpMachineName)
+ RtlFreeUnicodeString(&MachineNameW);
+
+ if (lpMessage)
+ RtlFreeUnicodeString(&MessageW);
+
+ SetLastError(LastError);
+ return rv;
+}
+
+/******************************************************************************
+ * InitiateShutdownW [ADVAPI32.@]
+ *
+ * @unimplamented
+ */
+DWORD WINAPI
+InitiateShutdownW(LPWSTR lpMachineName,
+ LPWSTR lpMessage,
+ DWORD dwGracePeriod,
+ DWORD dwShutdownFlags,
+ DWORD dwReason)
+{
+ UNIMPLEMENTED;
+ return ERROR_SUCCESS;
+}
+
+/******************************************************************************
+ * InitiateShutdownA [ADVAPI32.@]
+ *
+ * @unimplamented
+ */
+DWORD WINAPI
+InitiateShutdownA(LPSTR lpMachineName,
+ LPSTR lpMessage,
+ DWORD dwGracePeriod,
+ DWORD dwShutdownFlags,
+ DWORD dwReason)
+{
+ ANSI_STRING MachineNameA, MessageA;
+ UNICODE_STRING MachineNameW, MessageW;
+ NTSTATUS Status;
+ INT LastError;
+ DWORD rv;
+
+ MachineNameW.Buffer = NULL;
+ MessageW.Buffer = NULL;
+
+ if (lpMachineName)
+ {
+ RtlInitAnsiString(&MachineNameA, lpMachineName);
+ Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA,
TRUE);
+ if (STATUS_SUCCESS != Status)
+ {
+ if(MachineNameW.Buffer)
+ RtlFreeUnicodeString(&MachineNameW);
+
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ }
+
+ if (lpMessage)
+ {
+ RtlInitAnsiString(&MessageA, lpMessage);
+ Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
+ if (STATUS_SUCCESS != Status)
+ {
+ if (MessageW.Buffer)
+ RtlFreeUnicodeString(&MessageW);
+
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+ }
+
+ rv = InitiateShutdownW(MachineNameW.Buffer,
+ MessageW.Buffer,
+ dwGracePeriod,
+ dwShutdownFlags,
+ dwReason);
+ LastError = GetLastError();
+ if (lpMachineName)
+ RtlFreeUnicodeString(&MachineNameW);
+
+ if (lpMessage)
+ RtlFreeUnicodeString(&MessageW);
+
+ SetLastError(LastError);
+ return rv;
}
/* EOF */
Modified: trunk/reactos/include/psdk/winreg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winreg.h?rev=…
==============================================================================
--- trunk/reactos/include/psdk/winreg.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winreg.h [iso-8859-1] Thu Aug 16 22:14:49 2012
@@ -1,9 +1,12 @@
-#ifndef _WINREG_
-#define _WINREG_
+#ifndef _WINREG_H
+#define _WINREG_H
#ifdef __cplusplus
extern "C" {
#endif
+
+#include <reason.h>
+
#define HKEY_CLASSES_ROOT ((HKEY)0x80000000)
#define HKEY_CURRENT_USER ((HKEY)0x80000001)
#define HKEY_LOCAL_MACHINE ((HKEY)0x80000002)
@@ -34,6 +37,16 @@
#define REG_NOTIFY_CHANGE_LAST_SET 4
#define REG_NOTIFY_CHANGE_SECURITY 8
+/* Shutdown flags for InitiateShutdownA/W */
+#define SHUTDOWN_FORCE_OTHERS 0x00000001
+#define SHUTDOWN_FORCE_SELF 0x00000002
+#define SHUTDOWN_GRACE_OVERRIDE 0x00000020
+#define SHUTDOWN_INSTALL_UPDATES 0x00000040
+#define SHUTDOWN_NOREBOOT 0x00000010
+#define SHUTDOWN_POWEROFF 0x00000008
+#define SHUTDOWN_RESTART 0x00000004
+#define SHUTDOWN_RESTARTAPPS 0x00000080
+
#define RRF_RT_REG_NONE (1 << 0)
#define RRF_RT_REG_SZ (1 << 1)
#define RRF_RT_REG_EXPAND_SZ (1 << 2)
@@ -64,8 +77,14 @@
} VALENTW,*PVALENTW;
BOOL WINAPI AbortSystemShutdownA(LPCSTR);
BOOL WINAPI AbortSystemShutdownW(LPCWSTR);
+#if (_WIN32_WINNT >= 0x0600)
+DWORD WINAPI InitiateShutdownA(LPSTR, LPSTR, DWORD, DWORD, DWORD);
+DWORD WINAPI InitiateShutdownW(LPWSTR, LPWSTR, DWORD, DWORD, DWORD);
+#endif
BOOL WINAPI InitiateSystemShutdownA(LPSTR,LPSTR,DWORD,BOOL,BOOL);
BOOL WINAPI InitiateSystemShutdownW(LPWSTR,LPWSTR,DWORD,BOOL,BOOL);
+BOOL WINAPI InitiateSystemShutdownExA(LPSTR,LPSTR,DWORD,BOOL,BOOL,DWORD);
+BOOL WINAPI InitiateSystemShutdownExW(LPWSTR,LPWSTR,DWORD,BOOL,BOOL,DWORD);
LONG WINAPI RegCloseKey(HKEY);
LONG WINAPI RegConnectRegistryA(LPCSTR,HKEY,PHKEY);
LONG WINAPI RegConnectRegistryW(LPCWSTR,HKEY,PHKEY);
@@ -158,8 +177,10 @@
typedef VALENTW VALENT,*PVALENT;
#define AbortSystemShutdown AbortSystemShutdownW
#define InitiateSystemShutdown InitiateSystemShutdownW
+#define InitiateSystemShutdownEx InitiateSystemShutdownExW
#define RegConnectRegistry RegConnectRegistryW
#if (_WIN32_WINNT >= 0x0600)
+#define InitiateShutdown InitiateShutdownW
#define RegCopyTree RegCopyTreeW
#endif
#define RegCreateKey RegCreateKeyW
@@ -201,8 +222,10 @@
typedef VALENTA VALENT,*PVALENT;
#define AbortSystemShutdown AbortSystemShutdownA
#define InitiateSystemShutdown InitiateSystemShutdownA
+#define InitiateSystemShutdownEx InitiateSystemShutdownExA
#define RegConnectRegistry RegConnectRegistryA
#if (_WIN32_WINNT >= 0x0600)
+#define InitiateShutdown InitiateShutdownA
#define RegCopyTree RegCopyTreeA
#endif
#define RegCreateKey RegCreateKeyA
Modified: trunk/reactos/include/psdk/winuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winuser.h?rev…
==============================================================================
--- trunk/reactos/include/psdk/winuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winuser.h [iso-8859-1] Thu Aug 16 22:14:49 2012
@@ -613,13 +613,16 @@
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
#endif
-#define EWX_FORCE 4
+#define EWX_FORCE 0x00000004
#define EWX_LOGOFF 0
-#define EWX_POWEROFF 8
-#define EWX_REBOOT 2
-#define EWX_SHUTDOWN 1
+#define EWX_POWEROFF 0x00000008
+#define EWX_REBOOT 0x00000002
+#define EWX_SHUTDOWN 0x00000001
#if (_WIN32_WINNT >= 0x0500)
-#define EWX_FORCEIFHUNG 16
+#define EWX_FORCEIFHUNG 0x00000010
+#endif
+#if (_WIN32_WINNT > 0x06010000)
+#define EWX_HYBRID_SHUTDOWN 0x00400000
#endif
#define CS_BYTEALIGNCLIENT 4096
#define CS_BYTEALIGNWINDOW 8192