RemoveHeadList - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H

FORCEINLINE
PLIST_ENTRY
NTAPI_INLINE
RemoveHeadList(
    _Inout_ PLIST_ENTRY ListHead
    )
{
    PLIST_ENTRY Entry;
    PLIST_ENTRY NextEntry;

    Entry = ListHead->Flink;
    NextEntry = Entry->Flink;

#if !defined(NO_LIST_ENTRY_CHECKS)
    if ((Entry->Blink != ListHead) || (NextEntry->Blink != Entry)) 
    {
        RtlFatalListEntryError((PVOID)ListHead, (PVOID)Entry, (PVOID)NextEntry);
    }
#endif

    ListHead->Flink = NextEntry;
    NextEntry->Blink = ListHead;

    return Entry;
}

#endif

View code on GitHub
// wdm.h

PLIST_ENTRY RemoveHeadList(
  [in, out] PLIST_ENTRY ListHead
);

View the official Windows Driver Kit DDI reference

NtDoc

This function is documented in Windows Driver Kit.

Windows Driver Kit DDI reference (nf-wdm-removeheadlist)

RemoveHeadList function

Description

The RemoveHeadList routine removes an entry from the beginning of a doubly linked list of LIST_ENTRY structures.

Parameters

ListHead [in, out]

Pointer to the LIST_ENTRY structure that serves as the list header.

Return value

RemoveHeadList returns a pointer to the entry removed from the list. If the list is empty, RemoveHeadList returns ListHead.

Remarks

RemoveHeadList removes the first entry from the list by setting ListHead->Flink to point to the second entry in the list. The routine sets the Blink member of the second entry to ListHead. In the event the list is empty, this is effectively a no-op.

For information about using this routine when implementing a doubly linked list, see Singly and Doubly Linked Lists.

Callers of RemoveHeadList can be running at any IRQL. If RemoveHeadList is called at IRQL >= DISPATCH_LEVEL, the storage for ListHead and the list entries must be resident.

See also

ExInterlockedRemoveHeadList

InitializeListHead

IsListEmpty

RemoveEntryList

RemoveTailList