- change the GDI code a bit so it's able to handle multiple tables (e.g. separate...
authorGed Murphy <gedmurphy@reactos.org>
Sat, 1 Apr 2006 15:25:40 +0000 (15:25 +0000)
committerGed Murphy <gedmurphy@reactos.org>
Sat, 1 Apr 2006 15:25:40 +0000 (15:25 +0000)
- patch by Thomas Weidenmueller

svn path=/trunk/; revision=21433

31 files changed:
reactos/subsystems/win32/win32k/eng/palette.c
reactos/subsystems/win32/win32k/eng/surface.c
reactos/subsystems/win32/win32k/include/bitmaps.h
reactos/subsystems/win32/win32k/include/brush.h
reactos/subsystems/win32/win32k/include/dc.h
reactos/subsystems/win32/win32k/include/dce.h
reactos/subsystems/win32/win32k/include/gdiobj.h
reactos/subsystems/win32/win32k/include/object.h
reactos/subsystems/win32/win32k/include/palette.h
reactos/subsystems/win32/win32k/include/pen.h
reactos/subsystems/win32/win32k/include/region.h
reactos/subsystems/win32/win32k/include/ssec.h
reactos/subsystems/win32/win32k/include/text.h
reactos/subsystems/win32/win32k/include/win32k.h
reactos/subsystems/win32/win32k/main/dllmain.c
reactos/subsystems/win32/win32k/ntddraw/ddraw.c
reactos/subsystems/win32/win32k/ntuser/cursoricon.c
reactos/subsystems/win32/win32k/ntuser/misc.c
reactos/subsystems/win32/win32k/ntuser/painting.c
reactos/subsystems/win32/win32k/ntuser/ssec.c [deleted file]
reactos/subsystems/win32/win32k/ntuser/windc.c
reactos/subsystems/win32/win32k/objects/bitmaps.c
reactos/subsystems/win32/win32k/objects/brush.c
reactos/subsystems/win32/win32k/objects/cliprgn.c
reactos/subsystems/win32/win32k/objects/color.c
reactos/subsystems/win32/win32k/objects/dc.c
reactos/subsystems/win32/win32k/objects/gdiobj.c
reactos/subsystems/win32/win32k/objects/palobj.c
reactos/subsystems/win32/win32k/objects/region.c
reactos/subsystems/win32/win32k/objects/stockobj.c
reactos/subsystems/win32/win32k/win32k.rbuild

index 796d5e8..d8a95ef 100644 (file)
@@ -44,7 +44,7 @@ EngCreatePalette(ULONG Mode, ULONG NumColors, ULONG *Colors,
    Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
    if (Palette != NULL)
    {
-      GDIOBJ_SetOwnership(Palette, NULL);
+      GDIOBJ_SetOwnership(GdiHandleTable, Palette, NULL);
    }
 
    return Palette;
@@ -56,7 +56,7 @@ EngCreatePalette(ULONG Mode, ULONG NumColors, ULONG *Colors,
 BOOL STDCALL
 EngDeletePalette(IN HPALETTE Palette)
 {
-   GDIOBJ_SetOwnership(Palette, PsGetCurrentProcess());
+   GDIOBJ_SetOwnership(GdiHandleTable, Palette, PsGetCurrentProcess());
 
    return PALETTE_FreePalette(Palette);
 }
index c1a2589..e83124a 100644 (file)
@@ -373,7 +373,7 @@ EngCreateBitmap(IN SIZEL Size,
   if ( !NewBitmap )
          return 0;
 
-  GDIOBJ_SetOwnership(NewBitmap, NULL);
+  GDIOBJ_SetOwnership(GdiHandleTable, NewBitmap, NULL);
 
   return NewBitmap;
 }
@@ -394,7 +394,7 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
   if (NewSurface == NULL)
        return 0;
 
-  GDIOBJ_SetOwnership(NewSurface, NULL);
+  GDIOBJ_SetOwnership(GdiHandleTable, NewSurface, NULL);
 
   BitmapObj = BITMAPOBJ_LockBitmap(NewSurface);
   if (! BITMAPOBJ_InitBitsLock(BitmapObj))
@@ -506,7 +506,7 @@ EngModifySurface(
 BOOL STDCALL
 EngDeleteSurface(IN HSURF Surface)
 {
-   GDIOBJ_SetOwnership(Surface, PsGetCurrentProcess());
+   GDIOBJ_SetOwnership(GdiHandleTable, Surface, PsGetCurrentProcess());
    BITMAPOBJ_FreeBitmap(Surface);
    return TRUE;
 }
@@ -533,7 +533,7 @@ EngEraseSurface(SURFOBJ *Surface,
 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;
@@ -548,6 +548,6 @@ VOID STDCALL
 EngUnlockSurface(IN SURFOBJ *Surface)
 {
    if (Surface != NULL)
-      GDIOBJ_UnlockObjByPtr(Surface);
+      GDIOBJ_UnlockObjByPtr(GdiHandleTable, Surface);
 }
 /* EOF */
index d799330..a6f13cf 100644 (file)
@@ -25,9 +25,9 @@ typedef struct _BITMAPOBJ
 /*  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
index 65c40ca..54b2a4b 100644 (file)
@@ -68,10 +68,10 @@ typedef struct
 #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
index ae7f8b0..44941bb 100644 (file)
@@ -166,9 +166,9 @@ typedef struct
 /*  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
index 2fa1738..7bd3dfb 100644 (file)
@@ -44,10 +44,10 @@ typedef struct tagDCE
 #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);
index 4772206..357c1ff 100644 (file)
@@ -9,6 +9,21 @@
 /* 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
@@ -28,11 +43,11 @@ typedef struct _GDIOBJHDR
 #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
@@ -40,26 +55,26 @@ VOID    INTERNAL_CALL GDIOBJ_UnlockObjByPtr(PGDIOBJ Object);
 #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
index 2fd1898..4bf7f85 100644 (file)
@@ -125,8 +125,6 @@ typedef struct _USER_REFERENCE_ENTRY
    \
 }
 
-VOID  INTERNAL_CALL InitGdiObjectHandleTable (VOID);
-
 VOID  FASTCALL CreateStockObjects (VOID);
 VOID  FASTCALL CreateSysColorObjects (VOID);
 
index 74da8d8..bf6086f 100644 (file)
@@ -35,9 +35,9 @@ HPALETTE FASTCALL PALETTE_AllocPalette(ULONG Mode,
                                        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);
index e76555d..e8c2a51 100644 (file)
@@ -6,9 +6,9 @@
 \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
index c86c7cb..b5a49a1 100644 (file)
@@ -11,9 +11,9 @@ typedef struct _ROSRGNDATA {
 } 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
index cead19e..e69de29 100644 (file)
@@ -1,73 +0,0 @@
-/* $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 */
-
index b1cfa16..4d59c9f 100644 (file)
@@ -12,10 +12,10 @@ typedef struct
 /*  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);
index e00a604..026b9e6 100644 (file)
@@ -14,7 +14,6 @@
 /* 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>
index 9596aa2..c5af014 100644 (file)
 #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,
@@ -84,7 +86,7 @@ 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 */
@@ -102,7 +104,7 @@ Win32kProcessCallback(struct _EPROCESS *Process,
       /* 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);
 
@@ -340,13 +342,6 @@ DriverEntry (
      */
     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))
   {
@@ -445,7 +440,12 @@ DriverEntry (
       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())
index 55e4f0f..6b50ae3 100644 (file)
@@ -16,6 +16,8 @@
 /* swtich this off to get rid of all dx debug msg */
 #define DX_DEBUG
 
+#define DdHandleTable GdiHandleTable
+
 
 /************************************************************************/
 /* DIRECT DRAW OBJECT                                                   */
@@ -95,7 +97,7 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
                return NULL;
        }
 
-       hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
+       hDirectDraw = GDIOBJ_AllocObj(DdHandleTable, GDI_OBJECT_TYPE_DIRECTDRAW);
        if (!hDirectDraw)
        {
                /* No more memmory */
@@ -106,7 +108,7 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
                return NULL;
        }
 
-       pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
+       pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
        if (!pDirectDraw)
        {
                /* invalid handle */
@@ -133,7 +135,7 @@ HANDLE STDCALL NtGdiDdCreateDirectDrawObject(
        /* DD_PALETTECALLBACKS setup*/  
        RtlMoveMemory(&pDirectDraw->Pal, &surface_callbacks, sizeof(DD_PALETTECALLBACKS));
        
-       GDIOBJ_UnlockObjByPtr(pDirectDraw);
+       GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
        DC_UnlockDc(pDC);
 
        return hDirectDraw;
@@ -146,7 +148,7 @@ BOOL STDCALL NtGdiDdDeleteDirectDrawObject(
 #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(
@@ -201,7 +203,7 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
     }
    
     
-       pDirectDraw = GDIOBJ_LockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+       pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
        
        
        if (!pDirectDraw)
@@ -226,7 +228,7 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
 #ifdef DX_DEBUG
         DPRINT1(" Fail to get DirectDraw driver info \n");
 #endif
-               GDIOBJ_UnlockObjByPtr(pDirectDraw);
+               GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
                return FALSE;
        }
 
@@ -351,7 +353,7 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
     }
 #endif
         
-       GDIOBJ_UnlockObjByPtr(pDirectDraw);
+       GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
 
        return TRUE;
 }
@@ -364,7 +366,7 @@ DWORD STDCALL NtGdiDdGetDriverInfo(
 {
        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
@@ -397,7 +399,7 @@ DWORD STDCALL NtGdiDdGetDriverInfo(
        else
             ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
    
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
 
        return ddRVal;
 }
@@ -425,7 +427,7 @@ DWORD STDCALL NtGdiDdCreateSurface(
        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
@@ -456,7 +458,7 @@ DWORD STDCALL NtGdiDdCreateSurface(
        /* But back the orignal PDev */
        puCreateSurfaceData->lpDD = lgpl;
     
-       GDIOBJ_UnlockObjByPtr(pDirectDraw);     
+       GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);      
        return ddRVal;
 }
 
@@ -473,7 +475,7 @@ DWORD STDCALL NtGdiDdWaitForVerticalBlank(
 #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;
 
@@ -492,7 +494,7 @@ DWORD STDCALL NtGdiDdWaitForVerticalBlank(
        /* But back the orignal PDev */
        puWaitForVerticalBlankData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
        return ddRVal;
 }
 
@@ -504,7 +506,7 @@ DWORD STDCALL NtGdiDdCanCreateSurface(
        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
@@ -526,7 +528,7 @@ DWORD STDCALL NtGdiDdCanCreateSurface(
        /* But back the orignal PDev */
        puCanCreateSurfaceData->lpDD = lgpl;
 
-       GDIOBJ_UnlockObjByPtr(pDirectDraw);
+       GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
        return ddRVal;
 }
 
@@ -538,7 +540,7 @@ DWORD STDCALL NtGdiDdGetScanLine(
        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
@@ -560,7 +562,7 @@ DWORD STDCALL NtGdiDdGetScanLine(
        /* But back the orignal PDev */
        puGetScanLineData->lpDD = lgpl;
 
-       GDIOBJ_UnlockObjByPtr(pDirectDraw);
+       GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
        return ddRVal;
 }
 
@@ -579,7 +581,7 @@ DWORD STDCALL NtGdiDdDestroySurface(
 {      
        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
@@ -605,7 +607,7 @@ DWORD STDCALL NtGdiDdDestroySurface(
        }
 
        
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;                     
 }
 
@@ -620,7 +622,7 @@ DWORD STDCALL NtGdiDdFlip(
        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
@@ -643,7 +645,7 @@ DWORD STDCALL NtGdiDdFlip(
        /* But back the orignal PDev */
        puFlipData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;             
 }
 
@@ -656,7 +658,7 @@ DWORD STDCALL NtGdiDdLock(
        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
@@ -678,7 +680,7 @@ DWORD STDCALL NtGdiDdLock(
        /* But back the orignal PDev */
        puLockData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;             
 }
 
@@ -690,7 +692,7 @@ DWORD STDCALL NtGdiDdUnlock(
        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
@@ -712,7 +714,7 @@ DWORD STDCALL NtGdiDdUnlock(
        /* But back the orignal PDev */
        puUnlockData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);    
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);    
        return ddRVal;
 }
 
@@ -725,7 +727,7 @@ DWORD STDCALL NtGdiDdBlt(
     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
@@ -747,7 +749,7 @@ DWORD STDCALL NtGdiDdBlt(
        /* But back the orignal PDev */
        puBltData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;
    }
 
@@ -759,7 +761,7 @@ DWORD STDCALL NtGdiDdSetColorKey(
        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
@@ -781,7 +783,7 @@ DWORD STDCALL NtGdiDdSetColorKey(
        /* But back the orignal PDev */
        puSetColorKeyData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;     
 }
 
@@ -795,7 +797,7 @@ DWORD STDCALL NtGdiDdAddAttachedSurface(
        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
@@ -817,7 +819,7 @@ DWORD STDCALL NtGdiDdAddAttachedSurface(
        /* But back the orignal PDev */
        puAddAttachedSurfaceData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;     
 }
 
@@ -829,7 +831,7 @@ DWORD STDCALL NtGdiDdGetBltStatus(
        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
@@ -851,7 +853,7 @@ DWORD STDCALL NtGdiDdGetBltStatus(
        /* But back the orignal PDev */
        puGetBltStatusData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;             
 }
 
@@ -863,7 +865,7 @@ DWORD STDCALL NtGdiDdGetFlipStatus(
     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
@@ -885,7 +887,7 @@ DWORD STDCALL NtGdiDdGetFlipStatus(
        /* But back the orignal PDev */
        puGetFlipStatusData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;             
 }
 
@@ -898,7 +900,7 @@ DWORD STDCALL NtGdiDdUpdateOverlay(
        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
@@ -920,7 +922,7 @@ DWORD STDCALL NtGdiDdUpdateOverlay(
        /* But back the orignal PDev */
        puUpdateOverlayData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;
 }
 
@@ -933,7 +935,7 @@ DWORD STDCALL NtGdiDdSetOverlayPosition(
        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
@@ -955,7 +957,7 @@ DWORD STDCALL NtGdiDdSetOverlayPosition(
        /* But back the orignal PDev */
        puSetOverlayPositionData->lpDD = lgpl;
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
     return ddRVal;
 }
 
@@ -985,7 +987,7 @@ HANDLE STDCALL NtGdiDdCreateSurfaceObject(
     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");
@@ -994,9 +996,9 @@ HANDLE STDCALL NtGdiDdCreateSurfaceObject(
                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));
@@ -1010,8 +1012,8 @@ HANDLE STDCALL NtGdiDdCreateSurfaceObject(
        // 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;
 }
@@ -1026,7 +1028,7 @@ BOOL STDCALL NtGdiDdDeleteSurfaceObject(
     /* 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);
        
 }
 
@@ -1072,7 +1074,7 @@ DWORD STDCALL NtGdiDdGetAvailDriverMemory(
        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
@@ -1086,7 +1088,7 @@ DWORD STDCALL NtGdiDdGetAvailDriverMemory(
        /* make the call */
    // ddRVal = pDirectDraw->DdGetAvailDriverMemory(puGetAvailDriverMemoryData); 
  
-       GDIOBJ_UnlockObjByPtr(pDirectDraw);
+       GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
 
 
        /* But back the orignal PDev */
@@ -1106,7 +1108,7 @@ DWORD STDCALL NtGdiDdSetExclusiveMode(
        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");
@@ -1121,7 +1123,7 @@ DWORD STDCALL NtGdiDdSetExclusiveMode(
        /* make the call */
     ddRVal = pDirectDraw->DdSetExclusiveMode(puSetExclusiveModeData);
 
-    GDIOBJ_UnlockObjByPtr(pDirectDraw);
+    GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
 
        /* But back the orignal PDev */
        puSetExclusiveModeData->lpDD = lgpl;
index 410da3a..316e857 100644 (file)
@@ -490,12 +490,12 @@ IntDestroyCurIconObject(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT CurIcon, BOOL
    /* 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);
    }
 
@@ -587,7 +587,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(CurIcon->IconInfo.hbmColor, NULL);
+            GDIOBJ_SetOwnership(GdiHandleTable, CurIcon->IconInfo.hbmColor, NULL);
          }
          if(CurIcon->IconInfo.hbmMask &&
                (bmp = BITMAPOBJ_LockBitmap(CurIcon->IconInfo.hbmMask)))
@@ -598,7 +598,7 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL, BOOL Indirect)
                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
@@ -1142,7 +1142,7 @@ NtUserSetCursorIconContents(
       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
    {
@@ -1154,7 +1154,7 @@ NtUserSetCursorIconContents(
       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;
index 7fbed7e..01a881b 100644 (file)
@@ -1052,7 +1052,7 @@ IntSystemParametersInfo(
                         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)
index 9faaa1e..ada83d3 100644 (file)
@@ -194,7 +194,7 @@ IntGetNCUpdateRgn(PWINDOW_OBJECT Window, BOOL Validate)
          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))
@@ -251,7 +251,7 @@ co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
             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);
             }
          }
 
@@ -372,13 +372,13 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
       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;
       }
@@ -398,7 +398,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
          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;
          }
@@ -761,7 +761,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
       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);
       }
    }
 
@@ -793,7 +793,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
       {
          IntGetClientRect(Window, &Ps.rcPaint);
       }
-      GDIOBJ_SetOwnership(Window->UpdateRegion, PsGetCurrentProcess());
+      GDIOBJ_SetOwnership(GdiHandleTable, Window->UpdateRegion, PsGetCurrentProcess());
       Window->UpdateRegion = NULL;
    }
    else
diff --git a/reactos/subsystems/win32/win32k/ntuser/ssec.c b/reactos/subsystems/win32/win32k/ntuser/ssec.c
deleted file mode 100644 (file)
index 57256d0..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- *  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;
-}
index 4b77253..ac2167a 100644 (file)
@@ -123,7 +123,7 @@ DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
       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;
@@ -641,9 +641,9 @@ DceFreeDCE(PDCE dce, BOOLEAN Force)
    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());
    }
 
index 121ba6d..e39e1f6 100644 (file)
@@ -1516,7 +1516,7 @@ BITMAPOBJ_CopyBitmap(HBITMAP  hBitmap)
         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;
 
@@ -1536,7 +1536,7 @@ BITMAPOBJ_CopyBitmap(HBITMAP  hBitmap)
                ExFreePool (buf);
        }
 
-       GDIOBJ_UnlockObjByPtr(Bitmap);
+       GDIOBJ_UnlockObjByPtr(GdiHandleTable, Bitmap);
 
        return  res;
 }
index eb02e5b..ca2dbde 100644 (file)
@@ -42,7 +42,7 @@ BRUSH_Cleanup(PVOID ObjectBody)
   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);
   }
 
@@ -297,7 +297,7 @@ IntGdiCreateDIBBrush(
    BrushObject->hbmPattern = hPattern;
    /* FIXME: Fill in the rest of fields!!! */
 
-   GDIOBJ_SetOwnership(hPattern, NULL);
+   GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
 
    BRUSHOBJ_UnlockBrush(BrushObject);
 
@@ -340,7 +340,7 @@ IntGdiCreateHatchBrush(
    BrushObject->hbmPattern = hPattern;
    BrushObject->BrushAttr.lbColor = Color & 0xFFFFFF;
 
-   GDIOBJ_SetOwnership(hPattern, NULL);
+   GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
 
    BRUSHOBJ_UnlockBrush(BrushObject);
 
@@ -377,7 +377,7 @@ IntGdiCreatePatternBrush(
    BrushObject->hbmPattern = hPattern;
    /* FIXME: Fill in the rest of fields!!! */
 
-   GDIOBJ_SetOwnership(hPattern, NULL);
+   GDIOBJ_SetOwnership(GdiHandleTable, hPattern, NULL);
 
    BRUSHOBJ_UnlockBrush(BrushObject);
 
index 1c49d97..3e812b5 100644 (file)
@@ -81,7 +81,7 @@ NtGdiSelectVisRgn(HDC hdc, HRGN hrgn)
   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
     {
index 22653e5..2eb0ce3 100644 (file)
@@ -616,7 +616,7 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
    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);
@@ -642,7 +642,7 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
            break;
      }
 
-   GDIOBJ_UnlockObjByPtr(ptr);
+   GDIOBJ_UnlockObjByPtr(GdiHandleTable, ptr);
    return Ret;
 }
 
index a92752f..afb947d 100644 (file)
@@ -1065,7 +1065,7 @@ NtGdiDeleteObjectApp(HANDLE  DCHandle)
 {
   PDC  DCToDelete;
 
-  if (!GDIOBJ_OwnedByCurrentProcess(DCHandle))
+  if (!GDIOBJ_OwnedByCurrentProcess(GdiHandleTable, DCHandle))
     {
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       return FALSE;
@@ -1739,7 +1739,7 @@ IntGdiGetObject(HANDLE Handle, INT Count, LPVOID Buffer)
   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);
@@ -1780,7 +1780,7 @@ IntGdiGetObject(HANDLE Handle, INT Count, LPVOID Buffer)
         break;
     }
 
-  GDIOBJ_UnlockObjByPtr(GdiObject);
+  GDIOBJ_UnlockObjByPtr(GdiHandleTable, GdiObject);
 
   return Result;
 }
@@ -1857,7 +1857,7 @@ NtGdiGetObjectType(HANDLE handle)
   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);
@@ -1912,7 +1912,7 @@ NtGdiGetObjectType(HANDLE handle)
       result = 0;
       break;
   }
-  GDIOBJ_UnlockObjByPtr(ptr);
+  GDIOBJ_UnlockObjByPtr(GdiHandleTable, ptr);
   return result;
 }
 
@@ -2263,7 +2263,7 @@ DC_AllocDC(PUNICODE_STRING Driver)
     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)
@@ -2339,7 +2339,7 @@ DC_InitDC(HDC  DCHandle)
 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");
   }
@@ -2415,21 +2415,21 @@ DC_SetOwnership(HDC hDC, PEPROCESS Owner)
 {
   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);
     }
index 7135b81..a855638 100644 (file)
 /* 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;
@@ -63,7 +50,7 @@ typedef struct
 /*
  * Dummy GDI Cleanup Callback
  */
-BOOL INTERNAL_CALL
+static BOOL INTERNAL_CALL
 GDI_CleanupDummy(PVOID ObjectBody)
 {
   return TRUE;
@@ -71,7 +58,7 @@ GDI_CleanupDummy(PVOID ObjectBody)
 
 /* 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 */
@@ -96,7 +83,6 @@ GDI_OBJ_INFO ObjInfo[] =
 
 #define OBJTYPE_COUNT (sizeof(ObjInfo) / sizeof(ObjInfo[0]))
 
-static PGDI_HANDLE_TABLE HandleTable = NULL;
 static LARGE_INTEGER ShortDelay;
 
 #define DelayExecution() \
@@ -113,57 +99,80 @@ ULONG STDCALL KeRosGetStackFrames(PULONG Frames, ULONG FrameCount);
  * 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;
 
@@ -227,7 +236,7 @@ struct DbgOpenGDIHandle
 #define H 1024
 static struct DbgOpenGDIHandle h[H];
 
-void IntDumpHandleTable()
+void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable)
 {
        int i, n = 0, j, k, J;
 
@@ -318,9 +327,9 @@ done:
 */
 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;
@@ -339,7 +348,7 @@ GDIOBJ_AllocObj(ULONG ObjectType)
 
   ASSERT(ObjectType != GDI_OBJECT_TYPE_DONTCARE);
 
-  LookasideList = FindLookasideList(ObjectType);
+  LookasideList = FindLookasideList(HandleTable, ObjectType);
   if(LookasideList != NULL)
   {
     newObject = ExAllocateFromPagedLookasideList(LookasideList);
@@ -434,7 +443,7 @@ LockHandle:
       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
@@ -461,9 +470,9 @@ LockHandle:
 */
 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;
@@ -535,7 +544,7 @@ LockHandle:
         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);
@@ -603,18 +612,6 @@ LockHandle:
   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
@@ -626,7 +623,7 @@ NtGdiDeleteObject(HGDIOBJ hObject)
   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;
 }
 
 /*!
@@ -634,7 +631,7 @@ NtGdiDeleteObject(HGDIOBJ hObject)
  * \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;
@@ -673,7 +670,7 @@ GDI_CleanupForProcess (struct _EPROCESS *Process)
            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 */
@@ -705,9 +702,9 @@ GDI_CleanupForProcess (struct _EPROCESS *Process)
 */
 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;
@@ -858,9 +855,9 @@ GDIOBJ_LockObj (HGDIOBJ hObj, DWORD ObjectType)
 */
 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;
@@ -989,7 +986,7 @@ GDIOBJ_ShareLockObj (HGDIOBJ hObj, DWORD ObjectType)
  * \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
@@ -1005,7 +1002,7 @@ GDIOBJ_UnlockObjByPtr(PGDIOBJ Object)
 
 
 BOOL INTERNAL_CALL
-GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle)
+GDIOBJ_OwnedByCurrentProcess(PGDI_HANDLE_TABLE HandleTable, HGDIOBJ ObjectHandle)
 {
   PGDI_TABLE_ENTRY Entry;
   HANDLE ProcessId;
@@ -1029,7 +1026,7 @@ GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle)
 }
 
 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
@@ -1167,7 +1164,7 @@ LockHandle:
 }
 
 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;
@@ -1302,7 +1299,7 @@ LockHandle:
 }
 
 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;
@@ -1347,14 +1344,14 @@ LockHandleFrom:
             /* 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);
@@ -1417,23 +1414,33 @@ LockHandleFrom:
 }
 
 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 */
index d557fac..41f0725 100644 (file)
@@ -63,7 +63,7 @@ PALETTE_AllocPalette(ULONG Mode,
   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;
@@ -112,7 +112,7 @@ PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
   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;
index 2b9912a..64460ca 100644 (file)
@@ -1905,7 +1905,7 @@ HRGN FASTCALL RGNDATA_AllocRgn(INT n)
   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)))
         {
index fac0a07..9e543a7 100644 (file)
@@ -147,7 +147,7 @@ CreateStockObjects(void)
     {
       if (NULL != StockObjects[Object])
        {
-         GDIOBJ_ConvertToStockObj(&StockObjects[Object]);
+         GDIOBJ_ConvertToStockObj(GdiHandleTable, &StockObjects[Object]);
        }
     }
 
@@ -268,7 +268,7 @@ CreateSysColorObjects(VOID)
       SysColorBrushes[i] = IntGdiCreateSolidBrush(SysColors[i]);
       if(SysColorBrushes[i] != NULL)
       {
-        GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorBrushes[i]);
+        GDIOBJ_ConvertToStockObj(GdiHandleTable, (HGDIOBJ*)&SysColorBrushes[i]);
       }
     }
   }
@@ -285,7 +285,7 @@ CreateSysColorObjects(VOID)
       SysColorPens[i] = IntGdiCreatePenIndirect(&Pen);
       if(SysColorPens[i] != NULL)
       {
-        GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorPens[i]);
+        GDIOBJ_ConvertToStockObj(GdiHandleTable, (HGDIOBJ*)&SysColorPens[i]);
       }
     }
   }
index df46be1..21cf20b 100644 (file)
                        <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">