Re: Problem with linked list
From: Peter Schmitz (PeterSchmitz_at_discussions.microsoft.com)
Date: 08/13/04
- Next message: Max Paklin: "Re: Custom DeviceIoControl Handling in Stream Minidrive ? (shared memory user - kernel)"
- Previous message: Brian Catlin: "Re: Desperately want GDIINFO, how can I obtain this structure?"
- In reply to: Peter Wieland [MSFT]: "Re: Problem with linked list"
- Next in thread: Peter Wieland [MSFT]: "Re: Problem with linked list"
- Reply: Peter Wieland [MSFT]: "Re: Problem with linked list"
- Reply: Ray Trent: "Re: Problem with linked list"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 13 Aug 2004 10:37:04 -0700
Thanks for both answers!
It's true that I forgot to include the LIST_ENTRY size (now I know what few
sleep and lots of coffee can cause....), but anyway, adding this
unfortunately doesn't solve the problem.
The buffer is filled the following way:
//this is an excerpt of the function that fills MYSTRUCT a with data
NdisAllocateMemoryWithTag(&a->buffer,numbertoread,'HASA');
UTILReadOnPacket(packet,a->buffer,numbertoread,0,&BytesRead);
The second function is one of pcausa (thanks, by the way) and can be found at
http://www.ndis.com/papers/ndispacket/ndispacket1.htm
numbertoread contains the complete size of the ethernet packet (14bytes for
the ethernet frame and the ip header length field).
Any ideas?
Peter
"Peter Wieland [MSFT]" wrote:
> probably because you have a bug that's causing pool corruption.
>
> what's in the [...] section of MYSTRUCT (which you don't appear to have
> accounted for in your calculation of the size?).
> have you considered adding enough memory to your allocation of MYLIST to
> include the LIST_ENTRY?
>
> perhaps (sizeof(MYLIST) + a.bufferlen) would be a more sensible way to
> determine the size of the buffer than adding up the individual structure
> elements.
>
> -p
>
>
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Peter Schmitz" <mosquitooth@gmx.net> wrote in message
> news:O9a21iUgEHA.3192@tk2msftngp13.phx.gbl...
> > Hi again,
> >
> > I implemented the following double linked list stuff:
> >
> > typedef struct __MYSTRUCT {
> > UINT t;
> > [...]
> > UINT bufferlen; //length of buffer
> > BYTE *buffer;
> > }MYSTRUCT;
> >
> > typedef struct __MYLIST{
> > MYSTRUCT mystr;
> > LIST_ENTRY linkfield;
> > }MYLIST, *PMYLIST;
> >
> > LIST_ENTRY DoubleHead;
> > -------------------------------------------------------
> > [...]
> > MYSTRUCT a; //filled with data
> >
> > /*The size of all the entries is dynamic, that's why the size of the
> > structure is allocated again every time*/
> > UINT structsize = sizeof(UINT) + sizeof(UINT) + sizeof(a.buffer) +
> > a.bufferlen;
> >
> > PMYLIST psElement = (PMYLIST)
> > ExAllocatePoolWithTag(PagedPool,structsize,'HASA'); //here we CRASH!!!
> >
> > if(psElement == NULL)
> > {
> > DBGPRINT(("Allocatepool failed!"));
> > }
> > else
> > {
> > psElement->mystr = a;
> >
> > NdisAcquireSpinLock(&GlobalLock);
> > if(numberofentries <= MAX_LIST_ENTRIES) //limit for #elements
> > {
> > InsertTailList(&DoubleHead,&psElement->linkfield);
> > numberofentries = numberofentries + 1;
> > }
> > NdisReleaseSpinLock(&GlobalLock);
> > }
> >
> > When I execute the code above, the computer crashes:
> > DRIVER_CORRUPTED_EXPOOL, with an error in the marked line above.
> >
> > Any ideas why?
> >
> > Thanks
> > Peter
>
>
>
- Next message: Max Paklin: "Re: Custom DeviceIoControl Handling in Stream Minidrive ? (shared memory user - kernel)"
- Previous message: Brian Catlin: "Re: Desperately want GDIINFO, how can I obtain this structure?"
- In reply to: Peter Wieland [MSFT]: "Re: Problem with linked list"
- Next in thread: Peter Wieland [MSFT]: "Re: Problem with linked list"
- Reply: Peter Wieland [MSFT]: "Re: Problem with linked list"
- Reply: Ray Trent: "Re: Problem with linked list"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|