Hi,
I am writing NDIS miniport driver that is capable of forwarding network traffic via serial port (SLIP). I have managed to get it to stable working condition but I am unable to set its startup options to have it start properly.
When system boots the driver gets loaded and it tries to open the requested serial port. It works fine when it is configured to use the serial ports integrated on the system mainboard. The problems start to appear when I configure it to use the serial ports created by the USB to serial adapters. Most of the time when the system starts the driver reports that it could not open the requested serial port. I suspect that is due to fact that my driver gets loaded before the drivers for the USB stack so at that point in time the requested serial port simply does not exist yet. When I manually restart the driver (i.e. disable/enable the network adapter) once the system has started the driver is able to successfully open the requested serial port.
I have been trying to find out how to configure up the driver/service startup options to change (or delay) driver load or to add it load dependency. However nothing I change seems to be affecting the load ordering in the way I want. The miniport is registered as virtual device that is supposed to load along with other network drivers. I have tried to change driver’s LoadOrderGroup, Start Type, Device Id but it didn’t have any recognizable effect.
I have also tried to register the driver as software enumerated device hopping that it would help but I could not get it to work - the driver gets call to the DriverEntry procedure, successfully registers itself as miniport driver but then instead a call to the MiniportInitializeEx it gets unloaded and the system claims that it could not load the driver properly - Code 31.
The closest thing to the solution that I could find is to register the driver reinitialization procedure (IoRegisterDriverReinitialization) inside the DriverEntry , and in the reinitialization routine try to explicitly open the serial port again. This approach works in some cases but not all of them.
Is there clean a way to solve this problem?
Here is the inf file i am using:
[Version]
Signature=“$WINDOWS NT$”
Class=Net ; Network driver class
ClassGuid={4d36e972-e325-11ce-bfc1-08002be10318} ; Network driver class guid
Provider=%Provider%
DriverVer=01/01/2000,1.0.0.0
CatalogFile=netproxy.cat
;-----------------------------------------------------------------------------
[DestinationDirs]
DefaultDestDir = 12
;-----------------------------------------------------------------------------
[SourceDisksNames]
1 = %DiskName%,“”
[SourceDisksFiles.x86]
netproxy.x86.sys = 1,
[SourceDisksFiles.amd64]
netproxy.x64.sys = 1,
[Manufacturer]
%ManufacturerName%=NetProxy,NTx86,NTamd64
[NetProxy.NTx86]
%NetProxyDeviceDesc% = NetProxySetup.NTx86, root\NetProxyAdapter
[NetProxy.NTamd64]
%NetProxyDeviceDesc% = NetProxySetup.NTamd64, root\NetProxyAdapter
[NetProxySetup.NTx86]
AddReg = NetProxyReg
CopyFiles = CopyFiles.NTx86
Characteristics = 0x1 ; NCF_VIRTUAL
*IfType = 28 ; IF_TYPE_SLIP
*MediaType = 0 ; NdisMedium802_3
*PhysicalMediaType = 0 ; NdisPhysicalMediumUnspecified
[NetProxySetup.NTamd64]
AddReg = NetProxyReg
CopyFiles = CopyFiles.NTamd64
Characteristics = 0x1 ; NCF_VIRTUAL
*IfType = 28 ; IF_TYPE_SLIP
*MediaType = 0 ; NdisMedium802_3
*PhysicalMediaType = 0 ; NdisPhysicalMediumUnspecified
[NetProxySetup.NTx86.Services]
AddService = NetProxy, 2, NetProxyService, NetProxyEventLog
[NetProxySetup.NTamd64.Services]
AddService = NetProxy, 2, NetProxyService, NetProxyEventLog
[NetProxyReg]
HKR, Ndi, Service, 0, “NetProxyAdapter”
HKR, Ndi\Interfaces, UpperRange, 0, “ndis5”
HKR, Ndi\Interfaces, LowerRange, 0, “nolower”
[CopyFiles.NTx86]
netproxy.sys,netproxy.x86.sys,2
[CopyFiles.NTamd64]
netproxy.sys,netproxy.x64.sys,2
[NetProxyService]
DisplayName = %NetProxyService.DisplayName%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %12%\netproxy.sys
LoadOrderGroup = NDIS
AddReg = TextModeFlags.Reg
[NetProxyEventLog]
AddReg = NetProxyEventLog.Reg
[NetProxyEventLog.Reg]
HKR, , EventMessageFile, 0x00020000, “%%SystemRoot%%\System32\netevent.dll”
HKR, , TypesSupported, 0x00010001, 7 ; for drivers this is constant
[TextModeFlags.Reg]
HKR, , TextModeFlags, 0x00010001, 0x0001
[Strings]
Provider = “Dummy”
ManufacturerName = “Dummy”
DiskName = “Net Proxy Driver Source Disk”
NetProxyDeviceDesc = “Proxy Adapter”
NetProxyService.DisplayName = “NetProxy Miniport Driver”