阅读:1497回复:2
FltReadOnPacket 这个api到哪里也找不到啊! 高手帮忙啊~
//读取IP包头
FltReadOnPacket(Packet, &IPHeader, sizeof( IPHeader ), sizeof( struct _ether_header ),&NumberOfBytesRead); FltReadOnPacket api到哪里也找不到啊! 高手帮忙啊~ |
|
沙发#
发布于:2010-04-10 17:40
VOID FltReadOnPacket( IN PNDIS_PACKET Packet, IN PVOID lpBufferIn, IN ULONG nNumberOfBytesToRead, IN ULONG nOffset, // Byte Offset, Starting With MAC Header OUT PULONG lpNumberOfBytesRead ) { PNDIS_BUFFER CurrentBuffer; UINT nBufferCount, TotalPacketLength; PUCHAR VirtualAddress = NULL; PUCHAR lpBuffer = (PUCHAR )lpBufferIn; UINT CurrentLength, CurrentOffset; UINT AmountToMove; // // Sanity Check // if( !Packet || !lpBuffer || !lpNumberOfBytesRead ) { if( lpNumberOfBytesRead ) { *lpNumberOfBytesRead = 0; } return; } *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 // #if (defined(NDIS50) || defined(NDIS51)) NdisQueryBufferSafe( CurrentBuffer, &VirtualAddress, &CurrentLength, NormalPagePriority ); #else NdisQueryBuffer( CurrentBuffer, &VirtualAddress, &CurrentLength ); #endif // // Handle Possible Low-Resource Failure Of NdisQueryBufferSafe // if( !VirtualAddress ) { return; } __try { 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) __leave; // Leave __try and eventually return... #if (defined(NDIS50) || defined(NDIS51)) NdisQueryBufferSafe( CurrentBuffer, &VirtualAddress, &CurrentLength, NormalPagePriority ); #else NdisQueryBuffer( CurrentBuffer, &VirtualAddress, &CurrentLength ); #endif // // Handle Possible Low-Resource Failure Of NdisQueryBufferSafe // if( !VirtualAddress ) { __leave; // Leave __try and eventually return... } 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; } } __finally { // // lpNumberOfBytesRead may be less then specified if exception // occured... // } } |
|
板凳#
发布于:2010-04-10 19:40
楼上的 yexin218 , 真是太感谢你啊!!!!!!!!!
谢谢啊·~~~ |
|