mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 12:23:25 +00:00
Stricter checking of GDIOBJ handles
svn path=/trunk/; revision=6237
This commit is contained in:
@@ -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.26 2003/10/03 18:04:37 gvg Exp $
|
||||
/* $Id: windc.c,v 1.27 2003/10/04 21:09:29 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
@@ -32,7 +32,6 @@
|
||||
#include <ddk/ntddk.h>
|
||||
#include <win32k/win32k.h>
|
||||
#include <win32k/region.h>
|
||||
#include <win32k/userobj.h>
|
||||
#include <include/class.h>
|
||||
#include <include/error.h>
|
||||
#include <include/winsta.h>
|
||||
@@ -41,6 +40,7 @@
|
||||
#include <include/rect.h>
|
||||
#include <include/dce.h>
|
||||
#include <include/vis.h>
|
||||
#include <include/object.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
@@ -136,6 +136,7 @@ DceAllocDCE(HWND hWnd, DCE_TYPE Type)
|
||||
if (NULL == defaultDCstate)
|
||||
{
|
||||
defaultDCstate = NtGdiGetDCState(Dce->hDC);
|
||||
GDIOBJ_MarkObjectGlobal(defaultDCstate);
|
||||
}
|
||||
Dce->hwndCurrent = hWnd;
|
||||
Dce->hClipRgn = NULL;
|
||||
|
||||
@@ -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: bitmaps.c,v 1.39 2003/09/27 15:09:26 navaraf Exp $ */
|
||||
/* $Id: bitmaps.c,v 1.40 2003/10/04 21:09:29 gvg Exp $ */
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "../eng/handle.h"
|
||||
#include <include/inteng.h>
|
||||
#include <include/eng.h>
|
||||
#include <include/error.h>
|
||||
#include <include/surface.h>
|
||||
#include <include/palette.h>
|
||||
|
||||
@@ -55,7 +56,7 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
||||
POINTL SourcePoint;
|
||||
//PBITMAPOBJ DestBitmapObj;
|
||||
//PBITMAPOBJ SrcBitmapObj;
|
||||
BOOL Status, SurfDestAlloc, SurfSrcAlloc;
|
||||
BOOL Status;
|
||||
PPALGDI PalDestGDI, PalSourceGDI;
|
||||
PXLATEOBJ XlateObj = NULL;
|
||||
HPALETTE SourcePalette, DestPalette;
|
||||
@@ -87,9 +88,6 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
||||
SourcePoint.x = XSrc;
|
||||
SourcePoint.y = YSrc;
|
||||
|
||||
SurfDestAlloc = FALSE;
|
||||
SurfSrcAlloc = FALSE;
|
||||
|
||||
// Determine surfaces to be used in the bitblt
|
||||
SurfDest = (PSURFOBJ)AccessUserObject((ULONG)DCDest->Surface);
|
||||
SurfSrc = (PSURFOBJ)AccessUserObject((ULONG)DCSrc->Surface);
|
||||
@@ -116,8 +114,15 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
||||
}
|
||||
|
||||
PalSourceGDI = PALETTE_LockPalette(SourcePalette);
|
||||
if (NULL == PalSourceGDI)
|
||||
{
|
||||
GDIOBJ_UnlockMultipleObj(Lock, sizeof(Lock) / sizeof(Lock[0]));
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
SourceMode = PalSourceGDI->Mode;
|
||||
PALETTE_UnlockPalette(SourcePalette);
|
||||
|
||||
if (DestPalette == SourcePalette)
|
||||
{
|
||||
DestMode = SourceMode;
|
||||
@@ -125,19 +130,28 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest,
|
||||
else
|
||||
{
|
||||
PalDestGDI = PALETTE_LockPalette(DestPalette);
|
||||
if (NULL == PalDestGDI)
|
||||
{
|
||||
GDIOBJ_UnlockMultipleObj(Lock, sizeof(Lock) / sizeof(Lock[0]));
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
DestMode = PalDestGDI->Mode;
|
||||
PALETTE_UnlockPalette(DestPalette);
|
||||
}
|
||||
|
||||
XlateObj = (PXLATEOBJ)IntEngCreateXlate(DestMode, SourceMode, DestPalette, SourcePalette);
|
||||
if (NULL == XlateObj)
|
||||
{
|
||||
GDIOBJ_UnlockMultipleObj(Lock, sizeof(Lock) / sizeof(Lock[0]));
|
||||
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Perform the bitblt operation
|
||||
|
||||
/* Perform the bitblt operation */
|
||||
Status = IntEngBitBlt(SurfDest, SurfSrc, NULL, DCDest->CombinedClip, XlateObj, &DestRect, &SourcePoint, NULL, NULL, NULL, ROP);
|
||||
|
||||
EngDeleteXlate(XlateObj);
|
||||
if (SurfDestAlloc) ExFreePool(SurfDest);
|
||||
if (SurfSrcAlloc) ExFreePool(SurfSrc);
|
||||
|
||||
GDIOBJ_UnlockMultipleObj(Lock, sizeof(Lock) / sizeof(Lock[0]));
|
||||
|
||||
|
||||
@@ -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: brush.c,v 1.26 2003/08/29 09:29:11 gvg Exp $
|
||||
/* $Id: brush.c,v 1.27 2003/10/04 21:09:29 gvg Exp $
|
||||
*/
|
||||
|
||||
|
||||
@@ -288,18 +288,24 @@ BOOL STDCALL NtGdiPatBlt(HDC hDC,
|
||||
DC *dc = DC_LockDc(hDC);
|
||||
BOOL ret;
|
||||
|
||||
if (dc == NULL)
|
||||
if (NULL == dc)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
|
||||
if (NULL == BrushObj)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = IntPatBlt(dc,XLeft,YLeft,Width,Height,ROP,BrushObj);
|
||||
|
||||
BRUSHOBJ_UnlockBrush(dc->w.hBrush);
|
||||
DC_UnlockDc( hDC );
|
||||
return(ret);
|
||||
DC_UnlockDc(hDC);
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL STDCALL NtGdiSetBrushOrgEx(HDC hDC,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: dib.c,v 1.34 2003/09/26 10:45:45 gvg Exp $
|
||||
* $Id: dib.c,v 1.35 2003/10/04 21:09:29 gvg Exp $
|
||||
*
|
||||
* ReactOS W32 Subsystem
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
||||
@@ -158,6 +158,15 @@ NtGdiSetDIBits(
|
||||
|
||||
// Destination palette obtained from the hDC
|
||||
hDCPalette = PALETTE_LockPalette(dc->DevInfo->hpalDefault);
|
||||
if (NULL == hDCPalette)
|
||||
{
|
||||
EngDeleteSurface(SourceBitmap);
|
||||
EngDeleteSurface(DestBitmap);
|
||||
BITMAPOBJ_UnlockBitmap(hBitmap);
|
||||
DC_UnlockDc(hDC);
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return 0;
|
||||
}
|
||||
DDB_Palette_Type = hDCPalette->Mode;
|
||||
DDB_Palette = dc->DevInfo->hpalDefault;
|
||||
PALETTE_UnlockPalette(dc->DevInfo->hpalDefault);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
/*
|
||||
* GDIOBJ.C - GDI object manipulation routines
|
||||
*
|
||||
* $Id: gdiobj.c,v 1.44 2003/09/26 10:45:45 gvg Exp $
|
||||
* $Id: gdiobj.c,v 1.45 2003/10/04 21:09:29 gvg Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#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)) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
|
||||
&& (GDI_HANDLE_GET_TYPE((h)) == GDI_MAGIC_TO_TYPE((obj)->Magic)) \
|
||||
&& (((obj)->hProcessId == PsGetCurrentProcessId()) \
|
||||
|| (GDI_GLOBAL_PROCESS == (obj)->hProcessId) \
|
||||
|| ((f) & GDIOBJFLAG_IGNOREPID)))
|
||||
@@ -450,7 +450,8 @@ GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle)
|
||||
PGDIOBJHDR ObjHdr;
|
||||
|
||||
ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle));
|
||||
if (NULL == ObjHdr)
|
||||
if (NULL == ObjHdr
|
||||
|| ! GDI_VALID_OBJECT(ObjectHandle, ObjHdr, GDI_MAGIC_TO_TYPE(ObjHdr->Magic), 0))
|
||||
{
|
||||
DPRINT1("Invalid ObjectHandle 0x%08x\n", ObjectHandle);
|
||||
return 0;
|
||||
@@ -572,8 +573,8 @@ CleanupForProcess (struct _EPROCESS *Process, INT Pid)
|
||||
(INT) objectHeader->hProcessId == Pid)
|
||||
{
|
||||
DPRINT("CleanupForProcess: %d, process: %d, locks: %d, magic: 0x%x", i, objectHeader->hProcessId, objectHeader->dwCount, objectHeader->Magic);
|
||||
GDIOBJ_FreeObj(GDI_HANDLE_CREATE(i, GDI_OBJECT_TYPE_DONTCARE),
|
||||
GDI_OBJECT_TYPE_DONTCARE,
|
||||
GDIOBJ_FreeObj(GDI_HANDLE_CREATE(i, GDI_MAGIC_TO_TYPE(objectHeader->Magic)),
|
||||
GDI_MAGIC_TO_TYPE(objectHeader->Magic),
|
||||
GDIOBJFLAG_IGNOREPID | GDIOBJFLAG_IGNORELOCK);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user