Author: jgardou
Date: Thu Sep 18 12:09:19 2014
New Revision: 64187
URL:
http://svn.reactos.org/svn/reactos?rev=64187&view=rev
Log:
[WIN32K]
- Enable all debug channels if DEBUGCHANNEL is set to "+all".
- Fix GDI objects exclusive locks counting, fixing a memory corruption altogether.
- Add a missing lock release on error path.
- Add a debug print.
Modified:
trunk/reactos/win32ss/gdi/ntgdi/gdidbg.c
trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c
trunk/reactos/win32ss/user/ntuser/kbdlayout.c
trunk/reactos/win32ss/user/ntuser/ntuser.c
trunk/reactos/win32ss/user/ntuser/winpos.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/gdidbg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/gdidbg.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/gdidbg.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/gdidbg.c [iso-8859-1] Thu Sep 18 12:09:19 2014
@@ -595,6 +595,16 @@
DBG_CHANNEL *ChannelEntry;
UINT iLevel, iChannel;
+ /* Special treatment for the "all" channel */
+ if (wcscmp(channel, L"all") == 0)
+ {
+ for (iChannel = 0; iChannel < DbgChCount; iChannel++)
+ {
+ DbgAddDebugChannel(ppi, DbgChannels[iChannel].Name, level, op);
+ }
+ return TRUE;
+ }
+
ChannelEntry = (DBG_CHANNEL*)bsearch(channel,
DbgChannels,
DbgChCount,
Modified: trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/gdiobj.c [iso-8859-1] Thu Sep 18 12:09:19 2014
@@ -37,12 +37,40 @@
#define NDEBUG
#include <debug.h>
-// Move to gdidbg.h
+
+FORCEINLINE
+void
+INCREASE_THREAD_LOCK_COUNT(
+ _In_ HANDLE hobj)
+{
+ PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
+ DBG_UNREFERENCED_PARAMETER(hobj);
+ if (pti)
+ {
#if DBG
-#define DBG_INCREASE_LOCK_COUNT(pti, hobj) \
- if (pti) ((PTHREADINFO)pti)->acExclusiveLockCount[((ULONG_PTR)hobj >> 16)
& 0x1f]++;
-#define DBG_DECREASE_LOCK_COUNT(pti, hobj) \
- if (pti) ((PTHREADINFO)pti)->acExclusiveLockCount[((ULONG_PTR)hobj >> 16)
& 0x1f]--;
+ pti->acExclusiveLockCount[((ULONG_PTR)hobj >> 16) & 0x1f]++;
+#endif
+ pti->cExclusiveLocks++;
+ }
+}
+
+FORCEINLINE
+void
+DECREASE_THREAD_LOCK_COUNT(
+ _In_ HANDLE hobj)
+{
+ PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
+ DBG_UNREFERENCED_PARAMETER(hobj);
+ if (pti)
+ {
+#if DBG
+ pti->acExclusiveLockCount[((ULONG_PTR)hobj >> 16) & 0x1f]--;
+#endif
+ pti->cExclusiveLocks--;
+ }
+}
+
+#if DBG
#define ASSERT_SHARED_OBJECT_TYPE(objt) \
ASSERT((objt) == GDIObjType_SURF_TYPE || \
(objt) == GDIObjType_PAL_TYPE || \
@@ -55,8 +83,6 @@
#define ASSERT_TRYLOCK_OBJECT_TYPE(objt) \
ASSERT((objt) == GDIObjType_DRVOBJ_TYPE)
#else
-#define DBG_INCREASE_LOCK_COUNT(ppi, hobj)
-#define DBG_DECREASE_LOCK_COUNT(x, y)
#define ASSERT_SHARED_OBJECT_TYPE(objt)
#define ASSERT_EXCLUSIVE_OBJECT_TYPE(objt)
#define ASSERT_TRYLOCK_OBJECT_TYPE(objt)
@@ -684,7 +710,7 @@
/* Increase lock count */
pobj->cExclusiveLock++;
- DBG_INCREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), hobj);
+ INCREASE_THREAD_LOCK_COUNT(hobj);
DBG_LOGEVENT(&pobj->slhLog, EVENT_LOCK, 0);
/* Return the object */
@@ -735,7 +761,7 @@
/* Increase lock count */
pobj->cExclusiveLock++;
- DBG_INCREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), hobj);
+ INCREASE_THREAD_LOCK_COUNT(hobj);
DBG_LOGEVENT(&pobj->slhLog, EVENT_LOCK, 0);
/* Return the object */
@@ -751,7 +777,7 @@
/* Decrease lock count */
pobj->cExclusiveLock--;
- DBG_DECREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), pobj->hHmgr);
+ DECREASE_THREAD_LOCK_COUNT(pobj->hHmgr);
DBG_LOGEVENT(&pobj->slhLog, EVENT_UNLOCK, 0);
/* Check if this was the last lock */
@@ -802,7 +828,7 @@
ExAcquirePushLockExclusive(&pobj->pushlock);
pobj->cExclusiveLock = 1;
pobj->dwThreadId = PtrToUlong(PsGetCurrentThreadId());
- DBG_INCREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), pobj->hHmgr);
+ INCREASE_THREAD_LOCK_COUNT(pobj->hHmgr);
/* Get object type from the hHmgr field */
objt = ((ULONG_PTR)pobj->hHmgr >> 16) & 0xff;
@@ -1000,7 +1026,7 @@
/* Release the pushlock and reenable APCs */
ExReleasePushLockExclusive(&pobj->pushlock);
KeLeaveCriticalRegion();
- DBG_DECREASE_LOCK_COUNT(PsGetCurrentProcessWin32Process(), pobj->hHmgr);
+ DECREASE_THREAD_LOCK_COUNT(pobj->hHmgr);
}
}
Modified: trunk/reactos/win32ss/user/ntuser/kbdlayout.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/kbdlay…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/kbdlayout.c [iso-8859-1] Thu Sep 18 12:09:19 2014
@@ -475,7 +475,10 @@
UserEnterShared();
if (!gspklBaseLayout)
+ {
+ UserLeave();
return 0;
+ }
pKl = gspklBaseLayout;
if (nBuff == 0)
Modified: trunk/reactos/win32ss/user/ntuser/ntuser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/ntuser…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/ntuser.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/ntuser.c [iso-8859-1] Thu Sep 18 12:09:19 2014
@@ -244,6 +244,7 @@
VOID FASTCALL UserLeave(VOID)
{
ASSERT_NOGDILOCKS();
+ ASSERT(UserIsEntered());
ExReleaseResourceLite(&UserLock);
KeLeaveCriticalRegion();
}
Modified: trunk/reactos/win32ss/user/ntuser/winpos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winpos…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/winpos.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/winpos.c [iso-8859-1] Thu Sep 18 12:09:19 2014
@@ -1258,6 +1258,7 @@
if (!(WinPos->flags & SWP_NOSENDCHANGING))
{
+ TRACE("Sending WM_WINDOWPOSCHANGING to hwnd %p.\n", Window->head.h);
co_IntSendMessageNoWait(Window->head.h, WM_WINDOWPOSCHANGING, 0, (LPARAM)
WinPos);
}