RemoveTailList - NtDoc

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

FORCEINLINE
PLIST_ENTRY
NTAPI_INLINE
RemoveTailList(
    _Inout_ PLIST_ENTRY ListHead
    )
{
    PLIST_ENTRY Entry;
    PLIST_ENTRY PrevEntry;

    Entry = ListHead->Blink;
    PrevEntry = Entry->Blink;

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

    ListHead->Blink = PrevEntry;
    PrevEntry->Flink = ListHead;

    return Entry;
}

#endif

View code on GitHub
// wdm.h

PLIST_ENTRY RemoveTailList(
  [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-removetaillist)

RemoveTailList function

Description

The RemoveTailList routine removes an entry from the end 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

RemoveTailList returns a pointer to the entry that was at the tail of the list. If the list is empty, RemoveTailList returns ListHead.

Remarks

RemoveTailList removes the last entry from the list by setting ListHead->Blink to point to the second-to-last entry in the list. The routine sets the Flink member of the new first 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 InsertHeadList can be running at any IRQL. If InsertHeadList is called at IRQL >= DISPATCH_LEVEL, the storage for ListHead and the list entries must be resident.

See also

InitializeListHead

IsListEmpty

RemoveEntryList

RemoveHeadList