Partial fix for handling GDIOBJs between different processes

svn path=/trunk/; revision=6387
This commit is contained in:
Gé van Geldorp 2003-10-20 17:57:05 +00:00
parent b8b3cf100c
commit 44c92af3c6
4 changed files with 65 additions and 4 deletions

View file

@ -66,6 +66,8 @@ BOOL FASTCALL GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj);
BOOL FASTCALL GDIOBJ_UnlockObj (HGDIOBJ Obj, DWORD ObjectType);
BOOL FASTCALL GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj);
DWORD FASTCALL GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle);
BOOL FASTCALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
void FASTCALL GDIOBJ_TakeOwnership(HGDIOBJ ObjectHandle);
/* a couple macros for debugging GDIOBJ locking */
#define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,ty)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: windc.c,v 1.32 2003/10/17 21:35:45 gvg Exp $
/* $Id: windc.c,v 1.33 2003/10/20 17:57:05 gvg Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -266,6 +266,7 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags)
BOOL UpdateVisRgn = TRUE;
BOOL UpdateClipOrigin = FALSE;
HANDLE hRgnVisible = NULL;
PDC DC;
if (NULL == hWnd)
{
@ -380,6 +381,28 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags)
{
Dce = DceAllocDCE(NULL, DCE_CACHE_DC);
}
else if (! GDIOBJ_OwnedByCurrentProcess(Dce->Self))
{
GDIOBJ_TakeOwnership(Dce->Self);
GDIOBJ_TakeOwnership(Dce->hDC);
DC = DC_LockDc(Dce->hDC);
if (NULL != DC)
{
if (NULL != DC->w.hClipRgn)
{
GDIOBJ_TakeOwnership(DC->w.hClipRgn);
}
if (NULL != DC->w.hVisRgn)
{
GDIOBJ_TakeOwnership(DC->w.hVisRgn);
}
if (NULL != DC->w.hGCClipRgn)
{
GDIOBJ_TakeOwnership(DC->w.hGCClipRgn);
}
DC_UnlockDc(Dce->hDC);
}
}
}
else
{

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dc.c,v 1.88 2003/10/12 20:23:25 gvg Exp $
/* $Id: dc.c,v 1.89 2003/10/20 17:57:05 gvg Exp $
*
* DC.C - Device context functions
*
@ -413,6 +413,7 @@ NtGdiCreatePrimarySurface(LPCWSTR Driver,
DPRINT("Adjusting GDIInfo.ulLogPixelsY\n");
PrimarySurface.GDIInfo.ulLogPixelsY = 96;
}
GDIOBJ_MarkObjectGlobal(PrimarySurface.DevInfo.hpalDefault);
DPRINT("calling completePDev\n");

View file

@ -19,7 +19,7 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
* $Id: gdiobj.c,v 1.47 2003/10/16 03:26:51 vizzini Exp $
* $Id: gdiobj.c,v 1.48 2003/10/20 17:57:05 gvg Exp $
*
*/
@ -63,6 +63,8 @@
#define GDI_TYPE_TO_MAGIC(t) ((WORD) ((t) >> 16))
#define GDI_MAGIC_TO_TYPE(m) ((DWORD)(m) << 16)
/* FIXME Ownership of GDI objects by processes not properly implemented yet */
#if 0
#define GDI_VALID_OBJECT(h, obj, t, f) \
(NULL != (obj) \
&& (GDI_MAGIC_TO_TYPE((obj)->Magic) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
@ -70,6 +72,12 @@
&& (((obj)->hProcessId == PsGetCurrentProcessId()) \
|| (GDI_GLOBAL_PROCESS == (obj)->hProcessId) \
|| ((f) & GDIOBJFLAG_IGNOREPID)))
#else
#define GDI_VALID_OBJECT(h, obj, t, f) \
(NULL != (obj) \
&& (GDI_MAGIC_TO_TYPE((obj)->Magic) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
&& (GDI_HANDLE_GET_TYPE((h)) == GDI_MAGIC_TO_TYPE((obj)->Magic)))
#endif
typedef struct _GDI_HANDLE_TABLE
{
@ -438,7 +446,7 @@ GDIOBJ_UnmarkObjectGlobal(HGDIOBJ ObjectHandle)
DPRINT("GDIOBJ_MarkObjectGlobal handle 0x%08x\n", ObjectHandle);
ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle));
if (NULL == ObjHdr || GDI_GLOBAL_PROCESS != ObjHdr->hProcessId)
if (NULL == ObjHdr /*|| GDI_GLOBAL_PROCESS != ObjHdr->hProcessId*/)
{
return;
}
@ -620,6 +628,8 @@ GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
else if (ObjHdr->hProcessId != GDI_GLOBAL_PROCESS
&& ObjHdr->hProcessId != PsGetCurrentProcessId())
{
DPRINT1("object proc 0x%x current proc 0x%x\n", ObjHdr->hProcessId, PsGetCurrentProcessId());
__asm__("int $3\n");
reason = 3;
}
else if (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE)
@ -755,4 +765,29 @@ GDIOBJ_UnlockObj(HGDIOBJ hObj, DWORD ObjectType)
return TRUE;
}
BOOL FASTCALL
GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle)
{
PGDIOBJHDR ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle));
DPRINT("GDIOBJ_OwnedByCurrentProcess: ObjectHandle: 0x%08x\n", ObjectHandle);
ASSERT(GDI_VALID_OBJECT(ObjectHandle, ObjHdr, GDI_OBJECT_TYPE_DONTCARE, GDIOBJFLAG_IGNOREPID));
return ObjHdr->hProcessId == PsGetCurrentProcessId();
}
void FASTCALL
GDIOBJ_TakeOwnership(HGDIOBJ ObjectHandle)
{
PGDIOBJHDR ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle));
DPRINT("GDIOBJ_OwnedByCurrentProcess: ObjectHandle: 0x%08x\n", ObjectHandle);
ASSERT(GDI_VALID_OBJECT(ObjectHandle, ObjHdr, GDI_OBJECT_TYPE_DONTCARE, GDIOBJFLAG_IGNOREPID));
if (GDI_GLOBAL_PROCESS != ObjHdr->hProcessId)
{
ObjHdr->hProcessId = PsGetCurrentProcessId();
}
}
/* EOF */