20#define SHUTDOWN_TIMER_ID 2000
21#define SECONDS_PER_DAY 86400
22#define SECONDS_PER_DECADE 315360000
55 if (!pShutdownParams->bShuttingDown)
59 (pShutdownParams->bForceAppsClosed ?
EWX_FORCE : 0),
60 pShutdownParams->dwReason);
64 pShutdownParams->bShuttingDown =
FALSE;
79 INT iSeconds, iMinutes, iHours, iDays;
80 WCHAR szFormatBuffer[32];
82 WCHAR DesktopName[512];
84 if (!pShutdownParams->bShuttingDown)
117 ERR(
"GetUserObjectInformationW(0x%p) failed, error 0x%lx\n",
122 if (
bSuccess && (
wcscmp(DesktopName, pShutdownParams->DesktopName) != 0))
124 TRACE(
"Input desktop has changed: '%S' --> '%S'\n",
125 pShutdownParams->DesktopName, DesktopName);
128 pShutdownParams->wpPos.length =
sizeof(pShutdownParams->wpPos);
139 iSeconds = (
INT)pShutdownParams->dwTimeout;
140 iHours = iSeconds / 3600;
141 iSeconds -= iHours * 3600;
142 iMinutes = iSeconds / 60;
143 iSeconds -= iMinutes * 60;
146 swprintf(szBuffer, szFormatBuffer, iHours, iMinutes, iSeconds);
153 swprintf(szBuffer, szFormatBuffer, iDays);
158 if (pShutdownParams->dwTimeout == 0)
165 pShutdownParams->dwTimeout--;
189 if (pShutdownParams->pszMessage)
193 pShutdownParams->pszMessage);
200 if (pShutdownParams->wpPos.length ==
sizeof(pShutdownParams->wpPos))
218 OnTimer(hwndDlg, pShutdownParams);
264 ERR(
"GetUserObjectInformationW(0x%p) failed, error 0x%lx\n",
296 !(pShutdownParams->bShuttingDown && (pShutdownParams->dwTimeout > 0)))
353 if ((
dwTimeout != 0) && pMessage && pMessage->Length && pMessage->Buffer)
366 pMessage->Length /
sizeof(
WCHAR));
#define IDC_SYSSHUTDOWNTIMELEFT
#define IDS_TIMEOUTSHORTFORMAT
#define IDS_TIMEOUTLONGFORMAT
#define IDC_SYSSHUTDOWNMESSAGE
#define SECONDS_PER_DECADE
static VOID OnTimer(IN HWND hwndDlg, IN PSYS_SHUTDOWN_PARAMS pShutdownParams)
static BOOL DoSystemShutdown(IN PSYS_SHUTDOWN_PARAMS pShutdownParams)
#define SHUTDOWN_TIMER_ID
struct _SYS_SHUTDOWN_PARAMS SYS_SHUTDOWN_PARAMS
static DWORD WINAPI InitiateSystemShutdownThread(IN LPVOID lpParameter)
SYS_SHUTDOWN_PARAMS g_ShutdownParams
static INT_PTR CALLBACK ShutdownDialogProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
struct _SYS_SHUTDOWN_PARAMS * PSYS_SHUTDOWN_PARAMS
DWORD TerminateSystemShutdown(VOID)
DWORD StartSystemShutdown(IN PUNICODE_STRING pMessage, IN ULONG dwTimeout, IN BOOLEAN bForceAppsClosed, IN BOOLEAN bRebootAfterShutdown, IN ULONG dwReason)
#define ERROR_INVALID_PARAMETER
#define HeapFree(x, y, z)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
char _InterlockedCompareExchange8(_Interlocked_operand_ char volatile *_Destination, char _Exchange, char _Comparand)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOLEAN bRebootAfterShutdown
DWORD WINAPI GetLastError(void)
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
#define ERROR_NO_SHUTDOWN_IN_PROGRESS
#define ERROR_SHUTDOWN_IN_PROGRESS
#define GetWindowLongPtrW
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HDESK WINAPI OpenInputDesktop(_In_ DWORD, _In_ BOOL, _In_ DWORD)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI GetUserObjectInformationW(_In_ HANDLE hObj, _In_ int nIndex, _Out_writes_bytes_opt_(nLength) PVOID pvInfo, _In_ DWORD nLength, _Out_opt_ LPDWORD lpnLengthNeeded)
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
BOOL WINAPI CloseDesktop(_In_ HDESK)
#define MAKEINTRESOURCEW(i)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SetWindowLongPtrW
BOOL WINAPI SetWindowPlacement(_In_ HWND hWnd, _In_ const WINDOWPLACEMENT *)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)