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.
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.
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
"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.
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
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.