阅读:1018回复:3
帮帮小弟
NDIS_PROTOCOL_CHARACTERISTICS Protocol;
Protocol.ReceiveHandler= recv; .......... 后调NdisRegisterProtocol, 问题(1)我能不能改变recv里接收到的数据? (2)怎么改变呢? :D能发个例子让小弟学习 不胜感激 :D |
|
沙发#
发布于:2002-11-03 16:06
我也是粘过来的
以前的文章里有 ///////////////////////////////////////////////////////////////////////////// //// UTILReadOnPacket // // Purpose // Logical read on the packet data in a NDIS_PACKET. // // Parameters // // Return Value // // Remarks // The purpose of this function is to provide a convenient mechanism to // read packet data from an NDIS_PACKET that may have multiple chained // NDIS_BUFFERs. // VOID UTILReadOnPacket( PNDIS_PACKET Packet, PUCHAR lpBuffer, ULONG nNumberOfBytesToRead, ULONG nOffset, // Byte Offset, Starting With MAC Header PULONG lpNumberOfBytesRead ) { PNDIS_BUFFER CurrentBuffer; UINT nBufferCount, TotalPacketLength; PUCHAR VirtualAddress; UINT CurrentLength, CurrentOffset; UINT AmountToMove; *lpNumberOfBytesRead = 0; if (!nNumberOfBytesToRead) return; // // Query Packet // NdisQueryPacket( (PNDIS_PACKET )Packet, (PUINT )NULL, // Physical Buffer Count (PUINT )&nBufferCount, // Buffer Count &CurrentBuffer, // First Buffer &TotalPacketLength // TotalPacketLength ); // // Query The First Buffer // NdisQueryBuffer( CurrentBuffer, &VirtualAddress, &CurrentLength ); CurrentOffset = 0; while( nOffset || nNumberOfBytesToRead ) { while( !CurrentLength ) { NdisGetNextBuffer( CurrentBuffer, &CurrentBuffer ); // If we\'ve reached the end of the packet. We return with what // we\'ve done so far (which must be shorter than requested). if (!CurrentBuffer) return; NdisQueryBuffer( CurrentBuffer, &VirtualAddress, &CurrentLength ); CurrentOffset = 0; } if( nOffset ) { // Compute how much data to move from this fragment if( CurrentLength > nOffset ) CurrentOffset = nOffset; else CurrentOffset = CurrentLength; nOffset -= CurrentOffset; CurrentLength -= CurrentOffset; } if( nOffset ) { CurrentLength = 0; continue; } if( !CurrentLength ) { continue; } // Compute how much data to move from this fragment if (CurrentLength > nNumberOfBytesToRead) AmountToMove = nNumberOfBytesToRead; else AmountToMove = CurrentLength; // Copy the data. NdisMoveMemory( lpBuffer, &VirtualAddress[ CurrentOffset ], AmountToMove ); // Update destination pointer lpBuffer += AmountToMove; // Update counters *lpNumberOfBytesRead +=AmountToMove; nNumberOfBytesToRead -=AmountToMove; CurrentLength = 0; } } |
|
板凳#
发布于:2002-11-03 17:31
:D谢谢你!
|
|
地板#
发布于:2002-11-03 17:36
哈哈 你写的很难的啊 对我这个新手来说 要多研究一下 :D
|
|