Saturday, August 13, 2011

Automating Windows Driver Installs :(

Background


As a result of needing to reload a sizable quantity of machines with Windows, which really isn't a problem once you know to find the VEN_ and DEV_ information. I wanted to automate the whole process and for some reason I thought I should figure out how the .inf, .drv, .vxd, and .sys files worked with one another. This example just happens to be for the embedded 10/100 Broadcom 440x ethernet device.


Problem


I found a compatible driver on the Dell site like I would any other. But, even though it works-- did Dell put things in there that are tell tale signs that it doesn't belong if anybody were looking? These machines were not my own where certain inconsistencies may not be tolerated. The customers paid a fair price and they deserve a good and polished product.


Another question I asked myself was, "If I streamline the process, can I shave a few seconds off the device install?" Once the .inf file is prepared you still aren't off of the hook if there is no installer with options to install via a script. There is a way to script the install but I had to dig a little to find it.


Solution


Starting with the .inf file I did a lot of reading to figure out what each of the section does.


I renamed the section I wanted in the INF file so that I could use DefaultInstall as the section the OS would choose when I ran rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 132 E:\ethernet\bcm4sbxp.inf from the command line. This automates the installation of device driver files.


When I was done, I realized that I could have left the section named as the manufacturer had written it and changed my commandline to rundll32.exe setupapi.dll,InstallHinfSection BCM4401NIC 132 E:\ethernet\bcm4sbxp.inf to achieve the same results.


I removed all references to the Dell Computer Corporation.


Just as unnecessary cleanup, I also removed the ASUStek and MCI lines while I was figuring out what all of the stuff in this INF file was doing since it was an eMachines laptop without ASUS or MCI hardware dependent on those lines. When everything was said and done, because it worked without the alternative sections, I did not revert to the original file to add them back in.


The edited file follows below.

;*******************************************************************************
; Copyright 2002 Broadcom Corporation.
;
; INF for 32 bit Windows XP 
;
; History:
;    06/14/02        Inception.
;*******************************************************************************
[version]
Signature	= "$CHICAGO$"
Class=Net
ClassGUID	= {4d36e972-e325-11ce-bfc1-08002be10318}
Provider	= %V_BCM%
Compatible	= 1
CatalogFile=bcm4sbxp.cat
DriverVer=12/17/2002, 3.51.0.0

[Manufacturer]
%V_BCM% = BROADCOM, NTx86.5.1

[ControlFlags] 
ExcludeFromSelect = *

[BROADCOM.NTx86.5.1]

%BCM4401.DeviceDesc%           = BCM4401, PCI\VEN_14E4&DEV_4401

%BCM4401.DeviceDesc%        = BCM4401_broadcom, PCI\VEN_14E4&DEV_4401&SUBSYS_840114e4

%BCM4401.DeviceDesc%     = BCM4401_broadcom, PCI\VEN_14E4&DEV_4401&SUBSYS_00011179

;-----------------------------------------------------------------
; 32-bit Windows XP Install sections.
;  Broadcom  Catch All
[BCM4401.NTx86]
Characteristics	= 0x84			; NCF_PHYSICAL | NCF_HAS_UI
AddReg		= BCM4401AddRegisters, AdvancedTabReg, 8021pPriorityReg, DriverInfo
CopyFiles	= BCM4401.CopyFileNT
BusType		= 5			; PCI bus

[BCM4401.NTx86.Services]
AddService = bcm4sbxp, 2, BCM4401AddService, CommonEventLog

[BCM4401AddService]
DisplayName	= %BCM4401.Service.DispName%
ServiceType	= 1			; %SERVICE_KERNEL_DRIVER%
StartType	= 3
ErrorControl	= 1			; %SERVICE_ERROR_NORMAL%
ServiceBinary	= %12%\bcm4sbxp.sys
LoadOrderGroup	= NDIS

[BCM4401AddRegisters]
HKR,	Ndi,	Service,		0,	"bcm4sbxp"
HKR,	Ndi\Interfaces,	UpperRange,	,	"ndis5"
HKR,	Ndi\Interfaces,	LowerRange,	,	"ethernet"
HKR,	Ndi,	HelpText,		,	%BCM4401_HELP%



;  Broadcom  NIC
[DefaultInstall]
Characteristics	= 0x84			; NCF_PHYSICAL | NCF_HAS_UI
AddReg		= BCM4401_broadcomAddRegisters, AdvancedTabReg, 8021pPriorityReg, DriverInfo
CopyFiles	= BCM4401.CopyFileNT
BusType		= 5			; PCI bus

[BCM4401_broadcom.NTx86.Services]
AddService = bcm4sbxp, 2, BCM4401_broadcomAddService, CommonEventLog

[BCM4401_broadcomAddService]
DisplayName	= %BCM4401_broadcom.Service.DispName%
ServiceType	= 1			; %SERVICE_KERNEL_DRIVER%
StartType	= 3
ErrorControl	= 1			; %SERVICE_ERROR_NORMAL%
ServiceBinary	= %12%\bcm4sbxp.sys
LoadOrderGroup	= NDIS

[BCM4401_broadcomAddRegisters]
HKR,	Ndi,	Service,		0,	"bcm4sbxp"
HKR,	Ndi\Interfaces,	UpperRange,	,	"ndis5"
HKR,	Ndi\Interfaces,	LowerRange,	,	"ethernet"
HKR,	Ndi,	HelpText,		,	%BCM4401_HELP%




;-----------------------------------------------------------------
;
[CommonEventLog]
AddReg = CommonAddEventLogReg

[CommonAddEventLogReg]
HKR,	,	EventMessageFile,	0x00020000,	"%%SystemRoot%%\System32\netevent.dll;%%SystemRoot%%\System32\drivers\bcm4sbxp.sys"
HKR,	,	TypesSupported,		0x00010001,	7

[8021pPriorityReg]
HKR, Ndi\Params\8021pPriority,         ParamDesc,  0, %8021pPriority%
HKR, Ndi\Params\8021pPriority,         default,    0, "0"
HKR, Ndi\Params\8021pPriority\Enum,    "1",        0, %Enabled%
HKR, Ndi\Params\8021pPriority\Enum,    "0",        0, %Disabled%
HKR, Ndi\Params\8021pPriority,         type,       0, "enum"

[AdvancedTabReg]
HKR, Ndi\params\SpeedAndDuplex,       ParamDesc,  0, %SpeedAndDuplex%
HKR, Ndi\params\SpeedAndDuplex,       default,    0, "0"
HKR, Ndi\params\SpeedAndDuplex,       type,       0, "enum"
HKR, Ndi\params\SpeedAndDuplex\enum,  "0",        0, %AutoDetect%
HKR, Ndi\params\SpeedAndDuplex\enum,  "1",        0, %10MbHalfDuplex%
HKR, Ndi\params\SpeedAndDuplex\enum,  "2",        0, %10MbFullDuplex%
HKR, Ndi\params\SpeedAndDuplex\enum,  "3",        0, %100MbHalfDuplex%
HKR, Ndi\params\SpeedAndDuplex\enum,  "4",        0, %100MbFullDuplex%

HKR, Ndi\Params\WakeUpModeCap,       ParamDesc,   0 , %WakeUpMode%
HKR, Ndi\Params\WakeUpModeCap,       default,  0  , "2"
HKR, Ndi\Params\WakeUpModeCap,       type,      0  , "enum"
HKR, Ndi\Params\WakeUpModeCap\enum,  "0",        0 , %WakeUpMode_None%
HKR, Ndi\Params\WakeUpModeCap\enum,  "1",        0 , %WakeUpMode_Magic%
HKR, Ndi\Params\WakeUpModeCap\enum,  "2",        0 , %WakeUpMode_Pattern%

HKR, Ndi\Params\FlowControlCap,       ParamDesc,   0 , %FlowControlMode%
HKR, Ndi\Params\FlowControlCap,       default,  0  , "2"
HKR, Ndi\Params\FlowControlCap,       type,      0  , "enum"
HKR, Ndi\Params\FlowControlCap\enum,  "0",        0 , %FlowControlMode_None%
;   HKR, Ndi\Params\FlowControlCap\enum,  "1",        0 , %FlowControlMode_Rx%
HKR, Ndi\Params\FlowControlCap\enum,  "2",        0 , %FlowControlMode_Tx%
;  HKR, Ndi\Params\FlowControlCap\enum,  "3",        0 , %FlowControlMode_Both%



[DriverInfo]
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,Description,,%DriverDescription%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,CurrentVer,,%DriverOEMVersion%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,Ver_%DriverOEMVersion%,,%DriverVersionID%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,BaseDriverFileName,,%BaseDriverFileName%
HKLM,Software\InstalledOptions\%DriverOEM%\%DriverFamily%\%DriverMfgr%\%DriverProduct%,BaseDriverFileVersion,,%BaseDriverFileVersion%


[DestinationDirs]
DefaultDestDir = 11		; system32 on Win2k and system on win9x
BCM4401.CopyfileNT = 12
BCM4401.CopyFileW9x = 11

[SourceDisksNames]
1=%BCM4401.DiskName%,,

[SourceDisksFiles]
bcm4sbxp.sys=1

[BCM4401.CopyFileNT]
bcm4sbxp.sys,,,1

;-----------------------------------------------------------------
;
[strings]
; Provider
V_BCM = "Broadcom"

; PNP Devices
BCM4401.DeviceDesc = "Broadcom 440x 10/100 Integrated Controller"

BCM4401_HELP = "Broadcom 440x 10/100 Integrated Controller provides local area networking"

BCM4401.Service.DispName = "Broadcom 440x 10/100 Integrated Controller XP Driver"

BCM4401_broadcom.Service.DispName = "Broadcom 440x 10/100 Integrated Controller XP Driver"


BCM4401.DiskName = "Broadcom 440x 10/100 Integrated Controller Install Disk"

SpeedAndDuplex = "Speed & Duplex"
AutoDetect = "Auto"
10MbHalfDuplex = "10 Mb Half"
10MbFullDuplex = "10 Mb Full"
100MbHalfDuplex = "100 Mb Half"
100MbFullDuplex = "100 Mb Full"

8021pPriority = "802.1p QOS"
Enabled = "Enable"
Disabled = "Disable"

WakeUpMode         = "Wake Up Capabilities"
WakeUpMode_Magic   = "Magic Frame"
WakeUpMode_Pattern = "Wake Up Frame"
WakeUpMode_None    = "None"

FlowControlMode         = "Flow Control"
FlowControlMode_Both    = "Rx/Tx Pause"
FlowControlMode_Rx   = "Rx Pause"
;FlowControlMode_Tx   = "Tx Pause"
FlowControlMode_Tx   = "Enable"
FlowControlMode_None    = "Disable"


; Driver Information Entries
DriverMfgr="Broadcom"                                 ; IHV name
DriverVersionID="3.51"                                ; The IHV driver version
BaseDriverFileVersion="3.51"                          ; version of key file
BaseDriverFileName="bcm4sbxp.sys"                       ; Key file for version

; These items will be set by IHV and updated by OEM
DriverOEM="Dell"                                      ; name of the OEM
DriverFamily="NIC"                                    ; device family (NIC, Storage, Video...)
DriverProduct="BCM440X"                               ; Specific Name of device (chipset, for example)
DriverDescription="Broadcom 440x 10/100 Integrated Controller"  ; Description of device (product name, OS or system supported)
DriverOEMVersion="A00"                                ; OEM-specified version

No comments:

Post a Comment

Followers