Author: hbelusca Date: Fri Oct 12 22:12:44 2012 New Revision: 57546 URL: http://svn.reactos.org/svn/reactos?rev=57546&view=rev Log: [ADVAPI32] - Pre-implement InitiateSystemShutdownExW. - Cosmetic formatting code (by me). Patch by Lee Schroeder. See CORE-6613 for more details.
CORE-6613 #comment Committed shutdown.c. Modified: trunk/reactos/dll/win32/advapi32/misc/shutdown.c Modified: trunk/reactos/dll/win32/advapi32/misc/shutdown.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/misc/shutdown.c?rev=57546&r1=57545&r2=57546&view=diff ============================================================================== --- trunk/reactos/dll/win32/advapi32/misc/shutdown.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/misc/shutdown.c [iso-8859-1] Fri Oct 12 22:12:44 2012 @@ -10,8 +10,6 @@ #include <advapi32.h> WINE_DEFAULT_DEBUG_CHANNEL(advapi); -#define USZ {0,0,0} - /********************************************************************** * AbortSystemShutdownW * @@ -28,7 +26,7 @@ /********************************************************************** * AbortSystemShutdownA * - * @unimplemented + * see AbortSystemShutdownW */ BOOL WINAPI AbortSystemShutdownA(LPCSTR lpMachineName) @@ -42,8 +40,8 @@ Status = RtlAnsiStringToUnicodeString(&MachineNameW, &MachineNameA, TRUE); if (STATUS_SUCCESS != Status) { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; } rv = AbortSystemShutdownW(MachineNameW.Buffer); @@ -71,7 +69,8 @@ bRebootAfterShutdown, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | - SHTDN_REASON_FLAG_PLANNED); + SHTDN_REASON_FLAG_PLANNED + /* SHTDN_REASON_MAJOR_LEGACY_API */); } /********************************************************************** @@ -94,7 +93,8 @@ bRebootAfterShutdown, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | - SHTDN_REASON_FLAG_PLANNED); + SHTDN_REASON_FLAG_PLANNED + /* SHTDN_REASON_MAJOR_LEGACY_API */); } /****************************************************************************** @@ -110,23 +110,37 @@ BOOL bRebootAfterShutdown, DWORD dwReason) { - SHUTDOWN_ACTION Action = ShutdownNoReboot; - NTSTATUS Status; - - if (lpMachineName) - { - /* FIXME: remote machine shutdown not supported yet */ + SHUTDOWN_ACTION action; + NTSTATUS Status; + ULONG Timeout_ms; + + /* Convert to milliseconds so we can use the value later on */ + Timeout_ms = dwTimeout * 1000; + + if (lpMachineName != NULL) + { + /* FIXME: Remote system shutdown not supported yet */ SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; } - - if (dwTimeout) - { - } - - Status = NtShutdownSystem(Action); + else /* The local system is being used */ + { + /* FIXME: Right now, only basic shutting down and rebooting + is supported */ + if(bRebootAfterShutdown == TRUE) + { + action = ShutdownReboot; + } + else + { + action = ShutdownNoReboot; + } + + Status = NtShutdownSystem(action); + } + SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; + return (Status == STATUS_SUCCESS); } /****************************************************************************** @@ -186,6 +200,8 @@ bRebootAfterShutdown, dwReason); LastError = GetLastError(); + + /* Clear the values of both strings */ if (lpMachineName) RtlFreeUnicodeString(&MachineNameW); @@ -215,7 +231,7 @@ /****************************************************************************** * InitiateShutdownA [ADVAPI32.@] * - * @unimplamented + * see InitiateShutdownW */ DWORD WINAPI InitiateShutdownA(LPSTR lpMachineName, @@ -267,6 +283,8 @@ dwShutdownFlags, dwReason); LastError = GetLastError(); + + /* Clear the values of both strings */ if (lpMachineName) RtlFreeUnicodeString(&MachineNameW);