NdisAllocateNetBufferAndNetBufferList wrong pool type

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

NET_BUFFER_LIST_POOL_PARAMETERS PoolParameters;
NdisZeroMemory(&PoolParameters, sizeof(NET_BUFFER_LIST_POOL_PARAMETERS));

PoolParameters.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
PoolParameters.Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
PoolParameters.Header.Size = NDIS_SIZEOF_NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
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?

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

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!

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

Peter