Author: jimtabor
Date: Wed Jul 25 07:35:59 2007
New Revision: 27804
URL:
http://svn.reactos.org/svn/reactos?rev=27804&view=rev
Log:
Removed Dce from the DC handle table. Tested bootcd, Explorer and Taskmgr.
Modified:
trunk/reactos/include/reactos/win32k/ntgdihdl.h
trunk/reactos/subsystems/win32/win32k/include/dce.h
trunk/reactos/subsystems/win32/win32k/include/tags.h
trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
Modified: trunk/reactos/include/reactos/win32k/ntgdihdl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntg…
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntgdihdl.h (original)
+++ trunk/reactos/include/reactos/win32k/ntgdihdl.h Wed Jul 25 07:35:59 2007
@@ -50,7 +50,6 @@
/* Following object types made up for ROS */
#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000
#define GDI_OBJECT_TYPE_MEMDC 0x00750000
-#define GDI_OBJECT_TYPE_DCE 0x00770000
#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000
/** Not really an object type. Forces GDI_FreeObj to be silent. */
#define GDI_OBJECT_TYPE_SILENT 0x80000000
Modified: trunk/reactos/subsystems/win32/win32k/include/dce.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dce.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dce.h Wed Jul 25 07:35:59 2007
@@ -32,24 +32,21 @@
HRGN hClipRgn;
DCE_TYPE type;
DWORD DCXFlags;
+ PEPROCESS pProcess;
HANDLE Self;
} DCE; /* PDCE already declared at top of file */
-/* internal DCX flags */
+/* internal DCX flags, see psdk/winuser.h for the rest */
+#define DCX_EXCLUDEUPDATE 0x00000100
#define DCX_DCEEMPTY 0x00000800
#define DCX_DCEBUSY 0x00001000
#define DCX_DCEDIRTY 0x00002000
-#define DCX_USESTYLE 0x00010000
+#define DCX_USESTYLE 0x00010000
#define DCX_KEEPCLIPRGN 0x00040000
-#define DCX_NOCLIPCHILDREN 0x00080000
-
-#define DCEOBJ_AllocDCE() \
- ((HDCE) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_DCE))
-#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hDCE,
GDI_OBJECT_TYPE_DCE)
-#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hDCE,
GDI_OBJECT_TYPE_DCE))
-#define DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pDCE)
-BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody);
-
+#define DCX_NOCLIPCHILDREN 0x00080000
+#define DCX_NORECOMPUTE 0x00100000
+
+BOOL FASTCALL DCE_Cleanup(PDCE pDce);
PDCE FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
PDCE FASTCALL DCE_FreeDCE(PDCE dce);
VOID FASTCALL DCE_FreeWindowDCE(HWND);
Modified: trunk/reactos/subsystems/win32/win32k/include/tags.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/tags.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/tags.h Wed Jul 25 07:35:59 2007
@@ -24,7 +24,8 @@
#define TAG_TIMERBMP TAG('T', 'I', 'M', 'B') /* timers
bitmap */
#define TAG_CALLBACK TAG('C', 'B', 'C', 'K') /* callback
memory */
#define TAG_WINSTA TAG('W', 'S', 'T', 'A') /* window
station */
-
+#define TAG_PDCE TAG('U', 's', 'd', 'c') /* dce */
+
/* objects */
#define TAG_BEZIER TAG('B', 'E', 'Z', 'R') /* bezier */
#define TAG_BITMAP TAG('B', 'T', 'M', 'P') /* bitmap */
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c Wed Jul 25 07:35:59 2007
@@ -39,12 +39,23 @@
/* NOTE - I think we should store this per window station (including gdi objects) */
static PDCE FirstDce = NULL;
-static HDC defaultDCstate;
+static HDC defaultDCstate = NULL;
+//static INT DCECount = 0;
#define DCX_CACHECOMPAREMASK (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | \
DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)
/* FUNCTIONS *****************************************************************/
+
+HDC FASTCALL
+DceCreateDisplayDC(VOID)
+{
+ HDC hDC;
+ UNICODE_STRING DriverName;
+ RtlInitUnicodeString(&DriverName, L"DISPLAY");
+ hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
+ return hDC;
+}
VOID FASTCALL
DceInit(VOID)
@@ -103,56 +114,65 @@
PDCE FASTCALL
DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
{
- HDCE DceHandle;
- DCE* Dce;
- UNICODE_STRING DriverName;
-
- DceHandle = DCEOBJ_AllocDCE();
- if(!DceHandle)
- return NULL;
-
- RtlInitUnicodeString(&DriverName, L"DISPLAY");
-
- Dce = DCEOBJ_LockDCE(DceHandle);
- /* No real locking, just get the pointer */
- DCEOBJ_UnlockDCE(Dce);
- Dce->Self = DceHandle;
- Dce->hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE);
- if (NULL == defaultDCstate)
- {
- defaultDCstate = NtGdiGetDCState(Dce->hDC);
- DC_SetOwnership(defaultDCstate, NULL);
- }
- GDIOBJ_SetOwnership(GdiHandleTable, Dce->Self, NULL);
- DC_SetOwnership(Dce->hDC, NULL);
- Dce->hwndCurrent = (Window ? Window->hSelf : NULL);
- Dce->hClipRgn = NULL;
-
- Dce->next = FirstDce;
- FirstDce = Dce;
-
- if (Type != DCE_CACHE_DC)
- {
- Dce->DCXFlags = DCX_DCEBUSY;
-
- if (Window)
- {
- if (Window->Style & WS_CLIPCHILDREN)
- {
- Dce->DCXFlags |= DCX_CLIPCHILDREN;
- }
- if (Window->Style & WS_CLIPSIBLINGS)
- {
- Dce->DCXFlags |= DCX_CLIPSIBLINGS;
- }
- }
- }
- else
- {
- Dce->DCXFlags = DCX_CACHE | DCX_DCEEMPTY;
- }
-
- return(Dce);
+ PDCE pDce;
+
+ pDce = ExAllocatePoolWithTag(PagedPool, sizeof(DCE), TAG_PDCE);
+ if(!pDce)
+ return NULL;
+
+ pDce->hDC = DceCreateDisplayDC();
+ if(!pDce->hDC)
+ {
+ ExFreePoolWithTag(pDce, TAG_PDCE);
+ return NULL;
+ }
+
+ if (NULL == defaultDCstate) // Ultra HAX! Dedicated to GvG!
+ { // This is a cheesy way to do this.
+ // But, due to the right way of creating gdi handles there is no choice.
+ defaultDCstate = NtGdiGetDCState(pDce->hDC);
+ DC_SetOwnership( defaultDCstate, NULL);
+ }
+
+ pDce->hwndCurrent = (Window ? Window->hSelf : NULL);
+ pDce->hClipRgn = NULL;
+ pDce->pProcess = NULL;
+
+ pDce->next = FirstDce;
+ FirstDce = pDce;
+
+ if (Type == DCE_WINDOW_DC) //Window DCE have ownership.
+ {
+ DC_SetOwnership(pDce->hDC, PsGetCurrentProcess());
+ pDce->pProcess = PsGetCurrentProcess();
+ }
+ else
+ {
+ DC_SetOwnership(pDce->hDC, NULL); // This hDC is inaccessible!
+ }
+
+ if (Type != DCE_CACHE_DC)
+ {
+ pDce->DCXFlags = DCX_DCEBUSY;
+
+ if (Window)
+ {
+ if (Window->Style & WS_CLIPCHILDREN)
+ {
+ pDce->DCXFlags |= DCX_CLIPCHILDREN;
+ }
+ if (Window->Style & WS_CLIPSIBLINGS)
+ {
+ pDce->DCXFlags |= DCX_CLIPSIBLINGS;
+ }
+ }
+ }
+ else
+ {
+ pDce->DCXFlags = DCX_CACHE | DCX_DCEEMPTY;
+ }
+
+ return(pDce);
}
VOID static STDCALL
@@ -225,7 +245,15 @@
{
/* make the DC clean so that SetDCState doesn't try to update the vis rgn */
NtGdiSetHookFlags(dce->hDC, DCHF_VALIDATEVISRGN);
+
+ if( dce->pProcess ) // Attempt to fix Dc_Attr problem.
+ DC_SetOwnership( defaultDCstate, dce->pProcess);
+ else
+ DC_SetOwnership( defaultDCstate, PsGetCurrentProcess());
+
NtGdiSetDCState(dce->hDC, defaultDCstate);
+ DC_SetOwnership( defaultDCstate, NULL); // Return default dc state to inaccessible
mode.
+
dce->DCXFlags &= ~DCX_DCEBUSY;
if (dce->DCXFlags & DCX_DCEDIRTY)
{
@@ -237,7 +265,6 @@
dce->DCXFlags |= DCX_DCEEMPTY;
}
}
-
return 1;
}
@@ -535,12 +562,10 @@
}
-
-BOOL INTERNAL_CALL
-DCE_Cleanup(PVOID ObjectBody)
+BOOL FASTCALL
+DCE_Cleanup(PDCE pDce)
{
PDCE PrevInList;
- PDCE pDce = (PDCE)ObjectBody;
if (pDce == FirstDce)
{
@@ -604,7 +629,8 @@
}
-
+// Win 3.1 throw back, hWnd should be ignored and not used.
+// Replace with NtUserCallOneParam ((DWORD) hDC, ONEPARAM_ROUTINE_RELEASEDC);
INT STDCALL
NtUserReleaseDC(HWND hWnd, HDC hDc)
{
@@ -625,39 +651,37 @@
* DceFreeDCE
*/
PDCE FASTCALL
-DceFreeDCE(PDCE dce, BOOLEAN Force)
-{
- DCE *ret;
-
- if (NULL == dce)
- {
- return NULL;
- }
-
- ret = dce->next;
-
-#if 0 /* FIXME */
-
- SetDCHook(dce->hDC, NULL, 0L);
-#endif
-
- if(Force && !GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, dce->hDC))
- {
- GDIOBJ_SetOwnership(GdiHandleTable, dce->Self, PsGetCurrentProcess());
- DC_SetOwnership(dce->hDC, PsGetCurrentProcess());
- }
-
- NtGdiDeleteObjectApp(dce->hDC);
- if (dce->hClipRgn && ! (dce->DCXFlags & DCX_KEEPCLIPRGN))
- {
- NtGdiDeleteObject(dce->hClipRgn);
- }
-
- DCEOBJ_FreeDCE(dce->Self);
-
- return ret;
-}
-
+DceFreeDCE(PDCE pdce, BOOLEAN Force)
+ {
+ DCE *ret;
+
+ if (NULL == pdce)
+ {
+ return NULL;
+ }
+
+ ret = pdce->next;
+
+ #if 0 /* FIXME */
+
+ SetDCHook(pdce->hDC, NULL, 0L);
+ #endif
+
+ if(Force && !GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, pdce->hDC))
+ {
+ DC_SetOwnership( pdce->hDC, PsGetCurrentProcess());
+ }
+
+ NtGdiDeleteObjectApp(pdce->hDC);
+ if (pdce->hClipRgn && ! (pdce->DCXFlags & DCX_KEEPCLIPRGN))
+ {
+ NtGdiDeleteObject(pdce->hClipRgn);
+ }
+
+ DCE_Cleanup(pdce);
+ ExFreePoolWithTag(pdce, TAG_PDCE);
+ return ret;
+}
/***********************************************************************
* DceFreeWindowDCE
Modified: trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c Wed Jul 25 07:35:59 2007
@@ -77,7 +77,6 @@
{GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ), BRUSH_Cleanup},
{GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ), GDI_CleanupDummy},
{GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ), GDI_CleanupDummy},
- {GDI_OBJECT_TYPE_DCE, sizeof(DCE), DCE_Cleanup},
{GDI_OBJECT_TYPE_DIRECTDRAW, sizeof(DD_DIRECTDRAW), DD_Cleanup},
{GDI_OBJECT_TYPE_DD_SURFACE, sizeof(DD_SURFACE), DDSURF_Cleanup},
{GDI_OBJECT_TYPE_EXTPEN, sizeof(GDIBRUSHOBJ), EXTPEN_Cleanup},