NDIS driver halts when user space program crashes

Hello All,
I am new to Windows Driver Programming land and have been facing serious issue with NDIS driver. My NDIS is not supposed to do anything other than redirect packets to user space if one is connected.
Problem:
User application opens a handle to NDIS to capture packets and then sends them back.

  1. When user application exits gracefully (proper cleanup of resources acquired) NDIS continues to transfer packets to appropriate dest/src.
  2. When application crashes, NDIS is halt and does not permit any network traffic.
  3. When application crashes, NDIS is halt and does not permit any network traffic. Then I restart application and communication is back.

Above conclusion is based on the debug output from the debugger output. Another observation is when application crashes NDIS send/receive is still trying to pass packets about 4-5 packets.

Can someone please help me diagnose the problem? What methods shall I be looking into? Does driver receives any IOCTL when user application crashes, giving driver an opportunity to clean up?

Thank you,

You need to handle IRP_MJ_CLEANUP, which will be called for each open
user-mode handle when the application 1.) calls CloseHandle or 2.) exits
abnormally.

In addition, you must handle cancellation of IRPs that are pending in your
driver.

Handling these situations isn’t unique to NDIS. Study how a driver must
handle I/O.

Thomas F. Divine


From:
Sent: Wednesday, April 21, 2010 9:58 PM
To: “Windows System Software Devs Interest List”
Subject: [ntdev] NDIS driver halts when user space program crashes

> Hello All,
> I am new to Windows Driver Programming land and have been facing serious
> issue with NDIS driver. My NDIS is not supposed to do anything other than
> redirect packets to user space if one is connected.
> Problem:
> User application opens a handle to NDIS to capture packets and then sends
> them back.
> 1) When user application exits gracefully (proper cleanup of resources
> acquired) NDIS continues to transfer packets to appropriate dest/src.
> 2) When application crashes, NDIS is halt and does not permit any network
> traffic.
> 3) When application crashes, NDIS is halt and does not permit any network
> traffic. Then I restart application and communication is back.
>
> Above conclusion is based on the debug output from the debugger output.
> Another observation is when application crashes NDIS send/receive is still
> trying to pass packets about 4-5 packets.
>
> Can someone please help me diagnose the problem? What methods shall I be
> looking into? Does driver receives any IOCTL when user application
> crashes, giving driver an opportunity to clean up?
>
> Thank you,
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

Thomas,
Thank you for few pointers. I will look into it and will post my results.
-Anand Patel

On Wed, Apr 21, 2010 at 10:03 PM, Thomas F. Divine wrote:

> You need to handle IRP_MJ_CLEANUP, which will be called for each open
> user-mode handle when the application 1.) calls CloseHandle or 2.) exits
> abnormally.
>
> In addition, you must handle cancellation of IRPs that are pending in your
> driver.
>
> Handling these situations isn’t unique to NDIS. Study how a driver must
> handle I/O.
>
> Thomas F. Divine
>
>
> --------------------------------------------------
> From:
> Sent: Wednesday, April 21, 2010 9:58 PM
> To: “Windows System Software Devs Interest List”
> Subject: [ntdev] NDIS driver halts when user space program crashes
>
>
> Hello All,
>> I am new to Windows Driver Programming land and have been facing serious
>> issue with NDIS driver. My NDIS is not supposed to do anything other than
>> redirect packets to user space if one is connected.
>> Problem:
>> User application opens a handle to NDIS to capture packets and then sends
>> them back.
>> 1) When user application exits gracefully (proper cleanup of resources
>> acquired) NDIS continues to transfer packets to appropriate dest/src.
>> 2) When application crashes, NDIS is halt and does not permit any network
>> traffic.
>> 3) When application crashes, NDIS is halt and does not permit any network
>> traffic. Then I restart application and communication is back.
>>
>> Above conclusion is based on the debug output from the debugger output.
>> Another observation is when application crashes NDIS send/receive is still
>> trying to pass packets about 4-5 packets.
>>
>> Can someone please help me diagnose the problem? What methods shall I be
>> looking into? Does driver receives any IOCTL when user application crashes,
>> giving driver an opportunity to clean up?
>>
>> Thank you,
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>