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?