ReactOS  0.4.15-dev-4614-ga5a6101
clientobj.c File Reference
#include <precomp.h>
Include dependency graph for clientobj.c:

Go to the source code of this file.

Classes

struct  _CLIENTOBJLINK
 

Typedefs

typedef struct _CLIENTOBJLINK CLIENTOBJLINK
 
typedef struct _CLIENTOBJLINKPCLIENTOBJLINK
 

Functions

BOOL WINAPI GdiCreateClientObjLink (_In_ HGDIOBJ hobj, _In_ PVOID pvObject)
 
PVOID WINAPI GdiGetClientObjLink (_In_ HGDIOBJ hobj)
 
PVOID WINAPI GdiRemoveClientObjLink (_In_ HGDIOBJ hobj)
 
HGDIOBJ WINAPI GdiCreateClientObj (_In_ PVOID pvObject, _In_ GDILOOBJTYPE eObjType)
 
PVOID WINAPI GdiDeleteClientObj (_In_ HGDIOBJ hobj)
 

Variables

CRITICAL_SECTION gcsClientObjLinks
 
ULONG gcClientObj
 
PCLIENTOBJLINK gapcolHashTable [127]
 

Typedef Documentation

◆ CLIENTOBJLINK

◆ PCLIENTOBJLINK

Function Documentation

◆ GdiCreateClientObj()

HGDIOBJ WINAPI GdiCreateClientObj ( _In_ PVOID  pvObject,
_In_ GDILOOBJTYPE  eObjType 
)

Definition at line 148 of file clientobj.c.

151 {
152  HGDIOBJ hobj;
153 
154  /* Call win32k to create a client object handle */
155  hobj = NtGdiCreateClientObj(eObjType);
156  if (hobj == NULL)
157  {
158  return NULL;
159  }
160 
161  /* Create the client object link */
162  if (!GdiCreateClientObjLink(hobj, pvObject))
163  {
164  NtGdiDeleteClientObj(hobj);
165  return NULL;
166  }
167 
168  return hobj;
169 }
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteClientObj(_In_ HANDLE h)
BOOL WINAPI GdiCreateClientObjLink(_In_ HGDIOBJ hobj, _In_ PVOID pvObject)
Definition: clientobj.c:24
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiCreateClientObj(_In_ ULONG ulType)
#define NULL
Definition: types.h:112

Referenced by alloc_gdi_handle(), and CreateMetaFileW().

◆ GdiCreateClientObjLink()

BOOL WINAPI GdiCreateClientObjLink ( _In_ HGDIOBJ  hobj,
_In_ PVOID  pvObject 
)

Definition at line 24 of file clientobj.c.

27 {
28  PCLIENTOBJLINK pcol;
29  ULONG iHashIndex;
30 
31  /* Allocate a link structure */
32  pcol = HeapAlloc(GetProcessHeap(), 0, sizeof(*pcol));
33  if (pcol == NULL)
34  {
35  return FALSE;
36  }
37 
38  /* Setup the link structure */
39  pcol->hobj = hobj;
40  pcol->pvObj = pvObject;
41 
42  /* Calculate the hash index */
43  iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
44 
45  /* Enter the critical section */
47 
48  /* Insert the link structure */
49  pcol->pcolNext = gapcolHashTable[iHashIndex];
50  gapcolHashTable[iHashIndex] = pcol;
51  gcClientObj++;
52 
53  /* Leave the critical section */
55 
56  return TRUE;
57 }
#define TRUE
Definition: types.h:120
ULONG gcClientObj
Definition: clientobj.c:11
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define _countof(array)
Definition: sndvol32.h:68
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
PCLIENTOBJLINK gapcolHashTable[127]
Definition: clientobj.c:20
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by GDI_hdc_using_object(), and GdiCreateClientObj().

◆ GdiDeleteClientObj()

PVOID WINAPI GdiDeleteClientObj ( _In_ HGDIOBJ  hobj)

Definition at line 173 of file clientobj.c.

175 {
176  PVOID pvObject;
177 
178  /* Remove the client object link */
179  pvObject = GdiRemoveClientObjLink(hobj);
180  if (pvObject == NULL)
181  {
182  return NULL;
183  }
184 
185  /* Call win32k to delete the handle */
186  if (!NtGdiDeleteClientObj(hobj))
187  {
188  ASSERT(FALSE);
189  }
190 
191  return pvObject;
192 }
__kernel_entry W32KAPI BOOL APIENTRY NtGdiDeleteClientObj(_In_ HANDLE h)
PVOID WINAPI GdiRemoveClientObjLink(_In_ HGDIOBJ hobj)
Definition: clientobj.c:98
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
#define NULL
Definition: types.h:112

Referenced by CloseMetaFile(), CreateMetaFileW(), free_gdi_handle(), and METADC_DeleteDC().

◆ GdiGetClientObjLink()

PVOID WINAPI GdiGetClientObjLink ( _In_ HGDIOBJ  hobj)

Definition at line 61 of file clientobj.c.

63 {
64  ULONG iHashIndex;
65  PCLIENTOBJLINK pcol;
66  PVOID pvObject = NULL;
67 
68  /* Calculate the hash index */
69  iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
70 
71  /* Enter the critical section */
73 
74  /* Loop the link entries in this hash bucket */
75  pcol = gapcolHashTable[iHashIndex];
76  while (pcol != NULL)
77  {
78  /* Check if this is the object we want */
79  if (pcol->hobj == hobj)
80  {
81  /* Get the object pointer and bail out */
82  pvObject = pcol->pvObj;
83  break;
84  }
85 
86  /* Go to the next entry */
87  pcol = pcol->pcolNext;
88  }
89 
90  /* Leave the critical section */
92 
93  return pvObject;
94 }
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define _countof(array)
Definition: sndvol32.h:68
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
PCLIENTOBJLINK gapcolHashTable[127]
Definition: clientobj.c:20
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by GDI_GetObjPtr(), get_dc_ptr(), and get_metadc_ptr().

◆ GdiRemoveClientObjLink()

PVOID WINAPI GdiRemoveClientObjLink ( _In_ HGDIOBJ  hobj)

Definition at line 98 of file clientobj.c.

100 {
101  PCLIENTOBJLINK pcol, *ppcol;
102  ULONG iHashIndex;
103  PVOID pvObject = NULL;
104 
105  /* Calculate the hash index */
106  iHashIndex = (ULONG_PTR)hobj % _countof(gapcolHashTable);
107 
108  /* Enter the critical section */
110 
111  /* Loop the link entries in this hash bucket */
112  ppcol = &gapcolHashTable[iHashIndex];
113  while (*ppcol != NULL)
114  {
115  /* Get the current client object link */
116  pcol = *ppcol;
117 
118  /* Check if this is the one we want */
119  if (pcol->hobj == hobj)
120  {
121  /* Update the link pointer, removing this link */
122  *ppcol = pcol->pcolNext;
123  gcClientObj--;
124 
125  /* Get the object pointer */
126  pvObject = pcol->pvObj;
127 
128  /* Free the link structure */
129  HeapFree(GetProcessHeap(), 0, pcol);
130 
131  /* We're done */
132  break;
133  }
134 
135  /* Go to the next link pointer */
136  ppcol = &(pcol->pcolNext);
137  }
138 
139  /* Leave the critical section */
141 
142  /* Return the object pointer, or NULL if we did not find it */
143  return pvObject;
144 }
ULONG gcClientObj
Definition: clientobj.c:11
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define GetProcessHeap()
Definition: compat.h:595
#define _countof(array)
Definition: sndvol32.h:68
CRITICAL_SECTION gcsClientObjLinks
Definition: clientobj.c:10
PCLIENTOBJLINK gapcolHashTable[127]
Definition: clientobj.c:20
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by GDI_hdc_not_using_object(), GdiDeleteClientObj(), and METADC_RosGlueDeleteObject().

Variable Documentation

◆ gapcolHashTable

PCLIENTOBJLINK gapcolHashTable[127]

Definition at line 20 of file clientobj.c.

Referenced by GdiCreateClientObjLink(), GdiGetClientObjLink(), and GdiRemoveClientObjLink().

◆ gcClientObj

ULONG gcClientObj

Definition at line 11 of file clientobj.c.

Referenced by DeleteObject(), GdiCreateClientObjLink(), and GdiRemoveClientObjLink().

◆ gcsClientObjLinks