Exemple #1
0
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;
}
Exemple #2
0
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;
}