VOID LinkListTest()
{
LIST_ENTRY linkListHead;
//初始化链表
InitializeListHead(&linkListHead);
PMYDATASTRUCT pData;
KdPrint(("begin insert to the link list\n"));
ULONG i;
for (i = 0;i < 10;i++)
{
//分配分页内存
pData = (PMYDATASTRUCT)ExAllocatePool(PagedPool,sizeof(MYDATASTRUCT));
pData->number = i;
//从头部插入链表
InsertHeadList(&linkListHead,&pData->ListEntry);
}
//从链表读取并且显示
KdPrint(("Begin remove \n"));
while (!IsListEmpty(&linkListHead))
{
//从尾部开始删除链表
PLIST_ENTRY pEntry = RemoveTailList(&linkListHead);
pData = CONTAINING_RECORD(pEntry,MYDATASTRUCT,ListEntry);
KdPrint(("%d\n",pData->number));
ExFreePool(pData);
}
}