https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3318d8d5be273f92f77bda...
commit 3318d8d5be273f92f77bda4debd8b9cfa25ea599 Author: Eric Kohl eric.kohl@reactos.org AuthorDate: Mon Apr 2 18:52:47 2018 +0200 Commit: Eric Kohl eric.kohl@reactos.org CommitDate: Mon Apr 2 19:09:13 2018 +0200
[WINLOGON] Fix shutdown timeout format string for long timeout
- Use the "%d days" format for timeouts longer than a day. - Fail if timeout is 10 years or longer. - TODO: Replace format strings by resources. German WinXP uses "%d days" instead of "%d Tage". We can do better! ;-) --- base/system/winlogon/shutdown.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/base/system/winlogon/shutdown.c b/base/system/winlogon/shutdown.c index d09368664a..42452ca067 100644 --- a/base/system/winlogon/shutdown.c +++ b/base/system/winlogon/shutdown.c @@ -16,6 +16,8 @@ /* DEFINES *******************************************************************/
#define SHUTDOWN_TIMER_ID 2000 +#define SECONDS_PER_DAY 86400 +#define SECONDS_PER_DECADE 315360000
/* STRUCTS *******************************************************************/ @@ -46,16 +48,25 @@ OnTimer( HWND hwndDlg, PSYS_SHUTDOWN_PARAMS pShutdownParams) { - WCHAR szBuffer[10]; - INT iSeconds, iMinutes, iHours; + WCHAR szBuffer[12]; + INT iSeconds, iMinutes, iHours, iDays;
- iSeconds = (INT)pShutdownParams->dwTimeout; - iHours = iSeconds / 3600; - iSeconds -= iHours * 3600; - iMinutes = iSeconds / 60; - iSeconds -= iMinutes * 60; + if (pShutdownParams->dwTimeout < SECONDS_PER_DAY) + { + iSeconds = (INT)pShutdownParams->dwTimeout; + iHours = iSeconds / 3600; + iSeconds -= iHours * 3600; + iMinutes = iSeconds / 60; + iSeconds -= iMinutes * 60; + + swprintf(szBuffer, L"%02d:%02d:%02d", iHours, iMinutes, iSeconds); + } + else + { + iDays = (INT)(pShutdownParams->dwTimeout / SECONDS_PER_DAY); + swprintf(szBuffer, L"%d days", iDays); + }
- swprintf(szBuffer, L"%02d:%02d:%02d", iHours, iMinutes, iSeconds); SetDlgItemTextW(hwndDlg, IDC_SYSSHUTDOWNTIMELEFT, szBuffer);
if (pShutdownParams->dwTimeout == 0) @@ -185,6 +196,10 @@ StartSystemShutdown( { HANDLE hThread;
+ /* Fail if the timeout is 10 years or more */ + if (dwTimeout >= SECONDS_PER_DECADE) + return ERROR_INVALID_PARAMETER; + if (_InterlockedCompareExchange8((volatile char*)&g_ShutdownParams.bShuttingDown, TRUE, FALSE) == TRUE) return ERROR_SHUTDOWN_IN_PROGRESS;