Connectivity issues with LWF and Wifi

I’ve found that my LWF that attaches to wifi adapters causes loss of connectivity. I’ve narrowed it down to some issue with the OidRequestHandler. If I just make that NULL during the filter registration then the adapter works fine. But if the Oid handler is there and I try to add NDIS_PACKET_TYPE_PROMISCUOUS then the connection drops. There are various other messages about this problem but with no real solution other than just removing the Oid handler completely. I can recreate this problem on Windows 8.1 and 10. Haven’t tried on Windows 7 yet.

So to solve this, I created one filter that will detect which version is being loaded (wifi or ethernet) and either enable the Oid handler or just keep it NULL. I use a single INF to install both with the relevant install sections below. The ethernet version is supposed to only attach to “ethernet” media types but I find that this filter is still listed in the wifi adapter properties. The effect being that the wifi drops the connection because this ethernet filter has the Oid handler enabled. The way to fix this is to manually go into the adapter settings and uncheck the non-wifi LWF, disable the adapter and then re-enable. Obviously not a good solution. Is there a way to prevent the ethernet LWF from being added to the wifi via the INF? I thought just listing “ethernet” in the FilterMediaTypes would be sufficient.

Also, what is the issue with NDIS_PACKET_TYPE_PROMISCUOUS and wifi? Why does that cause connection loss?

[EthernetInstall]
HKR, Ndi,FilterClass, custom
HKR, Ndi,FilterType,0x00010001,2
HKR, Ndi\Interfaces,UpperRange,“noupper”
HKR, Ndi\Interfaces,LowerRange,“nolower”
HKR, Ndi\Interfaces, FilterMediaTypes,“ethernet”
HKR, Ndi,FilterRunType,0x00010001, 0x00000002 ; Optional filter

[WifiInstall]
HKR, Ndi,FilterClass, ms_medium_converter_128
HKR, Ndi,FilterType,0x00010001,2
HKR, Ndi\Interfaces,UpperRange,“noupper”
HKR, Ndi\Interfaces,LowerRange,“nolower”
HKR, Ndi\Interfaces, FilterMediaTypes,“vwifi,vchannel”
HKR, Ndi,FilterRunType,0x00010001, 0x00000002 ; Optional filter

OidRequestHandler code:

Status = NdisAllocateCloneOidRequest(pFilter->FilterHandle, Request, TAG_FILTER, &ClonedRequest);
if (Status == NDIS_STATUS_SUCCESS) {
Context = (PFILTER_REQUEST_CONTEXT)(&ClonedRequest->SourceReserved[0]);
*Context = Request;

bSubmitted = TRUE;
ClonedRequest->RequestId = Request->RequestId;
pFilter->PendingOidRequest = ClonedRequest;

if (ClonedRequest->RequestType == NdisRequestSetInformation) {
if (ClonedRequest->DATA.SET_INFORMATION.Oid == OID_GEN_CURRENT_PACKET_FILTER) {
pro = NDIS_PACKET_TYPE_PROMISCUOUS;
flgs = PtrToUlong(ClonedRequest->DATA.SET_INFORMATION.InformationBuffer);
if ((flgs & pro) == 0) {
flgs |= pro;
ClonedRequest->DATA.SET_INFORMATION.InformationBuffer = &flgs;
ClonedRequest->DATA.SET_INFORMATION.InformationBufferLength = sizeof(flgs);
}
}
}

Status = NdisFOidRequest(pFilter->FilterHandle, ClonedRequest);
if (Status != NDIS_STATUS_PENDING) {
FilterOidRequestComplete(pFilter, ClonedRequest, Status);
Status = NDIS_STATUS_PENDING;
}
}