mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 05:25:48 +00:00
Bye, bye, GDIOBJ header! You've served us well, but now the time has come for you to make room for BASEOBJECT.
Also bye, bye, HandleTable parameter. You've never done any reasonable job, so no one will be missing you. svn path=/trunk/; revision=32497
This commit is contained in:
parent
314611d68d
commit
c11d265144
24 changed files with 203 additions and 233 deletions
|
@ -68,7 +68,7 @@ EngCreatePalette(ULONG Mode, ULONG NumColors, ULONG *Colors,
|
|||
Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
|
||||
if (Palette != NULL)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Palette, NULL);
|
||||
GDIOBJ_SetOwnership(Palette, NULL);
|
||||
}
|
||||
|
||||
return Palette;
|
||||
|
@ -80,7 +80,7 @@ EngCreatePalette(ULONG Mode, ULONG NumColors, ULONG *Colors,
|
|||
BOOL STDCALL
|
||||
EngDeletePalette(IN HPALETTE Palette)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Palette, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(Palette, PsGetCurrentProcess());
|
||||
|
||||
return PALETTE_FreePalette(Palette);
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ EngCreateBitmap(IN SIZEL Size,
|
|||
if ( !NewBitmap )
|
||||
return 0;
|
||||
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, NewBitmap, NULL);
|
||||
GDIOBJ_SetOwnership(NewBitmap, NULL);
|
||||
|
||||
return NewBitmap;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
|
|||
if (NewSurface == NULL)
|
||||
return 0;
|
||||
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, NewSurface, NULL);
|
||||
GDIOBJ_SetOwnership(NewSurface, NULL);
|
||||
|
||||
BitmapObj = BITMAPOBJ_LockBitmap(NewSurface);
|
||||
if (! BITMAPOBJ_InitBitsLock(BitmapObj))
|
||||
|
@ -512,7 +512,7 @@ EngModifySurface(
|
|||
BOOL STDCALL
|
||||
EngDeleteSurface(IN HSURF Surface)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Surface, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(Surface, PsGetCurrentProcess());
|
||||
BITMAPOBJ_FreeBitmap(Surface);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ NtGdiEngLockSurface(IN HSURF Surface)
|
|||
SURFOBJ * STDCALL
|
||||
EngLockSurface(IN HSURF Surface)
|
||||
{
|
||||
BITMAPOBJ *bmp = GDIOBJ_ShareLockObj(GdiHandleTable, Surface, GDI_OBJECT_TYPE_BITMAP);
|
||||
BITMAPOBJ *bmp = GDIOBJ_ShareLockObj(Surface, GDI_OBJECT_TYPE_BITMAP);
|
||||
|
||||
if (bmp != NULL)
|
||||
return &bmp->SurfObj;
|
||||
|
@ -577,7 +577,7 @@ EngUnlockSurface(IN SURFOBJ *Surface)
|
|||
if (Surface != NULL)
|
||||
{
|
||||
BITMAPOBJ *bmp = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj);
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, bmp);
|
||||
GDIOBJ_ShareUnlockObjByPtr((POBJ)bmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,14 +27,14 @@ typedef struct _BITMAPOBJ
|
|||
/* Internal interface */
|
||||
|
||||
#define BITMAPOBJ_AllocBitmap() \
|
||||
((HBITMAP) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_BITMAP))
|
||||
((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP))
|
||||
#define BITMAPOBJ_FreeBitmap(hBMObj) \
|
||||
GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
|
||||
GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
|
||||
/* NOTE: Use shared locks! */
|
||||
#define BITMAPOBJ_LockBitmap(hBMObj) \
|
||||
((PBITMAPOBJ) GDIOBJ_ShareLockObj (GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP))
|
||||
((PBITMAPOBJ) GDIOBJ_ShareLockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP))
|
||||
#define BITMAPOBJ_UnlockBitmap(pBMObj) \
|
||||
GDIOBJ_UnlockObjByPtr (GdiHandleTable, pBMObj)
|
||||
GDIOBJ_ShareUnlockObjByPtr ((POBJ)pBMObj)
|
||||
|
||||
BOOL INTERNAL_CALL BITMAP_Cleanup(PVOID ObjectBody);
|
||||
|
||||
|
|
|
@ -72,10 +72,10 @@ typedef struct
|
|||
#define GDIBRUSH_IS_MASKING 0x8000 /* Pattern bitmap is used as transparent mask (?) */
|
||||
#define GDIBRUSH_CACHED_IS_SOLID 0x80000000
|
||||
|
||||
#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_BRUSH))
|
||||
#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
|
||||
#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
|
||||
#define BRUSHOBJ_UnlockBrush(pBrush) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pBrush)
|
||||
#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BRUSH))
|
||||
#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)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)
|
||||
|
||||
INT FASTCALL BRUSH_GetObject (PGDIBRUSHOBJ GdiObject, INT Count, LPLOGBRUSH Buffer);
|
||||
BOOL INTERNAL_CALL BRUSH_Cleanup(PVOID ObjectBody);
|
||||
|
|
|
@ -150,9 +150,9 @@ typedef struct
|
|||
/* Internal functions *********************************************************/
|
||||
|
||||
#define DC_LockDc(hDC) \
|
||||
((PDC) GDIOBJ_LockObj (GdiHandleTable, (HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
|
||||
((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
|
||||
#define DC_UnlockDc(pDC) \
|
||||
GDIOBJ_UnlockObjByPtr (GdiHandleTable, pDC)
|
||||
GDIOBJ_UnlockObjByPtr ((POBJ)pDC)
|
||||
|
||||
NTSTATUS FASTCALL InitDcImpl(VOID);
|
||||
PGDIDEVICE FASTCALL IntEnumHDev(VOID);
|
||||
|
|
|
@ -35,26 +35,8 @@ typedef PVOID PGDIOBJ;
|
|||
|
||||
typedef BOOL (INTERNAL_CALL *GDICLEANUPPROC)(PVOID ObjectBody);
|
||||
|
||||
/*!
|
||||
* GDI object header. This is a part of any GDI object. ROS specific header!
|
||||
*/
|
||||
typedef struct _GDIOBJHDR
|
||||
{
|
||||
PETHREAD LockingThread; /* only assigned if a thread is holding the lock! */
|
||||
ULONG Locks;
|
||||
#ifdef GDI_DEBUG
|
||||
const char* createdfile;
|
||||
int createdline;
|
||||
const char* lockfile;
|
||||
int lockline;
|
||||
#endif
|
||||
} GDIOBJHDR, *PGDIOBJHDR;
|
||||
|
||||
//
|
||||
// Every GDI Object must have this standard type of header.
|
||||
// It's for thread locking.
|
||||
// This header is standalone, used only in gdiobj.c.
|
||||
//
|
||||
/* Every GDI Object must have this standard type of header.
|
||||
* It's for thread locking. */
|
||||
typedef struct _BASEOBJECT
|
||||
{
|
||||
HGDIOBJ hHmgr;
|
||||
|
@ -64,23 +46,23 @@ typedef struct _BASEOBJECT
|
|||
PW32THREAD Tid;
|
||||
} BASEOBJECT, *POBJ;
|
||||
|
||||
BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle);
|
||||
void INTERNAL_CALL GDIOBJ_SetOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle, PEPROCESS Owner);
|
||||
void INTERNAL_CALL GDIOBJ_CopyOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
|
||||
BOOL INTERNAL_CALL GDIOBJ_ConvertToStockObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ *hObj);
|
||||
VOID INTERNAL_CALL GDIOBJ_UnlockObjByPtr(PGDI_HANDLE_TABLE HandleTable, PGDIOBJ Object);
|
||||
BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
|
||||
VOID INTERNAL_CALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);
|
||||
VOID INTERNAL_CALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
|
||||
BOOL INTERNAL_CALL GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
|
||||
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);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType);
|
||||
|
||||
PVOID INTERNAL_CALL GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process);
|
||||
|
||||
#define GDIOBJ_GetObjectType(Handle) \
|
||||
GDI_HANDLE_GET_TYPE(Handle)
|
||||
|
||||
BOOL INTERNAL_CALL GDIOBJ_ValidateHandle(HGDIOBJ hObj, ULONG ObjectType);
|
||||
HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(PGDI_HANDLE_TABLE HandleTable, ULONG ObjectType);
|
||||
BOOL INTERNAL_CALL GDIOBJ_FreeObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType);
|
||||
PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType);
|
||||
|
||||
PVOID INTERNAL_CALL GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process);
|
||||
|
||||
#define GDIOBJFLAG_DEFAULT (0x0)
|
||||
#define GDIOBJFLAG_IGNOREPID (0x1)
|
||||
#define GDIOBJFLAG_IGNORELOCK (0x2)
|
||||
|
|
|
@ -64,9 +64,9 @@ HPALETTE FASTCALL PALETTE_AllocPalette(ULONG Mode,
|
|||
ULONG Blue);
|
||||
HPALETTE FASTCALL PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
|
||||
CONST RGBQUAD *Colors);
|
||||
#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
|
||||
#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
|
||||
#define PALETTE_UnlockPalette(pPalette) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pPalette)
|
||||
#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
|
||||
#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
|
||||
#define PALETTE_UnlockPalette(pPalette) GDIOBJ_UnlockObjByPtr((POBJ)pPalette)
|
||||
BOOL INTERNAL_CALL PALETTE_Cleanup(PVOID ObjectBody);
|
||||
|
||||
HPALETTE FASTCALL PALETTE_Init (VOID);
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
/* Internal interface */
|
||||
|
||||
#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_PEN))
|
||||
#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
|
||||
#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
|
||||
#define PENOBJ_AllocExtPen() ((HPEN)GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_EXTPEN))
|
||||
#define PENOBJ_FreeExtPen(hBMObj) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_EXTPEN)
|
||||
#define PENOBJ_LockExtPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_EXTPEN))
|
||||
#define PENOBJ_UnlockPen(pPenObj) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pPenObj)
|
||||
#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PEN))
|
||||
#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
|
||||
#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
|
||||
#define PENOBJ_AllocExtPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_EXTPEN))
|
||||
#define PENOBJ_FreeExtPen(hBMObj) GDIOBJ_FreeObj((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)
|
||||
|
||||
INT STDCALL PEN_GetObject(PGDIBRUSHOBJ hPen, INT Count, PLOGPEN Buffer);
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ typedef struct _ROSRGNDATA
|
|||
|
||||
/* Functions ******************************************************************/
|
||||
|
||||
#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)
|
||||
#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION))
|
||||
#define RGNDATA_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pRgn)
|
||||
#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)
|
||||
#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION))
|
||||
#define RGNDATA_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr((POBJ)pRgn)
|
||||
|
||||
HRGN FASTCALL RGNDATA_AllocRgn(INT n);
|
||||
BOOL INTERNAL_CALL RGNDATA_Cleanup(PVOID ObjectBody);
|
||||
|
|
|
@ -69,10 +69,10 @@ typedef struct
|
|||
/* Internal interface */
|
||||
|
||||
#define TEXTOBJ_AllocText() \
|
||||
((HFONT) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_FONT))
|
||||
#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)
|
||||
#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj (GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT))
|
||||
#define TEXTOBJ_UnlockText(pBMObj) GDIOBJ_UnlockObjByPtr (GdiHandleTable, pBMObj)
|
||||
((HFONT) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_FONT))
|
||||
#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)
|
||||
#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT))
|
||||
#define TEXTOBJ_UnlockText(pBMObj) GDIOBJ_UnlockObjByPtr ((POBJ)pBMObj)
|
||||
|
||||
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle);
|
||||
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <debug.h>
|
||||
|
||||
PGDI_HANDLE_TABLE INTERNAL_CALL GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject);
|
||||
BOOL INTERNAL_CALL GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process);
|
||||
BOOL INTERNAL_CALL GDI_CleanupForProcess (struct _EPROCESS *Process);
|
||||
/* FIXME */
|
||||
PGDI_HANDLE_TABLE GdiHandleTable = NULL;
|
||||
PSECTION_OBJECT GdiTableSection = NULL;
|
||||
|
@ -136,7 +136,7 @@ Win32kProcessCallback(struct _EPROCESS *Process,
|
|||
/* no process windows should exist at this point, or the function will assert! */
|
||||
DestroyProcessClasses(Win32Process);
|
||||
|
||||
GDI_CleanupForProcess(GdiHandleTable, Process);
|
||||
GDI_CleanupForProcess(Process);
|
||||
|
||||
co_IntGraphicsCheck(FALSE);
|
||||
|
||||
|
|
|
@ -490,13 +490,13 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT CurIcon, BOOL
|
|||
/* delete bitmaps */
|
||||
if(bmpMask)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, bmpMask, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(bmpMask, PsGetCurrentProcess());
|
||||
NtGdiDeleteObject(bmpMask);
|
||||
CurIcon->IconInfo.hbmMask = NULL;
|
||||
}
|
||||
if(bmpColor)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, bmpColor, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(bmpColor, PsGetCurrentProcess());
|
||||
NtGdiDeleteObject(bmpColor);
|
||||
CurIcon->IconInfo.hbmColor = NULL;
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL, BOOL Indirect)
|
|||
CurIcon->Size.cx = bmp->SurfObj.sizlBitmap.cx;
|
||||
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy;
|
||||
BITMAPOBJ_UnlockBitmap(bmp);
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmColor, NULL);
|
||||
GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmColor, NULL);
|
||||
}
|
||||
if(CurIcon->IconInfo.hbmMask &&
|
||||
(bmp = BITMAPOBJ_LockBitmap(CurIcon->IconInfo.hbmMask)))
|
||||
|
@ -608,7 +608,7 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL, BOOL Indirect)
|
|||
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
|
||||
}
|
||||
BITMAPOBJ_UnlockBitmap(bmp);
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmMask, NULL);
|
||||
GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmMask, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1186,7 +1186,7 @@ NtUserSetCursorContents(
|
|||
CurIcon->Size.cx = bmp->SurfObj.sizlBitmap.cx;
|
||||
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy;
|
||||
BITMAPOBJ_UnlockBitmap(bmp);
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmColor, NULL);
|
||||
GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmColor, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1198,7 +1198,7 @@ NtUserSetCursorContents(
|
|||
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
|
||||
|
||||
BITMAPOBJ_UnlockBitmap(bmp);
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmMask, NULL);
|
||||
GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmMask, NULL);
|
||||
}
|
||||
|
||||
Ret = TRUE;
|
||||
|
|
|
@ -1277,7 +1277,7 @@ IntSystemParametersInfo(
|
|||
BITMAPOBJ_UnlockBitmap(bmp);
|
||||
|
||||
/* change the bitmap's ownership */
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, hNewBitmap, NULL);
|
||||
GDIOBJ_SetOwnership(hNewBitmap, NULL);
|
||||
}
|
||||
hOldBitmap = (HBITMAP)InterlockedExchange((LONG*)&WinStaObject->hbmWallpaper, (LONG)hNewBitmap);
|
||||
if(hOldBitmap != NULL)
|
||||
|
|
|
@ -211,7 +211,7 @@ IntGetNCUpdateRgn(PWINDOW_OBJECT Window, BOOL Validate)
|
|||
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
|
||||
hRgnWindow, RGN_AND) == NULLREGION)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
|
||||
NtGdiDeleteObject(Window->UpdateRegion);
|
||||
Window->UpdateRegion = NULL;
|
||||
if (!(Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT))
|
||||
|
@ -272,7 +272,7 @@ co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags, BOOL Recurse)
|
|||
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
|
||||
{
|
||||
/* NOTE: The region can already be deleted! */
|
||||
GDIOBJ_FreeObj(GdiHandleTable, TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
|
||||
GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,13 +398,13 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
|
|||
if (Window->UpdateRegion == NULL)
|
||||
{
|
||||
Window->UpdateRegion = NtGdiCreateRectRgn(0, 0, 0, 0);
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, NULL);
|
||||
GDIOBJ_SetOwnership(Window->UpdateRegion, NULL);
|
||||
}
|
||||
|
||||
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
|
||||
hRgn, RGN_OR) == NULLREGION)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
|
||||
NtGdiDeleteObject(Window->UpdateRegion);
|
||||
Window->UpdateRegion = NULL;
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
|
|||
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
|
||||
hRgn, RGN_DIFF) == NULLREGION)
|
||||
{
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
|
||||
NtGdiDeleteObject(Window->UpdateRegion);
|
||||
Window->UpdateRegion = NULL;
|
||||
}
|
||||
|
@ -801,7 +801,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
|
|||
if (hRgn != (HANDLE)1 && hRgn != NULL)
|
||||
{
|
||||
/* NOTE: The region can already by deleted! */
|
||||
GDIOBJ_FreeObj(GdiHandleTable, hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
|
||||
GDIOBJ_FreeObj(hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
|
|||
{
|
||||
IntGetClientRect(Window, &Ps.rcPaint);
|
||||
}
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
|
||||
/* The region is part of the dc now and belongs to the process! */
|
||||
Window->UpdateRegion = NULL;
|
||||
}
|
||||
|
|
|
@ -590,7 +590,7 @@ DceFreeDCE(PDCE pdce, BOOLEAN Force)
|
|||
SetDCHook(pdce->hDC, NULL, 0L);
|
||||
#endif
|
||||
|
||||
if (Force && !GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, pdce->hDC))
|
||||
if (Force && !GDIOBJ_OwnedByCurrentProcess(pdce->hDC))
|
||||
{
|
||||
DPRINT1("Change ownership for DCE!\n");
|
||||
|
||||
|
|
|
@ -634,7 +634,7 @@ BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Bitmap = GDIOBJ_LockObj(GdiHandleTable, hBitmap, GDI_OBJECT_TYPE_BITMAP);
|
||||
Bitmap = GDIOBJ_LockObj(hBitmap, GDI_OBJECT_TYPE_BITMAP);
|
||||
if (Bitmap == NULL)
|
||||
{
|
||||
return 0;
|
||||
|
@ -657,14 +657,14 @@ BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
|
|||
{
|
||||
PBYTE buf;
|
||||
|
||||
resBitmap = GDIOBJ_LockObj(GdiHandleTable, res, GDI_OBJECT_TYPE_BITMAP);
|
||||
resBitmap = GDIOBJ_LockObj(res, GDI_OBJECT_TYPE_BITMAP);
|
||||
if (resBitmap)
|
||||
{
|
||||
buf = ExAllocatePoolWithTag (PagedPool, bm.bmWidthBytes * abs(bm.bmHeight), TAG_BITMAP);
|
||||
if (buf == NULL)
|
||||
{
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, resBitmap);
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, Bitmap);
|
||||
GDIOBJ_UnlockObjByPtr((POBJ)resBitmap);
|
||||
GDIOBJ_UnlockObjByPtr((POBJ)Bitmap);
|
||||
NtGdiDeleteObject(res);
|
||||
return 0;
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
|
|||
IntSetBitmapBits (resBitmap, bm.bmWidthBytes * abs(bm.bmHeight), buf);
|
||||
ExFreePool (buf);
|
||||
resBitmap->flFlags = Bitmap->flFlags;
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, resBitmap);
|
||||
GDIOBJ_UnlockObjByPtr((POBJ)resBitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -681,7 +681,7 @@ BITMAPOBJ_CopyBitmap(HBITMAP hBitmap)
|
|||
}
|
||||
}
|
||||
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, Bitmap);
|
||||
GDIOBJ_UnlockObjByPtr((POBJ)Bitmap);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ BRUSH_Cleanup(PVOID ObjectBody)
|
|||
if(pBrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
|
||||
{
|
||||
ASSERT(pBrush->hbmPattern);
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, pBrush->hbmPattern, PsGetCurrentProcess());
|
||||
GDIOBJ_SetOwnership(pBrush->hbmPattern, PsGetCurrentProcess());
|
||||
NtGdiDeleteObject(pBrush->hbmPattern);
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ IntGdiCreateDIBBrush(
|
|||
BrushObject->hbmPattern = hPattern;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
|
||||
BRUSHOBJ_UnlockBrush(BrushObject);
|
||||
|
||||
|
@ -409,7 +409,7 @@ IntGdiCreateHatchBrush(
|
|||
BrushObject->hbmPattern = hPattern;
|
||||
BrushObject->BrushAttr.lbColor = Color & 0xFFFFFF;
|
||||
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
|
||||
BRUSHOBJ_UnlockBrush(BrushObject);
|
||||
|
||||
|
@ -446,7 +446,7 @@ IntGdiCreatePatternBrush(
|
|||
BrushObject->hbmPattern = hPattern;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
|
||||
BRUSHOBJ_UnlockBrush(BrushObject);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ IntGdiSelectVisRgn(HDC hdc, HRGN hrgn)
|
|||
if (dc->w.hVisRgn == NULL)
|
||||
{
|
||||
dc->w.hVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
|
||||
GDIOBJ_CopyOwnership(GdiHandleTable, hdc, dc->w.hVisRgn);
|
||||
GDIOBJ_CopyOwnership(hdc, dc->w.hVisRgn);
|
||||
}
|
||||
|
||||
retval = NtGdiCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY);
|
||||
|
|
|
@ -706,7 +706,7 @@ BOOL STDCALL
|
|||
NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
|
||||
{
|
||||
|
||||
GDIOBJHDR * ptr;
|
||||
POBJ pObject;
|
||||
DWORD objectType;
|
||||
BOOL Ret = FALSE;
|
||||
|
||||
|
@ -714,15 +714,15 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
|
|||
if(!hgdiobj)
|
||||
return Ret;
|
||||
|
||||
ptr = GDIOBJ_LockObj(GdiHandleTable, hgdiobj, GDI_OBJECT_TYPE_DONTCARE);
|
||||
if (ptr == 0)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return Ret;
|
||||
}
|
||||
pObject = GDIOBJ_LockObj(hgdiobj, GDI_OBJECT_TYPE_DONTCARE);
|
||||
if (pObject == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return Ret;
|
||||
}
|
||||
objectType = GDIOBJ_GetObjectType(hgdiobj);
|
||||
switch(objectType)
|
||||
{
|
||||
{
|
||||
/*
|
||||
msdn.microsoft.com,
|
||||
"Windows 2000/XP: If hgdiobj is a brush, UnrealizeObject does nothing,
|
||||
|
@ -738,9 +738,9 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
|
|||
default:
|
||||
DPRINT1("Magic 0x%08x not implemented\n", objectType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, ptr);
|
||||
GDIOBJ_UnlockObjByPtr(pObject);
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1019,7 +1019,7 @@ NtGdiDeleteObjectApp(HANDLE DCHandle)
|
|||
|
||||
if(IsObjectDead((HGDIOBJ)DCHandle)) return TRUE;
|
||||
|
||||
if (!GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, DCHandle))
|
||||
if (!GDIOBJ_OwnedByCurrentProcess(DCHandle))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
|
@ -1669,7 +1669,7 @@ IntGdiGetObject(IN HANDLE Handle,
|
|||
INT Result = 0;
|
||||
DWORD dwObjectType;
|
||||
|
||||
pGdiObject = GDIOBJ_LockObj(GdiHandleTable, Handle, GDI_OBJECT_TYPE_DONTCARE);
|
||||
pGdiObject = GDIOBJ_LockObj(Handle, GDI_OBJECT_TYPE_DONTCARE);
|
||||
if (!pGdiObject)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
|
@ -1711,7 +1711,7 @@ IntGdiGetObject(IN HANDLE Handle,
|
|||
break;
|
||||
}
|
||||
|
||||
GDIOBJ_UnlockObjByPtr(GdiHandleTable, pGdiObject);
|
||||
GDIOBJ_UnlockObjByPtr(pGdiObject);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
@ -2375,7 +2375,7 @@ DC_AllocDC(PUNICODE_STRING Driver)
|
|||
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
|
||||
}
|
||||
|
||||
hDC = (HDC) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_DC);
|
||||
hDC = (HDC) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DC);
|
||||
if (hDC == NULL)
|
||||
{
|
||||
if(Buf)
|
||||
|
@ -2546,7 +2546,7 @@ DC_FreeDC(HDC DCToFree)
|
|||
DC_FreeDcAttr(DCToFree);
|
||||
if(!IsObjectDead( DCToFree ))
|
||||
{
|
||||
if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC))
|
||||
if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC))
|
||||
{
|
||||
DPRINT1("DC_FreeDC failed\n");
|
||||
}
|
||||
|
@ -2629,21 +2629,21 @@ DC_SetOwnership(HDC hDC, PEPROCESS Owner)
|
|||
{
|
||||
PDC DC;
|
||||
|
||||
GDIOBJ_SetOwnership(GdiHandleTable, hDC, Owner);
|
||||
GDIOBJ_SetOwnership(hDC, Owner);
|
||||
DC = DC_LockDc(hDC);
|
||||
if (NULL != DC)
|
||||
{
|
||||
if (NULL != DC->w.hClipRgn)
|
||||
{
|
||||
GDIOBJ_CopyOwnership(GdiHandleTable, hDC, DC->w.hClipRgn);
|
||||
GDIOBJ_CopyOwnership(hDC, DC->w.hClipRgn);
|
||||
}
|
||||
if (NULL != DC->w.hVisRgn)
|
||||
{
|
||||
GDIOBJ_CopyOwnership(GdiHandleTable, hDC, DC->w.hVisRgn);
|
||||
GDIOBJ_CopyOwnership(hDC, DC->w.hVisRgn);
|
||||
}
|
||||
if (NULL != DC->w.hGCClipRgn)
|
||||
{
|
||||
GDIOBJ_CopyOwnership(GdiHandleTable, hDC, DC->w.hGCClipRgn);
|
||||
GDIOBJ_CopyOwnership(hDC, DC->w.hGCClipRgn);
|
||||
}
|
||||
DC_UnlockDc(DC);
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject)
|
|||
if (ObjTypeInfo[ObjType].bUseLookaside)
|
||||
{
|
||||
ExInitializePagedLookasideList(HandleTable->LookasideLists + ObjType, NULL, NULL, 0,
|
||||
ObjTypeInfo[ObjType].ulBodySize + sizeof(GDIOBJHDR), ObjTypeInfo[ObjType].Tag, 0);
|
||||
ObjTypeInfo[ObjType].ulBodySize, ObjTypeInfo[ObjType].Tag, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,10 +179,9 @@ GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject)
|
|||
}
|
||||
|
||||
static __inline PPAGED_LOOKASIDE_LIST
|
||||
FindLookasideList(PGDI_HANDLE_TABLE HandleTable,
|
||||
ULONG TypeIndex)
|
||||
FindLookasideList(ULONG TypeIndex)
|
||||
{
|
||||
return HandleTable->LookasideLists + TypeIndex;
|
||||
return GdiHandleTable->LookasideLists + TypeIndex;
|
||||
}
|
||||
|
||||
static __inline BOOL
|
||||
|
@ -338,7 +337,7 @@ LockErrorDebugOutput(HGDIOBJ hObj, PGDI_TABLE_ENTRY Entry, LPSTR Function)
|
|||
|
||||
ULONG
|
||||
FASTCALL
|
||||
InterlockedPopFreeEntry(PGDI_HANDLE_TABLE HandleTable)
|
||||
InterlockedPopFreeEntry()
|
||||
{
|
||||
ULONG idxFirstFree, idxNextFree, idxPrev;
|
||||
PGDI_TABLE_ENTRY pFreeEntry;
|
||||
|
@ -347,24 +346,24 @@ InterlockedPopFreeEntry(PGDI_HANDLE_TABLE HandleTable)
|
|||
|
||||
do
|
||||
{
|
||||
idxFirstFree = HandleTable->FirstFree;
|
||||
idxFirstFree = GdiHandleTable->FirstFree;
|
||||
if (idxFirstFree)
|
||||
{
|
||||
pFreeEntry = HandleTable->Entries + idxFirstFree;
|
||||
pFreeEntry = GdiHandleTable->Entries + idxFirstFree;
|
||||
ASSERT(((ULONG)pFreeEntry->KernelData & ~GDI_HANDLE_INDEX_MASK) == 0);
|
||||
idxNextFree = (ULONG)pFreeEntry->KernelData;
|
||||
idxPrev = (ULONG)_InterlockedCompareExchange((LONG*)&HandleTable->FirstFree, idxNextFree, idxFirstFree);
|
||||
idxPrev = (ULONG)_InterlockedCompareExchange((LONG*)&GdiHandleTable->FirstFree, idxNextFree, idxFirstFree);
|
||||
}
|
||||
else
|
||||
{
|
||||
idxFirstFree = HandleTable->FirstUnused;
|
||||
idxFirstFree = GdiHandleTable->FirstUnused;
|
||||
idxNextFree = idxFirstFree + 1;
|
||||
if (idxNextFree >= GDI_HANDLE_COUNT)
|
||||
{
|
||||
DPRINT1("No more gdi handles left!\n");
|
||||
return 0;
|
||||
}
|
||||
idxPrev = (ULONG)_InterlockedCompareExchange((LONG*)&HandleTable->FirstUnused, idxNextFree, idxFirstFree);
|
||||
idxPrev = (ULONG)_InterlockedCompareExchange((LONG*)&GdiHandleTable->FirstUnused, idxNextFree, idxFirstFree);
|
||||
}
|
||||
}
|
||||
while (idxPrev != idxFirstFree);
|
||||
|
@ -376,24 +375,24 @@ InterlockedPopFreeEntry(PGDI_HANDLE_TABLE HandleTable)
|
|||
The entry must be unlocked and the base type field must be 0 */
|
||||
VOID
|
||||
FASTCALL
|
||||
InterlockedPushFreeEntry(PGDI_HANDLE_TABLE HandleTable, ULONG idxToFree)
|
||||
InterlockedPushFreeEntry(ULONG idxToFree)
|
||||
{
|
||||
ULONG idxFirstFree, idxPrev;
|
||||
PGDI_TABLE_ENTRY pFreeEntry;
|
||||
|
||||
DPRINT("Enter InterlockedPushFreeEntry\n");
|
||||
|
||||
pFreeEntry = HandleTable->Entries + idxToFree;
|
||||
pFreeEntry = GdiHandleTable->Entries + idxToFree;
|
||||
ASSERT((pFreeEntry->Type & GDI_ENTRY_BASETYPE_MASK) == 0);
|
||||
ASSERT(pFreeEntry->ProcessId == 0);
|
||||
pFreeEntry->UserData = NULL;
|
||||
|
||||
do
|
||||
{
|
||||
idxFirstFree = HandleTable->FirstFree;
|
||||
idxFirstFree = GdiHandleTable->FirstFree;
|
||||
pFreeEntry->KernelData = (PVOID)idxFirstFree;
|
||||
|
||||
idxPrev = (ULONG)_InterlockedCompareExchange((LONG*)&HandleTable->FirstFree, idxToFree, idxFirstFree);
|
||||
idxPrev = (ULONG)_InterlockedCompareExchange((LONG*)&GdiHandleTable->FirstFree, idxToFree, idxFirstFree);
|
||||
}
|
||||
while (idxPrev != idxFirstFree);
|
||||
}
|
||||
|
@ -427,10 +426,10 @@ GDIOBJ_ValidateHandle(HGDIOBJ hObj, ULONG ObjectType)
|
|||
* \todo return the object pointer and lock it by default.
|
||||
*/
|
||||
HGDIOBJ INTERNAL_CALL
|
||||
GDIOBJ_AllocObj(PGDI_HANDLE_TABLE HandleTable, ULONG ObjectType)
|
||||
GDIOBJ_AllocObj(ULONG ObjectType)
|
||||
{
|
||||
PW32PROCESS W32Process;
|
||||
PGDIOBJHDR newObject = NULL;
|
||||
POBJ newObject = NULL;
|
||||
PPAGED_LOOKASIDE_LIST LookasideList = NULL;
|
||||
HANDLE CurrentProcessId, LockedProcessId;
|
||||
ULONG TypeIndex;
|
||||
|
@ -449,7 +448,7 @@ GDIOBJ_AllocObj(PGDI_HANDLE_TABLE HandleTable, ULONG ObjectType)
|
|||
TypeIndex = GDI_OBJECT_GET_TYPE_INDEX(ObjectType);
|
||||
if (ObjTypeInfo[TypeIndex].bUseLookaside)
|
||||
{
|
||||
LookasideList = FindLookasideList(HandleTable, TypeIndex);
|
||||
LookasideList = FindLookasideList(TypeIndex);
|
||||
if(LookasideList != NULL)
|
||||
{
|
||||
newObject = ExAllocateFromPagedLookasideList(LookasideList);
|
||||
|
@ -458,37 +457,31 @@ GDIOBJ_AllocObj(PGDI_HANDLE_TABLE HandleTable, ULONG ObjectType)
|
|||
else
|
||||
{
|
||||
newObject = ExAllocatePoolWithTag(PagedPool,
|
||||
ObjTypeInfo[TypeIndex].ulBodySize + sizeof(GDIOBJHDR),
|
||||
ObjTypeInfo[TypeIndex].ulBodySize,
|
||||
ObjTypeInfo[TypeIndex].Tag);
|
||||
}
|
||||
if(newObject != NULL)
|
||||
{
|
||||
UINT Index;
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
PGDIOBJ ObjectBody;
|
||||
LONG TypeInfo;
|
||||
|
||||
CurrentProcessId = PsGetCurrentProcessId();
|
||||
LockedProcessId = (HANDLE)((ULONG_PTR)CurrentProcessId | 0x1);
|
||||
|
||||
newObject->LockingThread = NULL;
|
||||
newObject->Locks = 0;
|
||||
|
||||
ObjectBody = GDIHdrToBdy(newObject);
|
||||
|
||||
RtlZeroMemory(ObjectBody, GetObjectSize(TypeIndex));
|
||||
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 = BRSUH, PEN, EXTPEN, basetype = BRUSH) */
|
||||
TypeInfo = (ObjectType & GDI_HANDLE_BASETYPE_MASK) | (ObjectType >> GDI_ENTRY_UPPER_SHIFT);
|
||||
|
||||
Index = InterlockedPopFreeEntry(HandleTable);
|
||||
Index = InterlockedPopFreeEntry();
|
||||
if (Index != 0)
|
||||
{
|
||||
HANDLE PrevProcId;
|
||||
|
||||
Entry = &HandleTable->Entries[Index];
|
||||
Entry = &GdiHandleTable->Entries[Index];
|
||||
|
||||
LockHandle:
|
||||
PrevProcId = _InterlockedCompareExchangePointer((PVOID*)&Entry->ProcessId, LockedProcessId, 0);
|
||||
|
@ -496,7 +489,7 @@ LockHandle:
|
|||
{
|
||||
HGDIOBJ Handle;
|
||||
|
||||
Entry->KernelData = ObjectBody;
|
||||
Entry->KernelData = newObject;
|
||||
|
||||
/* copy the reuse-counter */
|
||||
TypeInfo |= Entry->Type & GDI_ENTRY_REUSE_MASK;
|
||||
|
@ -518,7 +511,7 @@ LockHandle:
|
|||
}
|
||||
Handle = (HGDIOBJ)((Index & 0xFFFF) | (TypeInfo << GDI_ENTRY_UPPER_SHIFT));
|
||||
|
||||
DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, ObjectBody);
|
||||
DPRINT("GDIOBJ_AllocObj: 0x%x ob: 0x%x\n", Handle, newObject);
|
||||
return Handle;
|
||||
}
|
||||
else
|
||||
|
@ -548,7 +541,7 @@ LockHandle:
|
|||
}
|
||||
DPRINT1("Failed to insert gdi object into the handle table, no handles left!\n");
|
||||
#ifdef GDI_DEBUG
|
||||
IntDumpHandleTable(HandleTable);
|
||||
IntDumpHandleTable(GdiHandleTable);
|
||||
#endif /* GDI_DEBUG */
|
||||
}
|
||||
else
|
||||
|
@ -569,7 +562,7 @@ LockHandle:
|
|||
* to the calling process.
|
||||
*/
|
||||
BOOL INTERNAL_CALL
|
||||
GDIOBJ_FreeObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
||||
GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ExpectedType)
|
||||
{
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
PPAGED_LOOKASIDE_LIST LookasideList;
|
||||
|
@ -615,7 +608,7 @@ GDIOBJ_FreeObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
Entry = GDI_HANDLE_GET_ENTRY(HandleTable, hObj);
|
||||
Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, hObj);
|
||||
|
||||
LockHandle:
|
||||
/* lock the object, we must not delete global objects, so don't exchange the locking
|
||||
|
@ -627,11 +620,11 @@ LockHandle:
|
|||
((Entry->Type << GDI_ENTRY_UPPER_SHIFT) == HandleUpper) &&
|
||||
((Entry->Type & GDI_ENTRY_BASETYPE_MASK) == (HandleUpper & GDI_ENTRY_BASETYPE_MASK)) )
|
||||
{
|
||||
PGDIOBJHDR GdiHdr;
|
||||
POBJ Object;
|
||||
|
||||
GdiHdr = GDIBdyToHdr(Entry->KernelData);
|
||||
Object = Entry->KernelData;
|
||||
|
||||
if(GdiHdr->Locks == 0)
|
||||
if(Object->cExclusiveLock == 0)
|
||||
{
|
||||
BOOL Ret;
|
||||
PW32PROCESS W32Process = PsGetCurrentProcessWin32Process();
|
||||
|
@ -643,7 +636,7 @@ LockHandle:
|
|||
(void)_InterlockedExchangePointer((PVOID*)&Entry->ProcessId, NULL);
|
||||
|
||||
/* push this entry to the free list */
|
||||
InterlockedPushFreeEntry(HandleTable, GDI_ENTRY_TO_INDEX(HandleTable, Entry));
|
||||
InterlockedPushFreeEntry(GDI_ENTRY_TO_INDEX(GdiHandleTable, Entry));
|
||||
|
||||
if(W32Process != NULL)
|
||||
{
|
||||
|
@ -652,20 +645,20 @@ LockHandle:
|
|||
|
||||
/* call the cleanup routine. */
|
||||
TypeIndex = GDI_OBJECT_GET_TYPE_INDEX(HandleType);
|
||||
Ret = RunCleanupCallback(GDIHdrToBdy(GdiHdr), TypeIndex);
|
||||
Ret = RunCleanupCallback(Object, TypeIndex);
|
||||
|
||||
/* Now it's time to free the memory */
|
||||
if (ObjTypeInfo[TypeIndex].bUseLookaside)
|
||||
{
|
||||
LookasideList = FindLookasideList(HandleTable, TypeIndex);
|
||||
LookasideList = FindLookasideList(TypeIndex);
|
||||
if(LookasideList != NULL)
|
||||
{
|
||||
ExFreeToPagedLookasideList(LookasideList, GdiHdr);
|
||||
ExFreeToPagedLookasideList(LookasideList, Object);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ExFreePool(GdiHdr);
|
||||
ExFreePool(Object);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
|
@ -675,7 +668,7 @@ LockHandle:
|
|||
/*
|
||||
* The object is currently locked, so freeing is forbidden!
|
||||
*/
|
||||
DPRINT1("GdiHdr->Locks: %d\n", GdiHdr->Locks);
|
||||
DPRINT1("Object->cExclusiveLock = %d\n", Object->cExclusiveLock);
|
||||
#ifdef GDI_DEBUG
|
||||
// DPRINT1("Locked from:\n");
|
||||
// KeRosDumpStackFrames(GDIHandleLocker[GDI_HANDLE_GET_INDEX(hObj)], GDI_STACK_LEVELS);
|
||||
|
@ -758,7 +751,7 @@ NtGdiDeleteObject(HGDIOBJ hObject)
|
|||
if(!IsObjectDead(hObject))
|
||||
{
|
||||
return NULL != hObject
|
||||
? GDIOBJ_FreeObj(GdiHandleTable, hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
|
||||
? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -772,7 +765,7 @@ NtGdiDeleteObject(HGDIOBJ hObject)
|
|||
* \param Process - PID of the process that will be destroyed.
|
||||
*/
|
||||
BOOL INTERNAL_CALL
|
||||
GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process)
|
||||
GDI_CleanupForProcess (struct _EPROCESS *Process)
|
||||
{
|
||||
PGDI_TABLE_ENTRY Entry, End;
|
||||
PEPROCESS CurrentProcess;
|
||||
|
@ -795,8 +788,8 @@ GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process)
|
|||
we should delete it directly here! */
|
||||
ProcId = Process->UniqueProcessId;
|
||||
|
||||
End = &HandleTable->Entries[GDI_HANDLE_COUNT];
|
||||
for(Entry = &HandleTable->Entries[RESERVE_ENTRIES_COUNT];
|
||||
End = &GdiHandleTable->Entries[GDI_HANDLE_COUNT];
|
||||
for(Entry = &GdiHandleTable->Entries[RESERVE_ENTRIES_COUNT];
|
||||
Entry != End;
|
||||
Entry++, Index++)
|
||||
{
|
||||
|
@ -811,7 +804,7 @@ GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process)
|
|||
simply ignore this fact here. */
|
||||
ObjectHandle = (HGDIOBJ)(Index | (Entry->Type << GDI_ENTRY_UPPER_SHIFT));
|
||||
|
||||
if(GDIOBJ_FreeObj(HandleTable, ObjectHandle, GDI_OBJECT_TYPE_DONTCARE) &&
|
||||
if(GDIOBJ_FreeObj(ObjectHandle, GDI_OBJECT_TYPE_DONTCARE) &&
|
||||
W32Process->GDIObjects == 0)
|
||||
{
|
||||
/* there are no more gdi handles for this process, bail */
|
||||
|
@ -842,12 +835,12 @@ GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process)
|
|||
* \todo Get rid of the ExpectedType parameter!
|
||||
*/
|
||||
PGDIOBJ INTERNAL_CALL
|
||||
GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
||||
GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ExpectedType)
|
||||
{
|
||||
ULONG HandleIndex;
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
HANDLE ProcessId, HandleProcessId, LockedProcessId, PrevProcId;
|
||||
PGDIOBJ Object = NULL;
|
||||
POBJ Object = NULL;
|
||||
ULONG HandleType, HandleUpper;
|
||||
|
||||
HandleIndex = GDI_HANDLE_GET_INDEX(hObj);
|
||||
|
@ -858,7 +851,7 @@ GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
|||
if (HandleIndex >= GDI_HANDLE_COUNT)
|
||||
return NULL;
|
||||
|
||||
Entry = &HandleTable->Entries[HandleIndex];
|
||||
Entry = &GdiHandleTable->Entries[HandleIndex];
|
||||
|
||||
/* Check if we have the requested type */
|
||||
if ( (ExpectedType != GDI_OBJECT_TYPE_DONTCARE &&
|
||||
|
@ -921,32 +914,29 @@ GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
|||
if ( (Entry->KernelData != NULL) &&
|
||||
((Entry->Type << GDI_ENTRY_UPPER_SHIFT) == HandleUpper) )
|
||||
{
|
||||
PGDIOBJHDR GdiHdr = GDIBdyToHdr(Entry->KernelData);
|
||||
PETHREAD Thread = PsGetCurrentThread();
|
||||
PW32THREAD Thread = PsGetCurrentThreadWin32Thread();
|
||||
Object = Entry->KernelData;
|
||||
|
||||
if (GdiHdr->Locks == 0)
|
||||
if (Object->cExclusiveLock == 0)
|
||||
{
|
||||
GdiHdr->LockingThread = Thread;
|
||||
GdiHdr->Locks = 1;
|
||||
Object->Tid = Thread;
|
||||
Object->cExclusiveLock = 1;
|
||||
#ifdef GDI_DEBUG
|
||||
CaptureStackBackTace((PVOID*)GDIHandleLocker[GDI_HANDLE_GET_INDEX(hObj)], GDI_STACK_LEVELS);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
_InterlockedIncrement((PLONG)&GdiHdr->Locks);
|
||||
if (GdiHdr->LockingThread != Thread)
|
||||
if (Object->Tid != Thread)
|
||||
{
|
||||
_InterlockedDecrement((PLONG)&GdiHdr->Locks);
|
||||
|
||||
/* Unlock the handle table entry. */
|
||||
(void)_InterlockedExchangePointer((PVOID*)&Entry->ProcessId, PrevProcId);
|
||||
|
||||
DelayExecution();
|
||||
continue;
|
||||
}
|
||||
_InterlockedIncrement((PLONG)&Object->cExclusiveLock);
|
||||
}
|
||||
Object = Entry->KernelData;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -991,12 +981,12 @@ GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
|||
* \todo Get rid of the ExpectedType parameter!
|
||||
*/
|
||||
PGDIOBJ INTERNAL_CALL
|
||||
GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
|
||||
GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ExpectedType)
|
||||
{
|
||||
ULONG HandleIndex;
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
HANDLE ProcessId, HandleProcessId, LockedProcessId, PrevProcId;
|
||||
PGDIOBJ Object = NULL;
|
||||
POBJ Object = NULL;
|
||||
ULONG_PTR HandleType, HandleUpper;
|
||||
|
||||
HandleIndex = GDI_HANDLE_GET_INDEX(hObj);
|
||||
|
@ -1017,7 +1007,7 @@ GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD Expected
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Entry = &HandleTable->Entries[HandleIndex];
|
||||
Entry = &GdiHandleTable->Entries[HandleIndex];
|
||||
|
||||
ProcessId = (HANDLE)((ULONG_PTR)PsGetCurrentProcessId() & ~1);
|
||||
HandleProcessId = (HANDLE)((ULONG_PTR)Entry->ProcessId & ~1);
|
||||
|
@ -1059,18 +1049,17 @@ GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD Expected
|
|||
if ( (Entry->KernelData != NULL) &&
|
||||
(HandleUpper == (Entry->Type << GDI_ENTRY_UPPER_SHIFT)) )
|
||||
{
|
||||
PGDIOBJHDR GdiHdr = GDIBdyToHdr(Entry->KernelData);
|
||||
Object = (POBJ)Entry->KernelData;
|
||||
|
||||
#ifdef GDI_DEBUG
|
||||
if (_InterlockedIncrement((PLONG)&GdiHdr->Locks) == 1)
|
||||
if (_InterlockedIncrement((PLONG)&Object->ulShareCount) == 1)
|
||||
{
|
||||
memset(GDIHandleLocker[HandleIndex], 0x00, GDI_STACK_LEVELS * sizeof(ULONG));
|
||||
RtlCaptureStackBackTrace(1, GDI_STACK_LEVELS, (PVOID*)GDIHandleLocker[HandleIndex], NULL);
|
||||
}
|
||||
#else
|
||||
_InterlockedIncrement((PLONG)&GdiHdr->Locks);
|
||||
_InterlockedIncrement(Object->ulShareCount);
|
||||
#endif
|
||||
Object = Entry->KernelData;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1110,23 +1099,25 @@ GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD Expected
|
|||
* \param Object Object pointer (as returned by GDIOBJ_LockObj).
|
||||
*/
|
||||
VOID INTERNAL_CALL
|
||||
GDIOBJ_UnlockObjByPtr(PGDI_HANDLE_TABLE HandleTable, PGDIOBJ Object)
|
||||
GDIOBJ_UnlockObjByPtr(POBJ Object)
|
||||
{
|
||||
PGDIOBJHDR GdiHdr = GDIBdyToHdr(Object);
|
||||
#ifdef GDI_DEBUG
|
||||
if (_InterlockedDecrement((PLONG)&GdiHdr->Locks) == 0)
|
||||
{
|
||||
memset(GDIHandleLocker[GDI_HANDLE_GET_INDEX(Object)], 0x00, GDI_STACK_LEVELS * sizeof(ULONG));
|
||||
RtlCaptureStackBackTrace(1, GDI_STACK_LEVELS, (PVOID*)GDIHandleLocker[GDI_HANDLE_GET_INDEX(Object)], NULL);
|
||||
}
|
||||
#else
|
||||
if (_InterlockedDecrement((PLONG)&GdiHdr->Locks) < 0)
|
||||
DPRINT1("Trying to unlock non-existant object\n");
|
||||
#endif
|
||||
if (_InterlockedDecrement((PLONG)&Object->cExclusiveLock) < 0)
|
||||
{
|
||||
DPRINT1("Trying to unlock non-existant object\n");
|
||||
}
|
||||
}
|
||||
|
||||
VOID INTERNAL_CALL
|
||||
GDIOBJ_ShareUnlockObjByPtr(POBJ Object)
|
||||
{
|
||||
if (_InterlockedDecrement((PLONG)&Object->ulShareCount) < 0)
|
||||
{
|
||||
DPRINT1("Trying to unlock non-existant object\n");
|
||||
}
|
||||
}
|
||||
|
||||
BOOL INTERNAL_CALL
|
||||
GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle)
|
||||
GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle)
|
||||
{
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
HANDLE ProcessId;
|
||||
|
@ -1138,7 +1129,7 @@ GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle
|
|||
{
|
||||
ProcessId = PsGetCurrentProcessId();
|
||||
|
||||
Entry = GDI_HANDLE_GET_ENTRY(HandleTable, ObjectHandle);
|
||||
Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, ObjectHandle);
|
||||
Ret = Entry->KernelData != NULL &&
|
||||
(Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 &&
|
||||
(HANDLE)((ULONG_PTR)Entry->ProcessId & ~0x1) == ProcessId;
|
||||
|
@ -1150,7 +1141,7 @@ GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle
|
|||
}
|
||||
|
||||
BOOL INTERNAL_CALL
|
||||
GDIOBJ_ConvertToStockObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ *phObj)
|
||||
GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj)
|
||||
{
|
||||
/*
|
||||
* FIXME !!!!! THIS FUNCTION NEEDS TO BE FIXED - IT IS NOT SAFE WHEN OTHER THREADS
|
||||
|
@ -1158,7 +1149,7 @@ GDIOBJ_ConvertToStockObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ *phObj)
|
|||
*/
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
HANDLE ProcessId, LockedProcessId, PrevProcId;
|
||||
PETHREAD Thread;
|
||||
PW32THREAD Thread;
|
||||
HGDIOBJ hObj;
|
||||
#ifdef GDI_DEBUG
|
||||
ULONG Attempts = 0;
|
||||
|
@ -1169,14 +1160,14 @@ GDIOBJ_ConvertToStockObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ *phObj)
|
|||
|
||||
DPRINT("GDIOBJ_ConvertToStockObj: hObj: 0x%08x\n", hObj);
|
||||
|
||||
Thread = PsGetCurrentThread();
|
||||
Thread = PsGetCurrentThreadWin32Thread();
|
||||
|
||||
if(!GDI_HANDLE_IS_STOCKOBJ(hObj))
|
||||
{
|
||||
ProcessId = PsGetCurrentProcessId();
|
||||
LockedProcessId = (HANDLE)((ULONG_PTR)ProcessId | 0x1);
|
||||
|
||||
Entry = GDI_HANDLE_GET_ENTRY(HandleTable, hObj);
|
||||
Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, hObj);
|
||||
|
||||
LockHandle:
|
||||
/* lock the object, we must not convert stock objects, so don't check!!! */
|
||||
|
@ -1203,17 +1194,17 @@ LockHandle:
|
|||
PrevType = _InterlockedCompareExchange(&Entry->Type, NewType, OldType);
|
||||
if(PrevType == OldType && Entry->KernelData != NULL)
|
||||
{
|
||||
PETHREAD PrevThread;
|
||||
PGDIOBJHDR GdiHdr;
|
||||
PW32THREAD PrevThread;
|
||||
POBJ Object;
|
||||
|
||||
/* We successfully set the stock object flag.
|
||||
KernelData should never be NULL here!!! */
|
||||
ASSERT(Entry->KernelData);
|
||||
|
||||
GdiHdr = GDIBdyToHdr(Entry->KernelData);
|
||||
Object = Entry->KernelData;
|
||||
|
||||
PrevThread = GdiHdr->LockingThread;
|
||||
if(GdiHdr->Locks == 0 || PrevThread == Thread)
|
||||
PrevThread = Object->Tid;
|
||||
if(Object->cExclusiveLock == 0 || PrevThread == Thread)
|
||||
{
|
||||
/* dereference the process' object counter */
|
||||
if(PrevProcId != GDI_GLOBAL_PROCESS)
|
||||
|
@ -1249,10 +1240,7 @@ LockHandle:
|
|||
#ifdef GDI_DEBUG
|
||||
if(++Attempts > 20)
|
||||
{
|
||||
if(GdiHdr->lockfile != NULL)
|
||||
{
|
||||
DPRINT1("[%d]Locked by 0x%x (we're 0x%x)\n", Attempts, PrevThread, Thread);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* WTF?! The object is already locked by a different thread!
|
||||
|
@ -1294,39 +1282,39 @@ LockHandle:
|
|||
}
|
||||
|
||||
void INTERNAL_CALL
|
||||
GDIOBJ_SetOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle, PEPROCESS NewOwner)
|
||||
GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS NewOwner)
|
||||
{
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
HANDLE ProcessId, LockedProcessId, PrevProcId;
|
||||
PETHREAD Thread;
|
||||
PW32THREAD Thread;
|
||||
#ifdef GDI_DEBUG
|
||||
ULONG Attempts = 0;
|
||||
#endif
|
||||
|
||||
DPRINT("GDIOBJ_SetOwnership: hObj: 0x%x, NewProcess: 0x%x\n", ObjectHandle, (NewOwner ? PsGetProcessId(NewOwner) : 0));
|
||||
|
||||
Thread = PsGetCurrentThread();
|
||||
Thread = PsGetCurrentThreadWin32Thread();
|
||||
|
||||
if(!GDI_HANDLE_IS_STOCKOBJ(ObjectHandle))
|
||||
{
|
||||
ProcessId = PsGetCurrentProcessId();
|
||||
LockedProcessId = (HANDLE)((ULONG_PTR)ProcessId | 0x1);
|
||||
|
||||
Entry = GDI_HANDLE_GET_ENTRY(HandleTable, ObjectHandle);
|
||||
Entry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, ObjectHandle);
|
||||
|
||||
LockHandle:
|
||||
/* lock the object, we must not convert stock objects, so don't check!!! */
|
||||
PrevProcId = _InterlockedCompareExchangePointer((PVOID*)&Entry->ProcessId, ProcessId, LockedProcessId);
|
||||
if(PrevProcId == ProcessId)
|
||||
{
|
||||
PETHREAD PrevThread;
|
||||
PW32THREAD PrevThread;
|
||||
|
||||
if((Entry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && Entry->KernelData != NULL)
|
||||
{
|
||||
PGDIOBJHDR GdiHdr = GDIBdyToHdr(Entry->KernelData);
|
||||
POBJ Object = Entry->KernelData;
|
||||
|
||||
PrevThread = GdiHdr->LockingThread;
|
||||
if(GdiHdr->Locks == 0 || PrevThread == Thread)
|
||||
PrevThread = Object->Tid;
|
||||
if(Object->cExclusiveLock == 0 || PrevThread == Thread)
|
||||
{
|
||||
PEPROCESS OldProcess;
|
||||
PW32PROCESS W32Process;
|
||||
|
@ -1427,10 +1415,10 @@ LockHandle:
|
|||
}
|
||||
|
||||
void INTERNAL_CALL
|
||||
GDIOBJ_CopyOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ CopyFrom, HGDIOBJ CopyTo)
|
||||
GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo)
|
||||
{
|
||||
PGDI_TABLE_ENTRY FromEntry;
|
||||
PETHREAD Thread;
|
||||
PW32THREAD Thread;
|
||||
HANDLE FromProcessId, FromLockedProcessId, FromPrevProcId;
|
||||
#ifdef GDI_DEBUG
|
||||
ULONG Attempts = 0;
|
||||
|
@ -1438,11 +1426,11 @@ GDIOBJ_CopyOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ CopyFrom, HGDIOBJ Co
|
|||
|
||||
DPRINT("GDIOBJ_CopyOwnership: from: 0x%x, to: 0x%x\n", CopyFrom, CopyTo);
|
||||
|
||||
Thread = PsGetCurrentThread();
|
||||
Thread = PsGetCurrentThreadWin32Thread();
|
||||
|
||||
if(!GDI_HANDLE_IS_STOCKOBJ(CopyFrom) && !GDI_HANDLE_IS_STOCKOBJ(CopyTo))
|
||||
{
|
||||
FromEntry = GDI_HANDLE_GET_ENTRY(HandleTable, CopyFrom);
|
||||
FromEntry = GDI_HANDLE_GET_ENTRY(GdiHandleTable, CopyFrom);
|
||||
|
||||
FromProcessId = (HANDLE)((ULONG_PTR)FromEntry->ProcessId & ~0x1);
|
||||
FromLockedProcessId = (HANDLE)((ULONG_PTR)FromProcessId | 0x1);
|
||||
|
@ -1452,17 +1440,17 @@ LockHandleFrom:
|
|||
FromPrevProcId = _InterlockedCompareExchangePointer((PVOID*)&FromEntry->ProcessId, FromProcessId, FromLockedProcessId);
|
||||
if(FromPrevProcId == FromProcessId)
|
||||
{
|
||||
PETHREAD PrevThread;
|
||||
PGDIOBJHDR GdiHdr;
|
||||
PW32THREAD PrevThread;
|
||||
POBJ Object;
|
||||
|
||||
if((FromEntry->Type & ~GDI_ENTRY_REUSE_MASK) != 0 && FromEntry->KernelData != NULL)
|
||||
{
|
||||
GdiHdr = GDIBdyToHdr(FromEntry->KernelData);
|
||||
Object = FromEntry->KernelData;
|
||||
|
||||
/* save the pointer to the calling thread so we know it was this thread
|
||||
that locked the object */
|
||||
PrevThread = GdiHdr->LockingThread;
|
||||
if(GdiHdr->Locks == 0 || PrevThread == Thread)
|
||||
PrevThread = Object->Tid;
|
||||
if(Object->cExclusiveLock == 0 || PrevThread == Thread)
|
||||
{
|
||||
/* now let's change the ownership of the target object */
|
||||
|
||||
|
@ -1472,14 +1460,14 @@ LockHandleFrom:
|
|||
/* FIXME */
|
||||
if(NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)((ULONG_PTR)FromPrevProcId & ~0x1), &ProcessTo)))
|
||||
{
|
||||
GDIOBJ_SetOwnership(HandleTable, CopyTo, ProcessTo);
|
||||
GDIOBJ_SetOwnership(CopyTo, ProcessTo);
|
||||
ObDereferenceObject(ProcessTo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* mark the object as global */
|
||||
GDIOBJ_SetOwnership(HandleTable, CopyTo, NULL);
|
||||
GDIOBJ_SetOwnership(CopyTo, NULL);
|
||||
}
|
||||
|
||||
(void)_InterlockedExchangePointer((PVOID*)&FromEntry->ProcessId, FromPrevProcId);
|
||||
|
@ -1580,7 +1568,7 @@ NtGdiCreateClientObj(
|
|||
//
|
||||
INT Index;
|
||||
PGDI_TABLE_ENTRY Entry;
|
||||
HANDLE handle = GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_CLIOBJ);
|
||||
HANDLE handle = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_CLIOBJ);
|
||||
// Need to change handle type based on ulType.
|
||||
Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)handle);
|
||||
Entry = &GdiHandleTable->Entries[Index];
|
||||
|
@ -1600,7 +1588,7 @@ NtGdiDeleteClientObj(
|
|||
IN HANDLE h
|
||||
)
|
||||
{
|
||||
return GDIOBJ_FreeObj(GdiHandleTable, h, GDI_OBJECT_TYPE_CLIOBJ);
|
||||
return GDIOBJ_FreeObj(h, GDI_OBJECT_TYPE_CLIOBJ);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -63,7 +63,7 @@ PALETTE_AllocPalette(ULONG Mode,
|
|||
HPALETTE NewPalette;
|
||||
PPALGDI PalGDI;
|
||||
|
||||
NewPalette = (HPALETTE) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_PALETTE);
|
||||
NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
|
||||
if (NULL == NewPalette)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -112,7 +112,7 @@ PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
|
|||
PPALGDI PalGDI;
|
||||
unsigned i;
|
||||
|
||||
NewPalette = (HPALETTE) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_PALETTE);
|
||||
NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
|
||||
if (NULL == NewPalette)
|
||||
{
|
||||
return NULL;
|
||||
|
|
|
@ -2088,7 +2088,7 @@ RGNDATA_AllocRgn(INT n)
|
|||
HRGN hReg;
|
||||
PROSRGNDATA pReg;
|
||||
|
||||
if ((hReg = (HRGN) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_REGION)))
|
||||
if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
|
||||
{
|
||||
if (NULL != (pReg = RGNDATA_LockRgn(hReg)))
|
||||
{
|
||||
|
|
|
@ -149,7 +149,7 @@ CreateStockObjects(void)
|
|||
{
|
||||
if (NULL != StockObjects[Object])
|
||||
{
|
||||
GDIOBJ_ConvertToStockObj(GdiHandleTable, &StockObjects[Object]);
|
||||
GDIOBJ_ConvertToStockObj(&StockObjects[Object]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ CreateSysColorObjects(VOID)
|
|||
SysColorBrushes[i] = IntGdiCreateSolidBrush(SysColors[i]);
|
||||
if(SysColorBrushes[i] != NULL)
|
||||
{
|
||||
GDIOBJ_ConvertToStockObj(GdiHandleTable, (HGDIOBJ*)&SysColorBrushes[i]);
|
||||
GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorBrushes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ CreateSysColorObjects(VOID)
|
|||
SysColorPens[i] = IntGdiExtCreatePen(Pen.lopnStyle, Pen.lopnWidth.x, BS_SOLID, Pen.lopnColor, 0, 0, 0, NULL, 0, TRUE, NULL);
|
||||
if(SysColorPens[i] != NULL)
|
||||
{
|
||||
GDIOBJ_ConvertToStockObj(GdiHandleTable, (HGDIOBJ*)&SysColorPens[i]);
|
||||
GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorPens[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue