kok5168
驱动牛犊
驱动牛犊
  • 注册日期2010-03-07
  • 最后登录2010-06-06
  • 粉丝0
  • 关注0
  • 积分36分
  • 威望211点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1497回复:2

FltReadOnPacket 这个api到哪里也找不到啊! 高手帮忙啊~

楼主#
更多 发布于:2010-04-10 16:10
//读取IP包头
    FltReadOnPacket(Packet, &IPHeader, sizeof( IPHeader ),
        sizeof( struct _ether_header ),&NumberOfBytesRead);
FltReadOnPacket api到哪里也找不到啊! 高手帮忙啊~
yexin218
驱动牛犊
驱动牛犊
  • 注册日期2008-02-22
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分72分
  • 威望384点
  • 贡献值0点
  • 好评度3点
  • 原创分0分
  • 专家分0分
沙发#
发布于: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...
        //
    }
}

kok5168
驱动牛犊
驱动牛犊
  • 注册日期2010-03-07
  • 最后登录2010-06-06
  • 粉丝0
  • 关注0
  • 积分36分
  • 威望211点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2010-04-10 19:40
楼上的 yexin218 , 真是太感谢你啊!!!!!!!!!
谢谢啊·~~~
游客

返回顶部