Author: fireball
Date: Sat Aug 22 19:49:51 2009
New Revision: 42863
URL:
http://svn.reactos.org/svn/reactos?rev=42863&view=rev
Log:
- Purge user->kernel mapping for a terminated process.
- Define GDI_DEBUG to track doublefrees and similar problems for now.
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c
branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h
branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c [iso-8859-1] Sat Aug 22
19:49:51 2009
@@ -8,7 +8,7 @@
/** INCLUDES ******************************************************************/
-//#define GDI_DEBUG
+#define GDI_DEBUG
#include <win32k.h>
#define NDEBUG
@@ -1557,4 +1557,37 @@
KeReleaseSpinLock(&HandleMappingLock, OldIrql);
}
+VOID NTAPI
+GDI_CleanupHandleMapping()
+{
+ KIRQL OldIrql;
+ PLIST_ENTRY Current;
+ PHMAPPING Mapping;
+ HANDLE hProcessId = PsGetCurrentProcessId();
+
+ /* Acquire the lock and check if the list is empty */
+ KeAcquireSpinLock(&HandleMappingLock, &OldIrql);
+
+ /* Traverse the list to find all handles of a current process */
+ Current = HandleMapping.Flink;
+ while(Current != &HandleMapping)
+ {
+ Mapping = CONTAINING_RECORD(Current, HMAPPING, Entry);
+
+ /* Check if it's our entry */
+ if (Mapping->hProcessId == hProcessId)
+ {
+ /* Remove and free it */
+ RemoveEntryList(Current);
+ ExFreePool(Mapping);
+ }
+
+ /* Advance to the next pair */
+ Current = Current->Flink;
+ }
+
+ /* Release the lock and return the entry */
+ KeReleaseSpinLock(&HandleMappingLock, OldIrql);
+}
+
/* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h [iso-8859-1] Sat Aug
22 19:49:51 2009
@@ -90,5 +90,6 @@
VOID NTAPI GDI_AddHandleMapping(HGDIOBJ hKernel, HGDIOBJ hUser);
HGDIOBJ NTAPI GDI_MapUserHandle(HGDIOBJ hUser);
VOID NTAPI GDI_RemoveHandleMapping(HGDIOBJ hUser);
+VOID NTAPI GDI_CleanupHandleMapping();
#endif
Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] Sat Aug 22
19:49:51 2009
@@ -111,6 +111,9 @@
destroy_process_classes(Win32Process);
UserLeave();
+
+ /* Destroy all user->kernel handle mapping */
+ GDI_CleanupHandleMapping();
}
DPRINT("Leave Win32kProcessCallback\n");