[WINLOGON][WIN32K][WINSRV] -Silence a lot of debug prints in the shutdown sequence. Add some debug prints in case of error. Also print the name of the processes that get terminated. Keep the debug prints that show the parameters that are passed to SrvExitWindowsEx and WM_LOGONNOTIFY.

svn path=/trunk/; revision=75973
This commit is contained in:
Giannis Adamopoulos 2017-09-26 09:11:51 +00:00
parent b7bb40a33e
commit 03acaff5b1
6 changed files with 62 additions and 42 deletions

View file

@ -558,7 +558,7 @@ LogoffShutdownThread(
uFlags = EWX_CALLER_WINLOGON | (LSData->Flags & 0x0F);
ERR("In LogoffShutdownThread with uFlags == 0x%x; exit_in_progress == %s\n",
TRACE("In LogoffShutdownThread with uFlags == 0x%x; exit_in_progress == %s\n",
uFlags, ExitReactOSInProgress ? "true" : "false");
ExitReactOSInProgress = TRUE;
@ -585,7 +585,7 @@ KillComProcesses(
DWORD ret = 1;
PLOGOFF_SHUTDOWN_DATA LSData = (PLOGOFF_SHUTDOWN_DATA)Parameter;
ERR("In KillComProcesses\n");
TRACE("In KillComProcesses\n");
if (LSData->Session->UserToken != NULL &&
!ImpersonateLoggedOnUser(LSData->Session->UserToken))
@ -1446,7 +1446,7 @@ SASWindowProc(
}
}
ERR("In LN_LOGOFF, exit_in_progress == %s\n",
TRACE("In LN_LOGOFF, exit_in_progress == %s\n",
ExitReactOSInProgress ? "true" : "false");
/*

View file

@ -722,7 +722,7 @@ NtUserSetInformationThread(IN HANDLE ThreadHandle,
{
ULONG CapturedFlags = 0;
ERR("Shutdown initiated\n");
TRACE("Shutdown initiated\n");
if (ThreadInformationLength != sizeof(ULONG))
{
@ -764,7 +764,7 @@ NtUserSetInformationThread(IN HANDLE ThreadHandle,
{
NTSTATUS ShutdownStatus;
ERR("Shutdown ended\n");
TRACE("Shutdown ended\n");
if (ThreadInformationLength != sizeof(ShutdownStatus))
{

View file

@ -186,7 +186,7 @@ NotifyLogon(IN HWND hWndSta,
// if (hwndSAS && ( (Flags & EWX_SHUTDOWN) || RtlEqualLuid(CallerLuid, &SystemLuid)) )
if (hwndSAS)
{
ERR("\tSending %s message to Winlogon\n", Notif == LN_LOGOFF ? "LN_LOGOFF" : "LN_LOGOFF_CANCELED");
TRACE("\tSending %s message to Winlogon\n", Notif == LN_LOGOFF ? "LN_LOGOFF" : "LN_LOGOFF_CANCELED");
UserPostMessage(hwndSAS, WM_LOGONNOTIFY, Notif, (LPARAM)Param);
return TRUE;
}
@ -214,13 +214,13 @@ UserInitiateShutdown(IN PETHREAD Thread,
PPROCESSINFO ppi;
ERR("UserInitiateShutdown\n");
TRACE("UserInitiateShutdown\n");
/* Get the caller's LUID */
Status = GetProcessLuid(Thread, &CallerLuid);
if (!NT_SUCCESS(Status))
{
ERR("GetProcessLuid failed\n");
ERR("UserInitiateShutdown: GetProcessLuid failed\n");
return Status;
}
@ -239,7 +239,10 @@ UserInitiateShutdown(IN PETHREAD Thread,
/* Retrieve the Win32 process info */
ppi = PsGetProcessWin32Process(PsGetThreadProcess(Thread));
if (ppi == NULL)
{
ERR("UserInitiateShutdown: Failed to get win32 thread!\n");
return STATUS_INVALID_HANDLE;
}
/* If the caller is not Winlogon, do some security checks */
if (PsGetThreadProcessId(Thread) != gpidLogon)
@ -254,11 +257,17 @@ UserInitiateShutdown(IN PETHREAD Thread,
/* Check whether the current process is attached to a window station */
if (ppi->prpwinsta == NULL)
{
ERR("UserInitiateShutdown: Process is not attached to a desktop\n");
return STATUS_INVALID_HANDLE;
}
/* Check whether the window station of the current process can send exit requests */
if (!RtlAreAllAccessesGranted(ppi->amwinsta, WINSTA_EXITWINDOWS))
{
ERR("UserInitiateShutdown: Caller doesn't have the rights to shutdown\n");
return STATUS_ACCESS_DENIED;
}
/*
* NOTE: USERSRV automatically adds the shutdown flag when we poweroff or reboot.
@ -269,7 +278,10 @@ UserInitiateShutdown(IN PETHREAD Thread,
{
/* ... check whether it has shutdown privilege */
if (!HasPrivilege(&ShutdownPrivilege))
{
ERR("UserInitiateShutdown: Caller doesn't have the rights to shutdown\n");
return STATUS_PRIVILEGE_NOT_HELD;
}
}
else
{
@ -278,7 +290,10 @@ UserInitiateShutdown(IN PETHREAD Thread,
* window station is a non-IO one, fail the call.
*/
if (ppi->prpwinsta->Flags & WSS_NOIO)
{
ERR("UserInitiateShutdown: Caller doesn't have the rights to logoff\n");
return STATUS_INVALID_DEVICE_REQUEST;
}
}
}
@ -286,13 +301,13 @@ UserInitiateShutdown(IN PETHREAD Thread,
if (PsGetThreadProcessId(Thread) != gpidLogon)
{
// FIXME: HACK!! Do more checks!!
ERR("UserInitiateShutdown -- Notify Winlogon for shutdown\n");
TRACE("UserInitiateShutdown: Notify Winlogon for shutdown\n");
NotifyLogon(hwndSAS, &CallerLuid, Flags, STATUS_SUCCESS);
return STATUS_PENDING;
}
// If we reach this point, that means it's Winlogon that triggered the shutdown.
ERR("UserInitiateShutdown -- Winlogon is doing a shutdown\n");
TRACE("UserInitiateShutdown: Winlogon is doing a shutdown\n");
/*
* Update and save the shutdown flags globally for renotifying
@ -315,13 +330,13 @@ UserEndShutdown(IN PETHREAD Thread,
ULONG Flags;
LUID CallerLuid;
ERR("UserEndShutdown\n");
TRACE("UserEndShutdown called\n");
/*
* FIXME: Some cleanup should be done when shutdown succeeds,
* and some reset should be done when shutdown is cancelled.
*/
STUB;
//STUB;
Status = GetProcessLuid(Thread, &CallerLuid);
if (!NT_SUCCESS(Status))
@ -345,7 +360,7 @@ UserEndShutdown(IN PETHREAD Thread,
// FIXME: Should we reset gdwShutdownFlags to 0 ??
}
ERR("UserEndShutdown -- Notify Winlogon for end of shutdown\n");
TRACE("UserEndShutdown: Notify Winlogon for end of shutdown\n");
NotifyLogon(hwndSAS, &CallerLuid, Flags, ShutdownStatus);
/* Always return success */

View file

@ -24,12 +24,12 @@ ConsoleClientShutdown(IN PCSR_PROCESS CsrProcess,
{
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
UNIMPLEMENTED;
//FIXME: UNIMPLEMENTED!
if ( ProcessData->ConsoleHandle != NULL ||
ProcessData->HandleTable != NULL )
{
DPRINT1("ConsoleClientShutdown(0x%p, 0x%x, %s) - Console process [0x%x, 0x%x]\n",
DPRINT("ConsoleClientShutdown(0x%p, 0x%x, %s) - Console process [0x%x, 0x%x]\n",
CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
@ -39,7 +39,7 @@ ConsoleClientShutdown(IN PCSR_PROCESS CsrProcess,
}
else
{
DPRINT1("ConsoleClientShutdown(0x%p, 0x%x, %s) - Non-console process [0x%x, 0x%x]\n",
DPRINT("ConsoleClientShutdown(0x%p, 0x%x, %s) - Non-console process [0x%x, 0x%x]\n",
CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);

View file

@ -13,5 +13,5 @@ add_library(usersrv ${USERSRV_SOURCE})
add_dependencies(usersrv xdk)
add_pch(usersrv usersrv/usersrv.h USERSRV_SOURCE)
#add_object_library(usersrv ${USERSRV_SOURCE})
list(APPEND USERSRV_IMPORT_LIBS basesrv)
list(APPEND USERSRV_IMPORT_LIBS basesrv psapi)
set_module_type(usersrv module UNICODE)

View file

@ -11,6 +11,7 @@
#include "usersrv.h"
#include <commctrl.h>
#include <psapi.h>
#include "resource.h"
@ -222,7 +223,7 @@ SendClientShutdown(LPVOID Parameter)
/* If the shutdown is aborted, just notify the process, there is no need to wait */
if ((Context->wParam & (MCS_QUERYENDSESSION | MCS_ENDSESSION)) == 0)
{
MY_DPRINT("Called WM_CLIENTSHUTDOWN with wParam == 0 ...\n");
DPRINT("Called WM_CLIENTSHUTDOWN with wParam == 0 ...\n");
SendNotifyMessageW(Context->Wnd, WM_CLIENTSHUTDOWN,
Context->wParam, Context->lParam);
return QUERY_RESULT_CONTINUE;
@ -255,12 +256,12 @@ SendClientShutdown(LPVOID Parameter)
Ret = QUERY_RESULT_CONTINUE;
}
MY_DPRINT("SendClientShutdown -- Return == %s\n",
DPRINT("SendClientShutdown -- Return == %s\n",
Ret == QUERY_RESULT_CONTINUE ? "Continue" : "Abort");
return Ret;
}
MY_DPRINT("SendClientShutdown -- Error == %s\n",
DPRINT1("SendClientShutdown -- Error == %s\n",
GetLastError() == 0 ? "Timeout" : "error");
return (GetLastError() == 0 ? QUERY_RESULT_TIMEOUT : QUERY_RESULT_ERROR);
@ -374,7 +375,7 @@ NotifyTopLevelWindow(HWND Wnd, PNOTIFY_CONTEXT NotifyContext)
NotifyContext->QueryResult = QUERY_RESULT_TIMEOUT;
}
MY_DPRINT("NotifyContext->QueryResult == %d\n", NotifyContext->QueryResult);
DPRINT("NotifyContext->QueryResult == %d\n", NotifyContext->QueryResult);
return (NotifyContext->QueryResult == QUERY_RESULT_CONTINUE);
}
@ -672,7 +673,7 @@ UserExitReactOS(PCSR_THREAD CsrThread, UINT Flags)
goto Quit;
}
DPRINT1("Caller LUID is: %lx.%lx\n", CallerLuid.HighPart, CallerLuid.LowPart);
DPRINT("Caller LUID is: %lx.%lx\n", CallerLuid.HighPart, CallerLuid.LowPart);
/* Shutdown loop */
while (TRUE)
@ -681,23 +682,23 @@ UserExitReactOS(PCSR_THREAD CsrThread, UINT Flags)
Status = NtUserSetInformationThread(CsrThread->ThreadHandle,
UserThreadInitiateShutdown,
&Flags, sizeof(Flags));
DPRINT1("Win32k says: %lx\n", Status);
DPRINT("Win32k says: %lx\n", Status);
switch (Status)
{
/* We cannot wait here, the caller should start a new thread */
case STATUS_CANT_WAIT:
DPRINT1("STATUS_CANT_WAIT\n");
DPRINT1("NtUserSetInformationThread returned STATUS_CANT_WAIT\n");
goto Quit;
/* Shutdown is in progress */
case STATUS_PENDING:
DPRINT1("STATUS_PENDING\n");
DPRINT1("NtUserSetInformationThread returned STATUS_PENDING\n");
goto Quit;
/* Abort */
case STATUS_RETRY:
{
DPRINT1("STATUS_RETRY\n");
DPRINT1("NtUserSetInformationThread returned STATUS_RETRY\n");
UNIMPLEMENTED;
continue;
}
@ -740,7 +741,7 @@ UserExitReactOS(PCSR_THREAD CsrThread, UINT Flags)
UserThreadEndShutdown,
&Status, sizeof(Status));
DPRINT1("SrvExitWindowsEx returned 0x%08x\n", Status);
DPRINT("SrvExitWindowsEx returned 0x%08x\n", Status);
Quit:
/* We are done */
@ -755,9 +756,10 @@ UserClientShutdown(IN PCSR_PROCESS CsrProcess,
IN ULONG Flags,
IN BOOLEAN FirstPhase)
{
DPRINT1("UserClientShutdown(0x%p, 0x%x, %s) - [0x%x, 0x%x]\n",
DPRINT("UserClientShutdown(0x%p, 0x%x, %s) - [0x%x, 0x%x], ShutdownFlags: %lu\n",
CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread);
CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread,
CsrProcess->ShutdownFlags);
/*
* Check for process validity
@ -767,7 +769,7 @@ UserClientShutdown(IN PCSR_PROCESS CsrProcess,
if ((Flags & EWX_SHUTDOWN) == EWX_LOGOFF &&
(CsrProcess->ShutdownFlags & (SHUTDOWN_OTHERCONTEXT | SHUTDOWN_SYSTEMCONTEXT)))
{
DPRINT1("Do not kill a system process in a logoff request!\n");
DPRINT("Do not kill a system process in a logoff request!\n");
return CsrShutdownNonCsrProcess;
}
@ -775,32 +777,35 @@ UserClientShutdown(IN PCSR_PROCESS CsrProcess,
if (CsrProcess->ClientId.UniqueProcess == NtCurrentProcess() ||
CsrProcess->ClientId.UniqueProcess == UlongToHandle(LogonProcessId))
{
DPRINT1("Not killing %s; CsrProcess->ShutdownFlags = %lu\n",
DPRINT("Not killing %s; CsrProcess->ShutdownFlags = %lu\n",
CsrProcess->ClientId.UniqueProcess == NtCurrentProcess() ? "CSRSS" : "Winlogon",
CsrProcess->ShutdownFlags);
return CsrShutdownNonCsrProcess;
}
if (Flags & EWX_CALLER_SYSTEM)
DPRINT1("Killed by a SYSTEM process -- ShutdownFlags = %lu\n", CsrProcess->ShutdownFlags);
else
DPRINT1("Killing process with ShutdownFlags = %lu\n", CsrProcess->ShutdownFlags);
if (CsrProcess->ShutdownFlags & SHUTDOWN_OTHERCONTEXT)
DPRINT1("This process has SHUTDOWN_OTHERCONTEXT\n");
if (CsrProcess->ShutdownFlags & SHUTDOWN_SYSTEMCONTEXT)
DPRINT1("This process has SHUTDOWN_SYSTEMCONTEXT\n");
/* Notify the process for shutdown if needed */
if (!NotifyProcessForShutdown(CsrProcess, &ShutdownSettings, Flags))
{
DPRINT1("Process 0x%x aborted shutdown\n", CsrProcess->ClientId.UniqueProcess);
/* Abort shutdown */
return CsrShutdownCancelled;
}
/* Terminate this process */
#if DBG
{
WCHAR buffer[MAX_PATH];
if (!GetProcessImageFileNameW(CsrProcess->ProcessHandle, buffer, MAX_PATH))
{
DPRINT1("Terminating process %x\n", CsrProcess->ClientId.UniqueProcess);
}
else
{
DPRINT1("Terminating process %x (%S)\n", CsrProcess->ClientId.UniqueProcess, buffer);
}
}
#endif
NtTerminateProcess(CsrProcess->ProcessHandle, 0);
/* We are done */