Author: hbelusca
Date: Tue Jun 17 20:01:23 2014
New Revision: 63610
URL: http://svn.reactos.org/svn/reactos?rev=63610&view=rev
Log:
[WIN32K]
There is a bug in win32k (who would have thought that?) that consists in holding a winstation spinlock while running PAGED_CODE MmCopyToCaller function, when building the list of desktops of a given window station (the bug is easily triggerable when calling EnumDesktopsW). Since this lock is never used in anyplace but in this function, which, by the way, is just a reader function that fills user buffer, I consider that it is safe to remove this lock. However I want approval from win32k specialists. Hence I just disable the code with a define USE_WINSTA_LOCK. If this lock is really needed, please rewrite the BuildDesktopNameList function !! Otherwise remove this lock and the associated code !!
This is a blocker for the shutdown code.
Modified:
trunk/reactos/win32ss/user/ntuser/winsta.c
trunk/reactos/win32ss/user/ntuser/winsta.h
Modified: trunk/reactos/win32ss/user/ntuser/winsta.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winsta…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/winsta.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/winsta.c [iso-8859-1] Tue Jun 17 20:01:23 2014
@@ -451,7 +451,9 @@
/* Initialize the window station */
RtlZeroMemory(WindowStationObject, sizeof(WINSTATION_OBJECT));
+#ifdef USE_WINSTA_LOCK
KeInitializeSpinLock(&WindowStationObject->Lock);
+#endif
InitializeListHead(&WindowStationObject->DesktopListHead);
Status = RtlCreateAtomTable(37, &WindowStationObject->AtomTable);
WindowStationObject->Name = WindowStationName;
@@ -1203,7 +1205,9 @@
{
NTSTATUS Status;
PWINSTATION_OBJECT WindowStation;
+#ifdef USE_WINSTA_LOCK
KIRQL OldLevel;
+#endif
PLIST_ENTRY DesktopEntry;
PDESKTOP DesktopObject;
DWORD EntryCount;
@@ -1220,7 +1224,9 @@
return Status;
}
+#ifdef USE_WINSTA_LOCK
KeAcquireSpinLock(&WindowStation->Lock, &OldLevel);
+#endif
/*
* Count the required size of buffer.
@@ -1242,7 +1248,9 @@
Status = MmCopyToCaller(pRequiredSize, &ReturnLength, sizeof(ULONG));
if (! NT_SUCCESS(Status))
{
+#ifdef USE_WINSTA_LOCK
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
+#endif
ObDereferenceObject(WindowStation);
return STATUS_BUFFER_TOO_SMALL;
}
@@ -1253,7 +1261,9 @@
*/
if (dwSize < ReturnLength)
{
+#ifdef USE_WINSTA_LOCK
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
+#endif
ObDereferenceObject(WindowStation);
return STATUS_BUFFER_TOO_SMALL;
}
@@ -1264,7 +1274,9 @@
Status = MmCopyToCaller(lpBuffer, &EntryCount, sizeof(DWORD));
if (! NT_SUCCESS(Status))
{
+#ifdef USE_WINSTA_LOCK
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
+#endif
ObDereferenceObject(WindowStation);
return Status;
}
@@ -1280,7 +1292,9 @@
Status = MmCopyToCaller(lpBuffer, DesktopName.Buffer, DesktopName.Length);
if (! NT_SUCCESS(Status))
{
+#ifdef USE_WINSTA_LOCK
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
+#endif
ObDereferenceObject(WindowStation);
return Status;
}
@@ -1288,7 +1302,9 @@
Status = MmCopyToCaller(lpBuffer, &NullWchar, sizeof(WCHAR));
if (! NT_SUCCESS(Status))
{
+#ifdef USE_WINSTA_LOCK
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
+#endif
ObDereferenceObject(WindowStation);
return Status;
}
@@ -1298,7 +1314,9 @@
/*
* Clean up
*/
+#ifdef USE_WINSTA_LOCK
KeReleaseSpinLock(&WindowStation->Lock, OldLevel);
+#endif
ObDereferenceObject(WindowStation);
return STATUS_SUCCESS;
Modified: trunk/reactos/win32ss/user/ntuser/winsta.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winsta…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/winsta.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/winsta.h [iso-8859-1] Tue Jun 17 20:01:23 2014
@@ -7,11 +7,16 @@
#define WSS_LOCKED (1)
#define WSS_NOINTERACTIVE (2)
+// Uncomment for using WinSta spinlock
+// #define USE_WINSTA_LOCK
+
typedef struct _WINSTATION_OBJECT
{
DWORD dwSessionId;
+#ifdef USE_WINSTA_LOCK
KSPIN_LOCK Lock;
+#endif
UNICODE_STRING Name;
LIST_ENTRY DesktopListHead;
PRTL_ATOM_TABLE AtomTable;
Author: hbelusca
Date: Mon Jun 16 00:49:28 2014
New Revision: 63604
URL: http://svn.reactos.org/svn/reactos?rev=63604&view=rev
Log:
[SERVICES]
The SCM also sets a shutdown level, lower than the default value for programs (this was cross-checked with Windows 2k3, the value chosen is for compatibility purposes).
Modified:
trunk/reactos/base/system/services/services.c
Modified: trunk/reactos/base/system/services/services.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/services.c [iso-8859-1] Mon Jun 16 00:49:28 2014
@@ -402,6 +402,12 @@
/* Register event handler (used for system shutdown) */
SetConsoleCtrlHandler(ShutdownHandlerRoutine, TRUE);
+ /*
+ * Set our shutdown parameters: we want to shutdown after the maintained
+ * services (that inherit the default shutdown level of 640).
+ */
+ SetProcessShutdownParameters(480, SHUTDOWN_NORETRY);
+
/* Start auto-start services */
ScmAutoStartServices();
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) {