Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
if (Palette != NULL)
{
- GDIOBJ_SetOwnership(Palette, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, Palette, NULL);
}
return Palette;
BOOL STDCALL
EngDeletePalette(IN HPALETTE Palette)
{
- GDIOBJ_SetOwnership(Palette, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, Palette, PsGetCurrentProcess());
return PALETTE_FreePalette(Palette);
}
if ( !NewBitmap )
return 0;
- GDIOBJ_SetOwnership(NewBitmap, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, NewBitmap, NULL);
return NewBitmap;
}
if (NewSurface == NULL)
return 0;
- GDIOBJ_SetOwnership(NewSurface, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, NewSurface, NULL);
BitmapObj = BITMAPOBJ_LockBitmap(NewSurface);
if (! BITMAPOBJ_InitBitsLock(BitmapObj))
BOOL STDCALL
EngDeleteSurface(IN HSURF Surface)
{
- GDIOBJ_SetOwnership(Surface, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, Surface, PsGetCurrentProcess());
BITMAPOBJ_FreeBitmap(Surface);
return TRUE;
}
SURFOBJ * STDCALL
EngLockSurface(IN HSURF Surface)
{
- BITMAPOBJ *bmp = GDIOBJ_ShareLockObj(Surface, GDI_OBJECT_TYPE_BITMAP);
+ BITMAPOBJ *bmp = GDIOBJ_ShareLockObj(GdiHandleTable, Surface, GDI_OBJECT_TYPE_BITMAP);
if (bmp != NULL)
return &bmp->SurfObj;
EngUnlockSurface(IN SURFOBJ *Surface)
{
if (Surface != NULL)
- GDIOBJ_UnlockObjByPtr(Surface);
+ GDIOBJ_UnlockObjByPtr(GdiHandleTable, Surface);
}
/* EOF */
/* Internal interface */\r
\r
#define BITMAPOBJ_AllocBitmap() \\r
- ((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP))\r
+ ((HBITMAP) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_BITMAP))\r
#define BITMAPOBJ_FreeBitmap(hBMObj) \\r
- GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)\r
+ GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)\r
/* NOTE: Use shared locks! */\r
#define BITMAPOBJ_LockBitmap(hBMObj) (PBITMAPOBJ)EngLockSurface((HSURF)hBMObj)\r
#define BITMAPOBJ_UnlockBitmap(pBMObj) EngUnlockSurface(&pBMObj->SurfObj)\r
#define GDIBRUSH_IS_MASKING 0x8000 /* Pattern bitmap is used as transparent mask (?) */\r
#define GDIBRUSH_CACHED_IS_SOLID 0x80000000 \r
\r
-#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BRUSH))\r
-#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)\r
-#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))\r
-#define BRUSHOBJ_UnlockBrush(pBrush) GDIOBJ_UnlockObjByPtr(pBrush)\r
+#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_BRUSH))\r
+#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)\r
+#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))\r
+#define BRUSHOBJ_UnlockBrush(pBrush) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pBrush)\r
BOOL INTERNAL_CALL BRUSH_Cleanup(PVOID ObjectBody);\r
\r
#endif\r
/* Internal functions */\r
\r
#define DC_LockDc(hDC) \\r
- ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))\r
+ ((PDC) GDIOBJ_LockObj (GdiHandleTable, (HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))\r
#define DC_UnlockDc(pDC) \\r
- GDIOBJ_UnlockObjByPtr (pDC)\r
+ GDIOBJ_UnlockObjByPtr (GdiHandleTable, pDC)\r
\r
HDC FASTCALL RetrieveDisplayHDC(VOID);\r
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);\r
#define DCX_NOCLIPCHILDREN 0x00080000
#define DCEOBJ_AllocDCE() \
- ((HDCE) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_DCE))
-#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
-#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE))
-#define DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(pDCE)
+ ((HDCE) GDIOBJ_AllocObj (GdiHandleTable, GDI_OBJECT_TYPE_DCE))
+#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
+#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE))
+#define DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pDCE)
BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody);
PDCE FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
/* Public GDI Object/Handle definitions */\r
#include <win32k/ntgdihdl.h>\r
\r
+typedef struct _GDI_HANDLE_TABLE\r
+{\r
+ /* the table must be located at the beginning of this structure so it can be\r
+ properly mapped! */\r
+ GDI_TABLE_ENTRY Entries[GDI_HANDLE_COUNT];\r
+\r
+ PPAGED_LOOKASIDE_LIST LookasideLists;\r
+\r
+ SLIST_HEADER FreeEntriesHead;\r
+ SLIST_ENTRY FreeEntries[((GDI_HANDLE_COUNT * sizeof(GDI_TABLE_ENTRY)) << 3) /\r
+ (sizeof(SLIST_ENTRY) << 3)];\r
+} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;\r
+\r
+extern PGDI_HANDLE_TABLE GdiHandleTable;\r
+\r
typedef PVOID PGDIOBJ;\r
\r
typedef BOOL (INTERNAL_CALL *GDICLEANUPPROC)(PVOID ObjectBody);\r
#endif\r
} GDIOBJHDR, *PGDIOBJHDR;\r
\r
-BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);\r
-void INTERNAL_CALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);\r
-void INTERNAL_CALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);\r
-BOOL INTERNAL_CALL GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);\r
-VOID INTERNAL_CALL GDIOBJ_UnlockObjByPtr(PGDIOBJ Object);\r
+BOOL INTERNAL_CALL GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle);\r
+void INTERNAL_CALL GDIOBJ_SetOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle, PEPROCESS Owner);\r
+void INTERNAL_CALL GDIOBJ_CopyOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ CopyFrom, HGDIOBJ CopyTo);\r
+BOOL INTERNAL_CALL GDIOBJ_ConvertToStockObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ *hObj);\r
+VOID INTERNAL_CALL GDIOBJ_UnlockObjByPtr(PGDI_HANDLE_TABLE HandleTable, PGDIOBJ Object);\r
\r
#define GDIOBJ_GetObjectType(Handle) \\r
GDI_HANDLE_GET_TYPE(Handle)\r
#ifdef GDI_DEBUG\r
\r
/* a couple macros for debugging GDIOBJ locking */\r
-#define GDIOBJ_AllocObj(ty) GDIOBJ_AllocObjDbg(__FILE__,__LINE__,ty)\r
-#define GDIOBJ_FreeObj(obj,ty) GDIOBJ_FreeObjDbg(__FILE__,__LINE__,obj,ty)\r
-#define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,ty)\r
-#define GDIOBJ_ShareLockObj(obj,ty) GDIOBJ_ShareLockObjDbg(__FILE__,__LINE__,obj,ty)\r
+#define GDIOBJ_AllocObj(ty) GDIOBJ_AllocObjDbg(GdiHandleTable,__FILE__,__LINE__,ty)\r
+#define GDIOBJ_FreeObj(obj,ty) GDIOBJ_FreeObjDbg(GdiHandleTable,__FILE__,__LINE__,obj,ty)\r
+#define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(GdiHandleTable,__FILE__,__LINE__,obj,ty)\r
+#define GDIOBJ_ShareLockObj(obj,ty) GDIOBJ_ShareLockObjDbg(GdiHandleTable,__FILE__,__LINE__,obj,ty)\r
\r
-HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObjDbg(const char* file, int line, ULONG ObjectType);\r
-BOOL INTERNAL_CALL GDIOBJ_FreeObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);\r
-PGDIOBJ INTERNAL_CALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);\r
-PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);\r
+HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObjDbg(PGDI_HANDLE_TABLE HandleTable, const char* file, int line, ULONG ObjectType);\r
+BOOL INTERNAL_CALL GDIOBJ_FreeObjDbg (PGDI_HANDLE_TABLE HandleTable, const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);\r
+PGDIOBJ INTERNAL_CALL GDIOBJ_LockObjDbg (PGDI_HANDLE_TABLE HandleTable, const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);\r
+PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObjDbg (PGDI_HANDLE_TABLE HandleTable, const char* file, int line, HGDIOBJ hObj, DWORD ObjectType);\r
\r
#else /* !GDI_DEBUG */\r
\r
-HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(ULONG ObjectType);\r
-BOOL INTERNAL_CALL GDIOBJ_FreeObj (HGDIOBJ hObj, DWORD ObjectType);\r
-PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType);\r
-PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType);\r
+HGDIOBJ INTERNAL_CALL GDIOBJ_AllocObj(PGDI_HANDLE_TABLE HandleTable, ULONG ObjectType);\r
+BOOL INTERNAL_CALL GDIOBJ_FreeObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType);\r
+PGDIOBJ INTERNAL_CALL GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType);\r
+PGDIOBJ INTERNAL_CALL GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType);\r
\r
#endif /* GDI_DEBUG */\r
\r
-PVOID INTERNAL_CALL GDI_MapHandleTable(PEPROCESS Process);\r
+PVOID INTERNAL_CALL GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process);\r
\r
#define GDIOBJFLAG_DEFAULT (0x0)\r
#define GDIOBJFLAG_IGNOREPID (0x1)\r
\
}
-VOID INTERNAL_CALL InitGdiObjectHandleTable (VOID);
-
VOID FASTCALL CreateStockObjects (VOID);
VOID FASTCALL CreateSysColorObjects (VOID);
ULONG Blue);
HPALETTE FASTCALL PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors);
-#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
-#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
-#define PALETTE_UnlockPalette(pPalette) GDIOBJ_UnlockObjByPtr(pPalette)
+#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)
BOOL INTERNAL_CALL PALETTE_Cleanup(PVOID ObjectBody);
HPALETTE FASTCALL PALETTE_Init (VOID);
\r
/* Internal interface */\r
\r
-#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PEN))\r
-#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)\r
-#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))\r
-#define PENOBJ_UnlockPen(pPenObj) GDIOBJ_UnlockObjByPtr(pPenObj)\r
+#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_PEN))\r
+#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)\r
+#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))\r
+#define PENOBJ_UnlockPen(pPenObj) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pPenObj)\r
\r
#endif\r
} ROSRGNDATA, *PROSRGNDATA, *LPROSRGNDATA;\r
\r
\r
-#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)\r
-#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION))\r
-#define RGNDATA_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr(pRgn)\r
+#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)\r
+#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj(GdiHandleTable, (HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION))\r
+#define RGNDATA_UnlockRgn(pRgn) GDIOBJ_UnlockObjByPtr(GdiHandleTable, pRgn)\r
HRGN FASTCALL RGNDATA_AllocRgn(INT n);\r
BOOL INTERNAL_CALL RGNDATA_Cleanup(PVOID ObjectBody);\r
\r
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS Win32k subsystem
- * PURPOSE: shared sections
- * FILE: include/ssec.h
- * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
- *
- */
-
-#ifndef _WIN32K_SSEC_H
-#define _WIN32K_SSEC_H
-
-typedef struct _SHARED_SECTION
-{
- PSECTION_OBJECT SectionObject;
- PVOID SystemMappedBase;
- ULONG ViewSize;
-} SHARED_SECTION, *PSHARED_SECTION;
-
-typedef struct _SHARED_SECTIONS_ARRAY
-{
- struct _SHARED_SECTIONS_ARRAY *Next;
- ULONG nEntries;
- SHARED_SECTION SharedSection[0];
-} SHARED_SECTIONS_ARRAY, *PSHARED_SECTIONS_ARRAY;
-
-typedef struct _SHARED_SECTION_POOL
-{
- FAST_MUTEX Lock;
- ULONG PoolSize;
- ULONG PoolFree;
- ULONG SharedSectionCount;
- SHARED_SECTIONS_ARRAY SectionsArray;
-} SHARED_SECTION_POOL, *PSHARED_SECTION_POOL;
-
-NTSTATUS INTERNAL_CALL
-IntUserCreateSharedSectionPool(IN ULONG MaximumPoolSize,
- IN PSHARED_SECTION_POOL *SharedSectionPool);
-
-VOID INTERNAL_CALL
-IntUserFreeSharedSectionPool(IN PSHARED_SECTION_POOL SharedSectionPool);
-
-NTSTATUS INTERNAL_CALL
-InUserDeleteSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN PVOID SystemMappedBase);
-
-NTSTATUS INTERNAL_CALL
-IntUserCreateSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN OUT PVOID *SystemMappedBase,
- IN OUT ULONG *SharedSectionSize);
-
-NTSTATUS INTERNAL_CALL
-IntUserMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN PEPROCESS Process,
- IN PVOID SystemMappedBase,
- IN PLARGE_INTEGER SectionOffset OPTIONAL,
- IN OUT PVOID *UserMappedBase,
- IN PULONG ViewSize OPTIONAL,
- IN BOOLEAN ReadOnly);
-
-NTSTATUS INTERNAL_CALL
-IntUserUnMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN PEPROCESS Process,
- IN PVOID SystemMappedBase,
- IN PVOID UserMappedBase);
-
-extern PSHARED_SECTION_POOL SessionSharedSectionPool;
-
-#endif /* ! defined(_WIN32K_SSEC_H) */
-
-/* EOF */
-
/* Internal interface */
#define TEXTOBJ_AllocText() \
- ((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 (pBMObj)
+ ((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)
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle);
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont);
/* Internal Win32k Headers */
#include <include/ntuser.h>
#include <include/win32.h>
-#include <include/ssec.h>
#include <include/accelerator.h>
#include <include/callback.h>
#include <include/class.h>
#define NDEBUG
#include <debug.h>
-BOOL INTERNAL_CALL GDI_CleanupForProcess (struct _EPROCESS *Process);
+PGDI_HANDLE_TABLE INTERNAL_CALL GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject);
+BOOL INTERNAL_CALL GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process);
+/* FIXME */
+PGDI_HANDLE_TABLE GdiHandleTable = NULL;
+PSECTION_OBJECT GdiTableSection = NULL;
extern ULONG_PTR Win32kSSDT[];
extern UCHAR Win32kSSPT[];
extern ULONG Win32kNumberOfSysCalls;
-PSHARED_SECTION_POOL SessionSharedSectionPool = NULL;
-
NTSTATUS
STDCALL
Win32kProcessCallback(struct _EPROCESS *Process,
if(Process->Peb != NULL)
{
/* map the gdi handle table to user land */
- Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(Process);
+ Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(GdiTableSection, Process);
}
/* setup process flags */
/* no process windows should exist at this point, or the function will assert! */
DestroyProcessClasses(Win32Process);
- GDI_CleanupForProcess(Process);
+ GDI_CleanupForProcess(GdiHandleTable, Process);
co_IntGraphicsCheck(FALSE);
*/
PsEstablishWin32Callouts(&CalloutData);
- Status = IntUserCreateSharedSectionPool(48 * 1024 * 1024, /* 48 MB by default */
- &SessionSharedSectionPool);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Failed to initialize the shared section pool: Status 0x%x\n", Status);
- }
-
Status = InitUserImpl();
if (!NT_SUCCESS(Status))
{
return(Status);
}
- InitGdiObjectHandleTable ();
+ GdiHandleTable = GDIOBJ_iAllocHandleTable(&GdiTableSection);
+ if (GdiHandleTable == NULL)
+ {
+ DPRINT1("Failed to initialize the GDI handle table.\n");
+ return STATUS_UNSUCCESSFUL;
+ }
/* Initialize FreeType library */
if (! InitFontSupport())
/* swtich this off to get rid of all dx debug msg */
#define DX_DEBUG
+#define DdHandleTable GdiHandleTable
+
/************************************************************************/
/* DIRECT DRAW OBJECT */
return NULL;
}
- hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
+ hDirectDraw = GDIOBJ_AllocObj(DdHandleTable, GDI_OBJECT_TYPE_DIRECTDRAW);
if (!hDirectDraw)
{
/* No more memmory */
return NULL;
}
- pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
+ pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
if (!pDirectDraw)
{
/* invalid handle */
/* DD_PALETTECALLBACKS setup*/
RtlMoveMemory(&pDirectDraw->Pal, &surface_callbacks, sizeof(DD_PALETTECALLBACKS));
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
DC_UnlockDc(pDC);
return hDirectDraw;
#ifdef DX_DEBUG
DPRINT1("NtGdiDdDeleteDirectDrawObject\n");
#endif
- return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ return GDIOBJ_FreeObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
}
BOOL STDCALL NtGdiDdQueryDirectDrawObject(
}
- pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
if (!pDirectDraw)
#ifdef DX_DEBUG
DPRINT1(" Fail to get DirectDraw driver info \n");
#endif
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return FALSE;
}
}
#endif
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return TRUE;
}
{
DWORD ddRVal = 0;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdGetDriverInfo\n");
#endif
else
ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DPRINT1("NtGdiDdCreateSurface\n");
#endif
- pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
if (pDirectDraw == NULL)
{
#ifdef DX_DEBUG
/* But back the orignal PDev */
puCreateSurfaceData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
#endif
- pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
if (pDirectDraw == NULL)
return DDHAL_DRIVER_NOTHANDLED;
/* But back the orignal PDev */
puWaitForVerticalBlankData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdCanCreateSurface\n");
#endif
/* But back the orignal PDev */
puCanCreateSurfaceData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdGetScanLine\n");
#endif
/* But back the orignal PDev */
puGetScanLineData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
{
DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdDestroySurface\n");
#endif
}
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceTarget, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurfaceTarget, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdFlip\n");
#endif
/* But back the orignal PDev */
puFlipData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdLock\n");
#endif
/* But back the orignal PDev */
puLockData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdUnlock\n");
#endif
/* But back the orignal PDev */
puUnlockData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDest, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurfaceDest, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdBlt\n");
#endif
/* But back the orignal PDev */
puBltData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdSetColorKey\n");
#endif
/* But back the orignal PDev */
puSetColorKeyData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceAttached, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurfaceAttached, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdAddAttachedSurface\n");
#endif
/* But back the orignal PDev */
puAddAttachedSurfaceData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdGetBltStatus\n");
#endif
/* But back the orignal PDev */
puGetBltStatusData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdGetFlipStatus\n");
#endif
/* But back the orignal PDev */
puGetFlipStatusData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdUpdateOverlay\n");
#endif
/* But back the orignal PDev */
puUpdateOverlayData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hSurfaceDestination, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdSetOverlayPosition\n");
#endif
/* But back the orignal PDev */
puSetOverlayPositionData->lpDD = lgpl;
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;
}
BOOL bComplete
)
{
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
PDD_SURFACE pSurface;
#ifdef DX_DEBUG
DPRINT1("NtGdiDdCreateSurfaceObject\n");
return NULL;
if (!hSurface)
- hSurface = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DD_SURFACE);
+ hSurface = GDIOBJ_AllocObj(DdHandleTable, GDI_OBJECT_TYPE_DD_SURFACE);
- pSurface = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
+ pSurface = GDIOBJ_LockObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
/* FIXME - Handle pSurface == NULL!!!! */
RtlMoveMemory(&pSurface->Local, puSurfaceLocal, sizeof(DD_SURFACE_LOCAL));
// FIXME: figure out how to use this
pSurface->bComplete = bComplete;
- GDIOBJ_UnlockObjByPtr(pSurface);
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pSurface);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return hSurface;
}
/* FIXME add right GDI_OBJECT_TYPE_ for everthing for now
we are using same type */
/* return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE); */
- return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
+ return GDIOBJ_FreeObj(DdHandleTable, hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
}
DWORD ddRVal = DDHAL_DRIVER_NOTHANDLED;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdGetAvailDriverMemory\n");
#endif
/* make the call */
// ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData);
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
/* But back the orignal PDev */
DWORD ddRVal;
PDD_DIRECTDRAW_GLOBAL lgpl;
- PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
+ PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
#ifdef DX_DEBUG
DPRINT1("NtGdiDdSetExclusiveMode\n");
/* make the call */
ddRVal = pDirectDraw->DdSetExclusiveMode(puSetExclusiveModeData);
- GDIOBJ_UnlockObjByPtr(pDirectDraw);
+ GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
/* But back the orignal PDev */
puSetExclusiveModeData->lpDD = lgpl;
/* delete bitmaps */
if(bmpMask)
{
- GDIOBJ_SetOwnership(bmpMask, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, bmpMask, PsGetCurrentProcess());
NtGdiDeleteObject(bmpMask);
}
if(bmpColor)
{
- GDIOBJ_SetOwnership(bmpColor, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, bmpColor, PsGetCurrentProcess());
NtGdiDeleteObject(bmpColor);
}
CurIcon->Size.cx = bmp->SurfObj.sizlBitmap.cx;
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy;
BITMAPOBJ_UnlockBitmap(bmp);
- GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmColor, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmColor, NULL);
}
if(CurIcon->IconInfo.hbmMask &&
(bmp = BITMAPOBJ_LockBitmap(CurIcon->IconInfo.hbmMask)))
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
}
BITMAPOBJ_UnlockBitmap(bmp);
- GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmMask, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmMask, NULL);
}
}
else
CurIcon->Size.cx = bmp->SurfObj.sizlBitmap.cx;
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy;
BITMAPOBJ_UnlockBitmap(bmp);
- GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmColor, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmColor, NULL);
}
else
{
CurIcon->Size.cy = bmp->SurfObj.sizlBitmap.cy / 2;
BITMAPOBJ_UnlockBitmap(bmp);
- GDIOBJ_SetOwnership(CurIcon->IconInfo.hbmMask, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmMask, NULL);
}
Ret = TRUE;
BITMAPOBJ_UnlockBitmap(bmp);
/* change the bitmap's ownership */
- GDIOBJ_SetOwnership(hNewBitmap, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, hNewBitmap, NULL);
}
hOldBitmap = (HBITMAP)InterlockedExchange((LONG*)&WinStaObject->hbmWallpaper, (LONG)hNewBitmap);
if(hOldBitmap != NULL)
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
hRgnWindow, RGN_AND) == NULLREGION)
{
- GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
NtGdiDeleteObject(Window->UpdateRegion);
Window->UpdateRegion = NULL;
if (!(Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT))
if ((HANDLE) 1 != TempRegion && NULL != TempRegion)
{
/* NOTE: The region can already be deleted! */
- GDIOBJ_FreeObj(TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
+ GDIOBJ_FreeObj(GdiHandleTable, TempRegion, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
}
}
if (Window->UpdateRegion == NULL)
{
Window->UpdateRegion = NtGdiCreateRectRgn(0, 0, 0, 0);
- GDIOBJ_SetOwnership(Window->UpdateRegion, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, NULL);
}
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
hRgn, RGN_OR) == NULLREGION)
{
- GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
NtGdiDeleteObject(Window->UpdateRegion);
Window->UpdateRegion = NULL;
}
if (NtGdiCombineRgn(Window->UpdateRegion, Window->UpdateRegion,
hRgn, RGN_DIFF) == NULLREGION)
{
- GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
NtGdiDeleteObject(Window->UpdateRegion);
Window->UpdateRegion = NULL;
}
if (hRgn != (HANDLE)1 && hRgn != NULL)
{
/* NOTE: The region can already by deleted! */
- GDIOBJ_FreeObj(hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
+ GDIOBJ_FreeObj(GdiHandleTable, hRgn, GDI_OBJECT_TYPE_REGION | GDI_OBJECT_TYPE_SILENT);
}
}
{
IntGetClientRect(Window, &Ps.rcPaint);
}
- GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
Window->UpdateRegion = NULL;
}
else
+++ /dev/null
-/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998 - 2005 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: shared sections support
- * FILE: subsys/win32k/misc/ssec.c
- * PROGRAMER: Thomas Weidenmueller <w3seek@reactos.com>
- */
-
-#include <w32k.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/*
- * FIXME - instead of mapping the memory into system space using
- * MmMapViewInSystemSpace() we should rather use
- * MmMapViewInSessionSpace() to map it into session space!
- */
-
-NTSTATUS INTERNAL_CALL
-IntUserCreateSharedSectionPool(IN ULONG MaximumPoolSize,
- IN PSHARED_SECTION_POOL *SharedSectionPool)
-{
- PSHARED_SECTION_POOL Pool;
- ULONG PoolStructSize;
-
- ASSERT(SharedSectionPool);
-
- PoolStructSize = ROUND_UP(sizeof(SHARED_SECTION_POOL), PAGE_SIZE);
- Pool = ExAllocatePoolWithTag(NonPagedPool,
- PoolStructSize,
- TAG_SSECTPOOL);
- if(Pool != NULL)
- {
- RtlZeroMemory(Pool, PoolStructSize);
-
- /* initialize the session heap */
- ExInitializeFastMutex(&Pool->Lock);
- Pool->PoolSize = ROUND_UP(MaximumPoolSize, PAGE_SIZE);
- Pool->PoolFree = Pool->PoolSize;
- Pool->SharedSectionCount = 0;
- Pool->SectionsArray.Next = NULL;
- Pool->SectionsArray.nEntries = ((PoolStructSize - sizeof(SHARED_SECTION_POOL)) /
- sizeof(SHARED_SECTION)) - 1;
-
- ASSERT(Pool->SectionsArray.nEntries > 0);
-
- *SharedSectionPool = Pool;
-
- return STATUS_SUCCESS;
- }
-
- return STATUS_INSUFFICIENT_RESOURCES;
-}
-
-
-VOID INTERNAL_CALL
-IntUserFreeSharedSectionPool(IN PSHARED_SECTION_POOL SharedSectionPool)
-{
- PSHARED_SECTIONS_ARRAY Array, OldArray;
- PSHARED_SECTION SharedSection, LastSharedSection;
-
- ASSERT(SharedSectionPool);
-
- Array = &SharedSectionPool->SectionsArray;
-
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&SharedSectionPool->Lock);
- while(SharedSectionPool->SharedSectionCount > 0 && Array != NULL)
- {
- for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
- SharedSection != LastSharedSection && SharedSectionPool->SharedSectionCount > 0;
- SharedSection++)
- {
- if(SharedSection->SectionObject != NULL)
- {
- ASSERT(SharedSection->SystemMappedBase);
-
- /* FIXME - use MmUnmapViewInSessionSpace() once implemented! */
- MmUnmapViewInSystemSpace(SharedSection->SystemMappedBase);
- /* dereference the keep-alive reference so the section get's deleted */
- ObDereferenceObject(SharedSection->SectionObject);
-
- SharedSectionPool->SharedSectionCount--;
- }
- }
-
- OldArray = Array;
- Array = Array->Next;
-
- /* all shared sections in this array were freed, link the following array to
- the main session heap and free this array */
- SharedSectionPool->SectionsArray.Next = Array;
- ExFreePool(OldArray);
- }
-
- ASSERT(SharedSectionPool->SectionsArray.Next == NULL);
- ASSERT(SharedSectionPool->SharedSectionCount == 0);
-
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
-}
-
-
-NTSTATUS INTERNAL_CALL
-IntUserCreateSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN OUT PVOID *SystemMappedBase,
- IN OUT ULONG *SharedSectionSize)
-{
- PSHARED_SECTIONS_ARRAY Array, LastArray;
- PSHARED_SECTION FreeSharedSection, SharedSection, LastSharedSection;
- LARGE_INTEGER SectionSize;
- ULONG Size;
- NTSTATUS Status;
-
- ASSERT(SharedSectionPool && SharedSectionSize && (*SharedSectionSize) > 0 && SystemMappedBase);
-
- FreeSharedSection = NULL;
-
- Size = ROUND_UP(*SharedSectionSize, PAGE_SIZE);
-
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&SharedSectionPool->Lock);
-
- if(Size > SharedSectionPool->PoolFree)
- {
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
- DPRINT1("Shared Section Pool limit (0x%x KB) reached, attempted to allocate a 0x%x KB shared section!\n",
- SharedSectionPool->PoolSize / 1024, (*SharedSectionSize) / 1024);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- /* walk the array to find a free entry */
- for(Array = &SharedSectionPool->SectionsArray, LastArray = Array;
- Array != NULL && FreeSharedSection == NULL;
- Array = Array->Next)
- {
- LastArray = Array;
-
- for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
- SharedSection != LastSharedSection;
- SharedSection++)
- {
- if(SharedSection->SectionObject == NULL)
- {
- FreeSharedSection = SharedSection;
- break;
- }
- }
-
- if(Array->Next != NULL)
- {
- LastArray = Array;
- }
- }
-
- ASSERT(LastArray);
-
- if(FreeSharedSection == NULL)
- {
- ULONG nNewEntries;
- PSHARED_SECTIONS_ARRAY NewArray;
-
- ASSERT(LastArray->Next == NULL);
-
- /* couldn't find a free entry in the array, extend the array */
-
- nNewEntries = ((PAGE_SIZE - sizeof(SHARED_SECTIONS_ARRAY)) / sizeof(SHARED_SECTION)) + 1;
- NewArray = ExAllocatePoolWithTag(NonPagedPool,
- sizeof(SHARED_SECTIONS_ARRAY) + ((nNewEntries - 1) *
- sizeof(SHARED_SECTION)),
- TAG_SSECTPOOL);
- if(NewArray == NULL)
- {
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
- DPRINT1("Failed to allocate new array for shared sections!\n");
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- NewArray->nEntries = nNewEntries;
- NewArray->Next = NULL;
- LastArray->Next = NewArray;
-
- Array = NewArray;
- FreeSharedSection = &Array->SharedSection[0];
- }
-
- ASSERT(FreeSharedSection);
-
- /* now allocate a real section */
-
- SectionSize.QuadPart = Size;
- Status = MmCreateSection((PVOID)&FreeSharedSection->SectionObject,
- SECTION_ALL_ACCESS,
- NULL,
- &SectionSize,
- PAGE_EXECUTE_READWRITE,
- SEC_COMMIT,
- NULL,
- NULL);
- if(NT_SUCCESS(Status))
- {
- Status = MmMapViewInSystemSpace(FreeSharedSection->SectionObject,
- &FreeSharedSection->SystemMappedBase,
- &FreeSharedSection->ViewSize);
- if(NT_SUCCESS(Status))
- {
- (*SharedSectionSize) -= Size;
- SharedSectionPool->SharedSectionCount++;
-
- *SystemMappedBase = FreeSharedSection->SystemMappedBase;
- *SharedSectionSize = FreeSharedSection->ViewSize;
- }
- else
- {
- ObDereferenceObject(FreeSharedSection->SectionObject);
- FreeSharedSection->SectionObject = NULL;
- DPRINT1("Failed to map the shared section into system space! Status 0x%x\n", Status);
- }
- }
-
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
-
- return Status;
-}
-
-
-NTSTATUS INTERNAL_CALL
-InUserDeleteSharedSection(PSHARED_SECTION_POOL SharedSectionPool,
- PVOID SystemMappedBase)
-{
- PSHARED_SECTIONS_ARRAY Array;
- PSECTION_OBJECT SectionObject;
- PSHARED_SECTION SharedSection, LastSharedSection;
- NTSTATUS Status;
-
- ASSERT(SharedSectionPool && SystemMappedBase);
-
- SectionObject = NULL;
-
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&SharedSectionPool->Lock);
-
- for(Array = &SharedSectionPool->SectionsArray;
- Array != NULL && SectionObject == NULL;
- Array = Array->Next)
- {
- for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
- SharedSection != LastSharedSection;
- SharedSection++)
- {
- if(SharedSection->SystemMappedBase == SystemMappedBase)
- {
- SectionObject = SharedSection->SectionObject;
- SharedSection->SectionObject = NULL;
- SharedSection->SystemMappedBase = NULL;
-
- ASSERT(SharedSectionPool->SharedSectionCount > 0);
- SharedSectionPool->SharedSectionCount--;
- break;
- }
- }
- }
-
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
-
- if(SectionObject != NULL)
- {
- Status = MmUnmapViewInSystemSpace(SystemMappedBase);
- ObDereferenceObject(SectionObject);
- }
- else
- {
- DPRINT1("Couldn't find and delete a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
- Status = STATUS_UNSUCCESSFUL;
- }
-
- return Status;
-}
-
-
-NTSTATUS INTERNAL_CALL
-IntUserMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN PEPROCESS Process,
- IN PVOID SystemMappedBase,
- IN PLARGE_INTEGER SectionOffset OPTIONAL,
- IN OUT PVOID *UserMappedBase,
- IN PULONG ViewSize OPTIONAL,
- IN BOOLEAN ReadOnly)
-{
- PSHARED_SECTIONS_ARRAY Array;
- PSECTION_OBJECT SectionObject;
- PSHARED_SECTION SharedSection, LastSharedSection;
- NTSTATUS Status;
-
- ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
-
- SectionObject = NULL;
- SharedSection = NULL;
-
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&SharedSectionPool->Lock);
-
- for(Array = &SharedSectionPool->SectionsArray;
- Array != NULL && SectionObject == NULL;
- Array = Array->Next)
- {
- for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
- SharedSection != LastSharedSection;
- SharedSection++)
- {
- if(SharedSection->SystemMappedBase == SystemMappedBase)
- {
- SectionObject = SharedSection->SectionObject;
- break;
- }
- }
- }
-
- if(SectionObject != NULL)
- {
- ULONG RealViewSize = (ViewSize ? min(*ViewSize, SharedSection->ViewSize) : SharedSection->ViewSize);
-
- ObReferenceObjectByPointer(SectionObject,
- (ReadOnly ? SECTION_MAP_READ : SECTION_MAP_READ | SECTION_MAP_WRITE),
- NULL,
- KernelMode);
-
- Status = MmMapViewOfSection(SectionObject,
- Process,
- UserMappedBase,
- 0,
- 0,
- SectionOffset,
- &RealViewSize,
- ViewUnmap, /* not sure if we should inherit it... */
- MEM_COMMIT,
- (ReadOnly ? PAGE_READONLY : PAGE_READWRITE));
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("Failed to map shared section (readonly=%d) into user memory! Status: 0x%x\n", ReadOnly, Status);
- }
- }
- else
- {
- DPRINT1("Couldn't find and map a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
- Status = STATUS_UNSUCCESSFUL;
- }
-
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
-
- return Status;
-}
-
-
-NTSTATUS INTERNAL_CALL
-IntUserUnMapSharedSection(IN PSHARED_SECTION_POOL SharedSectionPool,
- IN PEPROCESS Process,
- IN PVOID SystemMappedBase,
- IN PVOID UserMappedBase)
-{
- PSHARED_SECTIONS_ARRAY Array;
- PSECTION_OBJECT SectionObject;
- PSHARED_SECTION SharedSection, LastSharedSection;
- NTSTATUS Status;
-
- ASSERT(SharedSectionPool && Process && SystemMappedBase && UserMappedBase);
-
- SectionObject = NULL;
-
- ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&SharedSectionPool->Lock);
-
- for(Array = &SharedSectionPool->SectionsArray;
- Array != NULL && SectionObject == NULL;
- Array = Array->Next)
- {
- for(SharedSection = Array->SharedSection, LastSharedSection = SharedSection + Array->nEntries;
- SharedSection != LastSharedSection;
- SharedSection++)
- {
- if(SharedSection->SystemMappedBase == SystemMappedBase)
- {
- SectionObject = SharedSection->SectionObject;
- break;
- }
- }
- }
-
- ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&SharedSectionPool->Lock);
-
- if(SectionObject != NULL)
- {
- Status = MmUnmapViewOfSection(Process,
- UserMappedBase);
- ObDereferenceObject(SectionObject);
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("Failed to unmap shared section UserMappedBase=0x%x! Status: 0x%x\n", UserMappedBase, Status);
- }
- }
- else
- {
- DPRINT1("Couldn't find and unmap a shared section with SystemMappedBase=0x%x!\n", SystemMappedBase);
- Status = STATUS_UNSUCCESSFUL;
- }
-
- return Status;
-}
defaultDCstate = NtGdiGetDCState(Dce->hDC);
DC_SetOwnership(defaultDCstate, NULL);
}
- GDIOBJ_SetOwnership(Dce->Self, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, Dce->Self, NULL);
DC_SetOwnership(Dce->hDC, NULL);
Dce->hwndCurrent = (Window ? Window->hSelf : NULL);
Dce->hClipRgn = NULL;
SetDCHook(dce->hDC, NULL, 0L);
#endif
- if(Force && !GDIOBJ_OwnedByCurrentProcess(dce->hDC))
+ if(Force && !GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, dce->hDC))
{
- GDIOBJ_SetOwnership(dce->Self, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, dce->Self, PsGetCurrentProcess());
DC_SetOwnership(dce->hDC, PsGetCurrentProcess());
}
if (hBitmap == NULL)
return 0;
- Bitmap = GDIOBJ_LockObj(hBitmap, GDI_OBJECT_TYPE_BITMAP);
+ Bitmap = GDIOBJ_LockObj(GdiHandleTable, hBitmap, GDI_OBJECT_TYPE_BITMAP);
if (Bitmap == NULL)
return 0;
ExFreePool (buf);
}
- GDIOBJ_UnlockObjByPtr(Bitmap);
+ GDIOBJ_UnlockObjByPtr(GdiHandleTable, Bitmap);
return res;
}
if(pBrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
{
ASSERT(pBrush->hbmPattern);
- GDIOBJ_SetOwnership(pBrush->hbmPattern, PsGetCurrentProcess());
+ GDIOBJ_SetOwnership(GdiHandleTable, pBrush->hbmPattern, PsGetCurrentProcess());
NtGdiDeleteObject(pBrush->hbmPattern);
}
BrushObject->hbmPattern = hPattern;
/* FIXME: Fill in the rest of fields!!! */
- GDIOBJ_SetOwnership(hPattern, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
BRUSHOBJ_UnlockBrush(BrushObject);
BrushObject->hbmPattern = hPattern;
BrushObject->BrushAttr.lbColor = Color & 0xFFFFFF;
- GDIOBJ_SetOwnership(hPattern, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
BRUSHOBJ_UnlockBrush(BrushObject);
BrushObject->hbmPattern = hPattern;
/* FIXME: Fill in the rest of fields!!! */
- GDIOBJ_SetOwnership(hPattern, NULL);
+ GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
BRUSHOBJ_UnlockBrush(BrushObject);
if (dc->w.hVisRgn == NULL)
{
dc->w.hVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
- GDIOBJ_CopyOwnership(hdc, dc->w.hVisRgn);
+ GDIOBJ_CopyOwnership(GdiHandleTable, hdc, dc->w.hVisRgn);
}
else
{
if(!hgdiobj)
return Ret;
- ptr = GDIOBJ_LockObj(hgdiobj, GDI_OBJECT_TYPE_DONTCARE);
+ ptr = GDIOBJ_LockObj(GdiHandleTable, hgdiobj, GDI_OBJECT_TYPE_DONTCARE);
if (ptr == 0)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
break;
}
- GDIOBJ_UnlockObjByPtr(ptr);
+ GDIOBJ_UnlockObjByPtr(GdiHandleTable, ptr);
return Ret;
}
{
PDC DCToDelete;
- if (!GDIOBJ_OwnedByCurrentProcess(DCHandle))
+ if (!GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, DCHandle))
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
INT Result = 0;
DWORD ObjectType;
- GdiObject = GDIOBJ_LockObj(Handle, GDI_OBJECT_TYPE_DONTCARE);
+ GdiObject = GDIOBJ_LockObj(GdiHandleTable, Handle, GDI_OBJECT_TYPE_DONTCARE);
if (NULL == GdiObject)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
break;
}
- GDIOBJ_UnlockObjByPtr(GdiObject);
+ GDIOBJ_UnlockObjByPtr(GdiHandleTable, GdiObject);
return Result;
}
INT result;
DWORD objectType;
- ptr = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE);
+ ptr = GDIOBJ_LockObj(GdiHandleTable, handle, GDI_OBJECT_TYPE_DONTCARE);
if (ptr == 0)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
result = 0;
break;
}
- GDIOBJ_UnlockObjByPtr(ptr);
+ GDIOBJ_UnlockObjByPtr(GdiHandleTable, ptr);
return result;
}
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
}
- hDC = (HDC) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DC);
+ hDC = (HDC) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_DC);
if (hDC == NULL)
{
if(Buf)
VOID FASTCALL
DC_FreeDC(HDC DCToFree)
{
- if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC))
+ if (!GDIOBJ_FreeObj(GdiHandleTable, DCToFree, GDI_OBJECT_TYPE_DC))
{
DPRINT("DC_FreeDC failed\n");
}
{
PDC DC;
- GDIOBJ_SetOwnership(hDC, Owner);
+ GDIOBJ_SetOwnership(GdiHandleTable, hDC, Owner);
DC = DC_LockDc(hDC);
if (NULL != DC)
{
if (NULL != DC->w.hClipRgn)
{
- GDIOBJ_CopyOwnership(hDC, DC->w.hClipRgn);
+ GDIOBJ_CopyOwnership(GdiHandleTable, hDC, DC->w.hClipRgn);
}
if (NULL != DC->w.hVisRgn)
{
- GDIOBJ_CopyOwnership(hDC, DC->w.hVisRgn);
+ GDIOBJ_CopyOwnership(GdiHandleTable, hDC, DC->w.hVisRgn);
}
if (NULL != DC->w.hGCClipRgn)
{
- GDIOBJ_CopyOwnership(hDC, DC->w.hGCClipRgn);
+ GDIOBJ_CopyOwnership(GdiHandleTable, hDC, DC->w.hGCClipRgn);
}
DC_UnlockDc(DC);
}
/* apparently the first 10 entries are never used in windows as they are empty */
#define RESERVE_ENTRIES_COUNT 10
-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];
-
- PPAGED_LOOKASIDE_LIST LookasideLists;
-
- SLIST_HEADER FreeEntriesHead;
- SLIST_ENTRY FreeEntries[((GDI_HANDLE_COUNT * sizeof(GDI_TABLE_ENTRY)) << 3) /
- (sizeof(SLIST_ENTRY) << 3)];
-} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
-
typedef struct
{
ULONG Type;
/*
* Dummy GDI Cleanup Callback
*/
-BOOL INTERNAL_CALL
+static BOOL INTERNAL_CALL
GDI_CleanupDummy(PVOID ObjectBody)
{
return TRUE;
/* Testing shows that regions are the most used GDIObj type,
so put that one first for performance */
-const
+static const
GDI_OBJ_INFO ObjInfo[] =
{
/* Type */ /* Size */ /* CleanupProc */
#define OBJTYPE_COUNT (sizeof(ObjInfo) / sizeof(ObjInfo[0]))
-static PGDI_HANDLE_TABLE HandleTable = NULL;
static LARGE_INTEGER ShortDelay;
#define DelayExecution() \
* Allocate GDI object table.
* \param Size - number of entries in the object table.
*/
-static PGDI_HANDLE_TABLE INTERNAL_CALL
-GDIOBJ_iAllocHandleTable(VOID)
+PGDI_HANDLE_TABLE INTERNAL_CALL
+GDIOBJ_iAllocHandleTable(OUT PSECTION_OBJECT *SectionObject)
{
- PGDI_HANDLE_TABLE handleTable;
- ULONG htSize;
+ PGDI_HANDLE_TABLE HandleTable = NULL;
+ LARGE_INTEGER htSize;
UINT ObjType;
UINT i;
+ ULONG ViewSize = 0;
PGDI_TABLE_ENTRY Entry;
+ NTSTATUS Status;
+
+ ASSERT(SectionObject != NULL);
- handleTable = NULL;
- htSize = sizeof(GDI_HANDLE_TABLE);
+ htSize.QuadPart = sizeof(GDI_HANDLE_TABLE);
+
+ Status = MmCreateSection((PVOID*)SectionObject,
+ SECTION_ALL_ACCESS,
+ NULL,
+ &htSize,
+ PAGE_READWRITE,
+ SEC_COMMIT,
+ NULL,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ return NULL;
+
+ /* FIXME - use MmMapViewInSessionSpace once available! */
+ Status = MmMapViewInSystemSpace(*SectionObject,
+ (PVOID*)&HandleTable,
+ &ViewSize);
+ if (!NT_SUCCESS(Status))
+ {
+ ObDereferenceObject(*SectionObject);
+ *SectionObject = NULL;
+ return NULL;
+ }
- IntUserCreateSharedSection(SessionSharedSectionPool,
- (PVOID*)&handleTable,
- &htSize);
- ASSERT( handleTable );
- RtlZeroMemory(handleTable, sizeof(GDI_HANDLE_TABLE));
+ RtlZeroMemory(HandleTable, sizeof(GDI_HANDLE_TABLE));
/*
* initialize the free entry cache
*/
- InitializeSListHead(&handleTable->FreeEntriesHead);
+ InitializeSListHead(&HandleTable->FreeEntriesHead);
Entry = &HandleTable->Entries[RESERVE_ENTRIES_COUNT];
for(i = GDI_HANDLE_COUNT - 1; i >= RESERVE_ENTRIES_COUNT; i--)
{
- InterlockedPushEntrySList(&handleTable->FreeEntriesHead, &handleTable->FreeEntries[i]);
+ InterlockedPushEntrySList(&HandleTable->FreeEntriesHead, &HandleTable->FreeEntries[i]);
}
- handleTable->LookasideLists = ExAllocatePoolWithTag(NonPagedPool,
+ HandleTable->LookasideLists = ExAllocatePoolWithTag(NonPagedPool,
OBJTYPE_COUNT * sizeof(PAGED_LOOKASIDE_LIST),
TAG_GDIHNDTBLE);
- if(handleTable->LookasideLists == NULL)
+ if(HandleTable->LookasideLists == NULL)
{
- InUserDeleteSharedSection(SessionSharedSectionPool,
- handleTable);
+ MmUnmapViewInSystemSpace(HandleTable);
+ ObDereferenceObject(*SectionObject);
+ *SectionObject = NULL;
return NULL;
}
for(ObjType = 0; ObjType < OBJTYPE_COUNT; ObjType++)
{
- ExInitializePagedLookasideList(handleTable->LookasideLists + ObjType, NULL, NULL, 0,
+ ExInitializePagedLookasideList(HandleTable->LookasideLists + ObjType, NULL, NULL, 0,
ObjInfo[ObjType].Size + sizeof(GDIOBJHDR), TAG_GDIOBJ, 0);
}
ShortDelay.QuadPart = -5000LL; /* FIXME - 0.5 ms? */
- return handleTable;
+ return HandleTable;
}
static __inline PPAGED_LOOKASIDE_LIST
-FindLookasideList(DWORD ObjectType)
+FindLookasideList(PGDI_HANDLE_TABLE HandleTable,
+ DWORD ObjectType)
{
int Index;
#define H 1024
static struct DbgOpenGDIHandle h[H];
-void IntDumpHandleTable()
+void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable)
{
int i, n = 0, j, k, J;
*/
HGDIOBJ INTERNAL_CALL
#ifdef GDI_DEBUG
-GDIOBJ_AllocObjDbg(const char* file, int line, ULONG ObjectType)
+GDIOBJ_AllocObjDbg(PGDI_HANDLE_TABLE HandleTable, const char* file, int line, ULONG ObjectType)
#else /* !GDI_DEBUG */
-GDIOBJ_AllocObj(ULONG ObjectType)
+GDIOBJ_AllocObj(PGDI_HANDLE_TABLE HandleTable, ULONG ObjectType)
#endif /* GDI_DEBUG */
{
PW32PROCESS W32Process;
ASSERT(ObjectType != GDI_OBJECT_TYPE_DONTCARE);
- LookasideList = FindLookasideList(ObjectType);
+ LookasideList = FindLookasideList(HandleTable, ObjectType);
if(LookasideList != NULL)
{
newObject = ExAllocateFromPagedLookasideList(LookasideList);
ExFreeToPagedLookasideList(LookasideList, newObject);
DPRINT1("Failed to insert gdi object into the handle table, no handles left!\n");
#ifdef GDI_DEBUG
- IntDumpHandleTable();
+ IntDumpHandleTable(HandleTable);
#endif /* GDI_DEBUG */
}
else
*/
BOOL INTERNAL_CALL
#ifdef GDI_DEBUG
-GDIOBJ_FreeObjDbg(const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
+GDIOBJ_FreeObjDbg(PGDI_HANDLE_TABLE HandleTable, const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
#else /* !GDI_DEBUG */
-GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType)
+GDIOBJ_FreeObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType)
#endif /* GDI_DEBUG */
{
PGDI_TABLE_ENTRY Entry;
Ret = RunCleanupCallback(GDIHdrToBdy(GdiHdr), Type);
/* Now it's time to free the memory */
- LookasideList = FindLookasideList(Type);
+ LookasideList = FindLookasideList(HandleTable, Type);
if(LookasideList != NULL)
{
ExFreeToPagedLookasideList(LookasideList, GdiHdr);
return FALSE;
}
-/*!
- * Initialization of the GDI object engine.
-*/
-VOID INTERNAL_CALL
-InitGdiObjectHandleTable (VOID)
-{
- DPRINT("InitGdiObjectHandleTable\n");
-
- HandleTable = GDIOBJ_iAllocHandleTable();
- DPRINT("HandleTable: %x\n", HandleTable);
-}
-
/*!
* Delete GDI object
* \param hObject object handle
DPRINT("NtGdiDeleteObject handle 0x%08x\n", hObject);
return NULL != hObject
- ? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
+ ? GDIOBJ_FreeObj(GdiHandleTable, hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
}
/*!
* \param Process - PID of the process that will be destroyed.
*/
BOOL INTERNAL_CALL
-GDI_CleanupForProcess (struct _EPROCESS *Process)
+GDI_CleanupForProcess (PGDI_HANDLE_TABLE HandleTable, struct _EPROCESS *Process)
{
PGDI_TABLE_ENTRY Entry, End;
PEPROCESS CurrentProcess;
simply ignore this fact here. */
ObjectHandle = (HGDIOBJ)(Index | (Entry->Type & 0xFFFF0000));
- if(GDIOBJ_FreeObj(ObjectHandle, GDI_OBJECT_TYPE_DONTCARE) &&
+ if(GDIOBJ_FreeObj(HandleTable, ObjectHandle, GDI_OBJECT_TYPE_DONTCARE) &&
W32Process->GDIObjects == 0)
{
/* there are no more gdi handles for this process, bail */
*/
PGDIOBJ INTERNAL_CALL
#ifdef GDI_DEBUG
-GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
+GDIOBJ_LockObjDbg (PGDI_HANDLE_TABLE HandleTable, const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
#else /* !GDI_DEBUG */
-GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType)
+GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType)
#endif /* GDI_DEBUG */
{
USHORT HandleIndex;
*/
PGDIOBJ INTERNAL_CALL
#ifdef GDI_DEBUG
-GDIOBJ_ShareLockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
+GDIOBJ_ShareLockObjDbg (PGDI_HANDLE_TABLE HandleTable, const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
#else /* !GDI_DEBUG */
-GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType)
+GDIOBJ_ShareLockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ObjectType)
#endif /* GDI_DEBUG */
{
USHORT HandleIndex;
* \param Object Object pointer (as returned by GDIOBJ_LockObj).
*/
VOID INTERNAL_CALL
-GDIOBJ_UnlockObjByPtr(PGDIOBJ Object)
+GDIOBJ_UnlockObjByPtr(PGDI_HANDLE_TABLE HandleTable, PGDIOBJ Object)
{
PGDIOBJHDR GdiHdr = GDIBdyToHdr(Object);
#ifdef GDI_DEBUG
BOOL INTERNAL_CALL
-GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle)
+GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle)
{
PGDI_TABLE_ENTRY Entry;
HANDLE ProcessId;
}
BOOL INTERNAL_CALL
-GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj)
+GDIOBJ_ConvertToStockObj(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ *hObj)
{
/*
* FIXME !!!!! THIS FUNCTION NEEDS TO BE FIXED - IT IS NOT SAFE WHEN OTHER THREADS
}
void INTERNAL_CALL
-GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS NewOwner)
+GDIOBJ_SetOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle, PEPROCESS NewOwner)
{
PGDI_TABLE_ENTRY Entry;
HANDLE ProcessId, LockedProcessId, PrevProcId;
}
void INTERNAL_CALL
-GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo)
+GDIOBJ_CopyOwnership(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ CopyFrom, HGDIOBJ CopyTo)
{
PGDI_TABLE_ENTRY FromEntry;
PETHREAD Thread;
/* FIXME */
if(NT_SUCCESS(PsLookupProcessByProcessId((HANDLE)((ULONG_PTR)FromPrevProcId & ~0x1), &ProcessTo)))
{
- GDIOBJ_SetOwnership(CopyTo, ProcessTo);
+ GDIOBJ_SetOwnership(HandleTable, CopyTo, ProcessTo);
ObDereferenceObject(ProcessTo);
}
}
else
{
/* mark the object as global */
- GDIOBJ_SetOwnership(CopyTo, NULL);
+ GDIOBJ_SetOwnership(HandleTable, CopyTo, NULL);
}
(void)InterlockedExchangePointer(&FromEntry->ProcessId, FromPrevProcId);
}
PVOID INTERNAL_CALL
-GDI_MapHandleTable(PEPROCESS Process)
+GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process)
{
- ULONG TableSize = sizeof(HandleTable->Entries);
- PVOID MappedGdiTable = NULL; /* FIXME - try preferred GDI_HANDLE_TABLE_BASE_ADDRESS? */
- NTSTATUS Status = IntUserMapSharedSection(SessionSharedSectionPool,
- Process,
- HandleTable,
- NULL,
- &MappedGdiTable,
- &TableSize,
- TRUE);
- if(NT_SUCCESS(Status))
- {
- return MappedGdiTable;
- }
-
- return NULL;
+ PVOID MappedView = NULL;
+ NTSTATUS Status;
+ LARGE_INTEGER Offset;
+ ULONG ViewSize = sizeof(GDI_HANDLE_TABLE);
+
+ Offset.QuadPart = 0;
+
+ ASSERT(SectionObject != NULL);
+ ASSERT(Process != NULL);
+
+ Status = MmMapViewOfSection(SectionObject,
+ Process,
+ &MappedView,
+ 0,
+ 0,
+ &Offset,
+ &ViewSize,
+ ViewUnmap,
+ SEC_NO_CHANGE,
+ PAGE_READONLY);
+
+ if (!NT_SUCCESS(Status))
+ return NULL;
+
+ return MappedView;
}
/* EOF */
HPALETTE NewPalette;
PPALGDI PalGDI;
- NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_PALETTE);
if (NULL == NewPalette)
{
return NULL;
PPALGDI PalGDI;
unsigned i;
- NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_PALETTE);
if (NULL == NewPalette)
{
return NULL;
HRGN hReg;
PROSRGNDATA pReg;
- if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
+ if ((hReg = (HRGN) GDIOBJ_AllocObj(GdiHandleTable, GDI_OBJECT_TYPE_REGION)))
{
if (NULL != (pReg = RGNDATA_LockRgn(hReg)))
{
{
if (NULL != StockObjects[Object])
{
- GDIOBJ_ConvertToStockObj(&StockObjects[Object]);
+ GDIOBJ_ConvertToStockObj(GdiHandleTable, &StockObjects[Object]);
}
}
SysColorBrushes[i] = IntGdiCreateSolidBrush(SysColors[i]);
if(SysColorBrushes[i] != NULL)
{
- GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorBrushes[i]);
+ GDIOBJ_ConvertToStockObj(GdiHandleTable, (HGDIOBJ*)&SysColorBrushes[i]);
}
}
}
SysColorPens[i] = IntGdiCreatePenIndirect(&Pen);
if(SysColorPens[i] != NULL)
{
- GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorPens[i]);
+ GDIOBJ_ConvertToStockObj(GdiHandleTable, (HGDIOBJ*)&SysColorPens[i]);
}
}
}
<file>copy.c</file>
</compilationunit>
<directory name="i386">
- <file>cos_asm.s</file>
- <file>sin_asm.s</file>
- <file>atan2_asm.s</file>
- <file>floor_asm.s</file>
- <file>ceil_asm.s</file>
+ <file>cos_asm.s</file>
+ <file>sin_asm.s</file>
+ <file>atan2_asm.s</file>
+ <file>floor_asm.s</file>
+ <file>ceil_asm.s</file>
</directory>
</directory>
<directory name="ntddraw">
<file>winpos.c</file>
<file>winsta.c</file>
<file>object.c</file>
- <file>ssec.c</file>
</compilationunit>
</directory>
<directory name="objects">