Ndis calling Driver Unload after DriverEntry Success

Hi,

I am working on driver implementation for USB WLAN adapter. As I am installing driver from device manager(update driver), the driver is not installing properly. It is showing error “driver cannot start(10)”. I analysed the setupapi.dev.log and found the error as “Device not started: Device has problem: 0x0a: CM_PROB_FAILED_START”. I thought that issue was with Inf file and modified(Bustype, adding WdfCoInstallerSection) several times. But any of my changes didn’t help me. In all my trails I saw that driver gets unloaded immediately after DriverEntry succeeds.

Now I am seeing a different behaviour with same driver, if I unplug and plug in the USB adapter then NDIS is calling miniport initialize handler after DriverEntry. Why It is happening? What is the reason for it?

Thanks,
Varshith.

Code 10 means DriverEntry and AddDevice succeeded, got to the point of sending IRP_MN_START_DEVICE and start device failed. Might be a configuration bug in the INF, but more likely a runtime issue.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, April 5, 2017 7:36 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Ndis calling Driver Unload after DriverEntry Success

Hi,

I am working on driver implementation for USB WLAN adapter. As I am installing driver from device manager(update driver), the driver is not installing properly. It is showing error “driver cannot start(10)”. I analysed the setupapi.dev.log and found the error as “Device not started: Device has problem: 0x0a: CM_PROB_FAILED_START”. I thought that issue was with Inf file and modified(Bustype, adding WdfCoInstallerSection) several times. But any of my changes didn’t help me. In all my trails I saw that driver gets unloaded immediately after DriverEntry succeeds.

Now I am seeing a different behaviour with same driver, if I unplug and plug in the USB adapter then NDIS is calling miniport initialize handler after DriverEntry. Why It is happening? What is the reason for it?

Thanks,
Varshith.


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>

Hi Doron,

Might be a configuration bug in the INF, but more likely a runtime issue.
Runtime issue: Could you elaborate more on it? What can be the issue?

Here I am sharing the INF file which I used…

[version]
Signature = “$Windows NT$”
Class = Net
ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318}
Provider = %SARUSB%
CatalogFile = sausb.cat
DriverVer = 09/22/2016,11.1.0.216

[Manufacturer]
%SARUSB% = Sarusb, NTX86.6.1

[Sarusb.NTX86.6.1]
; DisplayName Section DeviceID
; ----------- ------- --------
%SaUSB.DeviceDesc% = SaUSB.ndi, USB\VID_xxxx&PID_xxxx

[SaUSB.ndi.NTx86]
*IfType = 71 ; IF_TYPE_IEEE80211
*MediaType = 16 ; NdisMediumNative802_11
*PhysicalMediaType = 9 ; NdisPhysicalMediumNative802_11
Characteristics = 0x84 ; NCF_PHYSICAL | NCF_HAS_UI
BusType = 15 ;
AddReg = sausb.Reg
CopyFiles = sausb.CopyFiles

[SaUSB.ndi.NTx86.Services]
AddService = sausb, 2, sausb.Service, sausb.EventLog

[SaUSB.ndi.NTx86.HW]
AddReg = vwifi.reg

;-----------------------------------------------------------------------------
[sausb.Reg]
HKR, Ndi, Service, 0, “sausb”
HKR, Ndi\Interfaces, UpperRange, 0, “ndis5”
HKR, Ndi\Interfaces, LowerRange, 0, “wlan,ethernet,vwifi”

[sausb.Service]
DisplayName = %SARU.Service.DispName%
ServiceType = 1 ;SERVICE_KERNEL_DRIVER
StartType = 3 ;SERVICE_DEMAND_START
ErrorControl = 1 ;SERVICE_ERROR_NORMAL
ServiceBinary = %12%\sausb.sys
LoadOrderGroup = NDIS

[sausb.EventLog]
AddReg = sausb.AddEventLog.reg

[sausb.AddEventLog.reg]
HKR, , EventMessageFile, 0x00020000, “%%SystemRoot%%\System32\netevent.dll”
HKR, , TypesSupported , 0x00010001, 7
;

;; Adds the VWiFi PNP filter
[vwifi.reg]
HKR,“UpperFilters”,0x00010000,“vwifibus”

[sausb.CopyFiles]
sausb.sys,2
fw.bin,2
binary1.bin,2
binary2.bin,2

[SourceDisksNames]
1 = %DiskDescription%,

[SourceDisksFiles]
sausb.sys = 1,
fw.bin = 1,
binary1.bin = 1,
binary2.bin = 1,
board.bin = 1,
eeprom1.bin = 1,
eeprom2.bin = 1,
eeprom3.bin = 1,
eeprom4.bin = 1,

[DestinationDirs]
sausb.CopyFiles = 12
DefaultDestDirs = 11

Thanks,
Sathish.

About half the time an NDIS driver code-10’s, it’s because the driver’s MiniportInitializeEx failed.

Double-check that your NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES exactly agrees with the INF on the IfType, PhysicalMediumType and MediaType.

Enable NDIS’s WPP tracing and look for errors from NDIS.SYS.

Set a breakpoint on ndis!ndisMInitializeAdapter. You won’t be able to debug into it, but you can hit ‘gu’ and see what NTSTATUS code it returns (on amd64, it’s in the RAX register).

Hi Tippet,

About half the time an NDIS driver code-10’s, it’s because the driver’s Min=
iportInitializeEx failed.

– My driver is not at all calling MiniportInitializeEx handler. NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES is assigned in code block of MiniportInitializeEx handler.