Author: jimtabor
Date: Sun Jun 15 21:53:23 2014
New Revision: 63602
URL: http://svn.reactos.org/svn/reactos?rev=63602&view=rev
Log:
[User32]
- Patch by Henri Verbeet : Ensure at least one character is used in TEXT_WordBreak().
Modified:
trunk/reactos/win32ss/user/user32/windows/font.c
Modified: trunk/reactos/win32ss/user/user32/windows/font.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/font.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/font.c [iso-8859-1] Sun Jun 15 21:53:23 2014
@@ -636,8 +636,9 @@
DT_EDITCONTROL)
{
/* break the word after the last character that fits (there must be
- * at least one; none is caught earlier).
- */
+ * at least one). */
+ if (!chars_fit)
+ ++chars_fit;
*len_str = chars_fit;
*chars_used = chars_fit;
Author: hbelusca
Date: Sun Jun 15 20:02:26 2014
New Revision: 63601
URL: http://svn.reactos.org/svn/reactos?rev=63601&view=rev
Log:
[EXPLORER][EXPLORER_NEW]
[TASKMGR]
Set a proper shutdown level (with SetProcessShutdownParameters) so that explorer and taskmgr are terminated the very last when one shutdowns ReactOS.
See Windows Internals 4th page 286 (section "Shutdown") which gives the values (that I've cross-checked on Windows 2k3 too).
Modified:
branches/shell-experiments/base/shell/explorer-new/explorer.c
trunk/reactos/base/applications/taskmgr/taskmgr.c
trunk/reactos/base/shell/explorer/explorer.cpp
Modified: branches/shell-experiments/base/shell/explorer-new/explorer.c
URL: http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/explorer.c [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/explorer-new/explorer.c [iso-8859-1] Sun Jun 15 20:02:26 2014
@@ -407,6 +407,12 @@
InitCommonControls();
OleInitialize(NULL);
+ /*
+ * Set our shutdown parameters: we want to shutdown the very last,
+ * but before any TaskMgr instance (which has a shutdown level of 1).
+ */
+ SetProcessShutdownParameters(2, 0);
+
ProcessStartupItems();
if (GetShellWindow() == NULL)
Modified: trunk/reactos/base/applications/taskmgr/taskmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/taskmgr/…
==============================================================================
--- trunk/reactos/base/applications/taskmgr/taskmgr.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/taskmgr/taskmgr.c [iso-8859-1] Sun Jun 15 20:02:26 2014
@@ -172,6 +172,12 @@
return -1;
}
+ /*
+ * Set our shutdown parameters: we want to shutdown the very last,
+ * without displaying any end task dialog if needed.
+ */
+ SetProcessShutdownParameters(1, SHUTDOWN_NORETRY);
+
DialogBoxW(hInst, (LPCWSTR)IDD_TASKMGR_DIALOG, NULL, TaskManagerWndProc);
/* Save our settings to the registry */
Modified: trunk/reactos/base/shell/explorer/explorer.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/explor…
==============================================================================
--- trunk/reactos/base/shell/explorer/explorer.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer/explorer.cpp [iso-8859-1] Sun Jun 15 20:02:26 2014
@@ -1203,6 +1203,12 @@
"ROS Explorer - command line options", MB_OK);
}
+ /*
+ * Set our shutdown parameters: we want to shutdown the very last,
+ * but before any TaskMgr instance (which has a shutdown level of 1).
+ */
+ SetProcessShutdownParameters(2, 0);
+
Thread* pSSOThread = NULL;
if (startup_desktop) {
Author: hbelusca
Date: Sun Jun 15 19:28:41 2014
New Revision: 63600
URL: http://svn.reactos.org/svn/reactos?rev=63600&view=rev
Log:
[CSRSRV]
- Cleanup CSRSRV from the very last remnants of CsrEnumProcesses i.e. the old & buggy way of shutdowning process (lots of work must be done in winsrv side).
- Fixup FindProcessForShutdown (reenable commented code in it, and set a proper status error code if CsrImpersonateClient call fails).
Modified:
trunk/reactos/subsystems/win32/csrsrv/api.h
trunk/reactos/subsystems/win32/csrsrv/csrsrv.spec
trunk/reactos/subsystems/win32/csrsrv/procsup.c
Modified: trunk/reactos/subsystems/win32/csrsrv/api.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrsrv/ap…
==============================================================================
--- trunk/reactos/subsystems/win32/csrsrv/api.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrsrv/api.h [iso-8859-1] Sun Jun 15 19:28:41 2014
@@ -153,8 +153,6 @@
NTAPI
CsrInitializeProcessStructure(VOID);
-// NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
-// PVOID Context);
PCSR_THREAD
NTAPI
CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
Modified: trunk/reactos/subsystems/win32/csrsrv/csrsrv.spec
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrsrv/cs…
==============================================================================
--- trunk/reactos/subsystems/win32/csrsrv/csrsrv.spec [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrsrv/csrsrv.spec [iso-8859-1] Sun Jun 15 19:28:41 2014
@@ -12,7 +12,6 @@
@ stdcall CsrDereferenceWait(ptr)
@ stdcall CsrDestroyProcess(ptr long)
@ stdcall CsrDestroyThread(ptr)
-;@ stdcall CsrEnumProcesses(ptr ptr) ;;;;;;; Temporary hack used in win32csr, to be removed
@ stdcall CsrExecServerThread(ptr long)
@ stdcall CsrGetProcessLuid(ptr ptr)
@ stdcall CsrImpersonateClient(ptr)
Modified: trunk/reactos/subsystems/win32/csrsrv/procsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrsrv/pr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrsrv/procsup.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrsrv/procsup.c [iso-8859-1] Sun Jun 15 19:28:41 2014
@@ -94,109 +94,6 @@
&SetBasePriority,
sizeof(KPRIORITY));
}
-}
-
-/*++
- * @name FindProcessForShutdown
- *
- * The FindProcessForShutdown routine returns a CSR Process which is ready
- * to be shutdown, and sets the appropriate shutdown flags for it.
- *
- * @param CallerLuid
- * Pointer to the LUID of the CSR Process calling this routine.
- *
- * @return Pointer to a CSR Process which is ready to be shutdown.
- *
- * @remarks None.
- *
- *--*/
-PCSR_PROCESS
-NTAPI
-FindProcessForShutdown(IN PLUID CallerLuid)
-{
- PCSR_PROCESS CsrProcess, ReturnCsrProcess = NULL;
- // PCSR_THREAD CsrThread;
- NTSTATUS Status;
- ULONG Level = 0;
- LUID ProcessLuid;
- LUID SystemLuid = SYSTEM_LUID;
- // BOOLEAN IsSystemLuid = FALSE, IsOurLuid = FALSE;
- PLIST_ENTRY NextEntry;
-
- /* Set the List Pointers */
- NextEntry = CsrRootProcess->ListLink.Flink;
- while (NextEntry != &CsrRootProcess->ListLink)
- {
- /* Get the process */
- CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink);
-
- /* Move to the next entry */
- NextEntry = NextEntry->Flink;
-
- /* Skip this process if it's already been processed */
- if (CsrProcess->Flags & CsrProcessSkipShutdown) continue;
-
- /* Get the LUID of this Process */
- Status = CsrGetProcessLuid(CsrProcess->ProcessHandle, &ProcessLuid);
-
- /* Check if we didn't get access to the LUID */
- if (Status == STATUS_ACCESS_DENIED)
- {
- /* FIXME: Check if we have any threads */
-/*
- /\* Check if we have any threads *\/
- if (CsrProcess->ThreadCount)
- {
- /\* Impersonate one of the threads and retry *\/
- CsrThread = CONTAINING_RECORD(CsrProcess->ThreadList.Flink,
- CSR_THREAD,
- Link);
- CsrImpersonateClient(CsrThread);
- Status = CsrGetProcessLuid(NULL, &ProcessLuid);
- CsrRevertToSelf();
- }
-*/
- }
-
- if (!NT_SUCCESS(Status))
- {
- /* We didn't have access, so skip it */
- CsrProcess->Flags |= CsrProcessSkipShutdown;
- continue;
- }
-
- /* Check if this is the System LUID */
- if ((/*IsSystemLuid =*/ RtlEqualLuid(&ProcessLuid, &SystemLuid)))
- {
- /* Mark this process */
- CsrProcess->ShutdownFlags |= CsrShutdownSystem;
- }
- else if (!(/*IsOurLuid =*/ RtlEqualLuid(&ProcessLuid, CallerLuid)))
- {
- /* Our LUID doesn't match with the caller's */
- CsrProcess->ShutdownFlags |= CsrShutdownOther;
- }
-
- /* Check if we're past the previous level */
- // FIXME: if ((CsrProcess->ShutdownLevel > Level) || !(ReturnCsrProcess))
- if (CsrProcess->ShutdownLevel > Level /* || !ReturnCsrProcess */)
- {
- /* Update the level */
- Level = CsrProcess->ShutdownLevel;
-
- /* Set the final process */
- ReturnCsrProcess = CsrProcess;
- }
- }
-
- /* Check if we found a process */
- if (ReturnCsrProcess)
- {
- /* Skip this one next time */
- ReturnCsrProcess->Flags |= CsrProcessSkipShutdown;
- }
-
- return ReturnCsrProcess;
}
/*++
@@ -1244,6 +1141,110 @@
}
/*++
+ * @name FindProcessForShutdown
+ *
+ * The FindProcessForShutdown routine returns a CSR Process which is ready
+ * to be shutdown, and sets the appropriate shutdown flags for it.
+ *
+ * @param CallerLuid
+ * Pointer to the LUID of the CSR Process calling this routine.
+ *
+ * @return Pointer to a CSR Process which is ready to be shutdown.
+ *
+ * @remarks None.
+ *
+ *--*/
+PCSR_PROCESS
+NTAPI
+FindProcessForShutdown(IN PLUID CallerLuid)
+{
+ PCSR_PROCESS CsrProcess, ReturnCsrProcess = NULL;
+ PCSR_THREAD CsrThread;
+ NTSTATUS Status;
+ ULONG Level = 0;
+ LUID ProcessLuid;
+ LUID SystemLuid = SYSTEM_LUID;
+ PLIST_ENTRY NextEntry;
+
+ /* Set the List Pointers */
+ NextEntry = CsrRootProcess->ListLink.Flink;
+ while (NextEntry != &CsrRootProcess->ListLink)
+ {
+ /* Get the process */
+ CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink);
+
+ /* Move to the next entry */
+ NextEntry = NextEntry->Flink;
+
+ /* Skip this process if it's already been processed */
+ if (CsrProcess->Flags & CsrProcessSkipShutdown) continue;
+
+ /* Get the LUID of this process */
+ Status = CsrGetProcessLuid(CsrProcess->ProcessHandle, &ProcessLuid);
+
+ /* Check if we didn't get access to the LUID */
+ if (Status == STATUS_ACCESS_DENIED)
+ {
+ /* Check if we have any threads */
+ if (CsrProcess->ThreadCount)
+ {
+ /* Impersonate one of the threads and retry */
+ CsrThread = CONTAINING_RECORD(CsrProcess->ThreadList.Flink,
+ CSR_THREAD,
+ Link);
+ if (CsrImpersonateClient(CsrThread))
+ {
+ Status = CsrGetProcessLuid(NULL, &ProcessLuid);
+ CsrRevertToSelf();
+ }
+ else
+ {
+ Status = STATUS_BAD_IMPERSONATION_LEVEL;
+ }
+ }
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* We didn't have access, so skip it */
+ CsrProcess->Flags |= CsrProcessSkipShutdown;
+ continue;
+ }
+
+ /* Check if this is the System LUID */
+ if (RtlEqualLuid(&ProcessLuid, &SystemLuid))
+ {
+ /* Mark this process */
+ CsrProcess->ShutdownFlags |= CsrShutdownSystem;
+ }
+ else if (!RtlEqualLuid(&ProcessLuid, CallerLuid))
+ {
+ /* Our LUID doesn't match with the caller's */
+ CsrProcess->ShutdownFlags |= CsrShutdownOther;
+ }
+
+ /* Check if we're past the previous level */
+ if ((CsrProcess->ShutdownLevel > Level) || !ReturnCsrProcess)
+ {
+ /* Update the level */
+ Level = CsrProcess->ShutdownLevel;
+
+ /* Set the final process */
+ ReturnCsrProcess = CsrProcess;
+ }
+ }
+
+ /* Check if we found a process */
+ if (ReturnCsrProcess)
+ {
+ /* Skip this one next time */
+ ReturnCsrProcess->Flags |= CsrProcessSkipShutdown;
+ }
+
+ return ReturnCsrProcess;
+}
+
+/*++
* @name CsrShutdownProcesses
* @implemented NT4
*
@@ -1273,7 +1274,7 @@
BOOLEAN FirstTry;
ULONG i;
PCSR_SERVER_DLL ServerDll;
- ULONG Result = 0; /* Intentionally invalid enumeratee to silence compiler warning */
+ ULONG Result = 0;
/* Acquire process lock */
CsrAcquireProcessLock();
@@ -1353,7 +1354,7 @@
}
/* No matches during the first try, so loop again */
- if ((FirstTry) && (Result == CsrShutdownNonCsrProcess))
+ if (FirstTry && (Result == CsrShutdownNonCsrProcess))
{
FirstTry = FALSE;
continue;
@@ -1378,100 +1379,6 @@
return Status;
}
-/* HACK: Temporary hack. This is really "CsrShutdownProcesses", mostly. Used by winsrv */
-#if 0
-NTSTATUS
-WINAPI
-CsrEnumProcesses(IN CSRSS_ENUM_PROCESS_PROC EnumProc,
- IN PVOID Context)
-{
- PVOID* RealContext = (PVOID*)Context;
- PLUID CallerLuid = RealContext[0];
- PCSR_PROCESS CsrProcess = NULL;
- NTSTATUS Status = STATUS_UNSUCCESSFUL;
- BOOLEAN FirstTry;
- PLIST_ENTRY NextEntry;
- ULONG Result = 0;
-
- /* Acquire process lock */
- CsrAcquireProcessLock();
-
- /* Get the list pointers */
- NextEntry = CsrRootProcess->ListLink.Flink;
- while (NextEntry != &CsrRootProcess->ListLink)
- {
- /* Get the Process */
- CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink);
-
- /* Move to the next entry */
- NextEntry = NextEntry->Flink;
-
- /* Remove the skip flag, set shutdown flags to 0 */
- CsrProcess->Flags &= ~CsrProcessSkipShutdown;
- CsrProcess->ShutdownFlags = 0;
- }
-
- /* Set shudown Priority */
- CsrSetToShutdownPriority();
-
- /* Loop all processes */
- //DPRINT1("Enumerating for LUID: %lx %lx\n", CallerLuid->HighPart, CallerLuid->LowPart);
-
- /* Start looping */
- while (TRUE)
- {
- /* Find the next process to shutdown */
- FirstTry = TRUE;
- if (!(CsrProcess = FindProcessForShutdown(CallerLuid)))
- {
- /* Done, quit */
- CsrReleaseProcessLock();
- Status = STATUS_SUCCESS;
- goto Quickie;
- }
-
-LoopAgain:
- /* Release the lock, make the callback, and acquire it back */
- //DPRINT1("Found process: %lx\n", CsrProcess->ClientId.UniqueProcess);
- CsrReleaseProcessLock();
- Result = (ULONG)EnumProc(CsrProcess, (PVOID)((ULONG_PTR)Context | FirstTry));
- CsrAcquireProcessLock();
-
- /* Check the result */
- //DPRINT1("Result: %d\n", Result);
- if (Result == CsrShutdownCsrProcess)
- {
- /* The callback unlocked the process */
- break;
- }
- else if (Result == CsrShutdownNonCsrProcess)
- {
- /* A non-CSR process, the callback didn't touch it */
- //continue;
- }
- else if (Result == CsrShutdownCancelled)
- {
- /* Shutdown was cancelled, unlock and exit */
- CsrReleaseProcessLock();
- Status = STATUS_CANCELLED;
- goto Quickie;
- }
-
- /* No matches during the first try, so loop again */
- if (FirstTry && Result == CsrShutdownNonCsrProcess)
- {
- FirstTry = FALSE;
- goto LoopAgain;
- }
- }
-
-Quickie:
- /* Return to normal priority */
- CsrSetToNormalPriority();
- return Status;
-}
-#endif
-
/*++
* @name CsrUnlockProcess
* @implemented NT4