- simplify a check

- fix a check
- fix a region leak
- don't abuse GDIOBJ_LockObj to validate a handle, use GDIOBJ_ValidateHandle instead
- add some additional debug output

svn path=/trunk/; revision=32110
This commit is contained in:
Timo Kreuzer 2008-02-04 03:22:27 +00:00
parent faf0212f7b
commit edff92650c
2 changed files with 11 additions and 5 deletions

View file

@ -485,7 +485,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
else
{
Dce = Window->Dce;
if (NULL != Dce && Dce->hwndCurrent == (Window ? Window->hSelf : NULL))
if (Dce->hwndCurrent == Window->hSelf)
{
UpdateVisRgn = FALSE; /* updated automatically, via DCHook() */
}
@ -511,7 +511,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
if (0 == (Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && NULL != ClipRegion)
{
if (Flags & DCX_KEEPCLIPRGN)
if (!(Flags & DCX_KEEPCLIPRGN))
NtGdiDeleteObject(ClipRegion);
ClipRegion = NULL;
}
@ -520,7 +520,6 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
if (NULL != Dce->hClipRgn)
{
DceDeleteClipRgn(Dce);
Dce->hClipRgn = NULL;
}
#endif
@ -541,6 +540,7 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
{
Dce->hClipRgn = UnsafeIntCreateRectRgnIndirect(&Window->Wnd->WindowRect);
}
Dce->DCXFlags &= ~DCX_KEEPCLIPRGN;
}
else if (ClipRegion != NULL)
{
@ -715,8 +715,8 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
}
}
dc = DC_LockDc(pDCE->hDC);
if (dc == NULL)
if (!GDIOBJ_ValidateHandle(pDCE->hDC, GDI_OBJECT_TYPE_DC) ||
(dc = DC_LockDc(pDCE->hDC)) == NULL)
{
pDCE = (PDCE) pDCE->List.Flink;
continue;

View file

@ -857,6 +857,12 @@ GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
/* Check for invalid owner. */
if (ProcessId != HandleProcessId && HandleProcessId != NULL)
{
DPRINT1("Tried to lock object (0x%p) of wrong owner! ProcessId = %p, HandleProcessId = %p\n", hObj, ProcessId, HandleProcessId);
#ifdef GDI_DEBUG
KeRosDumpStackFrames(NULL, 20);
// DPRINT1("Handle allocator:\n");
// KeRosDumpStackFrames(GDIHandleAllocator[GDI_HANDLE_GET_INDEX(hObj)], GDI_STACK_LEVELS);
#endif
return NULL;
}