daisyboy
驱动小牛
驱动小牛
  • 注册日期2002-10-24
  • 最后登录2012-05-21
  • 粉丝3
  • 关注0
  • 积分599分
  • 威望140点
  • 贡献值1点
  • 好评度56点
  • 原创分0分
  • 专家分0分
阅读:1445回复:0

为什么NdisAllocateBufferPool总是分出NULL????

楼主#
更多 发布于:2004-01-30 19:15
小弟初学NDIS,想做个NdisTransferData的东东。参考网上的代码,实现如下:
NDIS_STATUS NDIS_API
My_Receive(
    IN NDIS_HANDLE NdisBindingContext,
    IN NDIS_HANDLE MacReceiveContext,
    IN PVOID HeaderBuffer,
    IN UINT HeaderBufferSize,
    IN PVOID LookAheadBuffer,
    IN UINT LookAheadBufferSize,
    IN UINT PacketSize
)
{
NDIS_STATUS status = NDIS_STATUS_SUCCESS;
PNDIS_PACKET Packet = NULL;
PNDIS_BUFFER hdr_buffer = NULL;
PNDIS_BUFFER data_buffer = NULL;
NDIS_PHYSICAL_ADDRESS  HighestAcceptableAddress;
UINT byteTransfered = 0;
void* buf = NULL;

NdisAllocatePacketPool(&status, &g_packet_pool, 20, sizeof(PACKET_RESERVED));
if(status!=NDIS_STATUS_SUCCESS )
{
dprintf((\"NdisAllocatePacketPool Failed.\\n\"));
}
NdisAllocateBufferPool(&status, &g_buffer_pool, 20);
if(status!=NDIS_STATUS_SUCCESS )
{
dprintf((\"NdisAllocateBufferPool Failed.\\n\"));
}
if(g_packet_pool==NULL)
{
          dprintf((\"ENUS_Receive:g_packet_pool is NULL.\\n\"));
}
else if(g_buffer_pool==NULL)
{
dprintf((\"ENUS_Receive:g_buffer_pool is NULL. %d\\n\",nstatus));
}
else
{
dprintf((\"ENUS_Receive:g_packet_pool=%x, g_buffer_pool=%x.\\n\",g_packet_pool,g_buffer_pool));
}

if( PacketSize>LookAheadBufferSize )
{
dprintf((\"ENUS_Receive:PacketSize = %d, LookAheadBufferSize = %d\\n\",PacketSize,LookAheadBufferSize));
buf = malloc_np(HeaderBufferSize + PacketSize);
if(buf == NULL)
{
dprintf((\"ENUS_Receive:malloc_np FAILED!\"));
           }
memcpy(buf, HeaderBuffer, HeaderBufferSize);
NdisAllocateBuffer(&status, &hdr_buffer, g_buffer_pool, buf, HeaderBufferSize);
NdisAllocateBuffer(&status, &data_buffer, g_buffer_pool, (char *)buf + HeaderBufferSize, PacketSize);
NdisAllocatePacket(&status, &Packet, g_packet_pool);

if(NULL!=Packet)
{
dprintf((\"ENUS_Receive:NdisAllocatePacket success\\n\"));
NdisChainBufferAtFront(Packet, data_buffer);
PROTOCOL_RESERVED(Packet)->buffer = hdr_buffer;
if(NULL!=NdisBindingContext)
          {
NdisTransferData( &status,
((PADAPT)NdisBindingContext)->BindingHandle,
MacReceiveContext,
0,
PacketSize,
Packet,
&byteTransfered
);
}
NdisFreePacket(Packet);
Packet = NULL;

可是跟踪发现 g_buffer_pool 总是NULL但status = NDIS_STATUS_SUCCESS,这是为什么啊???
合作c/c++/ndis/pppoe/802.1x!
游客

返回顶部