Hi,

I wrote the following code to walk a linked list:

>LIST_ENTRY DoubleHead; //points to the head of the double-linked
> list, initialized
>
> [...]
> PLIST_ENTRY plistentry = NULL;
> PMYSTRUCT pmystruct = NULL;
>
> if(!IsListEmpty(&DoubleHead))
> {
> plistentry = DoubleHead.Flink;
> while(plistentry != &DoubleHead)
> {
> pmystruct = CONTAINING_RECORD(plistentry, MYSTRUCT,
> linkfield);
>
> [...]//Doing some checking with pmystruct here
> plistentry = plistentry->Flink;//next one
> }
> }
>
Now, the problem is: although the list is filled with valid members
(not shown), when I check the items that way, 'pmystruct' contains
only invalid members. What am I doing wrong?


Thanks a lot
Peter

Re: Linked list in kernel mode by Walter

Walter
Sat Sep 18 08:06:46 CDT 2004

Peter Schmitz wrote:
> Now, the problem is: although the list is filled with valid members
> (not shown), when I check the items that way, 'pmystruct' contains
> only invalid members. What am I doing wrong?

Nothing that I can see. Did you initialize the list head before you
started putting elements onto it? Is there code elsewhere that frees the
MYSTRUCT's that are on the list?

--
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com