Author: tkreuzer
Date: Mon Oct 27 20:53:59 2014
New Revision: 65053
URL:
http://svn.reactos.org/svn/reactos?rev=65053&view=rev
Log:
[GDI32]
Add Support routines for client objects. Will be used later. You might wonder why the code
uses a lame hash table to link the client object handles to the user mode pointer, when it
should be clear that a *client* object should have a user mode attribute, like other
objects, that we can use, especially since that is the only real purpose of that object.
Well, tell that the MS developer, who implemented client objects without a user mode
attribute...
Added:
trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c (with props)
Modified:
trunk/reactos/win32ss/gdi/gdi32/CMakeLists.txt
trunk/reactos/win32ss/gdi/gdi32/include/gdi32p.h
trunk/reactos/win32ss/gdi/gdi32/main/dllmain.c
Modified: trunk/reactos/win32ss/gdi/gdi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/CMakeLis…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/CMakeLists.txt [iso-8859-1] Mon Oct 27 20:53:59 2014
@@ -24,6 +24,7 @@
objects/arc.c
objects/bitmap.c
objects/brush.c
+ objects/clientobj.c
objects/coord.c
objects/dc.c
objects/eng.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 Oct 27 20:53:59
2014
@@ -395,4 +395,20 @@
#endif
}
+HGDIOBJ
+WINAPI
+GdiInsertClientObj(
+ _In_ PVOID pvObject,
+ _In_ GDILOOBJTYPE eObjType);
+
+PVOID
+WINAPI
+GdiGetClientObject(
+ _In_ HGDIOBJ hobj);
+
+PVOID
+WINAPI
+GdiRemoveClientObject(
+ _In_ HGDIOBJ hobj);
+
/* EOF */
Modified: trunk/reactos/win32ss/gdi/gdi32/main/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/gdi32/main/dll…
==============================================================================
--- trunk/reactos/win32ss/gdi/gdi32/main/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/gdi32/main/dllmain.c [iso-8859-1] Mon Oct 27 20:53:59 2014
@@ -10,6 +10,7 @@
PGDIHANDLECACHE GdiHandleCache = NULL;
BOOL gbLpk = FALSE;
RTL_CRITICAL_SECTION semLocal;
+extern CRITICAL_SECTION gcsClientObjLinks;
/*
* GDI32.DLL does have an entry point for disable threadlibrarycall,. The initialization
is done by a call
@@ -49,6 +50,7 @@
GDI_BatchLimit = (DWORD)
NtCurrentTeb()->ProcessEnvironmentBlock->GdiDCAttributeList;
GdiHandleCache =
(PGDIHANDLECACHE)NtCurrentTeb()->ProcessEnvironmentBlock->GdiHandleBuffer;
RtlInitializeCriticalSection(&semLocal);
+ InitializeCriticalSection(&gcsClientObjLinks);
}
Added: 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 (added)
+++ trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c [iso-8859-1] Mon Oct 27 20:53:59
2014
@@ -0,0 +1,150 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS WIN32 subsystem
+ * PURPOSE: Support functions for GDI client objects
+ * PROGRAMMER: Timo Kreuzer (timo.kreuzer(a)reactos.org)
+ */
+
+#include <precomp.h>
+
+CRITICAL_SECTION gcsClientObjLinks;
+
+typedef struct _CLIENTOBJLINK
+{
+ struct _CLIENTOBJLINK *pcolNext;
+ HGDIOBJ hobj;
+ PVOID pvObj;
+} CLIENTOBJLINK, *PCLIENTOBJLINK;
+
+PCLIENTOBJLINK gapcolHashTable[127];
+
+HGDIOBJ
+WINAPI
+GdiInsertClientObj(
+ _In_ PVOID pvObject,
+ _In_ GDILOOBJTYPE eObjType)
+{
+ 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;
+ }
+
+ /* Setup the link structure */
+ pcol->hobj = hobj;
+ pcol->pvObj = pvObject;
+
+ /* Enter the critical section */
+ EnterCriticalSection(&gcsClientObjLinks);
+
+ /* Insert the link structure */
+ pcol->pcolNext = gapcolHashTable[iHashIndex];
+ gapcolHashTable[iHashIndex] = pcol;
+
+ /* Leave the critical section */
+ LeaveCriticalSection(&gcsClientObjLinks);
+
+ return hobj;
+}
+
+PVOID
+WINAPI
+GdiGetClientObject(
+ _In_ HGDIOBJ hobj)
+{
+ ULONG iHashIndex;
+ PCLIENTOBJLINK pcol;
+ PVOID pvObject = NULL;
+
+ /* Calculate the hash index */
+ iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
+
+ /* Enter the critical section */
+ EnterCriticalSection(&gcsClientObjLinks);
+
+ /* Loop the link entries in this hash bucket */
+ pcol = gapcolHashTable[iHashIndex];
+ while (pcol != NULL)
+ {
+ /* Check if this is the object we want */
+ if (pcol->hobj == hobj)
+ {
+ /* Get the object pointer and bail out */
+ pvObject = pcol->pvObj;
+ break;
+ }
+
+ /* Go to the next entry */
+ pcol = pcol->pcolNext;
+ }
+
+ /* Leave the critical section */
+ LeaveCriticalSection(&gcsClientObjLinks);
+
+ return pvObject;
+}
+
+PVOID
+WINAPI
+GdiRemoveClientObject(
+ _In_ HGDIOBJ hobj)
+{
+ PCLIENTOBJLINK pcol, *ppcol;
+ ULONG iHashIndex;
+ PVOID pvObject = NULL;
+
+ /* Calculate the hash index */
+ iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
+
+ /* Enter the critical section */
+ EnterCriticalSection(&gcsClientObjLinks);
+
+ /* Loop the link entries in this hash bucket */
+ ppcol = &gapcolHashTable[iHashIndex];
+ while (*ppcol != NULL)
+ {
+ /* Get the current client object link */
+ pcol = *ppcol;
+
+ /* Check if this is the one we want */
+ if (pcol->hobj == hobj)
+ {
+ /* Update the link pointer, removing this link */
+ *ppcol = pcol->pcolNext;
+
+ /* Get the object pointer */
+ pvObject = pcol->pvObj;
+
+ /* Free the link structure */
+ HeapFree(GetProcessHeap(), 0, pcol);
+
+ /* We're done */
+ break;
+ }
+
+ /* Go to the next link pointer */
+ ppcol = &(pcol->pcolNext);
+ }
+
+ /* Leave the critical section */
+ LeaveCriticalSection(&gcsClientObjLinks);
+
+ /* Return the object pointer, or NULL if we did not find it */
+ return pvObject;
+}
Propchange: trunk/reactos/win32ss/gdi/gdi32/objects/clientobj.c
------------------------------------------------------------------------------
svn:eol-style = native