[Win32k]
authorJames Tabor <james.tabor@reactos.org>
Thu, 10 Mar 2011 13:09:56 +0000 (13:09 +0000)
committerJames Tabor <james.tabor@reactos.org>
Thu, 10 Mar 2011 13:09:56 +0000 (13:09 +0000)
- Fix an uncovered bug. This should fix coolplayer and winamp type applications. Does not fix drawing issues.

svn path=/trunk/; revision=51008

reactos/subsystems/win32/win32k/include/gdiobj.h
reactos/subsystems/win32/win32k/objects/gdiobj.c
reactos/subsystems/win32/win32k/objects/region.c

index 9882e9d..3f581bc 100644 (file)
@@ -160,3 +160,7 @@ INT FASTCALL GreGetObjectOwner(HGDIOBJ, GDIOBJTYPE);
 
 #define GDIOBJ_GetKernelObj(Handle) \
   ((PGDI_TABLE_ENTRY)&GdiHandleTable->Entries[GDI_HANDLE_GET_INDEX(Handle)])->KernelData
+#define GDI_ENTRY_TO_INDEX(ht, e)                                              \
+  (((ULONG_PTR)(e) - (ULONG_PTR)&((ht)->Entries[0])) / sizeof(GDI_TABLE_ENTRY))
+#define GDI_HANDLE_GET_ENTRY(HandleTable, h)                                   \
+  (&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])
index dcf59df..6bbca8c 100644 (file)
 #define NDEBUG
 #include <debug.h>
 
-#define GDI_ENTRY_TO_INDEX(ht, e)                                              \
-  (((ULONG_PTR)(e) - (ULONG_PTR)&((ht)->Entries[0])) / sizeof(GDI_TABLE_ENTRY))
-#define GDI_HANDLE_GET_ENTRY(HandleTable, h)                                   \
-  (&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])
-
 #define BASE_OBJTYPE_COUNT 32
 
 #define DelayExecution() \
index c681d4e..d1b0044 100644 (file)
@@ -2073,14 +2073,12 @@ FASTCALL
 REGION_AllocUserRgnWithHandle(INT nRgn)
 {
     PROSRGNDATA pRgn;
-    INT Index;
     PGDI_TABLE_ENTRY Entry;
 
     pRgn = REGION_AllocRgnWithHandle(nRgn);
     if (pRgn)
     {
-       Index = GDI_HANDLE_GET_INDEX(pRgn->BaseObject.hHmgr);
-       Entry = &GdiHandleTable->Entries[Index];
+       Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, pRgn->BaseObject.hHmgr);
        Entry->UserData = AllocateObjectAttr();
     }
     return pRgn;
@@ -2090,23 +2088,18 @@ PROSRGNDATA
 FASTCALL
 RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr)
 {
-  INT Index;
   PGDI_TABLE_ENTRY Entry;
-  PROSRGNDATA pRgn;
   PRGN_ATTR pRgn_Attr;
-  HANDLE pid;
+  PROSRGNDATA pRgn = NULL;
 
   pRgn = REGION_LockRgn(hRgn);
 
-  if (pRgn)
+  if (pRgn && GDIOBJ_OwnedByCurrentProcess(hRgn))
   {
-     Index = GDI_HANDLE_GET_INDEX(hRgn);
-     Entry = &GdiHandleTable->Entries[Index];
+     Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, hRgn);
      pRgn_Attr = Entry->UserData;
-     pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
 
-     if ( pid == NtCurrentTeb()->ClientId.UniqueProcess &&
-          pRgn_Attr )
+     if ( pRgn_Attr )
      {
         _SEH2_TRY
         {
@@ -2151,20 +2144,15 @@ VOID
 FASTCALL
 RGNOBJAPI_Unlock(PROSRGNDATA pRgn)
 {
-  INT Index;
   PGDI_TABLE_ENTRY Entry;
   PRGN_ATTR pRgn_Attr;
-  HANDLE pid;
 
-  if (pRgn)
+  if (pRgn && GDIOBJ_OwnedByCurrentProcess(pRgn->BaseObject.hHmgr))
   {
-     Index = GDI_HANDLE_GET_INDEX(pRgn->BaseObject.hHmgr);
-     Entry = &GdiHandleTable->Entries[Index];
+     Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, pRgn->BaseObject.hHmgr);
      pRgn_Attr = Entry->UserData;
-     pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
 
-     if ( pid == NtCurrentTeb()->ClientId.UniqueProcess &&
-          pRgn_Attr )
+     if ( pRgn_Attr )
      {
         _SEH2_TRY
         {