Author: tkreuzer
Date: Mon Dec 29 13:11:48 2014
New Revision: 65882
URL:
http://svn.reactos.org/svn/reactos?rev=65882&view=rev
Log:
[GDI32]
Improve client object code
Modified:
trunk/reactos/win32ss/gdi/gdi32/include/gdi32p.h
trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c
Modified: trunk/reactos/win32ss/gdi/gdi32/include/gdi32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/include/…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/include/gdi32p.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/include/gdi32p.h [iso-8859-1] Mon Dec 29 13:11:48
2014
@@ -446,18 +446,32 @@
HGDIOBJ
WINAPI
-GdiInsertClientObj(
+GdiCreateClientObj(
_In_ PVOID pvObject,
_In_ GDILOOBJTYPE eObjType);
PVOID
WINAPI
-GdiGetClientObject(
+GdiDeleteClientObj(
_In_ HGDIOBJ hobj);
+BOOL
+WINAPI
+GdiCreateClientObjLink(
+ _In_ HGDIOBJ hobj,
+ _In_ PVOID pvObject);
+
PVOID
WINAPI
-GdiRemoveClientObject(
+GdiGetClientObjLink(
_In_ HGDIOBJ hobj);
+PVOID
+WINAPI
+GdiRemoveClientObjLink(
+ _In_ HGDIOBJ hobj);
+
+extern ULONG gcClientObj;
+
+
/* EOF */
Modified: trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/objects/…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c [iso-8859-1] Mon Dec 29 13:11:48
2014
@@ -8,6 +8,7 @@
#include <precomp.h>
CRITICAL_SECTION gcsClientObjLinks;
+ULONG gcClientObj;
typedef struct _CLIENTOBJLINK
{
@@ -18,37 +19,28 @@
PCLIENTOBJLINK gapcolHashTable[127];
-HGDIOBJ
+BOOL
WINAPI
-GdiInsertClientObj(
- _In_ PVOID pvObject,
- _In_ GDILOOBJTYPE eObjType)
+GdiCreateClientObjLink(
+ _In_ HGDIOBJ hobj,
+ _In_ PVOID pvObject)
{
PCLIENTOBJLINK pcol;
ULONG iHashIndex;
- HGDIOBJ hobj;
-
- /* Call win32k to create a client object handle */
- hobj = NtGdiCreateClientObj(eObjType);
- if (hobj == NULL)
- {
- return NULL;
- }
-
- /* Calculate the hash index */
- iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
/* Allocate a link structure */
pcol = HeapAlloc(GetProcessHeap(), 0, sizeof(*pcol));
if (pcol == NULL)
{
- NtGdiDeleteClientObj(hobj);
- return NULL;
+ return FALSE;
}
/* Setup the link structure */
pcol->hobj = hobj;
pcol->pvObj = pvObject;
+
+ /* Calculate the hash index */
+ iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
/* Enter the critical section */
EnterCriticalSection(&gcsClientObjLinks);
@@ -56,16 +48,17 @@
/* Insert the link structure */
pcol->pcolNext = gapcolHashTable[iHashIndex];
gapcolHashTable[iHashIndex] = pcol;
+ gcClientObj++;
/* Leave the critical section */
LeaveCriticalSection(&gcsClientObjLinks);
- return hobj;
+ return TRUE;
}
PVOID
WINAPI
-GdiGetClientObject(
+GdiGetClientObjLink(
_In_ HGDIOBJ hobj)
{
ULONG iHashIndex;
@@ -102,7 +95,7 @@
PVOID
WINAPI
-GdiRemoveClientObject(
+GdiRemoveClientObjLink(
_In_ HGDIOBJ hobj)
{
PCLIENTOBJLINK pcol, *ppcol;
@@ -127,6 +120,7 @@
{
/* Update the link pointer, removing this link */
*ppcol = pcol->pcolNext;
+ gcClientObj--;
/* Get the object pointer */
pvObject = pcol->pvObj;
@@ -148,3 +142,51 @@
/* Return the object pointer, or NULL if we did not find it */
return pvObject;
}
+
+HGDIOBJ
+WINAPI
+GdiCreateClientObj(
+ _In_ PVOID pvObject,
+ _In_ GDILOOBJTYPE eObjType)
+{
+ HGDIOBJ hobj;
+
+ /* Call win32k to create a client object handle */
+ hobj = NtGdiCreateClientObj(eObjType);
+ if (hobj == NULL)
+ {
+ return NULL;
+ }
+
+ /* Create the client object link */
+ if (!GdiCreateClientObjLink(hobj, pvObject))
+ {
+ NtGdiDeleteClientObj(hobj);
+ return NULL;
+ }
+
+ return hobj;
+}
+
+PVOID
+WINAPI
+GdiDeleteClientObj(
+ _In_ HGDIOBJ hobj)
+{
+ PVOID pvObject;
+
+ /* Remove the client object link */
+ pvObject = GdiRemoveClientObjLink(hobj);
+ if (pvObject == NULL)
+ {
+ return NULL;
+ }
+
+ /* Call win32k to delete the handle */
+ if (!NtGdiDeleteClientObj(hobj))
+ {
+ ASSERT(FALSE);
+ }
+
+ return pvObject;
+}