Author: tkreuzer
Date: Tue Mar 18 19:56:40 2008
New Revision: 32721
URL:
http://svn.reactos.org/svn/reactos?rev=3D32721&view=3Drev
Log:
- Rename GDIOBJ_AllocObj to GDIOBJ_allocObjWithHandle and make it return a =
pointer to a locked object.c
- Implement GDIOBJ_AllocObjDepricated as a wrapper for those functions that=
currently still need the old way of allocation. Will be gone soon
- Implement GDIOBJ_AllocObj that only allocates a memory object without a h=
andle
- Rename GDIOBJ_FreeObject to GDIOBJ_FreeObjByHandle
- Implement GDIOBJ_FreeObj that only frees the memory object
- Rename all XXX_Alloc and XXX_Free functions accordingly
- Fix NtGdiCreateClientObject and NtGdiDeleteClientObject
- Reformat TextIntCreateFontIndirect
- NtGdiHfontCreate: reformat and MmCopyFromCaller -> SEH
Modified:
trunk/reactos/subsystems/win32/win32k/eng/palette.c
trunk/reactos/subsystems/win32/win32k/eng/surface.c
trunk/reactos/subsystems/win32/win32k/include/bitmaps.h
trunk/reactos/subsystems/win32/win32k/include/brush.h
trunk/reactos/subsystems/win32/win32k/include/gdiobj.h
trunk/reactos/subsystems/win32/win32k/include/palette.h
trunk/reactos/subsystems/win32/win32k/include/pen.h
trunk/reactos/subsystems/win32/win32k/include/region.h
trunk/reactos/subsystems/win32/win32k/include/text.h
trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
trunk/reactos/subsystems/win32/win32k/objects/brush.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
trunk/reactos/subsystems/win32/win32k/objects/metafile.c
trunk/reactos/subsystems/win32/win32k/objects/palobj.c
trunk/reactos/subsystems/win32/win32k/objects/pen.c
trunk/reactos/subsystems/win32/win32k/objects/region.c
trunk/reactos/subsystems/win32/win32k/objects/text.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/palette.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/eng/palette.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/eng/palette.c (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/palette.c Tue Mar 18 19:56:40=
2008
@@ -82,7 +82,7 @@
{
GDIOBJ_SetOwnership(Palette, PsGetCurrentProcess());
=
- return PALETTE_FreePalette(Palette);
+ return PALETTE_FreePaletteByHandle(Palette);
}
=
/*
Modified: trunk/reactos/subsystems/win32/win32k/eng/surface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/eng/surface.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/eng/surface.c (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/surface.c Tue Mar 18 19:56:40=
2008
@@ -264,7 +264,7 @@
if (Format =3D=3D 0)
return 0;
=
- NewBitmap =3D BITMAPOBJ_AllocBitmap();
+ NewBitmap =3D BITMAPOBJ_AllocBitmapDepricated();
if (NewBitmap =3D=3D NULL)
return 0;
=
@@ -272,7 +272,7 @@
if (! BITMAPOBJ_InitBitsLock(BitmapObj))
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
- BITMAPOBJ_FreeBitmap(NewBitmap);
+ BITMAPOBJ_FreeBitmapByHandle(NewBitmap);
return 0;
}
SurfObj =3D &BitmapObj->SurfObj;
@@ -325,7 +325,7 @@
if (SurfObj->pvBits =3D=3D NULL)
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
- BITMAPOBJ_FreeBitmap(NewBitmap);
+ BITMAPOBJ_FreeBitmapByHandle(NewBitmap);
return 0;
}
}
@@ -396,7 +396,7 @@
SURFOBJ *SurfObj;
BITMAPOBJ *BitmapObj;
=
- NewSurface =3D (HSURF)BITMAPOBJ_AllocBitmap();
+ NewSurface =3D (HSURF)BITMAPOBJ_AllocBitmapDepricated();
if (NewSurface =3D=3D NULL)
return 0;
=
@@ -406,7 +406,7 @@
if (! BITMAPOBJ_InitBitsLock(BitmapObj))
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
- BITMAPOBJ_FreeBitmap(NewSurface);
+ BITMAPOBJ_FreeBitmapByHandle(NewSurface);
return 0;
}
SurfObj =3D &BitmapObj->SurfObj;
@@ -513,7 +513,7 @@
EngDeleteSurface(IN HSURF Surface)
{
GDIOBJ_SetOwnership(Surface, PsGetCurrentProcess());
- BITMAPOBJ_FreeBitmap(Surface);
+ BITMAPOBJ_FreeBitmapByHandle(Surface);
return TRUE;
}
=
Modified: trunk/reactos/subsystems/win32/win32k/include/bitmaps.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/bitmaps.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/bitmaps.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/bitmaps.h Tue Mar 18 19:5=
6:40 2008
@@ -26,10 +26,12 @@
=
/* Internal interface */
=
-#define BITMAPOBJ_AllocBitmap() \
- ((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP))
-#define BITMAPOBJ_FreeBitmap(hBMObj) \
- GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
+#define BITMAPOBJ_AllocBitmap() ((PBITMAPOBJ) GDIOBJ_AllocObj(GDIObjTy=
pe_SURF_TYPE))
+#define BITMAPOBJ_AllocBitmapWithHandle() ((PBITMAPOBJ) GDIOBJ_AllocOb=
jWithHandle(GDI_OBJECT_TYPE_BITMAP))
+#define BITMAPOBJ_AllocBitmapDepricated() ((HBITMAP) GDIOBJ_AllocObjDe=
pricated(GDI_OBJECT_TYPE_BITMAP))
+#define BITMAPOBJ_FreeBitmap(pBMObj) GDIOBJ_FreeObj((POBJ) pBMObj, GDIObj=
Type_SURF_TYPE)
+#define BITMAPOBJ_FreeBitmapByHandle(hBMObj) GDIOBJ_FreeObjByHandle((HGDI=
OBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
+
/* NOTE: Use shared locks! */
#define BITMAPOBJ_LockBitmap(hBMObj) \
((PBITMAPOBJ) GDIOBJ_ShareLockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BIT=
MAP))
Modified: trunk/reactos/subsystems/win32/win32k/include/brush.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/brush.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/brush.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/brush.h Tue Mar 18 19:56:=
40 2008
@@ -72,8 +72,11 @@
#define GDIBRUSH_IS_MASKING 0x8000 /* Pattern bitmap is used as transpare=
nt mask (?) */
#define GDIBRUSH_CACHED_IS_SOLID 0x80000000
=
-#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_=
BRUSH))
-#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OB=
JECT_TYPE_BRUSH)
+#define BRUSHOBJ_AllocBrush() ((PGDIBRUSHOBJ) GDIOBJ_AllocObj(GDIObjType_=
BRUSH_TYPE))
+#define BRUSHOBJ_AllocBrushWithHandle() ((PGDIBRUSHOBJ) GDIOBJ_AllocObjWi=
thHandle (GDI_OBJECT_TYPE_BRUSH))
+#define BRUSHOBJ_AllocBrushDepricated() ((HBRUSH) GDIOBJ_AllocObjDepricat=
ed (GDI_OBJECT_TYPE_BRUSH))
+#define BRUSHOBJ_FreeBrush(pBrush) GDIOBJ_FreeObj((POBJ)pBrush, GDIObjTyp=
e_BRUSH_TYPE)
+#define BRUSHOBJ_FreeBrushByHandle(hBrush) GDIOBJ_FreeObjByHandle((HGDIOB=
J)hBrush, GDI_OBJECT_TYPE_BRUSH)
#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ=
)hBrush, GDI_OBJECT_TYPE_BRUSH))
#define BRUSHOBJ_UnlockBrush(pBrush) GDIOBJ_UnlockObjByPtr((POBJ)pBrush)
=
Modified: trunk/reactos/subsystems/win32/win32k/include/gdiobj.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/gdiobj.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/gdiobj.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/gdiobj.h Tue Mar 18 19:56=
:40 2008
@@ -46,6 +46,11 @@
PW32THREAD Tid;
} BASEOBJECT, *POBJ;
=
+enum BASEFLAGS
+{
+ BASEFLAG_LOOKASIDE =3D 0x80
+};
+
BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
VOID INTERNAL_CALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS =
Owner);
VOID INTERNAL_CALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyT=
o);
@@ -53,8 +58,11 @@
VOID INTERNAL_CALL GDIOBJ_UnlockObjByPtr(POBJ Object);
VOID INTERNAL_CALL GDIOBJ_ShareUnlockObjByPtr(POBJ Object);
BOOL INTERNAL_CALL GDIOBJ_ValidateHandle(HGDIOBJ hObj, ULONG ObjectType=
);
-HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(ULONG ObjectType);
-BOOL INTERNAL_CALL GDIOBJ_FreeObj (HGDIOBJ hObj, DWORD ObjectType);
+POBJ INTERNAL_CALL GDIOBJ_AllocObj(UCHAR ObjectType);
+POBJ INTERNAL_CALL GDIOBJ_AllocObjWithHandle(ULONG ObjectType);
+HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObjDepricated(ULONG ObjectType);
+VOID INTERNAL_CALL GDIOBJ_FreeObj (POBJ pObj, UCHAR ObjectType);
+BOOL INTERNAL_CALL GDIOBJ_FreeObjByHandle (HGDIOBJ hObj, DWORD ObjectTy=
pe);
PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType);
PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType);
=
Modified: trunk/reactos/subsystems/win32/win32k/include/palette.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/palette.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/palette.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/palette.h Tue Mar 18 19:5=
6:40 2008
@@ -64,7 +64,8 @@
ULONG Blue);
HPALETTE FASTCALL PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors);
-#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, =
GDI_OBJECT_TYPE_PALETTE)
+#define PALETTE_FreePalette(pPalette) GDIOBJ_FreeObj((POBJ)pPalette, GDI=
ObjType_PAL_TYPE)
+#define PALETTE_FreePaletteByHandle(hPalette) GDIOBJ_FreeObjByHandle((HG=
DIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)h=
Palette, GDI_OBJECT_TYPE_PALETTE))
#define PALETTE_UnlockPalette(pPalette) GDIOBJ_UnlockObjByPtr((POBJ)pPale=
tte)
BOOL INTERNAL_CALL PALETTE_Cleanup(PVOID ObjectBody);
Modified: trunk/reactos/subsystems/win32/win32k/include/pen.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/pen.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/pen.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/pen.h Tue Mar 18 19:56:40=
2008
@@ -6,11 +6,17 @@
=
/* Internal interface */
=
-#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PEN))
-#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT=
_TYPE_PEN)
+#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDIObjType_BRUSH_TYPE))
+#define PENOBJ_AllocPenWithHandle() ((PGDIBRUSHOBJ)GDIOBJ_AllocObjWithHand=
le(GDI_OBJECT_TYPE_PEN))
+#define PENOBJ_AllocPenDepricated() ((HPEN)GDIOBJ_AllocObjDepricated(GDI_O=
BJECT_TYPE_PEN))
+#define PENOBJ_FreePen(pBMObj) GDIOBJ_FreeObj((POBJ) pBMObj, GDI_OBJECT_TY=
PE_PEN)
+#define PENOBJ_FreePenByHandle(hBMObj) GDIOBJ_FreeObjByHandle((HGDIOBJ) hB=
MObj, GDI_OBJECT_TYPE_PEN)
#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBM=
Obj, GDI_OBJECT_TYPE_PEN))
-#define PENOBJ_AllocExtPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_EXTPEN=
))
-#define PENOBJ_FreeExtPen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJ=
ECT_TYPE_EXTPEN)
+#define PENOBJ_AllocExtPen() ((PGDIBRUSHOBJ)GDIOBJ_AllocObj(GDIObjType_BRU=
SH_TYPE))
+#define PENOBJ_AllocExtPenWithHandle() ((PGDIBRUSHOBJ)GDIOBJ_AllocObjWithH=
andle(GDI_OBJECT_TYPE_EXTPEN))
+#define PENOBJ_AllocExtPenDepricated() ((HPEN)GDIOBJ_AllocObjDepricated(GD=
I_OBJECT_TYPE_EXTPEN))
+#define PENOBJ_FreeExtPen(pBMObj) GDIOBJ_FreeObj((POBJ) pBMObj, GDI_OBJECT=
_TYPE_EXTPEN)
+#define PENOBJ_FreeExtPenByHandle(hBMObj) GDIOBJ_FreeObjByHandle((HGDIOBJ)=
hBMObj, GDI_OBJECT_TYPE_EXTPEN)
#define PENOBJ_LockExtPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) =
hBMObj, GDI_OBJECT_TYPE_EXTPEN))
#define PENOBJ_UnlockPen(pPenObj) GDIOBJ_UnlockObjByPtr((POBJ)pPenObj)
=
Modified: trunk/reactos/subsystems/win32/win32k/include/region.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/region.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/region.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/region.h Tue Mar 18 19:56=
:40 2008
@@ -21,7 +21,8 @@
=
/* Functions *************************************************************=
*****/
=
-#define REGION_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TY=
PE_REGION)
+#define REGION_FreeRgn(pRgn) GDIOBJ_FreeObj((POBJ)pRgn, GDIObjType_RGN_T=
YPE)
+#define REGION_FreeRgnByHandle(hRgn) GDIOBJ_FreeObjbyHandle((HGDIOBJ)hRg=
n, GDI_OBJECT_TYPE_REGION)
#define REGION_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, =
GDI_OBJECT_TYPE_REGION))
#define REGION_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr((POBJ)pRgn)
=
Modified: trunk/reactos/subsystems/win32/win32k/include/text.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/include/text.h?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/include/text.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/text.h Tue Mar 18 19:56:4=
0 2008
@@ -68,9 +68,11 @@
=
/* Internal interface */
=
-#define TEXTOBJ_AllocText() \
- ((HFONT) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_FONT))
-#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OB=
JECT_TYPE_FONT)
+#define TEXTOBJ_AllocText() ((PTEXTOBJ) GDIOBJ_AllocObj(GDIObjType_=
LFONT_TYPE))
+#define TEXTOBJ_AllocTextWithHandle() ((PTEXTOBJ) GDIOBJ_AllocObjWithHand=
le(GDI_OBJECT_TYPE_FONT))
+#define TEXTOBJ_AllocTextDepricated() ((HFONT) GDIOBJ_AllocObj(GDI_OBJECT=
_TYPE_FONT))
+#define TEXTOBJ_FreeText(pBMObj) GDIOBJ_FreeObj((POBJ) pBMObj, GDILoObjT=
ype_LO_FONT_TYPE)
+#define TEXTOBJ_FreeTextByHandle(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj=
, GDI_OBJECT_TYPE_FONT)
#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hB=
MObj, GDI_OBJECT_TYPE_FONT))
#define TEXTOBJ_UnlockText(pBMObj) GDIOBJ_UnlockObjByPtr ((POBJ)pBMObj)
=
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/painting.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/ntuser/painting.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/ntuser/painting.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/painting.c Tue Mar 18 19:5=
6:40 2008
@@ -272,7 +272,7 @@
if ((HANDLE) 1 !=3D TempRegion && NULL !=3D TempRegion)
{
/* NOTE: The region can already be deleted! */
- GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJ=
ECT_TYPE_SILENT);
+ GDIOBJ_FreeObjByHandle(TempRegion, GDI_OBJECT_TYPE_REGION |=
GDI_OBJECT_TYPE_SILENT);
}
}
=
@@ -801,7 +801,7 @@
if (hRgn !=3D (HANDLE)1 && hRgn !=3D NULL)
{
/* NOTE: The region can already by deleted! */
- GDIOBJ_FreeObj(hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SIL=
ENT);
+ GDIOBJ_FreeObjByHandle(hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_=
TYPE_SILENT);
}
}
=
Modified: trunk/reactos/subsystems/win32/win32k/objects/brush.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/brush.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/brush.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/brush.c Tue Mar 18 19:56:=
40 2008
@@ -351,16 +351,14 @@
BitmapObject->hDIBPalette =3D BuildDIBPalette(BitmapInfo, &PaletteType);
BITMAPOBJ_UnlockBitmap(BitmapObject);
=
- hBrush =3D BRUSHOBJ_AllocBrush();
- if (hBrush =3D=3D NULL)
+ BrushObject =3D BRUSHOBJ_AllocBrushWithHandle();
+ if (BrushObject =3D=3D NULL)
{
NtGdiDeleteObject(hPattern);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
-
- BrushObject =3D BRUSHOBJ_LockBrush(hBrush);
- ASSERT(BrushObject !=3D NULL);
+ hBrush =3D BrushObject->BaseObject.hHmgr;
=
BrushObject->flAttrs |=3D GDIBRUSH_IS_BITMAP | GDIBRUSH_IS_DIB;
BrushObject->hbmPattern =3D hPattern;
@@ -394,16 +392,14 @@
return NULL;
}
=
- hBrush =3D BRUSHOBJ_AllocBrush();
- if (hBrush =3D=3D NULL)
+ BrushObject =3D BRUSHOBJ_AllocBrushWithHandle();
+ if (BrushObject =3D=3D NULL)
{
NtGdiDeleteObject(hPattern);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
-
- BrushObject =3D BRUSHOBJ_LockBrush(hBrush);
- ASSERT(BrushObject !=3D NULL);
+ hBrush =3D BrushObject->BaseObject.hHmgr;
=
BrushObject->flAttrs |=3D GDIBRUSH_IS_HATCH;
BrushObject->hbmPattern =3D hPattern;
@@ -431,16 +427,14 @@
return NULL;
}
=
- hBrush =3D BRUSHOBJ_AllocBrush();
- if (hBrush =3D=3D NULL)
+ BrushObject =3D BRUSHOBJ_AllocBrushWithHandle();
+ if (BrushObject =3D=3D NULL)
{
NtGdiDeleteObject(hPattern);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
-
- BrushObject =3D BRUSHOBJ_LockBrush(hBrush);
- ASSERT(BrushObject !=3D NULL);
+ hBrush =3D BrushObject->BaseObject.hHmgr;
=
BrushObject->flAttrs |=3D GDIBRUSH_IS_BITMAP;
BrushObject->hbmPattern =3D hPattern;
@@ -460,15 +454,13 @@
HBRUSH hBrush;
PGDIBRUSHOBJ BrushObject;
=
- hBrush =3D BRUSHOBJ_AllocBrush();
- if (hBrush =3D=3D NULL)
- {
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- BrushObject =3D BRUSHOBJ_LockBrush(hBrush);
- ASSERT(BrushObject !=3D NULL);
+ BrushObject =3D BRUSHOBJ_AllocBrushWithHandle();
+ if (BrushObject =3D=3D NULL)
+ {
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return NULL;
+ }
+ hBrush =3D BrushObject->BaseObject.hHmgr;
=
BrushObject->flAttrs |=3D GDIBRUSH_IS_SOLID;
=
@@ -486,15 +478,14 @@
HBRUSH hBrush;
PGDIBRUSHOBJ BrushObject;
=
- hBrush =3D BRUSHOBJ_AllocBrush();
- if (hBrush =3D=3D NULL)
- {
- SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
-
- BrushObject =3D BRUSHOBJ_LockBrush(hBrush);
- ASSERT(BrushObject !=3D NULL);
+ BrushObject =3D BRUSHOBJ_AllocBrushWithHandle();
+ if (BrushObject =3D=3D NULL)
+ {
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return NULL;
+ }
+ hBrush =3D BrushObject->BaseObject.hHmgr;
+
BrushObject->flAttrs |=3D GDIBRUSH_IS_NULL;
BRUSHOBJ_UnlockBrush(BrushObject);
=
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/dc.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c Tue Mar 18 19:56:40 =
2008
@@ -2270,7 +2270,7 @@
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
}
=
- hDC =3D (HDC) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DC);
+ hDC =3D (HDC) GDIOBJ_AllocObjDepricated(GDI_OBJECT_TYPE_DC);
if (hDC =3D=3D NULL)
{
if(Buf)
@@ -2441,7 +2441,7 @@
DC_FreeDcAttr(DCToFree);
if(!IsObjectDead( DCToFree ))
{
- if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC))
+ if (!GDIOBJ_FreeObjByHandle(DCToFree, GDI_OBJECT_TYPE_DC))
{
DPRINT1("DC_FreeDC failed\n");
}
Modified: trunk/reactos/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/dibobj.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/dibobj.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dibobj.c Tue Mar 18 19:56=
:40 2008
@@ -237,7 +237,7 @@
XlateObj =3D IntEngCreateXlate(DDB_Palette_Type, DIB_Palette_Type, DDB_P=
alette, DIB_Palette);
if (NULL =3D=3D XlateObj)
{
- PALETTE_FreePalette(DIB_Palette);
+ PALETTE_FreePaletteByHandle(DIB_Palette);
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
BITMAPOBJ_UnlockBitmap(bitmap);
@@ -265,7 +265,7 @@
=
// Clean up
EngDeleteXlate(XlateObj);
- PALETTE_FreePalette(DIB_Palette);
+ PALETTE_FreePaletteByHandle(DIB_Palette);
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
=
@@ -713,7 +713,7 @@
EngDeleteSurface((HSURF)hDestBitmap);
=
if (hDestPalette !=3D NULL && bPaletteMatch =3D=3D FALSE)
- PALETTE_FreePalette(hDestPalette);
+ PALETTE_FreePaletteByHandle(hDestPalette);
=
BITMAPOBJ_UnlockBitmap(BitmapObj);
=
@@ -1147,7 +1147,7 @@
=
if (dib) { ExFreePool(dib); dib =3D NULL; }
if (bmp) { bmp =3D NULL; }
- if (res) { BITMAPOBJ_FreeBitmap(res); res =3D 0; }
+ if (res) { BITMAPOBJ_FreeBitmapByHandle(res); res =3D 0; }
}
=
if (lpRGB !=3D bmi->bmiColors)
Modified: trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/gdiobj.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c Tue Mar 18 19:56=
:40 2008
@@ -72,7 +72,7 @@
{1, sizeof(DC), TAG_DC, DC_Cleanup}, /* 01 DC=
*/
{1, 0, 0, NULL}, /* 02 UN=
USED1 */
{1, 0, 0, NULL}, /* 03 UN=
USED2 */
- {1, sizeof(ROSRGNDATA), TAG_REGION, REGION_Cleanup}, /* 04 RGN=
*/
+ {1, sizeof(ROSRGNDATA), TAG_REGION, REGION_Cleanup}, /* 04 RG=
N */
{1, sizeof(BITMAPOBJ), TAG_SURFACE, BITMAP_Cleanup}, /* 05 SU=
RFACE */
{0, sizeof(DC), TAG_CLIENTOBJ, GDI_CleanupDummy}, /* 06 CL=
IENTOBJ: METADC,... FIXME: don't use DC struct */
{0, 0, TAG_PATH, NULL}, /* 07 PA=
TH, unused */
@@ -444,24 +444,51 @@
return FALSE;
}
=
+POBJ INTERNAL_CALL
+GDIOBJ_AllocObj(UCHAR BaseType)
+{
+ POBJ pObject;
+
+ ASSERT((BaseType & ~GDIObjTypeTotal) =3D=3D 0);
+// BaseType &=3D GDI_HANDLE_BASETYPE_MASK;
+
+ if (ObjTypeInfo[BaseType].bUseLookaside)
+ {
+ PPAGED_LOOKASIDE_LIST LookasideList;
+
+ LookasideList =3D GdiHandleTable->LookasideLists + BaseType;
+ pObject =3D ExAllocateFromPagedLookasideList(LookasideList);
+ }
+ else
+ {
+ pObject =3D ExAllocatePoolWithTag(PagedPool,
+ ObjTypeInfo[BaseType].ulBodySize,
+ ObjTypeInfo[BaseType].Tag);
+ }
+
+ if (pObject)
+ {
+ RtlZeroMemory(pObject, ObjTypeInfo[BaseType].ulBodySize);
+ }
+
+ return pObject;
+}
+
+
/*!
* Allocate memory for GDI object and return handle to it.
*
* \param ObjectType - type of object \ref GDI object types
*
- * \return Handle of the allocated object.
- *
- * \note Use GDIOBJ_Lock() to obtain pointer to the new object.
- * \todo return the object pointer and lock it by default.
+ * \return Pointer to the allocated object, which is locked.
*/
-HGDIOBJ INTERNAL_CALL
-GDIOBJ_AllocObj(ULONG ObjectType)
+POBJ INTERNAL_CALL
+GDIOBJ_AllocObjWithHandle(ULONG ObjectType)
{
PW32PROCESS W32Process;
POBJ newObject =3D NULL;
- PPAGED_LOOKASIDE_LIST LookasideList =3D NULL;
HANDLE CurrentProcessId, LockedProcessId;
- ULONG TypeIndex;
+ UCHAR TypeIndex;
#ifdef GDI_DEBUG
ULONG Attempts =3D 0;
#endif
@@ -475,106 +502,130 @@
ASSERT(ObjectType !=3D GDI_OBJECT_TYPE_DONTCARE);
=
TypeIndex =3D GDI_OBJECT_GET_TYPE_INDEX(ObjectType);
- if (ObjTypeInfo[TypeIndex].bUseLookaside)
- {
- LookasideList =3D FindLookasideList(TypeIndex);
- if (LookasideList !=3D NULL)
- {
- newObject =3D ExAllocateFromPagedLookasideList(LookasideList);
- }
+
+ newObject =3D GDIOBJ_AllocObj(TypeIndex);
+ if (!newObject)
+ {
+ DPRINT1("Not enough memory to allocate gdi object!\n");
+ return NULL;
+ }
+
+ UINT Index;
+ PGDI_TABLE_ENTRY Entry;
+ LONG TypeInfo;
+
+ CurrentProcessId =3D PsGetCurrentProcessId();
+ LockedProcessId =3D (HANDLE)((ULONG_PTR)CurrentProcessId | 0x1);
+
+// RtlZeroMemory(newObject, GetObjectSize(TypeIndex));
+
+ /* On Windows the higher 16 bit of the type field don't contain the
+ full type from the handle, but the base type.
+ (type =3D BRSUH, PEN, EXTPEN, basetype =3D BRUSH) */
+ TypeInfo =3D (ObjectType & GDI_HANDLE_BASETYPE_MASK) | (ObjectType >> =
GDI_ENTRY_UPPER_SHIFT);
+
+ Index =3D InterlockedPopFreeEntry();
+ if (Index !=3D 0)
+ {
+ HANDLE PrevProcId;
+
+ Entry =3D &GdiHandleTable->Entries[Index];
+
+LockHandle:
+ PrevProcId =3D _InterlockedCompareExchangePointer((PVOID*)&Entry->=
ProcessId, LockedProcessId, 0);
+ if (PrevProcId =3D=3D NULL)
+ {
+ PW32THREAD Thread =3D PsGetCurrentThreadWin32Thread();
+ HGDIOBJ Handle;
+
+ Entry->KernelData =3D newObject;
+
+ /* copy the reuse-counter */
+ TypeInfo |=3D Entry->Type & GDI_ENTRY_REUSE_MASK;
+
+ /* we found a free entry, no need to exchange this field atomi=
cally
+ since we're holding the lock */
+ Entry->Type =3D TypeInfo;
+
+ /* Create a handle */
+ Handle =3D (HGDIOBJ)((Index & 0xFFFF) | (TypeInfo << GDI_ENTRY=
_UPPER_SHIFT));
+
+ /* Initialize BaseObject fields */
+ newObject->hHmgr =3D Handle;
+ newObject->ulShareCount =3D 0;
+ newObject->cExclusiveLock =3D 1;
+ newObject->Tid =3D Thread;
+
+ /* unlock the entry */
+ (void)_InterlockedExchangePointer((PVOID*)&Entry->ProcessId, C=
urrentProcessId);
+
+ GDIDBG_CAPTUREALLOCATOR(Index);
+
+ if (W32Process !=3D NULL)
+ {
+ _InterlockedIncrement(&W32Process->GDIObjects);
+ }
+
+ DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, newObject);
+ return newObject;
+ }
+ else
+ {
+#ifdef GDI_DEBUG
+ if (++Attempts > 20)
+ {
+ DPRINT1("[%d]Waiting on handle in index 0x%x\n", Attempts,=
Index);
+ }
+#endif
+ /* damn, someone is trying to lock the object even though it d=
oesn't
+ even exist anymore, wait a little and try again!
+ FIXME - we shouldn't loop forever! Give up after some time!=
*/
+ DelayExecution();
+ /* try again */
+ goto LockHandle;
+ }
+ }
+
+ GDIOBJ_FreeObj(newObject, TypeIndex);
+
+ DPRINT1("Failed to insert gdi object into the handle table, no handles=
left!\n");
+ GDIDBG_DUMPHANDLETABLE();
+
+ return NULL;
+}
+
+/* Wrapper for compatibility with old calls, will be removed later */
+HGDIOBJ INTERNAL_CALL
+GDIOBJ_AllocObjDepricated(ULONG ObjectType)
+{
+ POBJ pObject;
+ HGDIOBJ hObject;
+
+ pObject =3D GDIOBJ_AllocObjWithHandle(ObjectType);
+ hObject =3D pObject->hHmgr;
+ GDIOBJ_UnlockObjByPtr(pObject);
+
+ return hObject;
+}
+
+
+VOID INTERNAL_CALL
+GDIOBJ_FreeObj(POBJ pObject, UCHAR BaseType)
+{
+ /* Object must not have a handle! */
+ ASSERT(pObject->hHmgr =3D=3D NULL);
+
+ if (ObjTypeInfo[BaseType].bUseLookaside)
+ {
+ PPAGED_LOOKASIDE_LIST LookasideList;
+
+ LookasideList =3D GdiHandleTable->LookasideLists + BaseType;
+ ExFreeToPagedLookasideList(LookasideList, pObject);
}
else
{
- newObject =3D ExAllocatePoolWithTag(PagedPool,
- ObjTypeInfo[TypeIndex].ulBodySiz=
e,
- ObjTypeInfo[TypeIndex].Tag);
- }
- if (newObject !=3D NULL)
- {
- UINT Index;
- PGDI_TABLE_ENTRY Entry;
- LONG TypeInfo;
-
- CurrentProcessId =3D PsGetCurrentProcessId();
- LockedProcessId =3D (HANDLE)((ULONG_PTR)CurrentProcessId | 0x1);
-
- RtlZeroMemory(newObject, GetObjectSize(TypeIndex));
-
- /* On Windows the higher 16 bit of the type field don't contain the
- full type from the handle, but the base type.
- (type =3D BRSUH, PEN, EXTPEN, basetype =3D BRUSH) */
- TypeInfo =3D (ObjectType & GDI_HANDLE_BASETYPE_MASK) | (ObjectType=
> GDI_ENTRY_UPPER_SHIFT);
-
- Index =3D InterlockedPopFreeEntry();
- if (Index !=3D 0)
- {
- HANDLE PrevProcId;
-
- Entry =3D &GdiHandleTable->Entries[Index];
-
-LockHandle:
- PrevProcId =3D _InterlockedCompareExchangePointer((PVOID*)&Ent=
ry->ProcessId, LockedProcessId, 0);
- if (PrevProcId =3D=3D NULL)
- {
- HGDIOBJ Handle;
-
- Entry->KernelData =3D newObject;
-
- /* copy the reuse-counter */
- TypeInfo |=3D Entry->Type & GDI_ENTRY_REUSE_MASK;
-
- /* we found a free entry, no need to exchange this field a=
tomically
- since we're holding the lock */
- Entry->Type =3D TypeInfo;
-
- /* unlock the entry */
- (void)_InterlockedExchangePointer((PVOID*)&Entry->ProcessI=
d, CurrentProcessId);
-
- GDIDBG_CAPTUREALLOCATOR(Index);
-
- if (W32Process !=3D NULL)
- {
- _InterlockedIncrement(&W32Process->GDIObjects);
- }
- Handle =3D (HGDIOBJ)((Index & 0xFFFF) | (TypeInfo << GDI_E=
NTRY_UPPER_SHIFT));
- newObject->hHmgr =3D Handle;
-
- DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, newObje=
ct);
- return Handle;
- }
- else
- {
-#ifdef GDI_DEBUG
- if (++Attempts > 20)
- {
- DPRINT1("[%d]Waiting on handle in index 0x%x\n", Attem=
pts, Index);
- }
-#endif
- /* damn, someone is trying to lock the object even though =
it doesn't
- eve nexist anymore, wait a little and try again!
- FIXME - we shouldn't loop forever! Give up after some t=
ime! */
- DelayExecution();
- /* try again */
- goto LockHandle;
- }
- }
-
- if (ObjTypeInfo[TypeIndex].bUseLookaside)
- {
- ExFreeToPagedLookasideList(LookasideList, newObject);
- }
- else
- {
- ExFreePool(newObject);
- }
- DPRINT1("Failed to insert gdi object into the handle table, no han=
dles left!\n");
- GDIDBG_DUMPHANDLETABLE();
- }
- else
- {
- DPRINT1("Not enough memory to allocate gdi object!\n");
- }
- return NULL;
+ ExFreePool(pObject);
+ }
}
=
/*!
@@ -588,10 +639,9 @@
* to the calling process.
*/
BOOL INTERNAL_CALL
-GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ExpectedType)
+GDIOBJ_FreeObjByHandle(HGDIOBJ hObj, DWORD ExpectedType)
{
PGDI_TABLE_ENTRY Entry;
- PPAGED_LOOKASIDE_LIST LookasideList;
HANDLE ProcessId, LockedProcessId, PrevProcId;
ULONG HandleType, HandleUpper, TypeIndex;
BOOL Silent;
@@ -658,6 +708,8 @@
/* push this entry to the free list */
InterlockedPushFreeEntry(GDI_ENTRY_TO_INDEX(GdiHandleTable=
, Entry));
=
+ Object->hHmgr =3D NULL;
+
if (W32Process !=3D NULL)
{
_InterlockedDecrement(&W32Process->GDIObjects);
@@ -668,18 +720,7 @@
Ret =3D RunCleanupCallback(Object, TypeIndex);
=
/* Now it's time to free the memory */
- if (ObjTypeInfo[TypeIndex].bUseLookaside)
- {
- LookasideList =3D FindLookasideList(TypeIndex);
- if (LookasideList !=3D NULL)
- {
- ExFreeToPagedLookasideList(LookasideList, Object);
- }
- }
- else
- {
- ExFreePool(Object);
- }
+ GDIOBJ_FreeObj(Object, TypeIndex);
=
return Ret;
}
@@ -764,7 +805,7 @@
if (!IsObjectDead(hObject))
{
return NULL !=3D hObject
- ? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
+ ? GDIOBJ_FreeObjByHandle(hObject, GDI_OBJECT_TYPE_DONTCARE)=
: FALSE;
}
else
{
@@ -818,7 +859,7 @@
simply ignore this fact here. */
ObjectHandle =3D (HGDIOBJ)(Index | (Entry->Type << GDI_ENT=
RY_UPPER_SHIFT));
=
- if (GDIOBJ_FreeObj(ObjectHandle, GDI_OBJECT_TYPE_DONTCARE)=
&&
+ if (GDIOBJ_FreeObjByHandle(ObjectHandle, GDI_OBJECT_TYPE_D=
ONTCARE) &&
W32Process->GDIObjects =3D=3D 0)
{
/* there are no more gdi handles for this process, bai=
l */
@@ -1569,21 +1610,30 @@
IN ULONG ulType
)
{
-// ATM we use DC object for KernelData. I think it should be at a minimum =
GDIOBJEMPTYHDR.
+// ATM we use DC object for KernelData. This is wrong.
+// The real type consists of BASEOBJECT and a pointer.
// The UserData is set in user mode, so it is always NULL.
+// HANDLE should be HGDIOBJ
//
- INT Index;
- PGDI_TABLE_ENTRY Entry;
- HANDLE handle =3D GDIOBJ_AllocObj(GDI_OBJECT_TYPE_CLIOBJ);
-// Need to change handle type based on ulType.
- Index =3D GDI_HANDLE_GET_INDEX((HGDIOBJ)handle);
- Entry =3D &GdiHandleTable->Entries[Index];
-// mask out lower half and set the type by ulType.
- Entry->Type &=3D GDI_HANDLE_UPPER_MASK;
- Entry->Type |=3D ulType >> GDI_ENTRY_UPPER_SHIFT;
-// mask out handle type than set it by ulType.
- handle =3D (HANDLE)(((ULONG_PTR)(handle)) & (GDI_HANDLE_REUSE_MASK|GDI=
_HANDLE_STOCK_MASK|0x0ffff));
- handle =3D (HANDLE)(((ULONG_PTR)(handle)) | ulType);
+ POBJ pObject;
+ HANDLE handle;
+
+ /* Mask out everything that would change the type in a wrong manner */
+ ulType &=3D (GDI_HANDLE_TYPE_MASK & ~GDI_HANDLE_BASETYPE_MASK);
+
+ /* Allocate a new object */
+ pObject =3D GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_CLIOBJ | ulType);
+ if (!pObject)
+ {
+ return NULL;
+ }
+
+ /* get the handle */
+ handle =3D pObject->hHmgr;
+
+ /* Unlock it */
+ GDIOBJ_UnlockObjByPtr(pObject);
+
return handle;
}
=
@@ -1594,7 +1644,16 @@
IN HANDLE h
)
{
- return GDIOBJ_FreeObj(h, GDI_OBJECT_TYPE_CLIOBJ);
+ /* We first need to get the real type from the handle */
+ ULONG type =3D GDI_HANDLE_GET_TYPE(h);
+
+ /* Check if it's really a CLIENTOBJ */
+ if ((type & GDI_HANDLE_BASETYPE_MASK) !=3D GDILoObjType_LO_CLIENTOBJ_T=
YPE)
+ {
+ /* FIXME: SetLastError? */
+ return FALSE;
+ }
+ return GDIOBJ_FreeObjByHandle(h, type);
}
=
INT
Modified: trunk/reactos/subsystems/win32/win32k/objects/metafile.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/metafile.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/metafile.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/metafile.c Tue Mar 18 19:=
56:40 2008
@@ -230,7 +230,7 @@
NtClose( Dc->hFile );
}
=
- hmf =3D GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_ENHMETAFILE);
+ hmf =3D GDIOBJ_AllocObjDepricated(GdiHandleTable, GDI_OBJECT_TYPE_ENHMET=
AFILE);
if (hmf !=3D NULL)
{
phmf =3D GDIOBJ_LockObj(GdiHandleTable, hmf, GDI_OBJECT_TYPE_ENHMETAF=
ILE);
Modified: trunk/reactos/subsystems/win32/win32k/objects/palobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/palobj.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/palobj.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/palobj.c Tue Mar 18 19:56=
:40 2008
@@ -63,7 +63,7 @@
HPALETTE NewPalette;
PPALGDI PalGDI;
=
- NewPalette =3D (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
+ NewPalette =3D (HPALETTE) GDIOBJ_AllocObjDepricated(GDI_OBJECT_TYPE_PALE=
TTE);
if (NULL =3D=3D NewPalette)
{
return NULL;
@@ -82,7 +82,7 @@
if (NULL =3D=3D PalGDI->IndexedColors)
{
PALETTE_UnlockPalette(PalGDI);
- PALETTE_FreePalette(NewPalette);
+ PALETTE_FreePaletteByHandle(NewPalette);
return NULL;
}
RtlCopyMemory(PalGDI->IndexedColors, Colors, sizeof(PALETTEENTRY) * =
NumColors);
@@ -112,7 +112,7 @@
PPALGDI PalGDI;
unsigned i;
=
- NewPalette =3D (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
+ NewPalette =3D (HPALETTE) GDIOBJ_AllocObjDepricated(GDI_OBJECT_TYPE_PALE=
TTE);
if (NULL =3D=3D NewPalette)
{
return NULL;
@@ -129,7 +129,7 @@
if (NULL =3D=3D PalGDI->IndexedColors)
{
PALETTE_UnlockPalette(PalGDI);
- PALETTE_FreePalette(NewPalette);
+ PALETTE_FreePaletteByHandle(NewPalette);
return NULL;
}
for (i =3D 0; i < NumColors; i++)
Modified: trunk/reactos/subsystems/win32/win32k/objects/pen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/pen.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/pen.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/pen.c Tue Mar 18 19:56:40=
2008
@@ -51,29 +51,20 @@
=
if (bOldStylePen)
{
- hPen =3D PENOBJ_AllocPen();
+ PenObject =3D PENOBJ_AllocPenWithHandle();
}
else
{
- hPen =3D PENOBJ_AllocExtPen();
- }
-
- if (!hPen)
+ PenObject =3D PENOBJ_AllocExtPenWithHandle();
+ }
+
+ if (!PenObject)
{
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
DPRINT("Can't allocate pen\n");
return 0;
}
-
- if (bOldStylePen)
- {
- PenObject =3D PENOBJ_LockPen(hPen);
- }
- else
- {
- PenObject =3D PENOBJ_LockExtPen(hPen);
- }
- /* FIXME - Handle PenObject =3D=3D NULL!!! */
+ hPen =3D PenObject->BaseObject.hHmgr;
=
PenObject->ptPenWidth.x =3D dwWidth;
PenObject->ptPenWidth.y =3D 0;
Modified: trunk/reactos/subsystems/win32/win32k/objects/region.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/region.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/region.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/region.c Tue Mar 18 19:56=
:40 2008
@@ -2024,7 +2024,7 @@
HRGN hReg;
PROSRGNDATA pReg;
=
- if ((hReg =3D (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
+ if ((hReg =3D (HRGN) GDIOBJ_AllocObjDepricated(GDI_OBJECT_TYPE_REGION)=
))
{
if (NULL !=3D (pReg =3D REGION_LockRgn(hReg)))
{
Modified: trunk/reactos/subsystems/win32/win32k/objects/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win3=
2k/objects/text.c?rev=3D32721&r1=3D32720&r2=3D32721&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/reactos/subsystems/win32/win32k/objects/text.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/text.c Tue Mar 18 19:56:4=
0 2008
@@ -487,36 +487,24 @@
TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont)
{
PTEXTOBJ TextObj;
- NTSTATUS Status =3D STATUS_SUCCESS;
-
- *NewFont =3D TEXTOBJ_AllocText();
- if (NULL !=3D *NewFont)
+
+ TextObj =3D TEXTOBJ_AllocTextWithHandle();
+ if (!TextObj)
{
- TextObj =3D TEXTOBJ_LockText(*NewFont);
- if (NULL !=3D TextObj)
- {
- memcpy(&TextObj->logfont.elfEnumLogfontEx.elfLogFont, lf, sizeof(LOG=
FONTW));
- if (lf->lfEscapement !=3D lf->lfOrientation)
- {
- /* this should really depend on whether GM_ADVANCED is set */
- TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation =3D
- TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement;
- }
- TEXTOBJ_UnlockText(TextObj);
- }
- else
- {
-/* FIXME */
-/* ASSERT(FALSE);*/
- Status =3D STATUS_INVALID_HANDLE;
- }
+ return STATUS_NO_MEMORY;
}
- else
+
+ *NewFont =3D TextObj->BaseObject.hHmgr;
+ memcpy(&TextObj->logfont.elfEnumLogfontEx.elfLogFont, lf, sizeof(LOGFONT=
W));
+ if (lf->lfEscapement !=3D lf->lfOrientation)
{
- Status =3D STATUS_NO_MEMORY;
+ /* this should really depend on whether GM_ADVANCED is set */
+ TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation =3D
+ TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement;
}
-
- return Status;
+ TEXTOBJ_UnlockText(TextObj);
+
+ return STATUS_SUCCESS;
}
=
HFONT
@@ -528,51 +516,51 @@
IN FLONG fl,
IN PVOID pvCliData )
{
- ENUMLOGFONTEXDVW SafeLogfont;
- HFONT NewFont;
- PTEXTOBJ TextObj;
- NTSTATUS Status =3D STATUS_SUCCESS;
-
- if (NULL !=3D pelfw)
+ ENUMLOGFONTEXDVW SafeLogfont;
+ HFONT hNewFont;
+ PTEXTOBJ TextObj;
+ NTSTATUS Status =3D STATUS_SUCCESS;
+
+ if (!pelfw)
{
- Status =3D MmCopyFromCaller(&SafeLogfont, pelfw, sizeof(ENUMLOGFONTEXD=
VW));
- if (NT_SUCCESS(Status))
- {
- NewFont =3D TEXTOBJ_AllocText();
- if (NULL !=3D NewFont)
- {
- TextObj =3D TEXTOBJ_LockText(NewFont);
-
- if (NULL !=3D TextObj)
- {
- RtlCopyMemory ( &TextObj->logfont,
- &SafeLogfont,
- sizeof(ENUMLOGFONTEXDVW));
-
- if (SafeLogfont.elfEnumLogfontEx.elfLogFont.lfEscapement !=3D
- SafeLogfont.elfEnumLogfontEx.elfLogFont.lfOrientation)
- {
- /* this should really depend on whether GM_ADVANCED is set */
- TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation=
=3D
- TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement;
- }
- TEXTOBJ_UnlockText(TextObj);
- }
- else
- {
-/* FIXME */
-/* ASSERT(FALSE);*/
- Status =3D STATUS_INVALID_HANDLE;
- }
- }
- }
+ return NULL;
}
- else
+
+ _SEH_TRY
{
- Status =3D STATUS_INVALID_PARAMETER;
+ ProbeForRead(pelfw, sizeof(ENUMLOGFONTEXDVW), 1);
+ RtlCopyMemory(&SafeLogfont, pelfw, sizeof(ENUMLOGFONTEXDVW));
}
-
- return NT_SUCCESS(Status) ? NewFont : NULL;
+ _SEH_HANDLE
+ {
+ Status =3D _SEH_GetExceptionCode();
+ }
+ _SEH_END
+
+ if (!NT_SUCCESS(Status))
+ {
+ return NULL;
+ }
+
+ TextObj =3D TEXTOBJ_AllocTextWithHandle();
+ if (!TextObj)
+ {
+ return NULL;
+ }
+ hNewFont =3D TextObj->BaseObject.hHmgr;
+
+ RtlCopyMemory (&TextObj->logfont, &SafeLogfont, sizeof(ENUMLOGFONTEXDVW)=
);
+
+ if (SafeLogfont.elfEnumLogfontEx.elfLogFont.lfEscapement !=3D
+ SafeLogfont.elfEnumLogfontEx.elfLogFont.lfOrientation)
+ {
+ /* this should really depend on whether GM_ADVANCED is set */
+ TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation =3D
+ TextObj->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement;
+ }
+ TEXTOBJ_UnlockText(TextObj);
+
+ return hNewFont;
=
}
=
@@ -1577,7 +1565,7 @@
=
Dc_Attr =3D dc->pDc_Attr;
if(!Dc_Attr) Dc_Attr =3D &dc->Dc_Attr;
- =
+
/* Check if String is valid */
if ((Count > 0xFFFF) || (Count > 0 && UnsafeString =3D=3D NULL))
{
@@ -2159,7 +2147,7 @@
SetLastWin32Error(Status);
return FALSE;
}
- =
+
BufferSize =3D Count * sizeof(ABC); // Same size!
SafeBuff =3D ExAllocatePoolWithTag(PagedPool, BufferSize, TAG_GDITEXT);
if (!fl) SafeBuffF =3D (LPABCFLOAT) SafeBuff;
@@ -2447,7 +2435,7 @@
WCHAR DefChar =3D 0;
PWSTR Buffer =3D NULL;
ULONG Size;
- =
+
if ((!UnSafepwc) && (!UnSafepgi)) return cwc;
=
dc =3D DC_LockDc(hdc);
@@ -2488,7 +2476,7 @@
goto ErrorRet;
}
IntGetOutlineTextMetrics(FontGDI, Size, potm);
- DefChar =3D potm->otmTextMetrics.tmDefaultChar; // May need this. =
+ DefChar =3D potm->otmTextMetrics.tmDefaultChar; // May need this.
ExFreePool(potm);
}
=
@@ -2508,7 +2496,7 @@
=
IntLockFreeType;
face =3D FontGDI->face;
- =
+
for (i =3D 0; i < cwc; i++)
{
Buffer[i] =3D FT_Get_Char_Index(face, UnSafepwc[i]);
@@ -3340,7 +3328,7 @@
PDC Dc;
PDC_ATTR Dc_Attr;
DWORD cscp =3D IntGdiGetCharSet(hDC);
- // If here, update everything! =
+ // If here, update everything!
Dc =3D DC_LockDc(hDC);
Dc_Attr =3D Dc->pDc_Attr;
if (!Dc_Attr) Dc_Attr =3D &Dc->Dc_Attr;