mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 04:37:15 +00:00
[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%29.aspx * 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. svn path=/trunk/; revision=57089
This commit is contained in:
parent
a4768e7acd
commit
97ce06cdeb
3 changed files with 182 additions and 64 deletions
|
@ -55,11 +55,10 @@ AbortSystemShutdownA(LPCSTR lpMachineName)
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* InitiateSystemShutdownW
|
||||
*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
BOOL WINAPI
|
||||
InitiateSystemShutdownW(LPWSTR lpMachineName,
|
||||
|
@ -67,6 +66,52 @@ InitiateSystemShutdownW(LPWSTR lpMachineName,
|
|||
DWORD dwTimeout,
|
||||
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,24 +132,21 @@ InitiateSystemShutdownW(LPWSTR lpMachineName,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* InitiateSystemShutdownA
|
||||
/******************************************************************************
|
||||
* InitiateSystemShutdownExA [ADVAPI32.@]
|
||||
*
|
||||
* @unimplemented
|
||||
* see InitiateSystemShutdownExW
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
InitiateSystemShutdownA(LPSTR lpMachineName,
|
||||
BOOL WINAPI
|
||||
InitiateSystemShutdownExA(LPSTR lpMachineName,
|
||||
LPSTR lpMessage,
|
||||
DWORD dwTimeout,
|
||||
BOOL bForceAppsClosed,
|
||||
BOOL bRebootAfterShutdown)
|
||||
BOOL bRebootAfterShutdown,
|
||||
DWORD dwReason)
|
||||
{
|
||||
ANSI_STRING MachineNameA;
|
||||
ANSI_STRING MessageA;
|
||||
UNICODE_STRING MachineNameW;
|
||||
UNICODE_STRING MessageW;
|
||||
ANSI_STRING MachineNameA, MessageA;
|
||||
UNICODE_STRING MachineNameW, MessageW;
|
||||
NTSTATUS Status;
|
||||
INT LastError;
|
||||
BOOL rv;
|
||||
|
@ -118,6 +160,9 @@ InitiateSystemShutdownA(LPSTR lpMachineName,
|
|||
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
|
||||
if (STATUS_SUCCESS != Status)
|
||||
{
|
||||
if(MachineNameW.Buffer)
|
||||
RtlFreeUnicodeString(&MachineNameW);
|
||||
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -129,63 +174,110 @@ InitiateSystemShutdownA(LPSTR lpMachineName,
|
|||
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,
|
||||
rv = InitiateSystemShutdownExW(MachineNameW.Buffer,
|
||||
MessageW.Buffer,
|
||||
dwTimeout,
|
||||
bForceAppsClosed,
|
||||
bRebootAfterShutdown);
|
||||
bRebootAfterShutdown,
|
||||
dwReason);
|
||||
LastError = GetLastError();
|
||||
if (lpMachineName)
|
||||
{
|
||||
RtlFreeUnicodeString(&MachineNameW);
|
||||
}
|
||||
|
||||
if (lpMessage)
|
||||
{
|
||||
RtlFreeUnicodeString(&MessageW);
|
||||
}
|
||||
|
||||
SetLastError(LastError);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* InitiateSystemShutdownExW [ADVAPI32.@]
|
||||
* InitiateShutdownW [ADVAPI32.@]
|
||||
*
|
||||
* see InitiateSystemShutdownExA
|
||||
* @unimplamented
|
||||
*/
|
||||
BOOL WINAPI
|
||||
InitiateSystemShutdownExW(LPWSTR lpMachineName,
|
||||
DWORD WINAPI
|
||||
InitiateShutdownW(LPWSTR lpMachineName,
|
||||
LPWSTR lpMessage,
|
||||
DWORD dwTimeout,
|
||||
BOOL bForceAppsClosed,
|
||||
BOOL bRebootAfterShutdown,
|
||||
DWORD dwGracePeriod,
|
||||
DWORD dwShutdownFlags,
|
||||
DWORD dwReason)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL WINAPI
|
||||
InitiateSystemShutdownExA(LPSTR lpMachineName,
|
||||
/******************************************************************************
|
||||
* InitiateShutdownA [ADVAPI32.@]
|
||||
*
|
||||
* @unimplamented
|
||||
*/
|
||||
DWORD WINAPI
|
||||
InitiateShutdownA(LPSTR lpMachineName,
|
||||
LPSTR lpMessage,
|
||||
DWORD dwTimeout,
|
||||
BOOL bForceAppsClosed,
|
||||
BOOL bRebootAfterShutdown,
|
||||
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 */
|
||||
|
|
|
@ -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 @@ extern "C" {
|
|||
#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 @@ typedef struct value_entW {
|
|||
} 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 @@ LONG WINAPI RegUnLoadKeyW(HKEY,LPCWSTR);
|
|||
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 VALENTW VALENT,*PVALENT;
|
|||
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
|
||||
|
|
|
@ -613,13 +613,16 @@ extern "C" {
|
|||
#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
|
||||
|
|
Loading…
Reference in a new issue