[WIN32K]
[reactos.git] / reactos / win32ss / gdi / ntgdi / gdiobj.c
index 8adec2e..f3365cb 100644 (file)
@@ -51,8 +51,7 @@
            (objt) == GDIObjType_BRUSH_TYPE)
 #define ASSERT_EXCLUSIVE_OBJECT_TYPE(objt) \
     ASSERT((objt) == GDIObjType_DC_TYPE || \
-           (objt) == GDIObjType_RGN_TYPE || \
-           (objt) == GDIObjType_LFONT_TYPE)
+           (objt) == GDIObjType_RGN_TYPE)
 #else
 #define DBG_INCREASE_LOCK_COUNT(ppi, hobj)
 #define DBG_DECREASE_LOCK_COUNT(x, y)
@@ -79,8 +78,8 @@ enum
 
 /* Per session handle table globals */
 static PVOID gpvGdiHdlTblSection = NULL;
-static PENTRY gpentHmgr;
-static PULONG gpaulRefCount;
+PENTRY gpentHmgr;
+PULONG gpaulRefCount;
 ULONG gulFirstFree;
 ULONG gulFirstUnused;
 static PPAGED_LOOKASIDE_LIST gpaLookasideList;
@@ -1238,6 +1237,11 @@ GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize)
     }
 
     pobj = GDIOBJ_AllocateObject(objt, cjSize, fl);
+    if (!pobj)
+    {
+        return NULL;
+    }
+
     if (!GDIOBJ_hInsertObject(pobj, GDI_OBJ_HMGR_POWNED))
     {
         GDIOBJ_vFreeObject(pobj);
@@ -1341,170 +1345,5 @@ GDI_CleanupForProcess(struct _EPROCESS *Process)
     return TRUE;
 }
 
-#if DBG && KDBG
-static const char * gpszObjectTypes[] =
-{
-    "FREE", "DC", "UNUSED1", "UNUSED2", "RGN", "SURF", "CLIENTOBJ", "PATH",
-    "PAL", "ICMLCS", "LFONT", "RFONT", "PFE", "PFT", "ICMCXF", "SPRITE",
-    "BRUSH", "UMPD", "UNUSED4", "SPACE", "UNUSED5", "META", "EFSTATE",
-    "BMFD", "VTFD", "TTFD", "RC", "TEMP", "DRVOBJ", "DCIOBJ", "SPOOL",
-    "RESERVED", "ALL"
-};
-
-extern PEPROCESS gpepCSRSS;;
-
-VOID
-NTAPI
-DbgDumpGdiHandleTable(ULONG argc, char *argv[])
-{
-    ULONG i;
-    UCHAR Objt, jReqestedType;
-    PENTRY pentry;
-    POBJ pobj;
-    KAPC_STATE ApcState;
-
-    /* No CSRSS, no handle table */
-    if (!gpepCSRSS) return;
-    KeStackAttachProcess(&gpepCSRSS->Pcb, &ApcState);
-
-    if (argc == 0)
-    {
-        USHORT Counts[GDIObjType_MAX_TYPE + 2] = {0};
-
-        /* Loop all possibly used entries in the handle table */
-        for (i = RESERVE_ENTRIES_COUNT; i < gulFirstUnused; i++)
-        {
-            if (MmIsAddressValid(&gpentHmgr[i]))
-            {
-                Objt = gpentHmgr[i].Objt & 0x1F;
-                Counts[Objt]++;
-            }
-        }
-
-        DbgPrint("Type         Count\n");
-        DbgPrint("-------------------\n");
-        for (i = 0; i <= GDIObjType_MAX_TYPE; i++)
-        {
-            DbgPrint("%02x %-9s %d\n",
-                     i, gpszObjectTypes[i], Counts[i]);
-        }
-        DbgPrint("\n");
-    }
-    else
-    {
-        /* Loop all object types */
-        for (i = 0; i <= GDIObjType_MAX_TYPE + 1; i++)
-        {
-            /* Check if this object type was requested */
-            if (stricmp(argv[0], gpszObjectTypes[i]) == 0)
-            {
-                jReqestedType = i;
-                break;
-            }
-        }
-
-        /* Check if we didn't find it yet */
-        if (i > GDIObjType_MAX_TYPE)
-        {
-            /* Try if it's a number */
-            i = atoi(argv[0]);
-
-            /* Check for "0" */
-            if ((i > GDIObjType_MAX_TYPE) ||
-                ((i == 0) && (stricmp(argv[0], "0") == 0)))
-            {
-                DbgPrint("Unknown object type: %s\n", argv[0]);
-                goto leave;
-            }
-
-            jReqestedType = i;
-        }
-
-        /* Print header */
-        DbgPrint("Index Handle   Type      ThreadId cLocks  ulRefCount\n");
-        DbgPrint("----------------------------------------------------\n");
-
-        /* Loop all possibly used entries in the handle table */
-        for (i = RESERVE_ENTRIES_COUNT; i < gulFirstUnused; i++)
-        {
-            /* Get the entry and the object */
-            pentry = &gpentHmgr[i];
-
-            if (!MmIsAddressValid(pentry)) continue;
-
-            pobj = pentry->einfo.pobj;
-            Objt = pentry->Objt & 0x1F;
-
-            if ((jReqestedType == GDIObjType_MAX_TYPE + 1) ||
-                (Objt == jReqestedType))
-            {
-                DbgPrint("%04lx  %p %-9s 0x%06lx %-7ld ",
-                         i, pobj->hHmgr, gpszObjectTypes[Objt],
-                         pobj->dwThreadId, pobj->cExclusiveLock);
-                if (MmIsAddressValid(&gpaulRefCount[i]))
-                    DbgPrint("0x%06lx\n", gpaulRefCount[i]);
-                else
-                    DbgPrint("????????\n");
-            }
-        }
-    }
-
-leave:
-    KeUnstackDetachProcess(&ApcState);
-}
-
-VOID
-NTAPI
-DbgDumpHandleInfo(char *argv)
-{
-    ULONG_PTR ulObject;
-    BASEOBJECT *pobj;
-    ENTRY *pentry;
-    USHORT usIndex;
-    char *endptr;
-    KAPC_STATE ApcState;
-
-    /* Skip optional '0x' prefix */
-    if ((argv[0] == '0') && ((argv[1] == 'x') || (argv[1] == 'X')))
-        argv += 2;
-
-    /* Make a number from the string (hex) */
-    ulObject = strtol(argv, &endptr, 16);
-    if (*endptr != '\0')
-        return;
-
-    /* No CSRSS, no handle table */
-    if (!gpepCSRSS) return;
-    KeStackAttachProcess(&gpepCSRSS->Pcb, &ApcState);
-
-    usIndex = ulObject & 0xFFFF;
-    pentry = &gpentHmgr[usIndex];
-
-    if (MmIsAddressValid(pentry))
-    {
-        pobj = pentry->einfo.pobj;
-
-        DbgPrint("GDI handle=%p, type=%s, index=0x%lx, pentry=%p.\n",
-                 ulObject, gpszObjectTypes[(ulObject >> 16) & 0x1f],
-                 usIndex, pentry);
-        DbgPrint(" ENTRY = {.pobj = %p, ObjectOwner = 0x%lx, FullUnique = 0x%04x,\n"
-                 "  Objt=0x%02x, Flags = 0x%02x, pUser = 0x%p}\n",
-                 pentry->einfo.pobj, pentry->ObjectOwner.ulObj, pentry->FullUnique,
-                 pentry->Objt, pentry->Flags, pentry->pUser);
-        DbgPrint(" BASEOBJECT = {hHmgr = %p, dwThreadId = 0x%lx,\n"
-                 "  cExclusiveLock = %ld, BaseFlags = 0x%lx}\n",
-                 pobj->hHmgr, pobj->dwThreadId,
-                 pobj->cExclusiveLock, pobj->BaseFlags);
-        if (MmIsAddressValid(&gpaulRefCount[usIndex]))
-            DbgPrint(" gpaulRefCount[idx] = %ld\n", gpaulRefCount[usIndex]);
-    }
-    else
-    {
-        DbgPrint("Coudn't access ENTRY. Probably paged out.\n");
-    }
-
-    KeUnstackDetachProcess(&ApcState);
-}
-#endif // DBG && KDBG
 
 /* EOF */