XiangXiangRen
总版主
总版主
  • 注册日期2003-02-22
  • 最后登录2015-09-01
  • 粉丝13
  • 关注0
  • 积分1042分
  • 威望472点
  • 贡献值1点
  • 好评度145点
  • 原创分13分
  • 专家分1分
阅读:1409回复:4

关于协议驱动例子packet的求助

楼主#
更多 发布于:2003-03-05 11:48
  我在win98上安装了98ddk上的协议驱动的例子packet,DriverEntry等等函数的调试信息也输出了,而且也调用了绑定函数,为什么重启之后,从来不见收到数据包呢(看不见Receive的调试信息),各位兄弟能帮帮忙吗?
rainsoft
驱动牛犊
驱动牛犊
  • 注册日期2002-11-08
  • 最后登录2003-07-14
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2003-03-05 16:00
可能写错了
nicol
驱动大牛
驱动大牛
  • 注册日期2001-11-28
  • 最后登录2009-07-30
  • 粉丝0
  • 关注0
  • 积分45分
  • 威望5点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-03-05 16:12
把你的receive函数贴上来。看看
==寂寞骆驼==
XiangXiangRen
总版主
总版主
  • 注册日期2003-02-22
  • 最后登录2015-09-01
  • 粉丝13
  • 关注0
  • 积分1042分
  • 威望472点
  • 贡献值1点
  • 好评度145点
  • 原创分13分
  • 专家分1分
地板#
发布于:2003-03-05 17:39
这个Receive就是98DDK中的Packet的Receive,我只加了一句话
NDIS_STATUS NDIS_API
PacketReceiveIndicate ( IN NDIS_HANDLE ProtocolBindingContext,
IN NDIS_HANDLE MacReceiveContext,
IN PVOID       pvHeaderBuffer,
IN UINT        uiHeaderBufferSize,
IN PVOID       pvLookAheadBuffer,
IN UINT        uiLookaheadBufferSize,
IN UINT        uiPacketSize
)
/*++

Routine Description:

Arguments:

Return Value:

    Status is returned.

--*/

#define pOpen ((POPEN_INSTANCE)ProtocolBindingContext)

{
PLIST_ENTRY PacketListEntry;
PNDIS_PACKET   pPacket;
ULONG           ulSizeToTransfer;
NDIS_STATUS     Status;
UINT           uiBytesTransferred;
PPACKET_RESERVED pReserved;
PNDIS_BUFFER pNdisBuffer;
PVOID pvActualVirtualAddress;
UINT uiActualLength;


// we wait to print the trace to see if we even have a buffer

PACKETASSERT( (pOpen != NULL) );

//
//  See if there are any pending read that we can satisfy
//
NdisAcquireSpinLock( &pOpen->RcvQSpinLock );

PacketListEntry = PacketRemoveHeadList( &pOpen->RcvList );

NdisReleaseSpinLock( &pOpen->RcvQSpinLock );

_Debug_Printf_Service(\"接收到包了!\");


if ( PacketListEntry == NULL )
{
return NDIS_STATUS_SUCCESS;
}


TRACE_ENTER( \"IndicateReceive\" );

pReserved = CONTAINING_RECORD( PacketListEntry, PACKET_RESERVED, ListElement );
pPacket   = CONTAINING_RECORD( pReserved, NDIS_PACKET, ProtocolReserved );


// Let\'s only print this when PACKET_DEBUG_VERY_LOUD is set
IF_PACKETDEBUG( PACKET_DEBUG_VERY_LOUD )
{
IF_TRACE_MSG( \"   Reserved : %lx\", pReserved );
IF_TRACE_MSG( \"    pPacket : %lx\", pPacket );
IF_TRACE_MSG2( \"     Header : %lx  %lx\", pvHeaderBuffer, uiHeaderBufferSize );
IF_TRACE_MSG2( \"  LookAhead : %lx  %lx\", pvLookAheadBuffer, uiLookaheadBufferSize );
IF_TRACE_MSG( \" PacketSize : %lx\", uiPacketSize );
}


PACKETASSERT( (pReserved != NULL) );
PACKETASSERT( (pPacket != NULL) );

// Clear total

uiBytesTransferred = 0;

// Get pointer to private buffer

pNdisBuffer = pPacket->Private.Head;

// Save private buffer\'s start address

pvActualVirtualAddress = pNdisBuffer->VirtualAddress;
uiActualLength = pNdisBuffer->Length;


// Copy header buffer into client buffer

if ( uiHeaderBufferSize > 0 )
{
if ( uiHeaderBufferSize > pNdisBuffer->Length )

uiHeaderBufferSize = pNdisBuffer->Length;

// copy the header buffer

NdisMoveMemory( pNdisBuffer->VirtualAddress, pvHeaderBuffer, uiHeaderBufferSize );

// update bytes transferred

uiBytesTransferred += uiHeaderBufferSize;

// Advance the NDIS_BUFFER address to the end of the header

(BYTE *)(pNdisBuffer->VirtualAddress) += uiHeaderBufferSize;

// Adjust the NDIS_BUFFER Length

pNdisBuffer->Length -= uiHeaderBufferSize;
}


// Copy look ahead buffer into client buffer

if ( uiLookaheadBufferSize > 0 )
{
if ( uiLookaheadBufferSize > pNdisBuffer->Length )

uiLookaheadBufferSize = pNdisBuffer->Length;

NdisMoveMemory( pNdisBuffer->VirtualAddress, pvLookAheadBuffer, uiLookaheadBufferSize );

// update bytes transferred

uiBytesTransferred += uiLookaheadBufferSize;

// Advance the NDIS_BUFFER address to the end of the Lookahead data

(BYTE *)(pNdisBuffer->VirtualAddress) += uiLookaheadBufferSize;

// Adjust the NDIS_BUFFER Length

pNdisBuffer->Length -= uiLookaheadBufferSize;
}


// Save bytes transferred to client buffer so far

*(pReserved->lpcbBytesReturned) = uiBytesTransferred;


// Copy any remaining bytes in packet

if ( uiLookaheadBufferSize < uiPacketSize )
{
if ( uiPacketSize >= 1500 )
{
_asm { int 3 }
}

// Adjust packet size by the look ahead buffer

ulSizeToTransfer = uiPacketSize - uiLookaheadBufferSize;

// Make sure we only copy as many bytes as the client buffer can handler

if ( ulSizeToTransfer > pNdisBuffer->Length )

ulSizeToTransfer = pNdisBuffer->Length;


//  Call the Mac to transfer the packet

NdisTransferData( &Status, // ndis status
pOpen->AdapterHandle, // from NdisOpenAdapter
MacReceiveContext, // handle from NIC
uiLookaheadBufferSize, // offset from start of buffer
ulSizeToTransfer, // number of bytes to copy
pPacket, // packet descriptor pointer
&uiBytesTransferred ); // number of bytes actually copied

// Restore the private buffer\'s address pointer

pNdisBuffer->VirtualAddress = pvActualVirtualAddress;
pNdisBuffer->Length = uiActualLength;

if ( Status != NDIS_STATUS_PENDING )
{
//  If it didn\'t pend, call the completeion routine now

PacketTransferDataComplete( pOpen, // protocol context
pPacket, // packet descriptor pointer
Status, // ndis status
uiBytesTransferred );// number of bytes actually copied
}
}
else
{
// The entire packet was in the look ahead buffer

Status = NDIS_STATUS_SUCCESS;

// Restore the private buffer\'s address pointer

pNdisBuffer->VirtualAddress = pvActualVirtualAddress;
pNdisBuffer->Length = uiActualLength;

PacketTransferDataComplete( pOpen, // protocol context
pPacket, // packet descriptor pointer
Status, // ndis status
0 ); // number of bytes copied by NdisTransferData
}

TRACE_LEAVE( \"IndicateReceive\" );

return NDIS_STATUS_SUCCESS;
XiangXiangRen
总版主
总版主
  • 注册日期2003-02-22
  • 最后登录2015-09-01
  • 粉丝13
  • 关注0
  • 积分1042分
  • 威望472点
  • 贡献值1点
  • 好评度145点
  • 原创分13分
  • 专家分1分
地下室#
发布于:2003-03-05 17:44
但是我觉得不是这个Receive有错,而是奇怪为何我已经绑定了网卡,这个Receive却总是得不到调用呢?
我另外又找了VtoolD下的一个协议驱动例子ndisprol,这个更邪气了。inf文件中拷贝到目的文件夹明明是11,结果却总是拷贝到c:\\windows下。调试信息是这样的:
-51.182749   Default     TRANS31 : OnSysDynamicDeviceInit Entry...
-51.182710   Default     TRANS31 : DriverEntry Entry...
-51.182687   Default     TRANS31 : Calling NdisRegisterProtocol...
-51.182613   Default     TRANS31 : NdisRegisterProtocol succeeded
,然后就什么都没有了!重起之后也没有什么,连ProtocolBindAdapter都没有调用。更别说调用ProtocolRecieve了
游客

返回顶部