2012-08-17 12:47:29 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2003-01-07 17:32:59 +00:00
|
|
|
* PROJECT: ReactOS system libraries
|
2012-08-17 12:47:29 +00:00
|
|
|
* FILE: dll/win32/advapi32/misc/shutdown.c
|
2003-01-07 17:32:59 +00:00
|
|
|
* PURPOSE: System shutdown functions
|
2012-09-29 09:06:42 +00:00
|
|
|
* PROGRAMMER: Lee Schroeder <spaceseel at gmail dot com>
|
2012-08-17 12:47:29 +00:00
|
|
|
* Emanuele Aliberti
|
2003-01-07 17:32:59 +00:00
|
|
|
*/
|
|
|
|
|
2005-08-05 10:31:28 +00:00
|
|
|
#include <advapi32.h>
|
2014-01-20 13:16:06 +00:00
|
|
|
|
|
|
|
#include <ndk/exfuncs.h>
|
|
|
|
|
2011-08-14 11:31:23 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(advapi);
|
2003-01-07 17:32:59 +00:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* AbortSystemShutdownW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
|
|
|
* @unimplemented
|
2003-01-07 17:32:59 +00:00
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2003-01-07 17:32:59 +00:00
|
|
|
AbortSystemShutdownW(LPCWSTR lpMachineName)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* AbortSystemShutdownA
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2012-10-12 22:12:44 +00:00
|
|
|
* see AbortSystemShutdownW
|
2003-01-07 17:32:59 +00:00
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2003-01-07 17:32:59 +00:00
|
|
|
AbortSystemShutdownA(LPCSTR lpMachineName)
|
|
|
|
{
|
|
|
|
ANSI_STRING MachineNameA;
|
|
|
|
UNICODE_STRING MachineNameW;
|
|
|
|
NTSTATUS Status;
|
|
|
|
BOOL rv;
|
|
|
|
|
2003-02-02 17:21:06 +00:00
|
|
|
RtlInitAnsiString(&MachineNameA, (LPSTR)lpMachineName);
|
2003-01-07 17:32:59 +00:00
|
|
|
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
|
2008-09-20 20:28:23 +00:00
|
|
|
if (STATUS_SUCCESS != Status)
|
|
|
|
{
|
2012-10-12 22:12:44 +00:00
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
2003-01-07 17:32:59 +00:00
|
|
|
}
|
2008-09-20 20:28:23 +00:00
|
|
|
|
2003-01-07 17:32:59 +00:00
|
|
|
rv = AbortSystemShutdownW(MachineNameW.Buffer);
|
|
|
|
RtlFreeUnicodeString(&MachineNameW);
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* InitiateSystemShutdownW
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2012-08-16 22:14:49 +00:00
|
|
|
* @implemented
|
2003-01-07 17:32:59 +00:00
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2008-09-20 20:28:23 +00:00
|
|
|
InitiateSystemShutdownW(LPWSTR lpMachineName,
|
|
|
|
LPWSTR lpMessage,
|
|
|
|
DWORD dwTimeout,
|
|
|
|
BOOL bForceAppsClosed,
|
|
|
|
BOOL bRebootAfterShutdown)
|
2012-08-16 22:14:49 +00:00
|
|
|
{
|
2012-09-29 09:06:42 +00:00
|
|
|
return InitiateSystemShutdownExW(lpMachineName,
|
2012-08-16 22:14:49 +00:00
|
|
|
lpMessage,
|
|
|
|
dwTimeout,
|
|
|
|
bForceAppsClosed,
|
|
|
|
bRebootAfterShutdown,
|
|
|
|
SHTDN_REASON_MAJOR_OTHER |
|
|
|
|
SHTDN_REASON_MINOR_OTHER |
|
2012-10-12 22:12:44 +00:00
|
|
|
SHTDN_REASON_FLAG_PLANNED
|
|
|
|
/* SHTDN_REASON_MAJOR_LEGACY_API */);
|
2012-08-16 22:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* InitiateSystemShutdownA
|
|
|
|
*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
InitiateSystemShutdownA(LPSTR lpMachineName,
|
|
|
|
LPSTR lpMessage,
|
|
|
|
DWORD dwTimeout,
|
|
|
|
BOOL bForceAppsClosed,
|
|
|
|
BOOL bRebootAfterShutdown)
|
|
|
|
{
|
2012-09-29 09:06:42 +00:00
|
|
|
return InitiateSystemShutdownExA(lpMachineName,
|
2012-08-16 22:14:49 +00:00
|
|
|
lpMessage,
|
|
|
|
dwTimeout,
|
|
|
|
bForceAppsClosed,
|
|
|
|
bRebootAfterShutdown,
|
|
|
|
SHTDN_REASON_MAJOR_OTHER |
|
|
|
|
SHTDN_REASON_MINOR_OTHER |
|
2012-10-12 22:12:44 +00:00
|
|
|
SHTDN_REASON_FLAG_PLANNED
|
|
|
|
/* SHTDN_REASON_MAJOR_LEGACY_API */);
|
2012-08-16 22:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* InitiateSystemShutdownExW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI
|
|
|
|
InitiateSystemShutdownExW(LPWSTR lpMachineName,
|
|
|
|
LPWSTR lpMessage,
|
|
|
|
DWORD dwTimeout,
|
|
|
|
BOOL bForceAppsClosed,
|
|
|
|
BOOL bRebootAfterShutdown,
|
|
|
|
DWORD dwReason)
|
2003-01-07 17:32:59 +00:00
|
|
|
{
|
2012-10-12 22:12:44 +00:00
|
|
|
SHUTDOWN_ACTION action;
|
2008-09-20 20:28:23 +00:00
|
|
|
NTSTATUS Status;
|
2012-10-12 22:12:44 +00:00
|
|
|
ULONG Timeout_ms;
|
2003-01-07 17:32:59 +00:00
|
|
|
|
2012-10-12 22:12:44 +00:00
|
|
|
/* Convert to milliseconds so we can use the value later on */
|
|
|
|
Timeout_ms = dwTimeout * 1000;
|
|
|
|
|
|
|
|
if (lpMachineName != NULL)
|
2008-09-20 20:28:23 +00:00
|
|
|
{
|
2012-10-12 22:12:44 +00:00
|
|
|
/* FIXME: Remote system shutdown not supported yet */
|
2003-01-07 17:32:59 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-10-12 22:12:44 +00:00
|
|
|
else /* The local system is being used */
|
2008-09-20 20:28:23 +00:00
|
|
|
{
|
2012-10-12 22:12:44 +00:00
|
|
|
/* FIXME: Right now, only basic shutting down and rebooting
|
|
|
|
is supported */
|
|
|
|
if(bRebootAfterShutdown == TRUE)
|
|
|
|
{
|
|
|
|
action = ShutdownReboot;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
action = ShutdownNoReboot;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = NtShutdownSystem(action);
|
2003-01-07 17:32:59 +00:00
|
|
|
}
|
2008-09-20 20:28:23 +00:00
|
|
|
|
2003-01-07 17:32:59 +00:00
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
2012-10-12 22:12:44 +00:00
|
|
|
return (Status == STATUS_SUCCESS);
|
2003-01-07 17:32:59 +00:00
|
|
|
}
|
|
|
|
|
2012-08-16 22:14:49 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* InitiateSystemShutdownExA [ADVAPI32.@]
|
2003-07-10 15:05:55 +00:00
|
|
|
*
|
2012-08-16 22:14:49 +00:00
|
|
|
* see InitiateSystemShutdownExW
|
2003-07-10 15:05:55 +00:00
|
|
|
*/
|
2012-08-16 22:14:49 +00:00
|
|
|
BOOL WINAPI
|
|
|
|
InitiateSystemShutdownExA(LPSTR lpMachineName,
|
|
|
|
LPSTR lpMessage,
|
|
|
|
DWORD dwTimeout,
|
|
|
|
BOOL bForceAppsClosed,
|
|
|
|
BOOL bRebootAfterShutdown,
|
|
|
|
DWORD dwReason)
|
2003-01-07 17:32:59 +00:00
|
|
|
{
|
2012-08-16 22:14:49 +00:00
|
|
|
ANSI_STRING MachineNameA, MessageA;
|
|
|
|
UNICODE_STRING MachineNameW, MessageW;
|
|
|
|
NTSTATUS Status;
|
|
|
|
INT LastError;
|
|
|
|
BOOL rv;
|
2003-01-07 17:32:59 +00:00
|
|
|
|
2012-08-16 22:14:49 +00:00
|
|
|
MachineNameW.Buffer = NULL;
|
|
|
|
MessageW.Buffer = NULL;
|
2008-11-06 00:24:40 +00:00
|
|
|
|
2008-09-20 20:28:23 +00:00
|
|
|
if (lpMachineName)
|
|
|
|
{
|
2003-01-07 17:32:59 +00:00
|
|
|
RtlInitAnsiString(&MachineNameA, lpMachineName);
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE);
|
2008-09-20 20:28:23 +00:00
|
|
|
if (STATUS_SUCCESS != Status)
|
|
|
|
{
|
2012-08-16 22:14:49 +00:00
|
|
|
if(MachineNameW.Buffer)
|
|
|
|
RtlFreeUnicodeString(&MachineNameW);
|
|
|
|
|
2003-01-07 17:32:59 +00:00
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2008-09-20 20:28:23 +00:00
|
|
|
|
|
|
|
if (lpMessage)
|
|
|
|
{
|
2003-01-07 17:32:59 +00:00
|
|
|
RtlInitAnsiString(&MessageA, lpMessage);
|
|
|
|
Status = RtlAnsiStringToUnicodeString(&MessageW, &MessageA, TRUE);
|
2008-09-20 20:28:23 +00:00
|
|
|
if (STATUS_SUCCESS != Status)
|
|
|
|
{
|
2012-08-16 22:14:49 +00:00
|
|
|
if (MessageW.Buffer)
|
|
|
|
RtlFreeUnicodeString(&MessageW);
|
2008-09-20 20:28:23 +00:00
|
|
|
|
2003-01-07 17:32:59 +00:00
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-09-29 09:06:42 +00:00
|
|
|
|
2012-08-16 22:14:49 +00:00
|
|
|
rv = InitiateSystemShutdownExW(MachineNameW.Buffer,
|
|
|
|
MessageW.Buffer,
|
|
|
|
dwTimeout,
|
|
|
|
bForceAppsClosed,
|
|
|
|
bRebootAfterShutdown,
|
|
|
|
dwReason);
|
2003-01-07 17:32:59 +00:00
|
|
|
LastError = GetLastError();
|
2012-10-12 22:12:44 +00:00
|
|
|
|
|
|
|
/* Clear the values of both strings */
|
2008-09-20 20:28:23 +00:00
|
|
|
if (lpMachineName)
|
2003-01-07 17:32:59 +00:00
|
|
|
RtlFreeUnicodeString(&MachineNameW);
|
2008-09-20 20:28:23 +00:00
|
|
|
|
|
|
|
if (lpMessage)
|
2003-01-07 17:32:59 +00:00
|
|
|
RtlFreeUnicodeString(&MessageW);
|
2008-09-20 20:28:23 +00:00
|
|
|
|
2003-01-07 17:32:59 +00:00
|
|
|
SetLastError(LastError);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2005-08-16 05:17:06 +00:00
|
|
|
/******************************************************************************
|
2012-08-16 22:14:49 +00:00
|
|
|
* InitiateShutdownW [ADVAPI32.@]
|
|
|
|
*
|
|
|
|
* @unimplamented
|
2005-08-16 05:17:06 +00:00
|
|
|
*/
|
2012-08-16 22:14:49 +00:00
|
|
|
DWORD WINAPI
|
|
|
|
InitiateShutdownW(LPWSTR lpMachineName,
|
|
|
|
LPWSTR lpMessage,
|
|
|
|
DWORD dwGracePeriod,
|
|
|
|
DWORD dwShutdownFlags,
|
|
|
|
DWORD dwReason)
|
2005-08-16 05:17:06 +00:00
|
|
|
{
|
2012-08-16 22:14:49 +00:00
|
|
|
UNIMPLEMENTED;
|
|
|
|
return ERROR_SUCCESS;
|
2007-10-19 23:21:45 +00:00
|
|
|
}
|
2005-08-16 05:17:06 +00:00
|
|
|
|
2012-08-16 22:14:49 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* InitiateShutdownA [ADVAPI32.@]
|
|
|
|
*
|
2012-10-12 22:12:44 +00:00
|
|
|
* see InitiateShutdownW
|
2012-08-16 22:14:49 +00:00
|
|
|
*/
|
|
|
|
DWORD WINAPI
|
|
|
|
InitiateShutdownA(LPSTR lpMachineName,
|
|
|
|
LPSTR lpMessage,
|
|
|
|
DWORD dwGracePeriod,
|
|
|
|
DWORD dwShutdownFlags,
|
|
|
|
DWORD dwReason)
|
Sync aclui, advapi32, atl, authz, kernel32, msi, oledlg, powrprof, qmgr, riched20, samlib to Wine 1.2rc5
Update some psdk Headers to get some more synched winetests build
svn path=/trunk/; revision=47930
2010-07-03 12:42:55 +00:00
|
|
|
{
|
2012-08-16 22:14:49 +00:00
|
|
|
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();
|
2012-10-12 22:12:44 +00:00
|
|
|
|
|
|
|
/* Clear the values of both strings */
|
2012-08-16 22:14:49 +00:00
|
|
|
if (lpMachineName)
|
|
|
|
RtlFreeUnicodeString(&MachineNameW);
|
|
|
|
|
|
|
|
if (lpMessage)
|
|
|
|
RtlFreeUnicodeString(&MessageW);
|
|
|
|
|
|
|
|
SetLastError(LastError);
|
|
|
|
return rv;
|
Sync aclui, advapi32, atl, authz, kernel32, msi, oledlg, powrprof, qmgr, riched20, samlib to Wine 1.2rc5
Update some psdk Headers to get some more synched winetests build
svn path=/trunk/; revision=47930
2010-07-03 12:42:55 +00:00
|
|
|
}
|
|
|
|
|
2003-01-07 17:32:59 +00:00
|
|
|
/* EOF */
|