mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 20:13:04 +00:00
[WINSRV] usersrv: remove wrong dead code and fix indentation
This commit is contained in:
parent
4bef6f5913
commit
cc710885d0
1 changed files with 89 additions and 124 deletions
|
@ -394,31 +394,6 @@ IsConsoleMode(VOID)
|
||||||
return (BOOLEAN)NtUserCallNoParam(NOPARAM_ROUTINE_ISCONSOLEMODE);
|
return (BOOLEAN)NtUserCallNoParam(NOPARAM_ROUTINE_ISCONSOLEMODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: Find an other way to do it. */
|
|
||||||
#if 0
|
|
||||||
VOID FASTCALL
|
|
||||||
ConioConsoleCtrlEventTimeout(DWORD Event, PCSR_PROCESS ProcessData, DWORD Timeout)
|
|
||||||
{
|
|
||||||
HANDLE Thread;
|
|
||||||
|
|
||||||
DPRINT("ConioConsoleCtrlEvent Parent ProcessId = %x\n", ProcessData->ClientId.UniqueProcess);
|
|
||||||
|
|
||||||
if (ProcessData->CtrlDispatcher)
|
|
||||||
{
|
|
||||||
Thread = CreateRemoteThread(ProcessData->ProcessHandle, NULL, 0,
|
|
||||||
(LPTHREAD_START_ROUTINE) ProcessData->CtrlDispatcher,
|
|
||||||
UlongToPtr(Event), 0, NULL);
|
|
||||||
if (Thread == NULL)
|
|
||||||
{
|
|
||||||
DPRINT1("Failed thread creation (Error: 0x%x)\n", GetLastError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
WaitForSingleObject(Thread, Timeout);
|
|
||||||
CloseHandle(Thread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
@ -448,8 +423,10 @@ ThreadShutdownNotify(IN PCSR_THREAD CsrThread,
|
||||||
}
|
}
|
||||||
if (TopWnd != tmpWnd) MY_DPRINT("(TopWnd = %x) != (tmpWnd = %x)\n", TopWnd, tmpWnd);
|
if (TopWnd != tmpWnd) MY_DPRINT("(TopWnd = %x) != (tmpWnd = %x)\n", TopWnd, tmpWnd);
|
||||||
}
|
}
|
||||||
if (TopWnd == NULL)
|
else
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Context->wParam = Flags2;
|
Context->wParam = Flags2;
|
||||||
Context->lParam = (0 != (Flags & EWX_CALLER_WINLOGON_LOGOFF) ?
|
Context->lParam = (0 != (Flags & EWX_CALLER_WINLOGON_LOGOFF) ?
|
||||||
|
@ -511,117 +488,105 @@ NotifyProcessForShutdown(PCSR_PROCESS CsrProcess,
|
||||||
UINT Flags)
|
UINT Flags)
|
||||||
{
|
{
|
||||||
DWORD QueryResult = QUERY_RESULT_CONTINUE;
|
DWORD QueryResult = QUERY_RESULT_CONTINUE;
|
||||||
|
PCSR_PROCESS Process;
|
||||||
|
PCSR_THREAD Thread;
|
||||||
|
PLIST_ENTRY NextEntry;
|
||||||
|
NOTIFY_CONTEXT Context;
|
||||||
|
|
||||||
/* In case we make a forced shutdown, just kill the process */
|
/* In case we make a forced shutdown, just kill the process */
|
||||||
if (Flags & EWX_FORCE)
|
if (Flags & EWX_FORCE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
// TODO: Find an other way whether or not the process has a console.
|
Context.ShutdownSettings = ShutdownSettings;
|
||||||
#if 0
|
Context.QueryResult = QUERY_RESULT_CONTINUE; // We continue shutdown by default.
|
||||||
if (CsrProcess->Console)
|
|
||||||
|
/* Lock the process */
|
||||||
|
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
||||||
|
|
||||||
|
/* Send first the QUERYENDSESSION messages to all the threads of the process */
|
||||||
|
MY_DPRINT2("Sending the QUERYENDSESSION messages...\n");
|
||||||
|
|
||||||
|
NextEntry = CsrProcess->ThreadList.Flink;
|
||||||
|
while (NextEntry != &CsrProcess->ThreadList)
|
||||||
{
|
{
|
||||||
ConioConsoleCtrlEventTimeout(CTRL_LOGOFF_EVENT, CsrProcess,
|
/* Get the current thread entry */
|
||||||
ShutdownSettings->WaitToKillAppTimeout);
|
Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
PCSR_PROCESS Process;
|
|
||||||
PCSR_THREAD Thread;
|
|
||||||
PLIST_ENTRY NextEntry;
|
|
||||||
|
|
||||||
NOTIFY_CONTEXT Context;
|
/* Move to the next entry */
|
||||||
Context.ShutdownSettings = ShutdownSettings;
|
NextEntry = NextEntry->Flink;
|
||||||
Context.QueryResult = QUERY_RESULT_CONTINUE; // We continue shutdown by default.
|
|
||||||
|
|
||||||
/* Lock the process */
|
/* If the thread is being terminated, just skip it */
|
||||||
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
if (Thread->Flags & CsrThreadTerminated) continue;
|
||||||
|
|
||||||
/* Send first the QUERYENDSESSION messages to all the threads of the process */
|
/* Reference the thread and temporarily unlock the process */
|
||||||
MY_DPRINT2("Sending the QUERYENDSESSION messages...\n");
|
CsrReferenceThread(Thread);
|
||||||
|
|
||||||
NextEntry = CsrProcess->ThreadList.Flink;
|
|
||||||
while (NextEntry != &CsrProcess->ThreadList)
|
|
||||||
{
|
|
||||||
/* Get the current thread entry */
|
|
||||||
Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
|
|
||||||
|
|
||||||
/* Move to the next entry */
|
|
||||||
NextEntry = NextEntry->Flink;
|
|
||||||
|
|
||||||
/* If the thread is being terminated, just skip it */
|
|
||||||
if (Thread->Flags & CsrThreadTerminated) continue;
|
|
||||||
|
|
||||||
/* Reference the thread and temporarily unlock the process */
|
|
||||||
CsrReferenceThread(Thread);
|
|
||||||
CsrUnlockProcess(Process);
|
|
||||||
|
|
||||||
Context.QueryResult = QUERY_RESULT_CONTINUE;
|
|
||||||
ThreadShutdownNotify(Thread, Flags,
|
|
||||||
MCS_QUERYENDSESSION,
|
|
||||||
&Context);
|
|
||||||
|
|
||||||
/* Lock the process again and dereference the thread */
|
|
||||||
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
|
||||||
CsrDereferenceThread(Thread);
|
|
||||||
|
|
||||||
// FIXME: Analyze Context.QueryResult !!
|
|
||||||
/**/if (Context.QueryResult == QUERY_RESULT_ABORT) goto Quit;/**/
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryResult = Context.QueryResult;
|
|
||||||
MY_DPRINT2("QueryResult = %s\n",
|
|
||||||
QueryResult == QUERY_RESULT_ABORT ? "Abort" : "Continue");
|
|
||||||
|
|
||||||
/* Now send the ENDSESSION messages to the threads */
|
|
||||||
MY_DPRINT2("Now sending the ENDSESSION messages...\n");
|
|
||||||
|
|
||||||
NextEntry = CsrProcess->ThreadList.Flink;
|
|
||||||
while (NextEntry != &CsrProcess->ThreadList)
|
|
||||||
{
|
|
||||||
/* Get the current thread entry */
|
|
||||||
Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
|
|
||||||
|
|
||||||
/* Move to the next entry */
|
|
||||||
NextEntry = NextEntry->Flink;
|
|
||||||
|
|
||||||
/* If the thread is being terminated, just skip it */
|
|
||||||
if (Thread->Flags & CsrThreadTerminated) continue;
|
|
||||||
|
|
||||||
/* Reference the thread and temporarily unlock the process */
|
|
||||||
CsrReferenceThread(Thread);
|
|
||||||
CsrUnlockProcess(Process);
|
|
||||||
|
|
||||||
Context.QueryResult = QUERY_RESULT_CONTINUE;
|
|
||||||
ThreadShutdownNotify(Thread, Flags,
|
|
||||||
(QUERY_RESULT_ABORT != QueryResult) ? MCS_ENDSESSION : 0,
|
|
||||||
&Context);
|
|
||||||
|
|
||||||
/* Lock the process again and dereference the thread */
|
|
||||||
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
|
||||||
CsrDereferenceThread(Thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
Quit:
|
|
||||||
/* Unlock the process */
|
|
||||||
CsrUnlockProcess(Process);
|
CsrUnlockProcess(Process);
|
||||||
|
|
||||||
#if 0
|
Context.QueryResult = QUERY_RESULT_CONTINUE;
|
||||||
if (Context.UIThread)
|
ThreadShutdownNotify(Thread, Flags,
|
||||||
{
|
MCS_QUERYENDSESSION,
|
||||||
if (Context.Dlg)
|
&Context);
|
||||||
{
|
|
||||||
SendMessageW(Context.Dlg, WM_CLOSE, 0, 0);
|
/* Lock the process again and dereference the thread */
|
||||||
}
|
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
||||||
else
|
CsrDereferenceThread(Thread);
|
||||||
{
|
|
||||||
TerminateThread(Context.UIThread, QUERY_RESULT_ERROR);
|
// FIXME: Analyze Context.QueryResult !!
|
||||||
}
|
/**/if (Context.QueryResult == QUERY_RESULT_ABORT) goto Quit;/**/
|
||||||
CloseHandle(Context.UIThread);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryResult = Context.QueryResult;
|
||||||
|
MY_DPRINT2("QueryResult = %s\n",
|
||||||
|
QueryResult == QUERY_RESULT_ABORT ? "Abort" : "Continue");
|
||||||
|
|
||||||
|
/* Now send the ENDSESSION messages to the threads */
|
||||||
|
MY_DPRINT2("Now sending the ENDSESSION messages...\n");
|
||||||
|
|
||||||
|
NextEntry = CsrProcess->ThreadList.Flink;
|
||||||
|
while (NextEntry != &CsrProcess->ThreadList)
|
||||||
|
{
|
||||||
|
/* Get the current thread entry */
|
||||||
|
Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
|
||||||
|
|
||||||
|
/* Move to the next entry */
|
||||||
|
NextEntry = NextEntry->Flink;
|
||||||
|
|
||||||
|
/* If the thread is being terminated, just skip it */
|
||||||
|
if (Thread->Flags & CsrThreadTerminated) continue;
|
||||||
|
|
||||||
|
/* Reference the thread and temporarily unlock the process */
|
||||||
|
CsrReferenceThread(Thread);
|
||||||
|
CsrUnlockProcess(Process);
|
||||||
|
|
||||||
|
Context.QueryResult = QUERY_RESULT_CONTINUE;
|
||||||
|
ThreadShutdownNotify(Thread, Flags,
|
||||||
|
(QUERY_RESULT_ABORT != QueryResult) ? MCS_ENDSESSION : 0,
|
||||||
|
&Context);
|
||||||
|
|
||||||
|
/* Lock the process again and dereference the thread */
|
||||||
|
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
||||||
|
CsrDereferenceThread(Thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
Quit:
|
||||||
|
/* Unlock the process */
|
||||||
|
CsrUnlockProcess(Process);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (Context.UIThread)
|
||||||
|
{
|
||||||
|
if (Context.Dlg)
|
||||||
|
{
|
||||||
|
SendMessageW(Context.Dlg, WM_CLOSE, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TerminateThread(Context.UIThread, QUERY_RESULT_ERROR);
|
||||||
|
}
|
||||||
|
CloseHandle(Context.UIThread);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Kill the process unless we abort shutdown */
|
/* Kill the process unless we abort shutdown */
|
||||||
return (QueryResult != QUERY_RESULT_ABORT);
|
return (QueryResult != QUERY_RESULT_ABORT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue