[Win32k]
authorJames Tabor <james.tabor@reactos.org>
Thu, 21 Jan 2010 00:14:06 +0000 (00:14 +0000)
committerJames Tabor <james.tabor@reactos.org>
Thu, 21 Jan 2010 00:14:06 +0000 (00:14 +0000)
- System regions do not possess user attribute sections. See bug 5124.
- Read the patch for more information.

svn path=/trunk/; revision=45168

reactos/subsystems/win32/win32k/objects/cliprgn.c
reactos/subsystems/win32/win32k/objects/dclife.c
reactos/subsystems/win32/win32k/objects/gdiobj.c
reactos/subsystems/win32/win32k/objects/region.c

index 92b2fcb..0fe9ade 100644 (file)
@@ -32,7 +32,7 @@ CLIPPING_UpdateGCRegion(DC* Dc)
 
    if (Dc->rosdc.hClipRgn == NULL)
       NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hVisRgn, 0, RGN_COPY);
-   else
+   else // FYI: Vis == NULL! source of "IntGdiCombineRgn requires hSrc2 != NULL for combine mode 1!"
       NtGdiCombineRgn(Dc->rosdc.hGCClipRgn, Dc->rosdc.hClipRgn, Dc->rosdc.hVisRgn, RGN_AND);
    NtGdiOffsetRgn(Dc->rosdc.hGCClipRgn, Dc->ptlDCOrig.x, Dc->ptlDCOrig.y);
 
index 72d843a..fa970bd 100644 (file)
@@ -167,22 +167,50 @@ BOOL
 FASTCALL
 DC_SetOwnership(HDC hDC, PEPROCESS Owner)
 {
+    INT Index;
+    PGDI_TABLE_ENTRY Entry;
     PDC pDC;
 
     if (!GDIOBJ_SetOwnership(hDC, Owner)) return FALSE;
     pDC = DC_LockDc(hDC);
     if (pDC)
     {
+    /*
+       System Regions:
+          These regions do not use attribute sections and when allocated, use
+          gdiobj level functions.
+    */
         if (pDC->rosdc.hClipRgn)
-        {
+        {   // FIXME! HAX!!!
+            KeEnterCriticalRegion();
+            Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hClipRgn);
+            Entry = &GdiHandleTable->Entries[Index];
+            if (Entry->UserData) FreeObjectAttr(Entry->UserData);
+            Entry->UserData = NULL;
+            KeLeaveCriticalRegion();
+            //
             if (!GDIOBJ_SetOwnership(pDC->rosdc.hClipRgn, Owner)) return FALSE;
         }
         if (pDC->rosdc.hVisRgn)
-        {
+        {   // FIXME! HAX!!!
+            KeEnterCriticalRegion();
+            Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hVisRgn);
+            Entry = &GdiHandleTable->Entries[Index];
+            if (Entry->UserData) FreeObjectAttr(Entry->UserData);
+            Entry->UserData = NULL;
+            KeLeaveCriticalRegion();
+            //
             if (!GDIOBJ_SetOwnership(pDC->rosdc.hVisRgn, Owner)) return FALSE;
         }
         if (pDC->rosdc.hGCClipRgn)
-        {
+        {   // FIXME! HAX!!!
+            KeEnterCriticalRegion();
+            Index = GDI_HANDLE_GET_INDEX(pDC->rosdc.hGCClipRgn);
+            Entry = &GdiHandleTable->Entries[Index];
+            if (Entry->UserData) FreeObjectAttr(Entry->UserData);
+            Entry->UserData = NULL;
+            KeLeaveCriticalRegion();
+            //
             if (!GDIOBJ_SetOwnership(pDC->rosdc.hGCClipRgn, Owner)) return FALSE;
         }
         if (pDC->dclevel.hPath)
index 3b6aeae..fca67fa 100644 (file)
@@ -753,7 +753,8 @@ GreDeleteObject(HGDIOBJ hObject)
              if (pAttr)
              {
                 KeEnterCriticalRegion();
-                FreeObjectAttr(pAttr);
+                if (pAttr) FreeObjectAttr(pAttr);
+                Entry->UserData = NULL;
                 KeLeaveCriticalRegion();
              }
              break;
index 7de49c2..ff3ff5d 100644 (file)
@@ -2085,6 +2085,7 @@ RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr)
   PGDI_TABLE_ENTRY Entry;
   PROSRGNDATA pRgn;
   PRGN_ATTR pRgn_Attr;
+  HANDLE pid;
 
   pRgn = REGION_LockRgn(hRgn);
 
@@ -2094,9 +2095,11 @@ RGNOBJAPI_Lock(HRGN hRgn, PRGN_ATTR *ppRgn_Attr)
      Index = GDI_HANDLE_GET_INDEX(hRgn);
      Entry = &GdiHandleTable->Entries[Index];
      pRgn_Attr = Entry->UserData;
+     pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
      KeLeaveCriticalRegion();
 
-     if (pRgn_Attr)
+     if ( pid == NtCurrentTeb()->ClientId.UniqueProcess &&
+          pRgn_Attr )
      {
         _SEH2_TRY
         {
@@ -2144,6 +2147,7 @@ RGNOBJAPI_Unlock(PROSRGNDATA pRgn)
   INT Index;
   PGDI_TABLE_ENTRY Entry;
   PRGN_ATTR pRgn_Attr;
+  HANDLE pid;
 
   if (pRgn)
   {
@@ -2151,9 +2155,11 @@ RGNOBJAPI_Unlock(PROSRGNDATA pRgn)
      Index = GDI_HANDLE_GET_INDEX(pRgn->BaseObject.hHmgr);
      Entry = &GdiHandleTable->Entries[Index];
      pRgn_Attr = Entry->UserData;
+     pid = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1);
      KeLeaveCriticalRegion();
 
-     if ( pRgn_Attr )
+     if ( pid == NtCurrentTeb()->ClientId.UniqueProcess &&
+          pRgn_Attr )
      {
         _SEH2_TRY
         {
@@ -2175,6 +2181,12 @@ RGNOBJAPI_Unlock(PROSRGNDATA pRgn)
   REGION_UnlockRgn(pRgn);
 }
 
+/*
+  System Regions:
+    These regions do not use attribute sections and when allocated, use gdiobj
+    level functions.
+*/
+
 BOOL INTERNAL_CALL
 REGION_Cleanup(PVOID ObjectBody)
 {
@@ -2191,7 +2203,6 @@ REGION_Delete(PROSRGNDATA pRgn)
   REGION_FreeRgn(pRgn);
 }
 
-
 VOID FASTCALL
 IntGdiReleaseRaoRgn(PDC pDC)
 {
@@ -2202,7 +2213,6 @@ IntGdiReleaseRaoRgn(PDC pDC)
   RECTL_vSetEmptyRect(&pDC->erclClip);
 }
 
-
 VOID FASTCALL
 IntGdiReleaseVisRgn(PDC pDC)
 {