none
NDIS 6 ,modify send packet , cause BSOD RRS feed

  • Question

  • Now my demo can transform duplicated packet well, but , when I Modified the packet's data, it caused BSOD,here's my modified (this demo only modified UDP ) :

    1.get real data, xor it .

    2.calculate checksum UDP data.

    3.calculate ip header checksum.

    4.send pakcet .

    Can I use the follow code instead checksum that I do?

    NET_BUFFER_LIST_INFO(pNewBufList, TcpIpChecksumNetBufferListInfo) = NET_BUFFER_LIST_INFO(pSendPacketList, TcpIpChecksumNetBufferListInfo);

    Monday, July 28, 2014 7:44 AM

All replies

  • here's code :

    (1).in FilterSendNetBufferLists:

    uRet = Ndis6FilterSendPacket( pFilter, NetBufferLists , &pNewNetBufferLists );
    if ( uRet == BLOCK_PACKET ) break;

    if ( pNewNetBufferLists != NULL )
    {
    SendFlags |= NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK;
    NdisFSendNetBufferLists(pFilter->FilterHandle, pNewNetBufferLists, 
    NDIS_DEFAULT_PORT_NUMBER, SendFlags);
    }
    else
    NdisFSendNetBufferLists(pFilter->FilterHandle, NetBufferLists, PortNumber, 
    SendFlags);


    (2).in  Ndis6FilterSendPacket:

    pNewBufList = allocateNetBufferAndList( pFilter, PacketSize , TRUE );
    if (  pNewBufList == NULL ) break;

    NtStatus = 
    NdisCopyFromNetBufferToNetBuffer(NET_BUFFER_LIST_FIRST_NB(pNewBufList),

    0,
    PacketSize,
    NET_BUFFER_LIST_FIRST_NB(pSendPacketList),
    0,
    &BytesCopied);

    if( NtStatus != STATUS_SUCCESS )

    {
    *pNewNetBufferLists = NULL;
    FreeMdlAndNetBufferList( pNewBufList );
    break;
    }

    NtStatus = ModifySendPacket( pFilter , pNewBufList );

    if( NtStatus != STATUS_SUCCESS )

    {
    *pNewNetBufferLists = NULL;
    FreeMdlAndNetBufferList( pNewBufList );
    break;
    }

    NET_BUFFER_LIST_INFO(pNewBufList, TcpIpChecksumNetBufferListInfo) = 
    NET_BUFFER_LIST_INFO(pSendPacketList, TcpIpChecksumNetBufferListInfo); 

    NET_BUFFER_DATA_LENGTH(NET_BUFFER_LIST_FIRST_NB(pNewBufList)) = BytesCopied;

    pNewBufList->SourceHandle = pFilter->SendNetBufferListPool;

    if(*pNewNetBufferLists == NULL)  
    {  
    *pNewNetBufferLists = pCopyNBLTail = pNewBufList;  
    }  
    else  
    {  
    NET_BUFFER_LIST_NEXT_NBL(pCopyNBLTail) = pNewBufList;  
    }
    (3).in FilterSendNetBufferListsComplete:
       
    if(NdisGetPoolFromNetBufferList(NetBufferLists) == 
    pFilter->SendNetBufferListPool)  
    {  
    //Please just free this NBL  
    bRet =  FreeMdlAndNetBufferList(NetBufferLists);  
    if(bRet == TRUE)  
    {  
    PRINTLOG(("Free my own NBL ====== FilterSendNetBufferListsComplete \n"));  
    }

    return;
    }


    Tuesday, July 29, 2014 2:40 AM