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 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; }
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; }