Author: fireball
Date: Sat Aug 1 00:08:01 2009
New Revision: 42320
URL:
http://svn.reactos.org/svn/reactos?rev=42320&view=rev
Log:
- Switch arwinss win32k to the GDI object manager from trunk. gdiobj.c is cleaned up from
functions which aren't used in arwinss, and the user<->kernel handle mapping
still remains. The only supported object types now are DC, SURFACE and PALETTE. (see
arwinss issue nr. 14).
- Kernelmode GDI handles leak now very significantly. To be investigated.
Added:
branches/arwinss/reactos/subsystems/win32/win32k/gre/gdidbg.c
- copied, changed from r42309,
trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c
- copied, changed from r42309,
trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c
branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.c
branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
branches/arwinss/reactos/subsystems/win32/win32k/gdi/enum.c
branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/palobj.c
branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h
branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h
branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h
branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h
branches/arwinss/reactos/subsystems/win32/win32k/include/tags.h
branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h
branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -24,18 +24,27 @@
IN FLONG flGreen,
IN FLONG flBlue)
{
- HPALETTE Palette;
+ HPALETTE Palette;
- Palette = PALETTE_AllocPalette(iMode, cColors, pulColors, flRed, flGreen, flBlue);
+ Palette = PALETTE_AllocPalette(iMode, cColors, pulColors, flRed, flGreen, flBlue);
- return Palette;
+ /* Make it global */
+ GDIOBJ_SetOwnership(Palette, NULL);
+
+ return Palette;
}
BOOL
APIENTRY
EngDeletePalette(IN HPALETTE hpal)
{
+ /* Get ownership */
+ GDIOBJ_SetOwnership(hpal, PsGetCurrentProcess());
+
+ /* Free palette by handle */
PALETTE_FreePaletteByHandle(hpal);
+
+ /* Report success */
return TRUE;
}
Modified: branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/eng/engsurf.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -30,6 +30,9 @@
/* Call the internal routine */
hNewBitmap = GreCreateBitmap(Size, Width, Format, Flags, Bits);
+ /* Make it global */
+ GDIOBJ_SetOwnership(hNewBitmap, NULL);
+
return hNewBitmap;
}
@@ -240,6 +243,9 @@
APIENTRY
EngDeleteSurface(IN HSURF hSurf)
{
+ /* Get ownership */
+ GDIOBJ_SetOwnership(hSurf, PsGetCurrentProcess());
+
/* Delete this bitmap */
GreDeleteBitmap((HGDIOBJ)hSurf);
@@ -255,7 +261,7 @@
DPRINT("EngLockSurface(%x)\n", hSurf);
/* Get a pointer to the surface */
- Surface = GDI_GetObjPtr(hSurf, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+ Surface = SURFACE_ShareLock(hSurf);
/* Return pointer to SURFOBJ object */
return &Surface->SurfObj;
@@ -263,12 +269,13 @@
VOID
APIENTRY
-EngUnlockSurface(IN SURFOBJ* Surface)
-{
- DPRINT("EngUnlockSurface(%p)\n", Surface);
+EngUnlockSurface(IN SURFOBJ* pSurfObj)
+{
+ SURFACE *pSurface = CONTAINING_RECORD(pSurfObj, SURFACE, SurfObj);
+ DPRINT("EngUnlockSurface(%p)\n", pSurface);
/* Release the surface */
- GDI_ReleaseObj(0);
+ SURFACE_ShareUnlock(pSurface);
}
BOOL
@@ -282,7 +289,7 @@
DPRINT("EngAssociateSurface(%x %x)\n", hSurf, hDev);
/* Get a pointer to the surface */
- pSurface = GDI_GetObjPtr(hSurf, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pSurface = SURFACE_Lock(hSurf);
/* Associate it */
pSurface->SurfObj.hdev = hDev;
@@ -294,7 +301,7 @@
DPRINT1("flHooks: 0x%x\n", flHooks);
/* Release the pointer */
- GDI_ReleaseObj(hSurf);
+ SURFACE_Unlock(pSurface);
/* Indicate success */
return TRUE;
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/bitmap.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -32,15 +32,15 @@
DPRINT("BitBlt %x -> %x\n", physDevSrc, physDevDst);
/* Get a pointer to the DCs */
- pSrc = GDI_GetObjPtr(physDevSrc, (SHORT)GDI_OBJECT_TYPE_DC);
- pDst = GDI_GetObjPtr(physDevDst, (SHORT)GDI_OBJECT_TYPE_DC);
+ pSrc = DC_Lock(physDevSrc);
+ pDst = DC_Lock(physDevDst);
/* Call the internal helper */
bRes = GreBitBlt(pDst, xDst, yDst, width, height, pSrc, xSrc, ySrc, rop);
/* Release DC objects */
- GDI_ReleaseObj(physDevDst);
- GDI_ReleaseObj(physDevSrc);
+ DC_Unlock(pDst);
+ DC_Unlock(pSrc);
/* Return status */
return bRes;
@@ -81,13 +81,13 @@
if (bmBits)
{
/* Get the object pointer */
- pSurface = GDI_GetObjPtr(hBitmap, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pSurface = SURFACE_Lock(hBitmap);
/* Copy bits */
GreSetBitmapBits(pSurface, pSurface->SurfObj.cjBits, bmBits);
/* Release the surface */
- GDI_ReleaseObj(hBitmap);
+ SURFACE_Unlock(pSurface);
}
/* Map handles */
@@ -143,11 +143,8 @@
return 0;
}
- psurf = GDI_GetObjPtr(hKernel, (SHORT)GDI_OBJECT_TYPE_BITMAP);
- if (!psurf)
- {
- return 0;
- }
+ psurf = SURFACE_Lock(hKernel);
+ if (!psurf) return 0;
bmSize = BITMAP_GetWidthBytes(psurf->SurfObj.sizlBitmap.cx,
BitsPerFormat(psurf->SurfObj.iBitmapFormat)) *
@@ -156,7 +153,7 @@
/* If the bits vector is null, the function should return the read size */
if (buffer == NULL)
{
- GDI_ReleaseObj(psurf);
+ SURFACE_Unlock(psurf);
return bmSize;
}
@@ -167,7 +164,7 @@
ret = GreGetBitmapBits(psurf, Bytes, buffer);
/* Release bitmap pointer */
- GDI_ReleaseObj(psurf);
+ SURFACE_Unlock(psurf);
return ret;
}
@@ -191,13 +188,13 @@
PDC pDst;
/* Get a pointer to the DCs */
- pDst = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDst = DC_Lock(physDev);
/* Call the internal helper */
bRet = GrePatBlt(pDst, left, top, width, height, rop, pDst->pLineBrush);
/* Release DC objects */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDst);
/* Return status */
return bRet;
@@ -223,7 +220,7 @@
HGDIOBJ hBitmap = GDI_MapUserHandle(hUserBitmap);
/* Get a pointer to the DCs */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
DPRINT("RosGdiSetDIBits for bitmap %x (user handle %x), StartScan %d, ScanLines
%d\n",
hBitmap, hUserBitmap, StartScan, ScanLines);
@@ -238,7 +235,7 @@
ColorUse);
/* Release DC objects */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
/* Return amount of lines set */
return ScanLines;
@@ -268,11 +265,10 @@
}
/* Get a pointer to the DCs */
- pDcDest = GDI_GetObjPtr(physDevDst, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDcDest = DC_Lock(physDevDst);
if (physDevSrc)
- pDcSrc = GDI_GetObjPtr(physDevSrc, (SHORT)GDI_OBJECT_TYPE_DC);
-
+ pDcSrc = DC_Lock(physDevSrc);
bRet = GreStretchBltMask(
pDcDest,
@@ -290,8 +286,8 @@
NULL);
/* Release DC objects */
- GDI_ReleaseObj(physDevDst);
- if (physDevSrc) GDI_ReleaseObj(physDevSrc);
+ DC_Unlock(pDcDest);
+ if (pDcSrc) DC_Unlock(pDcSrc);
/* Return result */
return bRet;
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -85,12 +85,11 @@
return STATUS_UNSUCCESSFUL;
/* Allocate storage for DC structure */
- pNewDC = ExAllocatePool(PagedPool, sizeof(DC));
+ pNewDC = (PDC)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_DC);
if (!pNewDC) return FALSE;
- RtlZeroMemory(pNewDC, sizeof(DC));
-
- /* Allocate a handle for it */
- hNewDC = alloc_gdi_handle(&pNewDC->BaseObject, (SHORT)GDI_OBJECT_TYPE_DC);
+
+ /* Save a handle to it */
+ hNewDC = pNewDC->BaseObject.hHmgr;
/* Set physical device pointer */
pNewDC->pPDevice = (PVOID)&PrimarySurface;
@@ -121,7 +120,7 @@
DPRINT("Creating a memory DC %x\n", hNewDC);
slSize.cx = 1; slSize.cy = 1;
hStockBitmap = GreCreateBitmap(slSize, 1, 1, 0, NULL);
- pNewDC->pBitmap = GDI_GetObjPtr(hStockBitmap, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pNewDC->pBitmap = SURFACE_ShareLock(hStockBitmap);
/* Set DC rectangles */
pNewDC->rcDcRect.left = 0; pNewDC->rcDcRect.top = 0;
@@ -131,7 +130,7 @@
else
{
DPRINT("Creating a display DC %x\n", hNewDC);
- pNewDC->pBitmap = GDI_GetObjPtr(PrimarySurface.pSurface,
(SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pNewDC->pBitmap = SURFACE_ShareLock(PrimarySurface.pSurface);
/* Set DC rectangles */
pNewDC->rcVport.left = 0;
@@ -145,23 +144,27 @@
/* Give handle to the caller */
*pdev = hNewDC;
+ /* Unlock the DC */
+ DC_Unlock(pNewDC);
+
/* Indicate success */
return TRUE;
}
BOOL APIENTRY RosGdiDeleteDC( HDC physDev )
{
- PDC pDC;
+ PDC pDC = DC_Lock(physDev);
+
DPRINT("RosGdiDeleteDC(%x)\n", physDev);
- /* Free the handle */
- pDC = free_gdi_handle((HGDIOBJ)physDev);
-
/* Release the surface */
- GDI_ReleaseObj(pDC->pBitmap);
-
- /* Free its storage */
- ExFreePool(pDC);
+ SURFACE_ShareUnlock(pDC->pBitmap);
+
+ /* Unlock DC */
+ DC_Unlock(pDC);
+
+ /* Free DC */
+ GDIOBJ_FreeObjByHandle(physDev, GDI_OBJECT_TYPE_DC);
/* Indicate success */
return TRUE;
@@ -199,8 +202,8 @@
DPRINT("Selecting %x bitmap to hdc %x\n", hBmpKern, physDev);
/* Get a pointer to the DC and the bitmap*/
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
- pSurface = GDI_GetObjPtr(hBmpKern, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pDC = DC_Lock(physDev);
+ pSurface = SURFACE_ShareLock(hBmpKern);
/* Select it */
pDC->pBitmap = pSurface;
@@ -213,7 +216,7 @@
pDC->rcDcRect = pDC->rcVport;
/* Release the DC object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
}
VOID APIENTRY RosGdiSelectBrush( HDC physDev, LOGBRUSH *pLogBrush )
@@ -223,7 +226,7 @@
PSURFACE pSurface;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
DPRINT("RosGdiSelectBrush(): dc %x, brush style %x, brush color %x\n",
physDev, pLogBrush->lbStyle, pLogBrush->lbColor);
@@ -261,7 +264,7 @@
DPRINT1("Trying to select an unknown bitmap %x to the DC %x!\n",
pLogBrush->lbHatch, physDev);
break;
}
- pSurface = GDI_GetObjPtr(hBmpKern, (SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pSurface = SURFACE_Lock(hBmpKern);
pDC->pFillBrush = GreCreatePatternBrush(pSurface);
break;
@@ -271,7 +274,7 @@
}
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
}
HFONT APIENTRY RosGdiSelectFont( HDC physDev, HFONT hfont, HANDLE gdiFont )
@@ -285,7 +288,7 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
DPRINT("RosGdiSelectPen(): dc %x, pen style %x, pen color %x\n", physDev,
pLogPen->lopnStyle, pLogPen->lopnColor);
@@ -293,7 +296,7 @@
{
DPRINT1("Ext pens aren't supported yet!");
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
return;
}
@@ -314,7 +317,7 @@
TRUE);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
}
COLORREF APIENTRY RosGdiSetBkColor( HDC physDev, COLORREF color )
@@ -322,13 +325,13 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Set the color */
pDC->crBackgroundClr = color;
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
/* Return the color set */
return color;
@@ -357,7 +360,7 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Delete old clipping region */
if (pDC->CombinedClip)
@@ -370,7 +373,7 @@
physDev, rcBounds->left, rcBounds->bottom, rcBounds->right,
rcBounds->top);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
}
BOOL APIENTRY RosGdiSetDeviceGammaRamp(HDC physDev, LPVOID ramp)
@@ -398,13 +401,13 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Set the color */
pDC->crForegroundClr = color;
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
/* Return the color set */
return color;
@@ -415,7 +418,7 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Set DC rectangle */
if (rcDcRect)
@@ -438,7 +441,7 @@
}
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
}
/* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/enum.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/enum.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/enum.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -50,13 +50,13 @@
INT iCaps;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Get device caps from the DC */
iCaps = GreGetDeviceCaps(pDC, cap);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
/* Return result */
return iCaps;
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/misc.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -55,13 +55,13 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Call GRE routine */
GreTextOut(pDC, x, y, flags, lprect, wstr, count, lpDx, formatEntry);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
return TRUE;
}
@@ -76,7 +76,7 @@
DPRINT("LineTo: (%d,%d)-(%d,%d)\n", x1, y1, x2, y2);
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
scrRect.left = scrRect.top = 0;
scrRect.right = 800;
@@ -105,7 +105,7 @@
IntEngDeleteClipRegion(pClipObj);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
return TRUE;
}
@@ -138,7 +138,7 @@
ULONG i;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Capture the points buffer */
_SEH2_TRY
@@ -161,7 +161,7 @@
if (!NT_SUCCESS(Status))
{
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
/* Free the buffer if it was allocated */
if (pPoints != pStackBuf) ExFreePool(pPoints);
@@ -181,7 +181,7 @@
GrePolygon(pDC, pPoints, count);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
/* Free the buffer if it was allocated */
if (pPoints != pStackBuf) ExFreePool(pPoints);
@@ -195,13 +195,13 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Draw the polyline */
GrePolyline(pDC, pt, count);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
return TRUE;
}
@@ -223,13 +223,13 @@
PDC pDC;
/* Get a pointer to the DC */
- pDC = GDI_GetObjPtr(physDev, (SHORT)GDI_OBJECT_TYPE_DC);
+ pDC = DC_Lock(physDev);
/* Draw the rectangle */
GreRectangle(pDC, rc->left, rc->top, rc->right, rc->bottom);
/* Release the object */
- GDI_ReleaseObj(physDev);
+ DC_Unlock(pDC);
return TRUE;
}
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/bitblt.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -427,7 +427,7 @@
INT DIBWidth;
// Check parameters
- if (!(bitmap = GDI_GetObjPtr(hBitmap, (SHORT)GDI_OBJECT_TYPE_BITMAP)))
+ if (!(bitmap = SURFACE_Lock(hBitmap)))
{
return 0;
}
@@ -454,7 +454,7 @@
(PVOID) Bits);
if (0 == SourceBitmap)
{
- GDI_ReleaseObj(bitmap);
+ SURFACE_Unlock(bitmap);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
@@ -463,7 +463,7 @@
if (NULL == SourceSurf)
{
EngDeleteSurface((HSURF)SourceBitmap);
- GDI_ReleaseObj(bitmap);
+ SURFACE_Unlock(bitmap);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
@@ -484,7 +484,7 @@
{
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- GDI_ReleaseObj(bitmap);
+ SURFACE_Unlock(bitmap);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
@@ -497,7 +497,7 @@
{
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- GDI_ReleaseObj(bitmap);
+ SURFACE_Unlock(bitmap);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
@@ -509,7 +509,7 @@
PALETTE_FreePaletteByHandle(DIB_Palette);
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- GDI_ReleaseObj(bitmap);
+ SURFACE_Unlock(bitmap);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
@@ -538,7 +538,7 @@
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- GDI_ReleaseObj(bitmap);
+ SURFACE_Unlock(bitmap);
return result;
}
Copied: branches/arwinss/reactos/subsystems/win32/win32k/gre/gdidbg.c (from r42309,
trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c)
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdidbg.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/gdidbg.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -212,11 +212,11 @@
r = 0;
DPRINT1("Used entry invalid KernelData\n");
}
- if (((POBJ)(pEntry->KernelData))->hHmgr != Handle)
+ if (((PBASEOBJECT)(pEntry->KernelData))->hHmgr != Handle)
{
r = 0;
DPRINT1("Used entry %ld, has invalid hHmg %p (expected: %p)\n",
- i, ((POBJ)(pEntry->KernelData))->hHmgr, Handle);
+ i, ((PBASEOBJECT)(pEntry->KernelData))->hHmgr, Handle);
}
nUsed++;
}
@@ -269,7 +269,7 @@
ULONG
FASTCALL
-GDIOBJ_IncrementShareCount(POBJ Object)
+GDIOBJ_IncrementShareCount(PBASEOBJECT Object)
{
INT cLocks = InterlockedIncrement((PLONG)&Object->ulShareCount);
GDIDBG_CAPTURESHARELOCKER(Object->hHmgr);
Copied: branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c (from r42309,
trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c)
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/gdiobj.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS win32 kernel mode subsystem
* LICENSE: GPL - See COPYING in the top level directory
- * FILE: subsystems/win32/win32k/objects/gdiobj.c
+ * FILE: subsystems/win32/win32k/gre/gdiobj.c
* PURPOSE: General GDI object manipulation routines
* PROGRAMMERS: ...
*/
@@ -10,7 +10,7 @@
//#define GDI_DEBUG
-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
@@ -31,7 +31,7 @@
#include "gdidbg.c"
/* static */ /* FIXME: -fno-unit-at-a-time breaks this */
-BOOL INTERNAL_CALL GDI_CleanupDummy(PVOID ObjectBody);
+BOOL APIENTRY GDI_CleanupDummy(PVOID ObjectBody);
/** GLOBALS *******************************************************************/
@@ -41,42 +41,42 @@
ULONG_PTR ulBodySize;
ULONG Tag;
GDICLEANUPPROC CleanupProc;
-} OBJ_TYPE_INFO, *POBJ_TYPE_INFO;
+} OBJ_TYPE_INFO, *PBASEOBJECT_TYPE_INFO;
static const
OBJ_TYPE_INFO ObjTypeInfo[BASE_OBJTYPE_COUNT] =
{
{0, 0, 0, NULL}, /* 00 reserved entry
*/
- {1, sizeof(DC), TAG_DC, DC_Cleanup}, /* 01 DC */
- {1, 0, 0, NULL}, /* 02 UNUSED1 */
- {1, 0, 0, NULL}, /* 03 UNUSED2 */
- {1, sizeof(ROSRGNDATA), TAG_REGION, REGION_Cleanup}, /* 04 RGN */
- {1, sizeof(SURFACE), TAG_SURFACE, SURFACE_Cleanup}, /* 05 SURFACE */
- {1, sizeof(CLIENTOBJ), TAG_CLIENTOBJ, GDI_CleanupDummy}, /* 06 CLIENTOBJ:
METADC,... */
- {1, sizeof(PATH), TAG_PATH, GDI_CleanupDummy}, /* 07 PATH */
- {1, sizeof(PALETTE), TAG_PALETTE, PALETTE_Cleanup}, /* 08 PAL */
- {1, sizeof(COLORSPACE), TAG_ICMLCS, GDI_CleanupDummy}, /* 09 ICMLCS, */
- {1, sizeof(TEXTOBJ), TAG_LFONT, GDI_CleanupDummy}, /* 0a LFONT */
- {0, 0, TAG_RFONT, NULL}, /* 0b RFONT, unused */
- {0, 0, TAG_PFE, NULL}, /* 0c PFE, unused */
- {0, 0, TAG_PFT, NULL}, /* 0d PFT, unused */
- {0, sizeof(GDICLRXFORM), TAG_ICMCXF, GDI_CleanupDummy}, /* 0e ICMCXF, */
- {0, 0, TAG_SPRITE, NULL}, /* 0f SPRITE, unused
*/
- {1, sizeof(BRUSH), TAG_BRUSH, BRUSH_Cleanup}, /* 10 BRUSH, PEN,
EXTPEN */
- {0, 0, TAG_UMPD, NULL}, /* 11 UMPD, unused */
+ {0, sizeof(DC), TAG_DC, GDI_CleanupDummy}, /* 01 DC */
+ {0, 0, 0, NULL}, /* 02 reserved entry
*/
+ {0, 0, 0, NULL}, /* 03 reserved entry
*/
+ {0, 0, 0, NULL}, /* 04 reserved entry
*/
+ {0, sizeof(SURFACE), TAG_SURFOBJ, GDI_CleanupDummy}, /* 05 SURFACE */
+ {0, 0, 0, NULL}, /* 06 reserved entry
*/
+ {0, 0, 0, NULL}, /* 07 reserved entry
*/
+ {0, sizeof(PALETTE), TAG_PALETTE, GDI_CleanupDummy}, /* 08 PAL */
+ {0, 0, 0, NULL}, /* 09 ICMLCS, */
+ {0, 0, 0, NULL}, /* 0a LFONT */
+ {0, 0, 0, NULL}, /* 0b RFONT, unused */
+ {0, 0, 0, NULL}, /* 0c PFE, unused */
+ {0, 0, 0, NULL}, /* 0d PFT, unused */
+ {0, 0, 0, NULL}, /* 0e ICMCXF, */
+ {0, 0, 0, NULL}, /* 0f SPRITE, unused
*/
+ {0, 0, 0, NULL}, /* 10 BRUSH, PEN,
EXTPEN */
+ {0, 0, 0, NULL}, /* 11 UMPD, unused */
{0, 0, 0, NULL}, /* 12 UNUSED4 */
- {0, 0, TAG_SPACE, NULL}, /* 13 SPACE, unused */
+ {0, 0, 0, NULL}, /* 13 SPACE, unused */
{0, 0, 0, NULL}, /* 14 UNUSED5 */
- {0, 0, TAG_META, NULL}, /* 15 META, unused */
- {0, 0, TAG_EFSTATE, NULL}, /* 16 EFSTATE, unused
*/
- {0, 0, TAG_BMFD, NULL}, /* 17 BMFD, unused */
- {0, 0, TAG_VTFD, NULL}, /* 18 VTFD, unused */
- {0, 0, TAG_TTFD, NULL}, /* 19 TTFD, unused */
- {0, 0, TAG_RC, NULL}, /* 1a RC, unused */
- {0, 0, TAG_TEMP, NULL}, /* 1b TEMP, unused */
- {0, sizeof(EDRIVEROBJ), TAG_DRVOBJ, DRIVEROBJ_Cleanup},/* 1c DRVOBJ */
- {0, 0, TAG_DCIOBJ, NULL}, /* 1d DCIOBJ, unused
*/
- {0, 0, TAG_SPOOL, NULL}, /* 1e SPOOL, unused */
+ {0, 0, 0, NULL}, /* 15 META, unused */
+ {0, 0, 0, NULL}, /* 16 EFSTATE, unused
*/
+ {0, 0, 0, NULL}, /* 17 BMFD, unused */
+ {0, 0, 0, NULL}, /* 18 VTFD, unused */
+ {0, 0, 0, NULL}, /* 19 TTFD, unused */
+ {0, 0, 0, NULL}, /* 1a RC, unused */
+ {0, 0, 0, NULL}, /* 1b TEMP, unused */
+ {0, 0, 0, NULL}, /* 1c DRVOBJ */
+ {0, 0, 0, NULL}, /* 1d DCIOBJ, unused
*/
+ {0, 0, 0, NULL}, /* 1e SPOOL, unused */
{0, 0, 0, NULL}, /* 1f reserved entry
*/
};
@@ -88,7 +88,7 @@
* Dummy GDI Cleanup Callback
*/
/* static */ /* FIXME: -fno-unit-at-a-time breaks this */
-BOOL INTERNAL_CALL
+BOOL APIENTRY
GDI_CleanupDummy(PVOID ObjectBody)
{
return TRUE;
@@ -98,7 +98,7 @@
* Allocate GDI object table.
* \param Size - number of entries in the object table.
*/
-PGDI_HANDLE_TABLE INTERNAL_CALL
+PGDI_HANDLE_TABLE APIENTRY
GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject)
{
PGDI_HANDLE_TABLE HandleTable = NULL;
@@ -288,7 +288,7 @@
BOOL
-INTERNAL_CALL
+APIENTRY
GDIOBJ_ValidateHandle(HGDIOBJ hObj, ULONG ObjectType)
{
PGDI_TABLE_ENTRY Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, hObj);
@@ -304,10 +304,10 @@
return FALSE;
}
-POBJ INTERNAL_CALL
+PBASEOBJECT APIENTRY
GDIOBJ_AllocObj(UCHAR BaseType)
{
- POBJ pObject;
+ PBASEOBJECT PBASEOBJECTect;
ASSERT((BaseType & ~GDIObjTypeTotal) == 0);
// BaseType &= GDI_HANDLE_BASETYPE_MASK;
@@ -317,21 +317,21 @@
PPAGED_LOOKASIDE_LIST LookasideList;
LookasideList = GdiHandleTable->LookasideLists + BaseType;
- pObject = ExAllocateFromPagedLookasideList(LookasideList);
+ PBASEOBJECTect = ExAllocateFromPagedLookasideList(LookasideList);
}
else
{
- pObject = ExAllocatePoolWithTag(PagedPool,
+ PBASEOBJECTect = ExAllocatePoolWithTag(PagedPool,
ObjTypeInfo[BaseType].ulBodySize,
ObjTypeInfo[BaseType].Tag);
}
- if (pObject)
- {
- RtlZeroMemory(pObject, ObjTypeInfo[BaseType].ulBodySize);
- }
-
- return pObject;
+ if (PBASEOBJECTect)
+ {
+ RtlZeroMemory(PBASEOBJECTect, ObjTypeInfo[BaseType].ulBodySize);
+ }
+
+ return PBASEOBJECTect;
}
@@ -342,11 +342,11 @@
*
* \return Pointer to the allocated object, which is locked.
*/
-POBJ INTERNAL_CALL
+PBASEOBJECT APIENTRY
GDIOBJ_AllocObjWithHandle(ULONG ObjectType)
{
PPROCESSINFO W32Process;
- POBJ newObject = NULL;
+ PBASEOBJECT newObject = NULL;
HANDLE CurrentProcessId, LockedProcessId;
UCHAR TypeIndex;
@@ -453,22 +453,22 @@
}
-VOID INTERNAL_CALL
-GDIOBJ_FreeObj(POBJ pObject, UCHAR BaseType)
+VOID APIENTRY
+GDIOBJ_FreeObj(PBASEOBJECT PBASEOBJECTect, UCHAR BaseType)
{
/* Object must not have a handle! */
- ASSERT(pObject->hHmgr == NULL);
+ ASSERT(PBASEOBJECTect->hHmgr == NULL);
if (ObjTypeInfo[BaseType].bUseLookaside)
{
PPAGED_LOOKASIDE_LIST LookasideList;
LookasideList = GdiHandleTable->LookasideLists + BaseType;
- ExFreeToPagedLookasideList(LookasideList, pObject);
+ ExFreeToPagedLookasideList(LookasideList, PBASEOBJECTect);
}
else
{
- ExFreePool(pObject);
+ ExFreePool(PBASEOBJECTect);
}
}
@@ -484,7 +484,7 @@
*
* \bug This function should return VOID and kill the object no matter what...
*/
-BOOL INTERNAL_CALL
+BOOL APIENTRY
GDIOBJ_FreeObjByHandle(HGDIOBJ hObj, DWORD ExpectedType)
{
PGDI_TABLE_ENTRY Entry;
@@ -493,8 +493,6 @@
BOOL Silent;
GDIDBG_INITLOOPTRACE();
-
- DPRINT("GDIOBJ_FreeObj: hObj: 0x%08x\n", hObj);
if (GDI_HANDLE_IS_STOCKOBJ(hObj))
{
@@ -535,7 +533,7 @@
((Entry->Type << GDI_ENTRY_UPPER_SHIFT) == HandleUpper) &&
((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == (HandleUpper &
GDI_ENTRY_BASETYPE_MASK)) )
{
- POBJ Object;
+ PBASEOBJECT Object;
Object = Entry->KernelData;
@@ -587,7 +585,6 @@
/*
* The object is currently locked by another thread, so freeing is
forbidden!
*/
- DPRINT1("Object->cExclusiveLock = %d\n",
Object->cExclusiveLock);
GDIDBG_TRACECALLER();
GDIDBG_TRACELOCKER(GDI_HANDLE_GET_INDEX(hObj));
(void)InterlockedExchangePointer((PVOID*)&Entry->ProcessId,
PrevProcId);
@@ -654,29 +651,6 @@
}
}
-
-/*!
- * Delete GDI object
- * \param hObject object handle
- * \return if the function fails the returned value is FALSE.
-*/
-BOOL
-FASTCALL
-GreDeleteObject(HGDIOBJ hObject)
-{
- DPRINT("NtGdiDeleteObject handle 0x%08x\n", hObject);
- if (!IsObjectDead(hObject))
- {
- return NULL != hObject
- ? GDIOBJ_FreeObjByHandle(hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
- }
- else
- {
- DPRINT1("Attempt DeleteObject 0x%x currently being
destroyed!!!\n",hObject);
- return TRUE; // return true and move on.
- }
-}
-
VOID
FASTCALL
IntDeleteHandlesForProcess(struct _EPROCESS *Process, ULONG ObjectType)
@@ -736,7 +710,7 @@
* Internal function. Called when the process is destroyed to free the remaining GDI
handles.
* \param Process - PID of the process that will be destroyed.
*/
-BOOL INTERNAL_CALL
+BOOL APIENTRY
GDI_CleanupForProcess(struct _EPROCESS *Process)
{
PEPROCESS CurrentProcess;
@@ -787,13 +761,13 @@
*
* \todo Get rid of the ExpectedType parameter!
*/
-PGDIOBJ INTERNAL_CALL
+PVOID APIENTRY
GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType)
{
ULONG HandleIndex;
PGDI_TABLE_ENTRY Entry;
HANDLE ProcessId, HandleProcessId, LockedProcessId, PrevProcId;
- POBJ Object = NULL;
+ PBASEOBJECT Object = NULL;
ULONG HandleType, HandleUpper;
HandleIndex = GDI_HANDLE_GET_INDEX(hObj);
@@ -877,7 +851,6 @@
{
/* Unlock the handle table entry. */
(void)InterlockedExchangePointer((PVOID*)&Entry->ProcessId, PrevProcId);
-
DelayExecution();
continue;
}
@@ -914,6 +887,20 @@
return Object;
}
+/*!
+ * Release GDI object. Every object locked by GDIOBJ_LockObj() must be unlocked.
+ * You should unlock the object
+ * as soon as you don't need to have access to it's data.
+
+ * \param Object Object pointer (as returned by GDIOBJ_LockObj).
+ */
+ULONG FASTCALL
+GDIOBJ_UnlockObjByPtr(PBASEOBJECT Object)
+{
+ INT cLocks = InterlockedDecrement((PLONG)&Object->cExclusiveLock);
+ ASSERT(cLocks >= 0);
+ return cLocks;
+}
/*!
* Return pointer to the object by handle (and allow sharing of the handle
@@ -926,13 +913,13 @@
*
* \todo Get rid of the ExpectedType parameter!
*/
-PGDIOBJ INTERNAL_CALL
+PVOID APIENTRY
GDIOBJ_ShareLockObj(HGDIOBJ hObj, DWORD ExpectedType)
{
ULONG HandleIndex;
PGDI_TABLE_ENTRY Entry;
HANDLE ProcessId, HandleProcessId, LockedProcessId, PrevProcId;
- POBJ Object = NULL;
+ PBASEOBJECT Object = NULL;
ULONG_PTR HandleType, HandleUpper;
HandleIndex = GDI_HANDLE_GET_INDEX(hObj);
@@ -995,7 +982,7 @@
if ( (Entry->KernelData != NULL) &&
(HandleUpper == (Entry->Type << GDI_ENTRY_UPPER_SHIFT)) )
{
- Object = (POBJ)Entry->KernelData;
+ Object = (PBASEOBJECT)Entry->KernelData;
GDIDBG_CAPTURESHARELOCKER(HandleIndex);
#ifdef GDI_DEBUG3
@@ -1038,7 +1025,7 @@
return Object;
}
-BOOL INTERNAL_CALL
+BOOL APIENTRY
GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle)
{
PGDI_TABLE_ENTRY Entry;
@@ -1062,140 +1049,7 @@
return FALSE;
}
-BOOL INTERNAL_CALL
-GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
-{
- /*
- * FIXME !!!!! THIS FUNCTION NEEDS TO BE FIXED - IT IS NOT SAFE WHEN OTHER THREADS
- * MIGHT ATTEMPT TO LOCK THE OBJECT DURING THIS CALL!!!
- */
- PGDI_TABLE_ENTRY Entry;
- HANDLE ProcessId, LockedProcessId, PrevProcId;
- PTHREADINFO Thread;
- HGDIOBJ hObj;
-
- GDIDBG_INITLOOPTRACE();
-
- ASSERT(phObj);
- hObj = *phObj;
-
- DPRINT("GDIOBJ_ConvertToStockObj: hObj: 0x%08x\n", hObj);
-
- Thread = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
-
- if (!GDI_HANDLE_IS_STOCKOBJ(hObj))
- {
- ProcessId = PsGetCurrentProcessId();
- LockedProcessId = (HANDLE)((ULONG_PTR)ProcessId | 0x1);
-
- Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, hObj);
-
-LockHandle:
- /* lock the object, we must not convert stock objects, so don't check!!! */
- PrevProcId = InterlockedCompareExchangePointer((PVOID*)&Entry->ProcessId,
LockedProcessId, ProcessId);
- if (PrevProcId == ProcessId)
- {
- LONG NewType, PrevType, OldType;
-
- /* we're locking an object that belongs to our process. First calculate
- the new object type including the stock object flag and then try to
- exchange it.*/
- /* On Windows the higher 16 bit of the type field don't contain the
- full type from the handle, but the base type.
- (type = BRSUH, PEN, EXTPEN, basetype = BRUSH) */
- OldType = ((ULONG)hObj & GDI_HANDLE_BASETYPE_MASK) | ((ULONG)hObj
>> GDI_ENTRY_UPPER_SHIFT);
- /* We are currently not using bits 24..31 (flags) of the type field, but for
compatibility
- we copy them as we can't get them from the handle */
- OldType |= Entry->Type & GDI_ENTRY_FLAGS_MASK;
-
- /* As the object should be a stock object, set it's flag, but only in the
lower 16 bits */
- NewType = OldType | GDI_ENTRY_STOCK_MASK;
-
- /* Try to exchange the type field - but only if the old (previous type)
matches! */
- PrevType = InterlockedCompareExchange(&Entry->Type, NewType,
OldType);
- if (PrevType == OldType && Entry->KernelData != NULL)
- {
- PTHREADINFO PrevThread;
- POBJ Object;
-
- /* We successfully set the stock object flag.
- KernelData should never be NULL here!!! */
- ASSERT(Entry->KernelData);
-
- Object = Entry->KernelData;
-
- PrevThread = Object->Tid;
- if (Object->cExclusiveLock == 0 || PrevThread == Thread)
- {
- /* dereference the process' object counter */
- if (PrevProcId != GDI_GLOBAL_PROCESS)
- {
- PEPROCESS OldProcess;
- PPROCESSINFO W32Process;
- NTSTATUS Status;
-
- /* FIXME */
- Status =
PsLookupProcessByProcessId((HANDLE)((ULONG_PTR)PrevProcId & ~0x1), &OldProcess);
- if (NT_SUCCESS(Status))
- {
- W32Process = (PPROCESSINFO)OldProcess->Win32Process;
- if (W32Process != NULL)
- {
-
InterlockedDecrement(&W32Process->GDIHandleCount);
- }
- ObDereferenceObject(OldProcess);
- }
- }
-
- hObj = (HGDIOBJ)((ULONG)(hObj) | GDI_HANDLE_STOCK_MASK);
- *phObj = hObj;
- Object->hHmgr = hObj;
-
- /* remove the process id lock and make it global */
- (void)InterlockedExchangePointer((PVOID*)&Entry->ProcessId,
GDI_GLOBAL_PROCESS);
-
- /* we're done, successfully converted the object */
- return TRUE;
- }
- else
- {
- GDIDBG_TRACELOOP(hObj, PrevThread, Thread);
-
- /* WTF?! The object is already locked by a different thread!
- Release the lock, wait a bit and try again!
- FIXME - we should give up after some time unless we want to wait
forever! */
- (void)InterlockedExchangePointer((PVOID*)&Entry->ProcessId,
PrevProcId);
-
- DelayExecution();
- goto LockHandle;
- }
- }
- else
- {
- DPRINT1("Attempted to convert object 0x%x that is deleted! Should
never get here!!!\n", hObj);
- DPRINT1("OldType = 0x%x, Entry->Type = 0x%x, NewType = 0x%x,
Entry->KernelData = 0x%x\n", OldType, Entry->Type, NewType,
Entry->KernelData);
- }
- }
- else if (PrevProcId == LockedProcessId)
- {
- GDIDBG_TRACELOOP(hObj, PrevProcId, ProcessId);
-
- /* the object is currently locked, wait some time and try again.
- FIXME - we shouldn't loop forever! Give up after some time! */
- DelayExecution();
- /* try again */
- goto LockHandle;
- }
- else
- {
- DPRINT1("Attempted to convert invalid handle: 0x%x\n", hObj);
- }
- }
-
- return FALSE;
-}
-
-BOOL INTERNAL_CALL
+BOOL APIENTRY
GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS NewOwner)
{
PGDI_TABLE_ENTRY Entry;
@@ -1225,7 +1079,7 @@
if ((Entry->Type & GDI_ENTRY_BASETYPE_MASK) != 0)
{
- POBJ Object = Entry->KernelData;
+ PBASEOBJECT Object = Entry->KernelData;
PrevThread = Object->Tid;
if (Object->cExclusiveLock == 0 || PrevThread == Thread)
@@ -1324,7 +1178,7 @@
return Ret;
}
-BOOL INTERNAL_CALL
+BOOL APIENTRY
GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo)
{
PGDI_TABLE_ENTRY FromEntry;
@@ -1351,7 +1205,7 @@
if (FromPrevProcId == FromProcessId)
{
PTHREADINFO PrevThread;
- POBJ Object;
+ PBASEOBJECT Object;
if ((FromEntry->Type & GDI_ENTRY_BASETYPE_MASK) != 0)
{
@@ -1431,7 +1285,7 @@
return Ret;
}
-PVOID INTERNAL_CALL
+PVOID APIENTRY
GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process)
{
PVOID MappedView = NULL;
@@ -1461,328 +1315,114 @@
return MappedView;
}
-/** PUBLIC FUNCTIONS **********************************************************/
-
-/*
- Since Brush/Pen and Region objects are sharable,,, we can just use
- UserHeapAlloc to allocate the small attribute objects.
-
- Example Allocating:
-
- // Save Kernel Space Pointer
- (PBRUSH)->pBrushAttr = IntGdiAllocObjAttr(GDIObjType_BRUSH_TYPE);
-
- // Kernel Space to User Space Pointer
- (PGDI_TABLE_ENTRY)->UserData = pBrushAttr;
- // Gdi will adjust for heap delta.
-
- Example Freeing:
-
- (PGDI_TABLE_ENTRY)->UserData = NULL; // Zero the user ptr.
- UserHeapFree((PBRUSH)->pBrushAttr); // Free from kernel ptr.
- (PBRUSH)->pBrushAttr = NULL;
-
- Notes:
- Testing with DC_ATTR works but has drawing difficulties.
- Base on observation, (Over looking the obvious) we need to supply heap delta
- to user space gdi. Now, with testing, looks all normal.
-
- */
-PVOID
-FASTCALL
-IntGdiAllocObjAttr(GDIOBJTYPE Type)
-{
- PVOID pMemAttr = NULL;
-
- switch( Type )
- {
- case GDIObjType_DC_TYPE:
- pMemAttr = UserHeapAlloc(sizeof(DC_ATTR));
- if (pMemAttr) RtlZeroMemory(pMemAttr, sizeof(DC_ATTR));
- break;
- case GDIObjType_RGN_TYPE:
- pMemAttr = UserHeapAlloc(sizeof(RGN_ATTR));
- if (pMemAttr) RtlZeroMemory(pMemAttr, sizeof(RGN_ATTR));
- break;
- case GDIObjType_BRUSH_TYPE:
- pMemAttr = UserHeapAlloc(sizeof(BRUSH_ATTR));
- if (pMemAttr) RtlZeroMemory(pMemAttr, sizeof(BRUSH_ATTR));
- break;
- default:
- break;
- }
- return pMemAttr;
-}
-
-
-BOOL
-FASTCALL
-IntGdiSetBrushOwner(PBRUSH pbr, DWORD OwnerMask)
-{
- HBRUSH hBR;
- PEPROCESS Owner = NULL;
- PGDI_TABLE_ENTRY pEntry = NULL;
-
- if (!pbr) return FALSE;
-
- hBR = pbr->BaseObject.hHmgr;
-
- if (!hBR || (GDI_HANDLE_GET_TYPE(hBR) != GDI_OBJECT_TYPE_BRUSH))
- return FALSE;
- else
- {
- INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hBR);
- pEntry = &GdiHandleTable->Entries[Index];
- }
-
- if (pbr->flAttrs & GDIBRUSH_IS_GLOBAL)
- {
- GDIOBJ_ShareUnlockObjByPtr((POBJ)pbr);
- return TRUE;
- }
-
- if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE)
- {
- // Set this Brush to inaccessible mode and to an Owner of NONE.
-// if (OwnerMask == GDI_OBJ_HMGR_NONE) Owner = OwnerMask;
-
- if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, Owner))
- return FALSE;
-
- // Deny user access to User Data.
- pEntry->UserData = NULL; // This hBR is inaccessible!
- }
-
- if (OwnerMask == GDI_OBJ_HMGR_POWNED)
- {
- if (!GDIOBJ_SetOwnership((HGDIOBJ) hBR, PsGetCurrentProcess() ))
- return FALSE;
-
- // Allow user access to User Data.
- pEntry->UserData = pbr->pBrushAttr;
- }
- return TRUE;
-}
-
-
-BOOL
-FASTCALL
-IntGdiSetDCOwnerEx( HDC hDC, DWORD OwnerMask, BOOL NoSetBrush)
-{
- PDC pDC;
- BOOL Ret = FALSE;
-
- if (!hDC || (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)) return FALSE;
-
- if ((OwnerMask == GDI_OBJ_HMGR_PUBLIC) || OwnerMask == GDI_OBJ_HMGR_NONE)
- {
- pDC = DC_LockDc ( hDC );
- MmCopyFromCaller(&pDC->dcattr, pDC->pdcattr, sizeof(DC_ATTR));
- DC_UnlockDc( pDC );
-
- DC_FreeDcAttr( hDC ); // Free the dcattr!
-
- if (!DC_SetOwnership( hDC, NULL )) // This hDC is inaccessible!
- return Ret;
- }
-
- if (OwnerMask == GDI_OBJ_HMGR_POWNED)
- {
- pDC = DC_LockDc ( hDC );
- ASSERT(pDC->pdcattr == &pDC->dcattr);
- DC_UnlockDc( pDC );
-
- if (!DC_SetOwnership( hDC, PsGetCurrentProcess() )) return Ret;
-
- DC_AllocateDcAttr( hDC ); // Allocate new dcattr
-
- DCU_SynchDcAttrtoUser( hDC ); // Copy data from dc to dcattr
- }
-
- if ((OwnerMask != GDI_OBJ_HMGR_NONE) && !NoSetBrush)
- {
- pDC = DC_LockDc ( hDC );
- if (IntGdiSetBrushOwner((PBRUSH)pDC->dclevel.pbrFill, OwnerMask))
- IntGdiSetBrushOwner((PBRUSH)pDC->dclevel.pbrLine, OwnerMask);
- DC_UnlockDc( pDC );
- }
- return TRUE;
-}
-
-INT
-FASTCALL
-GreGetObjectOwner(HGDIOBJ Handle, GDIOBJTYPE ObjType)
-{
- INT Ret = GDI_OBJ_HMGR_RESTRICTED;
-
- if ( GDI_HANDLE_GET_INDEX(Handle) < GDI_HANDLE_COUNT )
- {
- PGDI_TABLE_ENTRY pEntry =
&GdiHandleTable->Entries[GDI_HANDLE_GET_INDEX(Handle)];
-
- if (pEntry->ObjectType == ObjType)
- {
- if (pEntry->FullUnique == (GDI_HANDLE_GET_UPPER(Handle) >>
GDI_ENTRY_UPPER_SHIFT))
- Ret = pEntry->ProcessId & ~1;
- }
- }
- return Ret;
-}
-
-
-W32KAPI
-HANDLE
-APIENTRY
-NtGdiCreateClientObj(
- IN ULONG ulType
-)
-{
- POBJ pObject;
- HANDLE handle;
-
- /* Mask out everything that would change the type in a wrong manner */
- ulType &= (GDI_HANDLE_TYPE_MASK & ~GDI_HANDLE_BASETYPE_MASK);
-
- /* Allocate a new object */
- pObject = GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_CLIOBJ | ulType);
- if (!pObject)
- {
- return NULL;
- }
-
- /* get the handle */
- handle = pObject->hHmgr;
-
- /* Unlock it */
- GDIOBJ_UnlockObjByPtr(pObject);
-
- return handle;
-}
-
-W32KAPI
-BOOL
-APIENTRY
-NtGdiDeleteClientObj(
- IN HANDLE h
-)
-{
- /* We first need to get the real type from the handle */
- ULONG type = GDI_HANDLE_GET_TYPE(h);
-
- /* Check if it's really a CLIENTOBJ */
- if ((type & GDI_HANDLE_BASETYPE_MASK) != GDILoObjType_LO_CLIENTOBJ_TYPE)
- {
- /* FIXME: SetLastError? */
- return FALSE;
- }
- return GDIOBJ_FreeObjByHandle(h, type);
-}
-
-INT
-FASTCALL
-IntGdiGetObject(IN HANDLE Handle,
- IN INT cbCount,
- IN LPVOID lpBuffer)
-{
- PVOID pGdiObject;
- INT Result = 0;
- DWORD dwObjectType;
-
- pGdiObject = GDIOBJ_LockObj(Handle, GDI_OBJECT_TYPE_DONTCARE);
- if (!pGdiObject)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return 0;
- }
-
- dwObjectType = GDIOBJ_GetObjectType(Handle);
- switch (dwObjectType)
- {
- case GDI_OBJECT_TYPE_PEN:
- case GDI_OBJECT_TYPE_EXTPEN:
- Result = PEN_GetObject((PBRUSH) pGdiObject, cbCount, (PLOGPEN) lpBuffer); //
IntGdiCreatePenIndirect
- break;
-
- case GDI_OBJECT_TYPE_BRUSH:
- Result = BRUSH_GetObject((PBRUSH ) pGdiObject, cbCount, (LPLOGBRUSH)lpBuffer);
- break;
-
- case GDI_OBJECT_TYPE_BITMAP:
- Result = BITMAP_GetObject((SURFACE *) pGdiObject, cbCount, lpBuffer);
- break;
- case GDI_OBJECT_TYPE_FONT:
- Result = FontGetObject((PTEXTOBJ) pGdiObject, cbCount, lpBuffer);
-#if 0
- // Fix the LOGFONT structure for the stock fonts
- if (FIRST_STOCK_HANDLE <= Handle && Handle <= LAST_STOCK_HANDLE)
- {
- FixStockFontSizeW(Handle, cbCount, lpBuffer);
- }
-#endif
- break;
-
- case GDI_OBJECT_TYPE_PALETTE:
- Result = PALETTE_GetObject((PPALETTE) pGdiObject, cbCount, lpBuffer);
- break;
-
- default:
- DPRINT1("GDI object type 0x%08x not implemented\n", dwObjectType);
- break;
- }
-
- GDIOBJ_UnlockObjByPtr(pGdiObject);
-
- return Result;
-}
-
-
-
-W32KAPI
-INT
-APIENTRY
-NtGdiExtGetObjectW(IN HANDLE hGdiObj,
- IN INT cbCount,
- OUT LPVOID lpBuffer)
-{
- INT iRetCount = 0;
- INT cbCopyCount;
- union
- {
- BITMAP bitmap;
- DIBSECTION dibsection;
- LOGPEN logpen;
- LOGBRUSH logbrush;
- LOGFONTW logfontw;
- EXTLOGFONTW extlogfontw;
- ENUMLOGFONTEXDVW enumlogfontexdvw;
- } Object;
-
- // Normalize to the largest supported object size
- cbCount = min((UINT)cbCount, sizeof(Object));
-
- // Now do the actual call
- iRetCount = IntGdiGetObject(hGdiObj, cbCount, lpBuffer ? &Object : NULL);
- cbCopyCount = min((UINT)cbCount, (UINT)iRetCount);
-
- // Make sure we have a buffer and a copy size
- if ((cbCopyCount) && (lpBuffer))
- {
- // Enter SEH for buffer transfer
- _SEH2_TRY
- {
- // Probe the buffer and copy it
- ProbeForWrite(lpBuffer, cbCopyCount, sizeof(WORD));
- RtlCopyMemory(lpBuffer, &Object, cbCopyCount);
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- // Clear the return value.
- // Do *NOT* set last error here!
- iRetCount = 0;
- }
- _SEH2_END;
- }
- // Return the count
- return iRetCount;
+/* Usermode -> kernelmode handle mapping */
+LIST_ENTRY HandleMapping;
+KSPIN_LOCK HandleMappingLock;
+
+typedef struct _HMAPPING
+{
+ HGDIOBJ hUser;
+ HGDIOBJ hKernel;
+ HANDLE hProcessId;
+ LIST_ENTRY Entry;
+} HMAPPING, *PHMAPPING;
+
+VOID NTAPI
+GDI_InitHandleMapping()
+{
+ /* Initialize handles list and a spinlock */
+ InitializeListHead(&HandleMapping);
+ KeInitializeSpinLock(&HandleMappingLock);
+}
+
+VOID NTAPI
+GDI_AddHandleMapping(HGDIOBJ hKernel, HGDIOBJ hUser)
+{
+ HGDIOBJ hExisting;
+ PHMAPPING pMapping = ExAllocatePool(NonPagedPool, sizeof(HMAPPING));
+ if (!pMapping) return;
+
+ /* Set mapping */
+ pMapping->hUser = hUser;
+ pMapping->hKernel = hKernel;
+ pMapping->hProcessId = PsGetCurrentProcessId();
+
+ /* Debug check: see if we already have this mapping */
+ hExisting = GDI_MapUserHandle(hUser);
+ if (hExisting)
+ DPRINT1("Trying to map already existing mapping %x -> %x to %x!\n",
hUser, hExisting, hKernel);
+
+ /* Add it to the list */
+ ExInterlockedInsertHeadList(&HandleMapping, &pMapping->Entry,
&HandleMappingLock);
+}
+
+HGDIOBJ NTAPI
+GDI_MapUserHandle(HGDIOBJ hUser)
+{
+ KIRQL OldIrql;
+ PLIST_ENTRY Current;
+ PHMAPPING Mapping;
+ HGDIOBJ Found = 0;
+ HANDLE hProcessId = PsGetCurrentProcessId();
+
+ /* Acquire the lock and check if the list is empty */
+ KeAcquireSpinLock(&HandleMappingLock, &OldIrql);
+
+ /* Traverse the list to find our mapping */
+ Current = HandleMapping.Flink;
+ while(Current != &HandleMapping)
+ {
+ Mapping = CONTAINING_RECORD(Current, HMAPPING, Entry);
+
+ /* Check if it's our entry */
+ if (Mapping->hUser == hUser && Mapping->hProcessId == hProcessId)
+ {
+ /* Found it, save it and break out of the loop */
+ Found = Mapping->hKernel;
+ break;
+ }
+
+ /* Advance to the next pair */
+ Current = Current->Flink;
+ }
+
+ /* Release the lock and return the entry */
+ KeReleaseSpinLock(&HandleMappingLock, OldIrql);
+ return Found;
+}
+
+VOID NTAPI
+GDI_RemoveHandleMapping(HGDIOBJ hUser)
+{
+ KIRQL OldIrql;
+ PLIST_ENTRY Current;
+ PHMAPPING Mapping;
+ HANDLE hProcessId = PsGetCurrentProcessId();
+
+ /* Acquire the lock and check if the list is empty */
+ KeAcquireSpinLock(&HandleMappingLock, &OldIrql);
+
+ /* Traverse the list to find our mapping */
+ Current = HandleMapping.Flink;
+ while(Current != &HandleMapping)
+ {
+ Mapping = CONTAINING_RECORD(Current, HMAPPING, Entry);
+
+ /* Check if it's our entry */
+ if (Mapping->hUser == hUser && Mapping->hProcessId == hProcessId)
+ {
+ /* Remove and free it */
+ RemoveEntryList(Current);
+ ExFreePool(Mapping);
+ break;
+ }
+
+ /* Advance to the next pair */
+ Current = Current->Flink;
+ }
+
+ /* Release the lock and return the entry */
+ KeReleaseSpinLock(&HandleMappingLock, OldIrql);
}
/* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/palobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/palobj.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/palobj.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -28,13 +28,10 @@
HPALETTE NewPalette;
PPALETTE PalGDI;
- PalGDI = ExAllocatePool(PagedPool, sizeof(PALETTE));
- if (!PalGDI)
- {
- return NULL;
- }
-
- NewPalette = alloc_gdi_handle(&PalGDI->BaseObject,
(SHORT)GDI_OBJECT_TYPE_PALETTE);
+ PalGDI = (PPALETTE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_PALETTE);
+ if (!PalGDI) return NULL;
+
+ NewPalette = PalGDI->BaseObject.hHmgr;
PalGDI->Self = NewPalette;
PalGDI->Mode = Mode;
@@ -61,21 +58,9 @@
PalGDI->BlueMask = Blue;
}
+ PALETTE_UnlockPalette(PalGDI);
+
return NewPalette;
-}
-
-VOID
-FASTCALL
-PALETTE_FreePaletteByHandle(HGDIOBJ hPalette)
-{
- PPALETTE pPal;
- DPRINT("RosGdiDeleteDC(%x)\n", hPalette);
-
- /* Free the handle */
- pPal = free_gdi_handle(hPalette);
-
- /* Free its storage */
- ExFreePool(pPal);
}
HPALETTE
@@ -87,13 +72,10 @@
PPALETTE PalGDI;
UINT i;
- PalGDI = ExAllocatePool(PagedPool, sizeof(PALETTE));
- if (!PalGDI)
- {
- return NULL;
- }
-
- NewPalette = alloc_gdi_handle(&PalGDI->BaseObject,
(SHORT)GDI_OBJECT_TYPE_PALETTE);
+ PalGDI = (PPALETTE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_PALETTE);
+ if (!PalGDI) return NULL;
+
+ NewPalette = PalGDI->BaseObject.hHmgr;
PalGDI->Self = NewPalette;
PalGDI->Mode = PAL_INDEXED;
@@ -117,6 +99,8 @@
}
PalGDI->NumColors = NumColors;
+
+ PALETTE_UnlockPalette(PalGDI);
return NewPalette;
}
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/gre/surfobj.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -136,44 +136,43 @@
return 0;
/* Allocate storage for surface object */
- pSurface = EngAllocMem(FL_ZERO_MEMORY, sizeof(SURFACE), TAG_SURFOBJ);
- if (!pSurface) return NULL;
-
- /* Create a handle for it */
- hSurface = alloc_gdi_handle(&pSurface->BaseObject,
(SHORT)GDI_OBJECT_TYPE_BITMAP);
+ pSurface = (PSURFACE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_BITMAP);
+ if (!pSurface) return 0;
+
+ /* Save a handle to it */
+ hSurface = pSurface->BaseObject.hHmgr;
/* Check the format */
if (Format == BMF_4RLE || Format == BMF_8RLE)
{
DPRINT1("Bitmaps with format 0x%x aren't supported yet!\n",
Format);
+
+ /* Cleanup and exit */
+ GDIOBJ_FreeObjByHandle(hSurface, GDI_OBJECT_TYPE_BITMAP);
+ return 0;
+ }
+
+ /* Initialize SURFOBJ */
+ pSurfObj = &pSurface->SurfObj;
+
+ pSurfObj->hsurf = (HSURF)hSurface;
+ pSurfObj->sizlBitmap = Size;
+ pSurfObj->iType = STYPE_BITMAP;
+ pSurfObj->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
+
+ pSurfObj->lDelta = abs(Width);
+ pSurfObj->cjBits = pSurfObj->lDelta * Size.cy;
+
+#if 0
+ if (!Bits)
+ {
+ DPRINT1("Bitmaps without Bits aren't supported yet!\n");
/* Cleanup and exit */
free_gdi_handle(hSurface);
ExFreePool(pSurface);
return 0;
}
-
- /* Initialize SURFOBJ */
- pSurfObj = &pSurface->SurfObj;
-
- pSurfObj->hsurf = (HSURF)hSurface;
- pSurfObj->sizlBitmap = Size;
- pSurfObj->iType = STYPE_BITMAP;
- pSurfObj->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
-
- pSurfObj->lDelta = abs(Width);
- pSurfObj->cjBits = pSurfObj->lDelta * Size.cy;
-
-#if 0
- if (!Bits)
- {
- DPRINT1("Bitmaps without Bits aren't supported yet!\n");
-
- /* Cleanup and exit */
- free_gdi_handle(hSurface);
- ExFreePool(pSurface);
- return 0;
- }
#endif
if (!Bits)
{
@@ -184,8 +183,7 @@
if (!pSurfObj->pvBits)
{
/* Cleanup and exit */
- free_gdi_handle(hSurface);
- ExFreePool(pSurface);
+ GDIOBJ_FreeObjByHandle(hSurface, GDI_OBJECT_TYPE_BITMAP);
return 0;
}
}
@@ -206,6 +204,9 @@
/* Set the format */
pSurfObj->iBitmapFormat = Format;
+ /* Unlock the surface */
+ SURFACE_Unlock(pSurface);
+
/* Return handle to it */
return hSurface;
}
@@ -213,13 +214,7 @@
VOID FASTCALL
GreDeleteBitmap(HGDIOBJ hBitmap)
{
- PSURFACE pSurf;
-
- /* Free the handle */
- pSurf = free_gdi_handle(hBitmap);
-
- /* Free its storage */
- EngFreeMem(pSurf);
+ GDIOBJ_FreeObjByHandle(hBitmap, GDI_OBJECT_TYPE_BITMAP);
}
LONG FASTCALL
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -3,7 +3,7 @@
typedef struct _DC
{
- GDIOBJHDR BaseObject;
+ BASEOBJECT BaseObject;
PPDEVOBJ pPDevice;
@@ -29,107 +29,11 @@
MATRIX mxWorldToPage;
} DC, *PDC;
+#define DC_Lock(hDC) \
+ ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
+#define DC_Unlock(pDC) \
+ GDIOBJ_UnlockObjByPtr ((PBASEOBJECT)pDC)
+
INT APIENTRY GreGetDeviceCaps(PDC pDC, INT cap);
-/* NOTE! Following structures are direct copies from gdi_private.h */
-typedef enum tagGdiPathState
-{
- PATH_Null,
- PATH_Open,
- PATH_Closed
-} GdiPathState;
-
-typedef struct tagGdiPath
-{
- GdiPathState state;
- POINT *pPoints;
- BYTE *pFlags;
- int numEntriesUsed, numEntriesAllocated;
- BOOL newStroke;
-} GdiPath;
-
-typedef struct tagGdiFont GdiFont;
-
-struct saved_visrgn
-{
- struct saved_visrgn *next;
- HRGN hrgn;
-};
-
-typedef struct tagUSERDC
-{
- GDIOBJHDR header;
- HDC hSelf; /* Handle to this DC */
- const struct tagDC_FUNCS *funcs; /* DC function table */
- PVOID physDev; /* Physical device (driver-specific) */
- DWORD thread; /* thread owning the DC */
- LONG refcount; /* thread refcount */
- LONG dirty; /* dirty flag */
- INT saveLevel;
- HDC saved_dc;
- DWORD_PTR dwHookData;
- PVOID hookProc; /* the original SEGPTR ... */
- PVOID hookThunk; /* ... and the thunk to call it */
-
- INT wndOrgX; /* Window origin */
- INT wndOrgY;
- INT wndExtX; /* Window extent */
- INT wndExtY;
- INT vportOrgX; /* Viewport origin */
- INT vportOrgY;
- INT vportExtX; /* Viewport extent */
- INT vportExtY;
- FLOAT miterLimit;
-
- int flags;
- DWORD layout;
- HRGN hClipRgn; /* Clip region (may be 0) */
- HRGN hMetaRgn; /* Meta region (may be 0) */
- HRGN hMetaClipRgn; /* Intersection of meta and clip regions (may be 0) */
- HRGN hVisRgn; /* Visible region (must never be 0) */
- HPEN hPen;
- HBRUSH hBrush;
- HFONT hFont;
- HBITMAP hBitmap;
- HANDLE hDevice;
- HPALETTE hPalette;
-
- GdiFont *gdiFont;
- GdiPath path;
-
- UINT font_code_page;
- WORD ROPmode;
- WORD polyFillMode;
- WORD stretchBltMode;
- WORD relAbsMode;
- WORD backgroundMode;
- COLORREF backgroundColor;
- COLORREF textColor;
- COLORREF dcBrushColor;
- COLORREF dcPenColor;
- short brushOrgX;
- short brushOrgY;
-
- WORD textAlign; /* Text alignment from SetTextAlign() */
- INT charExtra; /* Spacing from SetTextCharacterExtra() */
- INT breakExtra; /* breakTotalExtra / breakCount */
- INT breakRem; /* breakTotalExtra % breakCount */
- INT MapMode;
- INT GraphicsMode; /* Graphics mode */
- ABORTPROC pAbortProc; /* AbortProc for Printing */
-#ifndef __REACTOS__
- ABORTPROC16 pAbortProc16;
#endif
- INT CursPosX; /* Current position */
- INT CursPosY;
- INT ArcDirection;
- XFORM xformWorld2Wnd; /* World-to-window transformation */
- XFORM xformWorld2Vport; /* World-to-viewport transformation */
- XFORM xformVport2World; /* Inverse of the above transformation */
- BOOL vport2WorldValid; /* Is xformVport2World valid? */
- RECT BoundsRect; /* Current bounding rect */
-
- struct saved_visrgn *saved_visrgn;
-} USERDC;
-
-#endif
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/gdiobj.h [iso-8859-1] Sat Aug
1 00:08:01 2009
@@ -1,15 +1,40 @@
#ifndef __WIN32K_GDIOBJ_H
#define __WIN32K_GDIOBJ_H
+typedef struct _GDI_HANDLE_TABLE
+{
+/* The table must be located at the beginning of this structure so it can be
+ * properly mapped!
+ */
+//////////////////////////////////////////////////////////////////////////////
+ GDI_TABLE_ENTRY Entries[GDI_HANDLE_COUNT];
+ DEVCAPS DevCaps; // Device Capabilities.
+ FLONG flDeviceUniq; // Device settings uniqueness.
+ PVOID pvLangPack; // Language Pack.
+ CFONT cfPublic[GDI_CFONT_MAX]; // Public Fonts.
+ DWORD dwCFCount;
+//////////////////////////////////////////////////////////////////////////////
+ PPAGED_LOOKASIDE_LIST LookasideLists;
-typedef struct tagGDIOBJHDR
+ ULONG FirstFree;
+ ULONG FirstUnused;
+
+} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
+
+extern PGDI_HANDLE_TABLE GdiHandleTable;
+
+typedef struct _BASEOBJECT
{
- SHORT type; /* object type (one of the OBJ_* constants) */
- SHORT system : 1; /* system object flag */
- SHORT deleted : 1; /* whether DeleteObject has been called on this object */
- LONG selcount; /* number of times the object is selected in a DC */
-} GDIOBJHDR;
+ HGDIOBJ hHmgr;
+ ULONG ulShareCount;
+ USHORT cExclusiveLock;
+ USHORT BaseFlags;
+ PTHREADINFO Tid;
+} BASEOBJECT, *PBASEOBJECT;
+typedef BOOL (APIENTRY *GDICLEANUPPROC)(PVOID ObjectBody);
+
+#if 0
extern BOOLEAN GDIOBJ_Init(void);
extern HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, SHORT type);
extern void *free_gdi_handle( HGDIOBJ handle );
@@ -17,6 +42,48 @@
extern void GDI_ReleaseObj( HGDIOBJ );
extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle );
extern BOOL GDI_dec_ref_count( HGDIOBJ handle );
+#endif
+
+enum BASEFLAGS
+{
+ BASEFLAG_LOOKASIDE = 0x80,
+
+ /* ReactOS specific: */
+ BASEFLAG_READY_TO_DIE = 0x1000
+};
+
+PGDI_HANDLE_TABLE APIENTRY GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject);
+PVOID APIENTRY GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS
Process);
+
+BOOL APIENTRY GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
+BOOL APIENTRY GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);
+BOOL APIENTRY GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
+BOOL APIENTRY GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
+BOOL APIENTRY GDIOBJ_ValidateHandle(HGDIOBJ hObj, ULONG ObjectType);
+PBASEOBJECT APIENTRY GDIOBJ_AllocObj(UCHAR ObjectType);
+PBASEOBJECT APIENTRY GDIOBJ_AllocObjWithHandle(ULONG ObjectType);
+VOID APIENTRY GDIOBJ_FreeObj (PBASEOBJECT pObj, UCHAR ObjectType);
+BOOL APIENTRY GDIOBJ_FreeObjByHandle (HGDIOBJ hObj, DWORD ObjectType);
+PVOID APIENTRY GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType);
+ULONG FASTCALL GDIOBJ_UnlockObjByPtr(PBASEOBJECT Object);
+
+PVOID APIENTRY GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType);
+
+/* Inlines */
+ULONG
+FORCEINLINE
+GDIOBJ_ShareUnlockObjByPtr(PBASEOBJECT Object)
+{
+ HGDIOBJ hobj = Object->hHmgr;
+ USHORT flags = Object->BaseFlags;
+ INT cLocks = InterlockedDecrement((PLONG)&Object->ulShareCount);
+ ASSERT(cLocks >= 0);
+ if ((flags & BASEFLAG_READY_TO_DIE) && (cLocks == 0))
+ {
+ GDIOBJ_FreeObjByHandle(hobj, GDI_OBJECT_TYPE_DONTCARE);
+ }
+ return cLocks;
+}
/* Handle mapping */
VOID NTAPI GDI_InitHandleMapping();
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/palobj.h [iso-8859-1] Sat Aug
1 00:08:01 2009
@@ -3,7 +3,7 @@
typedef struct _PALETTE
{
- GDIOBJHDR BaseObject;
+ BASEOBJECT BaseObject;
PALOBJ PalObj;
//XLATEOBJ *logicalToSystem;
@@ -24,9 +24,6 @@
ULONG Green,
ULONG Blue);
-VOID FASTCALL
-PALETTE_FreePaletteByHandle(HGDIOBJ hPalette);
-
HPALETTE FASTCALL
PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors);
@@ -37,8 +34,15 @@
HPALETTE NTAPI
BuildDIBPalette(CONST BITMAPINFO *bmi, PINT paletteType);
-#define PALETTE_LockPalette(hPalette) ((PPALETTE)GDI_GetObjPtr(hPalette,
(SHORT)GDI_OBJECT_TYPE_PALETTE))
-#define PALETTE_UnlockPalette(pPalette) GDI_ReleaseObj((HANDLE)pPalette)
+VOID
+FORCEINLINE
+PALETTE_FreePaletteByHandle(HGDIOBJ hPalette)
+{
+ GDIOBJ_FreeObjByHandle(hPalette, GDI_OBJECT_TYPE_PALETTE);
+}
+
+#define PALETTE_LockPalette(hPalette) ((PPALETTE)GDIOBJ_LockObj((HGDIOBJ)hPalette,
GDI_OBJECT_TYPE_PALETTE))
+#define PALETTE_UnlockPalette(pPalette) GDIOBJ_UnlockObjByPtr((PBASEOBJECT)pPalette)
#endif
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1] Sat
Aug 1 00:08:01 2009
@@ -4,7 +4,7 @@
typedef struct _SURFACE
{
- GDIOBJHDR BaseObject;
+ BASEOBJECT BaseObject;
SURFOBJ SurfObj;
FLONG flHooks;
@@ -33,6 +33,14 @@
#define GDIDEVFUNCS(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))->DriverFunctions
+#define SURFACE_Lock(hBMObj) \
+ ((PSURFACE) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP))
+#define SURFACE_ShareLock(hBMObj) \
+ ((PSURFACE) GDIOBJ_ShareLockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP))
+#define SURFACE_Unlock(pBMObj) \
+ GDIOBJ_UnlockObjByPtr ((PBASEOBJECT)pBMObj)
+#define SURFACE_ShareUnlock(pBMObj) \
+ GDIOBJ_ShareUnlockObjByPtr ((PBASEOBJECT)pBMObj)
#define SURFACE_LockBitmapBits(x)
#define SURFACE_UnlockBitmapBits(x)
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/tags.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/tags.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/tags.h [iso-8859-1] Sat Aug
1 00:08:01 2009
@@ -5,9 +5,11 @@
#define TAG_CLIP TAG('C', 'L', 'I', 'P') /*
clipping */
#define TAG_CLIPOBJ TAG('C', 'L', 'P', 'O') /* clip
object */
#define TAG_COLORMAP TAG('C', 'O', 'L', 'M') /* color
map */
+#define TAG_DC TAG('D', 'C', ' ', ' ') /* DC */
#define TAG_DFSM TAG('D', 'f', 's', 'm') /* Eng
event allocation */
#define TAG_DIB TAG('D', 'I', 'B', ' ') /* dib
*/
#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video
drivers */
+#define TAG_GDIHNDTBLE TAG('G', 'D', 'I', 'H') /* gdi
handle table */
#define TAG_GSEM TAG('G', 's', 'e', 'm') /* Gdi
Semaphore */
#define TAG_SURFOBJ TAG('S', 'R', 'F', 'O') /*
surface object */
#define TAG_PALETTE TAG('G', 'l', 'a', '8')
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Sat Aug
1 00:08:01 2009
@@ -22,6 +22,7 @@
struct msg_queue *queue; /* main message queue */
obj_handle_t winstation; /* main handle to process window station */
obj_handle_t desktop; /* handle to desktop to use for new threads */
+ LONG GDIHandleCount; /* kernelmode GDI handles count */
} PROCESSINFO;
#include <pshpack1.h>
Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] Sat Aug 1
00:08:01 2009
@@ -26,6 +26,8 @@
HANDLE GlobalUserHeap = NULL;
PSECTION_OBJECT GlobalUserHeapSection = NULL;
+PGDI_HANDLE_TABLE GdiHandleTable = NULL;
+PSECTION_OBJECT GdiTableSection = NULL;
/* PRIVATE FUNCTIONS *********************************************************/
@@ -333,7 +335,15 @@
init_directories();
/* Initialize GDI objects implementation */
- if (!GDIOBJ_Init()) return STATUS_UNSUCCESSFUL;
+ GdiHandleTable = GDIOBJ_iAllocHandleTable(&GdiTableSection);
+ if (GdiHandleTable == NULL)
+ {
+ DPRINT1("Failed to initialize the GDI handle table.\n");
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Initialize handle-mapping */
+ GDI_InitHandleMapping();
/* Init video driver implementation */
InitDcImpl();