Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

Proper way of freeing buffers when using NdisSendPackets? (NDIS 5.0)

brad_Hbrad_H Member Posts: 86

Hey everyone,

When using the simple case of NdisSend, I free the packet buffer and the buffer in case the returned status is not NDIS_STATUS_PENDING,

But how to properly free buffers in case of NdisSendPackets when i send multiple packets at once? because unlike NdisSend, it does not return any status.

So what is the proper way of freeing the buffers that i Allocated with NdisAllocatePacket and NdisAllcateBuffer in the case of NdisSendPackets?

Comments

  • brad_Hbrad_H Member Posts: 86
    edited July 26

    Also, in the NdisSendPackets page, MSDN says:

    "The caller of NdisSendPackets should test the returned status for each packet in such an array individually when its ProtocolSendComplete function is called with the completion Status"

    But in the ProtocolSendComplete MSDN, it says:

    "This function is a required driver function that completes the processing of a protocol-initiated send previously passed to NdisSendPackets or NdisSend, which returned NDIS_STATUS_PENDING."

    So.. based on what i gathered, SendComplete is called only for packets that returned NDIS_STATUS_PENDING.
    But why it says that i "should test the returned status " in the SendComplete, if its only for NDIS_STATUS_PENDING?!

    And how should i free Buffers then? Should i look through all the packets after Call to NdisSendPackets and use NDIS_GET_PACKET_STATUS to see the result, and if its not NDIS_STATUS_PENDING then free it? or..?!

    (Note that currently i already free every packet buffer that i receive in my SendComplete)

  • brad_Hbrad_H Member Posts: 86

    The main problem I'm facing right now is that even tho I'm looping through every packet in the array after NdisSendPackets, and freeing only the ones that are not NDIS_STATUS_PENDING, i got a bugcheck at NdisFreeBuffer for "Attempt to free pool which was already freed" (BAD_POOL_CALLER), even tho I'm sure as hell i didn't free it before myself..

  • brad_Hbrad_H Member Posts: 86

    And weirdly enough, when i don't free the packet buffers that do not have NDIS_STATUS_PENDING in their status, i don't get any BSOD.

    So it seems like that my SendComplete is getting called for every one of the packets, not not just the ones that had NDIS_STATUS_PENDING..? I thought it only gets called for packets that have NDIS_STATUS_PENDING? at least its the case when using NdisSend.

  • brad_Hbrad_H Member Posts: 86

    Update: So it seems like my assumption was true and my SendComplete gets called for every packet, and not just the ones that return NDIS_STATUS_PENDING..

    Anyone got any idea why this is happening?

    And another question:
    Do all NICs support multi packet send/recv? Is there any need for me to be worry when i use a packet array with NdisSendPackets and NdisMIndicateReceivePacket, instead of a single packet, or do all the NICs properly support multi packet send/recv?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 15 November 2021 Live, Online
Writing WDF Drivers TBD Live, Online
Developing Minifilters 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online