Index: dll/win32/advapi32/advapi32.spec =================================================================== --- dll/win32/advapi32/advapi32.spec (revision 57085) +++ dll/win32/advapi32/advapi32.spec (working copy) @@ -314,6 +314,8 @@ @ stdcall InitializeAcl(ptr long long) @ stdcall InitializeSecurityDescriptor(ptr long) @ stdcall InitializeSid(ptr ptr long) +@ stdcall InitiateShutdownA(wstr wstr long long long) +@ stdcall InitiateShutdownW(wstr wstr long long long) @ stdcall InitiateSystemShutdownA(str str long long long) @ stdcall InitiateSystemShutdownExA(str str long long long long) @ stdcall InitiateSystemShutdownExW(wstr wstr long long long long) Index: dll/win32/advapi32/misc/shutdown.c =================================================================== --- dll/win32/advapi32/misc/shutdown.c (revision 57085) +++ dll/win32/advapi32/misc/shutdown.c (working copy) @@ -55,11 +55,10 @@ return rv; } - /********************************************************************** * InitiateSystemShutdownW * - * @unimplemented + * @implemented */ BOOL WINAPI InitiateSystemShutdownW(LPWSTR lpMachineName, @@ -68,6 +67,52 @@ BOOL bForceAppsClosed, BOOL bRebootAfterShutdown) { + return InitiateSystemShutdownExW(lpMachineName, + lpMessage, + dwTimeout, + bForceAppsClosed, + bRebootAfterShutdown, + SHTDN_REASON_MAJOR_OTHER | + SHTDN_REASON_MINOR_OTHER | + SHTDN_REASON_FLAG_PLANNED); +} + +/********************************************************************** + * InitiateSystemShutdownA + * + * @implemented + */ +BOOL +WINAPI +InitiateSystemShutdownA(LPSTR lpMachineName, + LPSTR lpMessage, + DWORD dwTimeout, + BOOL bForceAppsClosed, + BOOL bRebootAfterShutdown) +{ + return InitiateSystemShutdownExA(lpMachineName, + lpMessage, + dwTimeout, + bForceAppsClosed, + bRebootAfterShutdown, + SHTDN_REASON_MAJOR_OTHER | + SHTDN_REASON_MINOR_OTHER | + SHTDN_REASON_FLAG_PLANNED); +} + +/****************************************************************************** + * InitiateSystemShutdownExW [ADVAPI32.@] + * + * @unimplemented + */ +BOOL WINAPI +InitiateSystemShutdownExW(LPWSTR lpMachineName, + LPWSTR lpMessage, + DWORD dwTimeout, + BOOL bForceAppsClosed, + BOOL bRebootAfterShutdown, + DWORD dwReason) +{ SHUTDOWN_ACTION Action = ShutdownNoReboot; NTSTATUS Status; @@ -87,30 +132,27 @@ return FALSE; } - -/********************************************************************** - * InitiateSystemShutdownA +/****************************************************************************** + * InitiateSystemShutdownExA [ADVAPI32.@] * - * @unimplemented + * see InitiateSystemShutdownExW */ -BOOL -WINAPI -InitiateSystemShutdownA(LPSTR lpMachineName, - LPSTR lpMessage, - DWORD dwTimeout, - BOOL bForceAppsClosed, - BOOL bRebootAfterShutdown) +BOOL WINAPI +InitiateSystemShutdownExA(LPSTR lpMachineName, + LPSTR lpMessage, + DWORD dwTimeout, + BOOL bForceAppsClosed, + BOOL bRebootAfterShutdown, + DWORD dwReason) { - ANSI_STRING MachineNameA; - ANSI_STRING MessageA; - UNICODE_STRING MachineNameW; - UNICODE_STRING MessageW; - NTSTATUS Status; - INT LastError; - BOOL rv; + ANSI_STRING MachineNameA, MessageA; + UNICODE_STRING MachineNameW, MessageW; + NTSTATUS Status; + INT LastError; + BOOL rv; - MachineNameW.Buffer = NULL; - MessageW.Buffer = NULL; + MachineNameW.Buffer = NULL; + MessageW.Buffer = NULL; if (lpMachineName) { @@ -118,6 +160,9 @@ Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE); if (STATUS_SUCCESS != Status) { + if(MachineNameW.Buffer) + RtlFreeUnicodeString(&MachineNameW); + SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } @@ -129,63 +174,110 @@ Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE); if (STATUS_SUCCESS != Status) { - if (MachineNameW.Buffer) - { - RtlFreeUnicodeString(&MachineNameW); - } + if (MessageW.Buffer) + RtlFreeUnicodeString(&MessageW); SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } } - - rv = InitiateSystemShutdownW(MachineNameW.Buffer, - MessageW.Buffer, - dwTimeout, - bForceAppsClosed, - bRebootAfterShutdown); + + rv = InitiateSystemShutdownExW(MachineNameW.Buffer, + MessageW.Buffer, + dwTimeout, + bForceAppsClosed, + bRebootAfterShutdown, + dwReason); LastError = GetLastError(); if (lpMachineName) - { RtlFreeUnicodeString(&MachineNameW); - } if (lpMessage) - { RtlFreeUnicodeString(&MessageW); - } SetLastError(LastError); return rv; } /****************************************************************************** - * InitiateSystemShutdownExW [ADVAPI32.@] - * - * see InitiateSystemShutdownExA + * InitiateShutdownW [ADVAPI32.@] + * + * @unimplamented */ -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) { - UNIMPLEMENTED; - return TRUE; + UNIMPLEMENTED; + return ERROR_SUCCESS; } -BOOL WINAPI -InitiateSystemShutdownExA(LPSTR lpMachineName, - LPSTR lpMessage, - DWORD dwTimeout, - BOOL bForceAppsClosed, - BOOL bRebootAfterShutdown, - DWORD dwReason) +/****************************************************************************** + * InitiateShutdownA [ADVAPI32.@] + * + * @unimplamented + */ +DWORD WINAPI +InitiateShutdownA(LPSTR lpMachineName, + LPSTR lpMessage, + DWORD dwGracePeriod, + DWORD dwShutdownFlags, + DWORD dwReason) { - UNIMPLEMENTED; - return TRUE; + 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 */ Index: include/psdk/winreg.h =================================================================== --- include/psdk/winreg.h (revision 57085) +++ include/psdk/winreg.h (working copy) @@ -1,9 +1,12 @@ -#ifndef _WINREG_ -#define _WINREG_ +#ifndef _WINREG_H +#define _WINREG_H #ifdef __cplusplus extern "C" { #endif + +#include + #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 Index: include/psdk/winuser.h =================================================================== --- include/psdk/winuser.h (revision 57085) +++ include/psdk/winuser.h (working copy) @@ -613,14 +613,17 @@ #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 #define CS_KEYCVTWINDOW 4