Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

NdisAllocateNetBufferAndNetBufferList wrong pool type

kolakola Member Posts: 7

I want to send UDP packet from my filter driver, and use the following code:

NdisZeroMemory(&PoolParameters, sizeof(NET_BUFFER_LIST_POOL_PARAMETERS));

PoolParameters.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
PoolParameters.ProtocolId = NDIS_PROTOCOL_ID_DEFAULT;
PoolParameters.ContextSize = 0;
PoolParameters.DataSize = 0x100; // My packet size
PoolParameters.fAllocateNetBuffer = TRUE;
PoolParameters.PoolTag = 'KFLT';

NDIS_HANDLE hPoolHandle = NdisAllocateNetBufferListPool(g_NdisFilterDeviceHandle, &PoolParameters);

PNET_BUFFER_LIST pMyNbl = NdisAllocateNetBufferAndNetBufferList(hPoolHandle, 0, 0, NULL, 0, 0);

NdisAllocateNetBufferListPool returns valid handle, but NdisAllocateNetBufferAndNetBufferList returns NULL, and outputs the debug string:

NdisAllocateNetBufferAndNetBufferList: Pool <address> wrong pool type

Can you explain what's wrong?


  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,050

    I know LESS than nothing about NDIS anymore. But I can read the documentation:

    The fAllocateNetBuffer member of the NET_BUFFER_LIST_POOL_PARAMETERS structure that the caller passed to NdisAllocateNetBufferListPool must have been set to TRUE and the DataSize member set to zero.


    Peter Viscarola

  • kolakola Member Posts: 7

    Good point, but a bit below, opposite thing is written:

    You can also call NdisAllocateNetBufferListPool and set the DataSize member to a nonzero value when creating a NET_BUFFER_LIST structure pool. In this case, a NET_BUFFER structure, MDL, and data are preallocated with each NET_BUFFER_LIST structure that the caller allocates from the pool.

    However, in this case, NdisAllocateNetBufferList should be used, that makes sense, since NET_BUFFER is already pre-allocated by NdisAllocateNetBufferListPool.

    Now it works , thanks again, Peter!

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,050

    That’s why I’m here: To work miracles. By reading the MSDN pages. ;-)


    Peter Viscarola

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 30 Nov 2020 LIVE ONLINE
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Developing Minifilters Early 2021 LIVE ONLINE