Author: jimtabor
Date: Thu Dec 6 05:09:56 2007
New Revision: 31033
URL:
http://svn.reactos.org/svn/reactos?rev=31033&view=rev
Log:
Fixed one more test, now from 23 to 22 fail. Reordered NtGdiDeleteObjectApp and created a
separate function so that applications can not delete DCs belonging to DCEs. Add a check
for Wnd = NULL for UserGetDCEx, this did not help the test results. Test Qemu Linux, Xp
and hardware. Install and run AbiWord and FF as tests.
Modified:
trunk/reactos/subsystems/win32/win32k/include/dc.h
trunk/reactos/subsystems/win32/win32k/include/dce.h
trunk/reactos/subsystems/win32/win32k/ntuser/windc.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dc.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dc.h Thu Dec 6 05:09:56 2007
@@ -108,12 +108,14 @@
VOID FASTCALL DC_UnlockDisplay(HDC);
VOID FASTCALL IntGdiCopyFromSaveState(PDC, PDC, HDC);
VOID FASTCALL IntGdiCopyToSaveState(PDC, PDC);
+BOOL FASTCALL IntGdiDeleteDC(HDC, BOOL);
VOID FASTCALL DC_UpdateXforms(PDC dc);
BOOL FASTCALL DC_InvertXform(const XFORM *xformSrc, XFORM *xformDest);
BOOL FASTCALL DCU_SyncDcAttrtoUser(PDC);
BOOL FASTCALL DCU_SynchDcAttrtoUser(HDC);
+VOID FASTCALL DCU_SetDcUndeletable(HDC);
VOID FASTCALL IntGetViewportExtEx(PDC dc, LPSIZE pt);
VOID FASTCALL IntGetViewportOrgEx(PDC dc, LPPOINT pt);
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 Thu Dec 6 05:09:56 2007
@@ -40,6 +40,7 @@
#define DCX_DCEEMPTY 0x00000800
#define DCX_DCEBUSY 0x00001000
#define DCX_DCEDIRTY 0x00002000
+#define DCX_DCOWNED 0x00008000
#define DCX_USESTYLE 0x00010000
#define DCX_KEEPCLIPRGN 0x00040000
#define DCX_NOCLIPCHILDREN 0x00080000
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 Thu Dec 6 05:09:56 2007
@@ -161,6 +161,8 @@
FirstDce = pDce;
KeLeaveCriticalRegion();
+ DCU_SetDcUndeletable(pDce->hDC);
+
if (Type == DCE_WINDOW_DC) //Window DCE have ownership.
{ // Process should already own it.
pDce->pProcess = PsGetCurrentProcess();
@@ -403,8 +405,11 @@
PWINDOW Wnd = NULL;
if (NULL == Window)
- {
- Flags &= ~DCX_USESTYLE;
+ { // Do the same as GetDC with a NULL.
+ Window = UserGetWindowObject(IntGetDesktopWindow());
+ if (Window) Wnd = Window->Wnd;
+ else
+ Flags &= ~DCX_USESTYLE;
}
else
Wnd = Window->Wnd;
@@ -723,7 +728,8 @@
}
}
- NtGdiDeleteObjectApp(pdce->hDC);
+ IntGdiDeleteDC(pdce->hDC, TRUE);
+
if (pdce->hClipRgn && ! (pdce->DCXFlags & DCX_KEEPCLIPRGN))
{
NtGdiDeleteObject(pdce->hClipRgn);
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c Thu Dec 6 05:09:56 2007
@@ -910,29 +910,32 @@
}
+//
+//
+//
BOOL
-STDCALL
-NtGdiDeleteObjectApp(HANDLE DCHandle)
-{
- PDC DCToDelete;
-
- if (GDI_HANDLE_GET_TYPE(DCHandle) != GDI_OBJECT_TYPE_DC)
- return NtGdiDeleteObject((HGDIOBJ) DCHandle);
-
- if(IsObjectDead((HGDIOBJ)DCHandle)) return TRUE;
-
- if (!GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, DCHandle))
+FASTCALL
+IntGdiDeleteDC(HDC hDC, BOOL Force)
+{
+ BOOL Ret = FALSE;
+ PDC DCToDelete = DC_LockDc(hDC);
+
+ if (DCToDelete == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
- DCToDelete = DC_LockDc(DCHandle);
- if (DCToDelete == NULL)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return FALSE;
- }
+ if(!Force)
+ {
+ if (DCToDelete->DC_Flags & DC_FLAG_PERMANENT)
+ {
+ DPRINT1("No! You Naughty Application!\n");
+// if(!UserReleaseDC(NULL, hDC, FALSE)) Ret = FALSE;
+ }
+ DC_UnlockDc( DCToDelete );
+ return Ret;
+ }
/* First delete all saved DCs */
while (DCToDelete->saveLevel)
@@ -995,8 +998,29 @@
}
DC_UnlockDc( DCToDelete );
- DC_FreeDC ( DCHandle );
+ DC_FreeDC ( hDC );
return TRUE;
+}
+
+BOOL
+STDCALL
+NtGdiDeleteObjectApp(HANDLE DCHandle)
+{
+
+ if (GDI_HANDLE_IS_STOCKOBJ(DCHandle)) return TRUE;
+
+ if (GDI_HANDLE_GET_TYPE(DCHandle) != GDI_OBJECT_TYPE_DC)
+ return NtGdiDeleteObject((HGDIOBJ) DCHandle);
+
+ if(IsObjectDead((HGDIOBJ)DCHandle)) return TRUE;
+
+ if (!GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, DCHandle))
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ return IntGdiDeleteDC(DCHandle, FALSE);
}
INT
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcutil.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ob…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dcutil.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dcutil.c Thu Dec 6 05:09:56 2007
@@ -257,3 +257,19 @@
NtGdiSelectBrush(hDC, hBrush);
return oldColor;
}
+
+VOID
+FASTCALL
+DCU_SetDcUndeletable(HDC hDC)
+{
+ PDC dc = DC_LockDc(hDC);
+ if (!dc)
+ {
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ return;
+ }
+
+ dc->DC_Flags |= DC_FLAG_PERMANENT;
+ DC_UnlockDc( dc );
+ return;
+}