26#if !defined(SHUTDOWN_SYSTEMCONTEXT) && !defined(SHUTDOWN_OTHERCONTEXT)
27#define SHUTDOWN_SYSTEMCONTEXT CsrShutdownSystem
28#define SHUTDOWN_OTHERCONTEXT CsrShutdownOther
32#define MY_DPRINT DPRINT1
33#define MY_DPRINT2 DPRINT
52#define QUERY_RESULT_ABORT 0
53#define QUERY_RESULT_CONTINUE 1
54#define QUERY_RESULT_TIMEOUT 2
55#define QUERY_RESULT_ERROR 3
56#define QUERY_RESULT_FORCE 4
86 if (InitProc ==
NULL)
return;
155 MY_DPRINT(
"Closing progress dlg by hand\n");
209 if (NotifyContext->
Dlg ==
NULL)
235 DPRINT(
"Called WM_CLIENTSHUTDOWN with wParam == 0 ...\n");
268 DPRINT(
"SendClientShutdown -- Return == %s\n",
273 DPRINT1(
"SendClientShutdown -- Error == %s\n",
299 MessageContext.
Wnd = Wnd;
300 MessageContext.
Msg = NotifyContext->
Msg;
308 if (Passed < MessageContext.
Timeout)
310 MessageContext.
Timeout -= Passed;
313 if (MessageThread ==
NULL)
338 Threads[0] = MessageThread;
339 Threads[1] = NotifyContext->
UIThread;
421 MY_DPRINT(
"GetWindow(TopWnd, GW_OWNER) not returned NULL...\n");
424 if (TopWnd != tmpWnd)
MY_DPRINT(
"(TopWnd = %x) != (tmpWnd = %x)\n", TopWnd, tmpWnd);
433 ENDSESSION_LOGOFF : 0);
449 MY_DPRINT(
"After switching to desktop (Success = %s ; last error = %d); going to notify top-level...\n",
460 MY_DPRINT(
"Context->UIThread != NULL\n");
463 MY_DPRINT(
"Sending WM_CLOSE because Dlg is != NULL\n");
468 MY_DPRINT(
"Terminating UIThread thread with QUERY_RESULT_ERROR\n");
510 MY_DPRINT2(
"Sending the QUERYENDSESSION messages...\n");
519 NextEntry = NextEntry->
Flink;
550 QueryResult =
Context.QueryResult;
555 MY_DPRINT2(
"Now sending the ENDSESSION messages...\n");
564 NextEntry = NextEntry->
Flink;
618 DPRINT1(
"SrvExitWindowsEx(ClientId: %lx.%lx, Flags: 0x%x)\n",
630 DPRINT1(
"SrvExitWindowsEx call not from Winlogon\n");
649 DPRINT1(
"Unable to get caller LUID, Status = 0x%08x\n",
Status);
667 DPRINT1(
"NtUserSetInformationThread returned STATUS_CANT_WAIT\n");
672 DPRINT1(
"NtUserSetInformationThread returned STATUS_PENDING\n");
678 DPRINT1(
"NtUserSetInformationThread returned STATUS_RETRY\n");
711 DPRINT1(
"Failed to shutdown processes, Status = 0x%08x\n",
Status);
738 DPRINT(
"UserClientShutdown(0x%p, 0x%x, %s) - [0x%x, 0x%x], ShutdownFlags: %lu\n",
751 DPRINT(
"Do not kill a system process in a logoff request!\n");
758 DPRINT(
"Not killing Winlogon; CsrProcess->ShutdownFlags = %lu\n",
813 DPRINT1(
"Failed to set thread desktop!\n");
833 DPRINT1(
"SrvEndTask is HACKPLEMENTED!!\n");
841 DPRINT1(
"Failed to set thread desktop!\n");
850 if (EndTaskRequest->
Force)
#define UlongToHandle(ul)
VOID NTAPI CsrReferenceThread(IN PCSR_THREAD CsrThread)
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
#define CsrGetClientThread()
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
BOOLEAN NTAPI CsrRevertToSelf(VOID)
VOID NTAPI CsrDereferenceThread(IN PCSR_THREAD CsrThread)
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL)
NTSTATUS NTAPI CsrShutdownProcesses(IN PLUID CallerLuid, IN ULONG Flags)
NTSTATUS NTAPI CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL, OUT PLUID Luid)
@ CsrShutdownNonCsrProcess
VOID NTAPI CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
static const WCHAR Title[]
#define GetProcAddress(x, y)
#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)
BOOL WINAPI TerminateThread(IN HANDLE hThread, IN DWORD dwExitCode)
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
DWORD WINAPI GetTickCount(VOID)
DWORD WINAPI GetProcessImageFileNameW(HANDLE hProcess, LPWSTR lpImageFileName, DWORD nSize)
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
static PPROGRESSBAR ProgressBar
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
NTSTATUS NTAPI NtUserSetInformationThread(IN HANDLE ThreadHandle, IN USERTHREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
DWORD_PTR NTAPI NtUserCallNoParam(DWORD Routine)
#define NOPARAM_ROUTINE_ISCONSOLEMODE
@ UserThreadRestoreDesktop
@ UserThreadInitiateShutdown
@ UserThreadUseActiveDesktop
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
#define STATUS_BAD_IMPERSONATION_LEVEL
struct _LIST_ENTRY * Flink
PSHUTDOWN_SETTINGS ShutdownSettings
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
DWORD WINAPI WaitForMultipleObjectsEx(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds, IN BOOL bAlertable)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
#define CONTAINING_RECORD(address, type, field)
#define STATUS_ACCESS_DENIED
#define MCSR_GOODFORSHUTDOWN
#define MCS_QUERYENDSESSION
#define MCSR_SHUTDOWNFINISHED
#define EWX_CALLER_WINLOGON
#define WM_CLIENTSHUTDOWN
#define EWX_CALLER_WINLOGON_LOGOFF
#define MCSR_DONOTSHUTDOWN
static int Link(const char **args)
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
SHUTDOWN_SETTINGS ShutdownSettings
BOOL CALLBACK FindTopLevelWnd(IN HWND hWnd, IN LPARAM lParam)
HINSTANCE UserServerDllInstance
#define QUERY_RESULT_CONTINUE
static DWORD WINAPI SendClientShutdown(LPVOID Parameter)
static VOID CallInitCommonControls(VOID)
static VOID FASTCALL UpdateProgressBar(HWND ProgressBar, PNOTIFY_CONTEXT NotifyContext)
struct tagMESSAGE_CONTEXT MESSAGE_CONTEXT
static NTSTATUS FASTCALL UserExitReactOS(PCSR_THREAD CsrThread, UINT Flags)
#define SHUTDOWN_OTHERCONTEXT
struct tagMESSAGE_CONTEXT * PMESSAGE_CONTEXT
static BOOL NotifyTopLevelWindow(HWND Wnd, PNOTIFY_CONTEXT NotifyContext)
static DWORD WINAPI EndNowThreadProc(LPVOID Parameter)
static BOOLEAN IsConsoleMode(VOID)
struct tagNOTIFY_CONTEXT NOTIFY_CONTEXT
static INT_PTR CALLBACK EndNowDlgProc(HWND Dlg, UINT Msg, WPARAM wParam, LPARAM lParam)
#define QUERY_RESULT_TIMEOUT
static HMODULE hComCtl32Lib
void(WINAPI * INITCOMMONCONTROLS_PROC)(void)
#define QUERY_RESULT_FORCE
#define QUERY_RESULT_ABORT
#define SHUTDOWN_SYSTEMCONTEXT
#define QUERY_RESULT_ERROR
ULONG NTAPI UserClientShutdown(IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
struct tagNOTIFY_CONTEXT * PNOTIFY_CONTEXT
static BOOL ThreadShutdownNotify(IN PCSR_THREAD CsrThread, IN ULONG Flags, IN ULONG Flags2, IN PNOTIFY_CONTEXT Context)
static ULONG NotifyUserProcessForShutdown(PCSR_PROCESS CsrProcess, PSHUTDOWN_SETTINGS ShutdownSettings, UINT Flags)
DWORD WINAPI GetLastError(void)
DWORD WINAPI GetCurrentThreadId(void)
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
struct _USER_API_MESSAGE * PUSER_API_MESSAGE
HDESK WINAPI GetThreadDesktop(_In_ DWORD)
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI SendNotifyMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GetWindowLongPtrW
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI SwitchDesktop(_In_ HDESK)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define CreateDialogParam
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
int WINAPI GetWindowTextLengthW(_In_ HWND)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
#define SetWindowLongPtrW
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
_Must_inspect_result_ _In_ ULONG Flags
_Inout_opt_ PVOID Parameter
#define NtCurrentThread()