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

Home NTDEV
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

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/


[UPDATE][RESOLVED] NDIS Miniport Driver Hangs on Disable in Windows 2012 R2

J_McLeanJ_McLean Member Posts: 1
Hello everyone,

I took over development of the driver described in this thread:
https://www.osronline.com/showthread.cfm?link=276242

I figured I would post a follow up thread describing the fix for anyone who may stumble on that thread having the same issue.

Summary:
NDIS Miniport driver would hang on disable in Windows Server 2012 R2 but not in Windows Server 2012 R1. Computer Management would stop responding and the machine required a reboot.

Solution:
Through kernel debugging and driver logging I discovered there was a new OID that we were not handling correctly. The upgrade to 2012 R2 includes an upgrade to NDIS 6.40. There is a new OID called OID_GEN_ISOLATION_PARAMETERS. We were returning NDIS_STATUS_NOT_SUPPORTED for this request. From the MSDN spec at:
https://msdn.microsoft.com/en-us/library/windows/hardware/dn383690(v=vs.85).aspx

"If no multi-tenancy configuration parameters are set on the VM network adapter, the network adapter miniport driver sets the DATA.QUERY_INFORMATION.BytesWritten member of the NDIS_OID_REQUEST structure to zero and returns NDIS_STATUS_SUCCESS. In this case, the data within the DATA.QUERY_INFORMATION.InformationBuffer member is not modified by the miniport driver."

So I set BytesWritten to 0 and returned NDIS_STATUS_SUCCESS. With this fix, my PT_OPENED reference counts went back to 0 on disable, which allowed my Driver Unload handler to be called, and I was able to disable and enable the driver at will. Hope this helps anyone who may be experiencing this issue as well.

Additional Question:
I ran into another issue, but that was not what the original thread was encompassing. I am curious if anyone has an answer for this though, so I will ask in this thread as opposed to starting a new one.

My question is about the Miniport Adapter States as described here:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff560490(v=vs.85).aspx

In Windows Server 2012 R1, upon installing/enabling our NDIS Miniport Driver, we would transition through the restarting states multiple times before actually settling in the Running state. However, in Windows Server 2012 R2, upon install/enabling of the NDIS Miniport Driver, we do not restart multiple times, it essentially just starts right up. We went from around 60 state transitions to only, I think, 7.

Turns out we were only handling OID Requests in the Running state. From the above page: "A driver must handle OID Requests in the Running, Restarting, Paused, and Pausing states."

Upon updating the code to handle the OID requests in the additional required states, the driver functions correctly in R2. My guess is that in R1 we were just getting lucky since we arrived in the Running state multiple times before settling. Is there a reason that in Windows Server 2012 R2 our driver does not restart multiple times upon install/enable? We now have our driver working perfectly, so my question is simply curiosity rather than need.

Thank you to those who replied in the original thread. Your answers were helpful. Hopefully this post can save at least one person the time and headache that it caused me.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA