判断链表是否为空 IsListEmpty
初始化双向链表头 InitializeListHead
插入链表头部 InsertHeadList
插入链表尾部 InsertTailList
移除头部节点 RemoveHeadList
移除尾部节点 RemoveTailList
移除当前节点 RemoveEntryList
#include <ntifs.h>
#include <ntstrsafe.h>
typedef struct _TEST
{
ULONG u1;
ULONG u2;
LIST_ENTRY node;
}TEST,*PTEST;
VOID DriverUnload(PDRIVER_OBJECT pDriver)
{
DbgPrint("驱动卸载! \n");
}
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriver, PUNICODE_STRING pReg)
{
//测试链表结构
TEST Test[5] = { 0 };
for (size_t i = 0; i < 5; i++)
{
Test[i].u1 = i;
Test[i].u2 = i;
}
//初始化链表
InitializeListHead(&Test[0].node);
//判断链表是否为空
if (IsListEmpty(&Test[0].node))
{
DbgPrint("Empty");
}
//头部插入节点
InsertHeadList(&Test[0].node, &Test[1].node);
InsertHeadList(&Test[0].node, &Test[2].node);
//尾部插入节点
InsertHeadList(&Test[0].node, &Test[3].node);
pDriver->DriverUnload = DriverUnload;
return STATUS_SUCCESS;
}
1491

被折叠的 条评论
为什么被折叠?



