; BUGBUG - what should Manufacturer be?
; BUGBUG - what should version be?  1.0 or 3.5?
; BUGBUG - what should the Source Media Descriptions be?

; ------------------------------------------------------------------------
; Microsoft Windows NT 3.5 Driver Installation
; Thomas-Conrad Driver for TCNS and generic ARCNET Adapters
; Copyright 1994 Thomas-Conrad Corporation
; v1.00 (940713)
; ------------------------------------------------------------------------

[FileConstants]
   Manufacturer             = "Thomas-Conrad"
   TccBaseName              = "tcarc"
   SoftwareMajorVersion     = "4"
   SoftwareMinorVersion     = "0"
   InterruptTextList        = ^(InterruptChoices, 1)
   InterruptValueList       = ^(InterruptChoices, 2)
   IoBaseTextList           = ^(IoBaseChoices, 1)
   IoBaseValueList          = ^(IoBaseChoices, 2)
   MemoryBaseTextList       = ^(MemoryBaseChoices, 1)
   MemoryBaseValueList      = ^(MemoryBaseChoices, 2)
   EisaSlotTextList         = ^(EisaSlotChoices, 1)
   EisaSlotValueList        = ^(EisaSlotChoices, 2)
   NetEventDLL              = "%SystemRoot%\System32\netevent.dll"
   IoLogMsgDLL              = "%SystemRoot%\System32\IoLogMsg.dll"
   UtilityInf               = "UTILITY.INF"
   SubroutineInf            = "SUBROUTN.INF"
   SoftwareType             = "driver"
   Exit_Code                = 0
   SoftwareVersion          = $(SoftwareMajorVersion)"."$(SoftwareMinorVersion)
   SoftwareImage            = "\SystemRoot\System32\drivers\"$(TccBaseName)".sys"
   NetRuleSoftwareType      = $(TccBaseName)"Sys ndisDriver "$(TccBaseName)"Driver"
   NetRuleSoftwareBindForm  = """"$(TccBaseName)"Sys"" yes no container"
   NetRuleSoftwareBindable  = {""$(TccBaseName)"Driver "$(TccBaseName)"Adapter non exclusive 100"}
   NetRuleSoftwareClass     = {""$(TccBaseName)"Driver basic"}
   NetRuleSoftwareUse       = $(SoftwareType)
   NetRuleHardwareType      = $(TccBaseName)" "$(TccBaseName)"Adapter"
   NetRuleHardwareClass     = {""$(TccBaseName)"Adapter basic"}
   NetRuleHardwareBindForm  = " yes yes container"
   ProductOpSupport     = 134 ; 0x0086 ; Display,Removable,Properties,Not Updatable
   KeyName_SoftwareRoot     = $(!NTN_SoftwareBase)"\"$(Manufacturer)
   KeyName_Software         = $(KeyName_SoftwareRoot)"\"$(TccBaseName)"\CurrentVersion"

[InterruptChoices]
   Interrupt_1  = "2/9",  2
   Interrupt_2  = "3"  ,  3
   Interrupt_3  = "4"  ,  4
   Interrupt_4  = "5"  ,  5
   Interrupt_5  = "6"  ,  6
   Interrupt_6  = "7"  ,  7
   Interrupt_7  = "10" , 10
   Interrupt_8  = "11" , 11
   Interrupt_9  = "12" , 12
   Interrupt_10 = "14" , 14
   Interrupt_11 = "15" , 15

[MemoryBaseChoices]  
   MemoryBaseChoice_1 = "C0000", 49152
   MemoryBaseChoice_2 = "C4000", 50176
   MemoryBaseChoice_3 = "C8000", 51200
   MemoryBaseChoice_4 = "CC000", 52224
   MemoryBaseChoice_5 = "D0000", 53248
   MemoryBaseChoice_6 = "D4000", 54272
   MemoryBaseChoice_7 = "D8000", 55296
   MemoryBaseChoice_8 = "DC000", 56320

[IoBaseChoices]  
   IoBaseChoice_1 = "260", 608
   IoBaseChoice_2 = "290", 656
   IoBaseChoice_3 = "2E0", 736
   IoBaseChoice_4 = "2F0", 752
   IoBaseChoice_5 = "300", 768
   IoBaseChoice_6 = "350", 848
   IoBaseChoice_7 = "380", 896
   IoBaseChoice_8 = "3E0", 992

[EisaSlotChoices]
   EisaSlot_1  = "1",    1
   EisaSlot_2  = "2",    2
   EisaSlot_3  = "3"  ,  3
   EisaSlot_4  = "4"  ,  4
   EisaSlot_5  = "5"  ,  5
   EisaSlot_6  = "6"  ,  6
   EisaSlot_7  = "7"  ,  7
   EisaSlot_8  = "8"  ,  8
   EisaSlot_9  = "9"  ,  9
   EisaSlot_10 = "10" , 10
   EisaSlot_11 = "11" , 11
   EisaSlot_12 = "12" , 12

[TcarcIsaDlg]
   DlgType                 = "RadioCombination"
   Label1                  = $(InterruptLabel)
   Label2                  = $(BaseIoLabel)
   Label3                  = $(MemoryLabel)
   DlgTemplate             = "UBNDIS"
   Caption                 = $(FunctionTitle)
   Combo1List              = $(InterruptTextList)
   Combo1Out               = $(InterruptTextDlgDefault)
   Combo2List              = $(IoBaseTextList)
   Combo2Out               = $(IoBaseTextDlgDefault)
   Combo3List              = $(MemoryBaseTextList)
   Combo3Out               = $(MemoryBaseTextDlgDefault)
   RadioIn                 = {}
   ComboListItemsIn        = {Combo1List,Combo2List,Combo3List}
   ComboListItemsOut       = {Combo1Out,Combo2Out,Combo3Out}
   CBOptionsGreyed         = {}
   EditTextIn              = ""
   EditTextLim             = ""
   NotifyFields            = {NO, NO, NO}
   HelpContext             = $(!IDH_DB_OEMNADAR1_INS) 

[TcnsIsaDlg]
   DlgType                 = "RadioCombination"
   Label1                  = $(InterruptLabel)
   Label2                  = $(BaseIoLabel)
   Label3                  = $(MemoryLabel)
   DlgTemplate             = "UBNDIS"
   Caption                 = $(TcnsCaption)
   Combo1List              = $(InterruptTextList)
   Combo1Out               = $(InterruptTextDlgDefault)
   Combo2List              = $(IoBaseTextList)
   Combo2Out               = $(IoBaseTextDlgDefault)
   Combo3List              = $(MemoryBaseTextList)
   Combo3Out               = $(MemoryBaseTextDlgDefault)
   RadioIn                 = {}
   ComboListItemsIn        = {Combo1List,Combo2List,Combo3List}
   ComboListItemsOut       = {Combo1Out,Combo2Out,Combo3Out}
   CBOptionsGreyed         = {}
   EditTextIn              = ""
   EditTextLim             = ""
   NotifyFields            = {NO, NO, NO}
   HelpContext             = $(!IDH_DB_OEMNADAR2_INS)  

[TcnsEisaDlg]
   DlgType                 = "RadioCombination"
   Label1                  = $(SlotNumberLabel)
   DlgTemplate             = "SINGLE_COMBO"
   Caption                 = $(TcnsEISACaption)
   Combo1List              = $(EisaSlotTextList)
   Combo1Out               = $(EisaSlotTextDlgDefault)
   RadioIn                 = {}
   ComboListItemsIn        = {Combo1List}
   ComboListItemsOut       = {Combo1Out}
   CBOptionsGreyed         = {}
   EditTextIn              = ""
   EditTextLim             = ""
   NotifyFields            = {NO}
   HelpContext             = $(!IDH_DB_OEMNADAR3_INS)  

[Identify]
   set Status          = STATUS_SUCCESSFUL
   set Identifier      = NetAdapter
   set Media           = #("Source Media Descriptions", 1, 1)
   Return $(Status) $(Identifier) $(Media)

[ReturnOptions]
   set Status          = STATUS_FAILED
   set OptionList      = {}
   set OptionTextList  = {}
   set LanguageList    = ^(LanguagesSupported, 1)
   Ifcontains(i) $($0) in $(LanguageList)
      ifstr(i) $($1) == ""
         goto ReturnOptions_Set
      endif
      set PlatformList = ^(PlatformsSupported, 1)
      Ifcontains(i) $($1) in $(PlatformList)
         goto ReturnOptions_Set
      else
         set Status = STATUS_NOTSUPPORTED
         goto ReturnOptions_Exit
      endif
   else
      set Status = STATUS_NOLANGUAGE
      goto ReturnOptions_Exit
   endif
ReturnOptions_Set = +
    set OptionList      = ^(OptList$($0), 1)
    set OptionTextList  = ^(OptList$($0), 2)
    set Status          = STATUS_SUCCESSFUL
ReturnOptions_Exit = +
    Return $(Status) $(OptionList) $(OptionTextList)

[GeneralConstants]
   from                     = ""
   to                       = ""
   ExitCodeOk               = 0
   ExitCodeCancel           = 1
   ExitCodeFatal            = 2
   Key_Null                 = ""
   MAXIMUM_ALLOWED          = 33554432
   RegistryErrorIndex       = NO_ERROR
   Key_Product              = ""
   Key_HardwareParameters   = ""
   TRUE                     = 1
   FALSE                    = 0
   NoTitle                  = 0
   ExitState                = "Active"
   OldVersionExisted        = $(FALSE)
   DriverPath               = $(!STF_NTPATH)\drivers
                           
[date]                     
   Now                      = {} ? $(!LIBHANDLE) GetSystemDate
 
[PlatformsSupported]
   ISA
   EISA
   MCA

[Install-Option]
   Debug-Output "$(STF_CONTEXTINFNAME): Entering Install-Option"
   set STF_VITAL = ""
   ifstr(i) $(AddCopy) == "YES"
      set STF_VITAL = "YES"
      AddSectionFilesToCopyList Files-Driver $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
   endif
   ifstr(i) $(DoCopy) == "YES"
      set STF_VITAL = "YES"
      set !STF_NCPA_FLUSH_COPYLIST = TRUE
      CopyFilesInCopyList
   endif
   ifstr(i) $(DoConfig) == "YES"
   endif
   exit

[Install-Update]
   Debug-Output "$(STF_CONTEXTINFNAME): Entering Install-Update"
   set STF_VITAL        = "YES"
   set STF_OVERWRITE    = "VERIFYSOURCEOLDER"
   AddSectionFilesToCopyList Files-Driver  $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList
   exit

[InstallOption]
;   set !DebugOutputControl = 1
;   set !STF_DISPLAYDEBUGOUTPUT = 1
   set TccOption = $($1)
   set SrcDir    = $($2)
   set AddCopy   = $($3)
   set DoCopy    = $($4)
   set DoConfig  = $($5)
   Debug-Output "$(STF_CONTEXTINFNAME): Entering InstallOption"
   Debug-Output "$(STF_CONTEXTINFNAME): STF_CWDIR: .$(!STF_CWDIR)."
   Debug-Output "$(STF_CONTEXTINFNAME): STF_LANGUAGE: .$(!STF_LANGUAGE)."
   Debug-Output "$(STF_CONTEXTINFNAME): !NTN_RegBase .$(!NTN_RegBase)."
   Debug-Output "$(STF_CONTEXTINFNAME): !NTN_SoftwareBase .$(!NTN_SoftwareBase)."
   Debug-Output "$(STF_CONTEXTINFNAME): TccOption: .$(TccOption). SrcDir: .$(SrcDir)."
   Debug-Output "$(STF_CONTEXTINFNAME): AddCopy: .$(AddCopy). DoCopy: .$(DoCopy). DoConfig: .$(DoConfig)."
   set LanguageList = ^(LanguagesSupported, 1)
   Ifcontains(i) $($0) NOT-IN $(LanguageList)
      Return STATUS_NOLANGUAGE
   endif
   set-subst LF = "\n"
   read-syms GeneralConstants
   read-syms FileConstants
   set OptionNameList           = ^(OptList$(!STF_LANGUAGE), 1 )
   set OptionHdwrNameList       = ^(OptList$(!STF_LANGUAGE), 3 )
   set OptionHdwrTitleList      = ^(OptList$(!STF_LANGUAGE), 4 )
   set OptionHdwrDescList       = ^(OptList$(!STF_LANGUAGE), 5 )
   set ProductHdwrName          = *($(OptionHdwrNameList),+
                                  ~($(OptionNameList), $($1)))
   set ProductHdwrTitle         = *($(OptionHdwrTitleList),+
                                  ~($(OptionNameList), $($1)))
   set ProductHdwrDesc          = *($(OptionHdwrDescList),+
                                  ~($(OptionNameList), $($1)))
   Debug-Output "$(STF_CONTEXTINFNAME): ProductHdwrName .$(ProductHdwrName)."
   Debug-Output "$(STF_CONTEXTINFNAME): ProductHdwrTitle .$(ProductHdwrTitle)."
   Debug-Output "$(STF_CONTEXTINFNAME): ProductHdwrDesc .$(ProductHdwrDesc)."
   read-syms DialogConstants$(!STF_LANGUAGE)
   ifstr(i) $(!NTN_Origination) == "NCPA"
      set Continue = "OK"
   endif
   read-syms FileConstants$(!STF_LANGUAGE)
   detect date
   set-title $(FunctionTitle)
   set to   = InstallOptionDispatch
   set from = InstallOptionDispatch
   set CommonStatus = STATUS_SUCCESSFUL
   EndWait

InstallOptionDispatch = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering InstallOptionDispatch"
   Ifstr(i) $(!NTN_InstallMode) == deinstall
      set StartLabel = RemoveAdapterFromRegistry
   else-Ifstr(i) $(!NTN_InstallMode) == Update
      set StartLabel = UpgradeSoftware
   else-Ifstr(i) $(!NTN_InstallMode) == bind
      set StartLabel = CheckAdapterBinding
   else-Ifstr(i) $(!NTN_InstallMode) == configure
      set StartLabel = GetAdapterConfigFromRegistry
      Ifstr(i) $(KeyName_Software) == $(!NTN_RegBase)
         Debug-Output "$(STF_CONTEXTINFNAME): Cannot configure driver software."
         Shell $(UtilityInf), RegistryErrorString, CANNOT_CONFIGURE_SOFTWARE
         ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set ShellErrorSection = UtilityInf:RegistryErrorString
            goto ShellCodeError
         endif
         set Error = $($R0)
         set from = InstallOptionExit
         set to = InstallOptionExit
         goto SetNonFatalInfo
      endif
   else
      set StartLabel = TestForExistingInstallation
      set OEM_ABANDON_OPTIONS = {}
      set OEM_ABANDON_SOFTWARE = FALSE
      set OEM_ABANDON_ON = TRUE
   endif
   set InterruptValue         = 2
   set MemoryBaseValue        = 53248
   set IoBaseValue            = 736
   set SlotNumberValue        = 1
   set BusNumberValue         = 0
   set BusTypeValue           = 1
   set MediaTypeValue         = 8
   set PacketSizeValue        = 1024
   set NdisInterfaceIsa       = 1
   set NdisInterfaceEisa      = 2
   set Tc3047EisaIdValue      = 1349464391
   set Tc3147EisaIdValue      = 1349464135
   set from                   = $(FatalError)
   set to                     = $(FatalError)
   goto $(StartLabel)

TestForExistingInstallation = +
   set OldVersionExisted = $(FALSE)
   Debug-Output "$(STF_CONTEXTINFNAME): Entering TestForExistingInstallation"
   OpenRegKey $(!REG_H_LOCAL) "" $(KeyName_Software) $(MAXIMUM_ALLOWED) Key_Product
   Ifstr $(Key_Product) != $(Key_Null)
      CloseRegKey $(Key_Product)
      ifstr(i) $(!NTN_RegBase) == $(KeyName_Software)
         Shell $(UtilityInf), VerExistedDlg, $(SoftwareTitle), $(SoftwareVersion)
         ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set ShellErrorSection = UtilityInf:VerExistedDlg
            goto ShellCodeError
         endif
         goto end
      else
         Shell $(UtilityInf), CardExistedDlg
         ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set ShellErrorSection = UtilityInf:CardExistedDlg
            goto ShellCodeError
         endif
         ifstr(i) $($R1) == "OK"
            set OldVersionExisted = $(TRUE)
         else
            goto InstallOptionExit
         endif
      endif
   endif

CopyAdapterFiles = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering CopyAdapterFiles"
   ifint $(OldVersionExisted) == $(TRUE)
      ifstr(i) $(!NTN_InstallMode) == configure
         goto GetAdapterConfigFromUser
      endif
   endif
   StartWait
   ifint $(OldVersionExisted) == $(FALSE)
      ifstr(i) $(!NTN_InstallMode) == "install"
         Ifstr(i) $(DoCopy) == "YES"
            Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES
            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
               set ShellErrorSection = UtilityInf:DoAskSource
               Goto ShellCodeError
            Else-Ifstr(i) $($R0) == STATUS_FAILED
               Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
               ifint $($ShellCode) != $(!SHELL_CODE_OK)
                  set ShellErrorSection = UtilityInf:RegistryErrorString
                  goto ShellCodeError
               endif
               set Error = $($R0)
               Goto FatalError
            Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
               Goto ProcessSuccessExit
            Endif
            Set SrcDir = $($R1)
         Endif
         install "Install-Option"
         ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
            Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
               set ShellErrorSection = UtilityInf:RegistryErrorString
               goto ShellCodeError
            endif
            set Error = $($R0)
            goto FatalError
         endif
      endif
   endif

GetAdapterConfigFromRegistry = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering GetAdapterConfigFromRegistry"
   ifstr(i) $(!NTN_InstallMode) == "install"
      goto GetAdapterConfigFromUser
   else
      Ifstr $(Key_Product) == $(Key_Null)
         OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) Key_Product
         Ifstr $(Key_Product) == $(Key_Null)
            set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
            Debug-Output $(STF_CONTEXTINFNAME)": Cannot find component product key"
            goto FatalRegistryError
         Endif
      Endif
      Shell $(UtilityInf) FindService, $(Key_Product)
      Ifint $($ShellCode) != $(!SHELL_CODE_OK)
         set ShellErrorSection = UtilityInf:FindService
         Goto ShellCodeError
      Endif
      Ifstr(i) $($R0) != NO_ERROR
         Debug-Output "$(STF_CONTEXTINFNAME): Utility:FindService error: $($R0)"
         Goto FatalRegistryError
      endif
      set Key_HardwareParameters = $($R2)
      CloseRegKey $($R1)
      Ifstr $(Key_HardwareParameters) == $(Key_Null)
         set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
         Debug-Output $(STF_CONTEXTINFNAME)": Cannot find component service"
         goto FatalRegistryError
      endif
      set OldVersionExisted = $(TRUE)
      set ValueName = ""
      set ValueData = ""
      set ValueStr  = ""
      set ValueList = {}
      EnumRegValue $(Key_HardwareParameters) ValueList
      ForListDo $(ValueList)
         set ValueItem = $($)
         set ValueName = *($(ValueItem),1)
         set ValueData = *($(ValueItem),4)
         Ifstr(i) $(ValueName) == "AdapterType"
            set AdapterTypeValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "BusNumber"
            set BusNumberValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "BusType"
            set BusTypeValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "Interrupt"
            set InterruptValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "IoBase"
            set IoBaseValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "MediaType"
            set MediaTypeValue = $(ValueData)
         else-Ifstr(i) $(ValueName) == "MemoryBase"
            set MemoryBaseValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "PacketSize"
            set PacketSizeValue  = $(ValueData)
         else-Ifstr(i) $(ValueName) == "SlotNumber"
            set SlotNumberValue = $(ValueData)
         endif
         Debug-Output "$(STF_CONTEXTINFNAME): $(ValueName) == .$(ValueData)."
      EndForListDo
   Endif

GetAdapterConfigFromUser = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering GetAdapterConfigFromUser"
   set from = GetAdapterConfigFromUser
   set InterruptTextDlgDefault      = *($(InterruptTextList),+
                                      ~($(InterruptValueList), +
                                       $(InterruptValue)))
   set MemoryBaseTextDlgDefault     = *($(MemoryBaseTextList),+
                                      ~($(MemoryBaseValueList), +
                                       $(MemoryBaseValue)))
   set IoBaseTextDlgDefault         = *($(IoBaseTextList),+
                                      ~($(IoBaseValueList), +
                                       $(IoBaseValue)))
   set SlotTextDlgDefault           = ~($(SlotSupportValueList), +
                                       $(SlotSupportValue))
   ifstr(i) $(TccOption) == "tc$arcnet"
      read-syms TcarcIsaDlg
   else-ifstr(i) $(TccOption) == "tc$tcns"
      read-syms TcnsIsaDlg
   else-ifstr(i) $(TccOption) == "tc$3147"
      read-syms TcnsEisaDlg
   else
      read-syms TcarcIsaDlg
   endif
   ui start "InputDlg"
   ifstr(i) $(DLGEVENT) == "CONTINUE"
      ifstr(i) $(TccOption) == "tc$3147e"
         set SlotNumberValue  = *($(SlotValueList),+
                                ~($(SlotTextList),+
                                $(Combo1Out)))
      else
         set InterruptValue   = *($(InterruptValueList),+
                                ~($(InterruptTextList),+
                                  $(Combo1Out)))
         set IoBaseValue      = *($(IoBaseValueList),+
                                ~($(IoBaseTextList),+
                                 $(Combo2Out)))
         set MemoryBaseValue  = *($(MemoryBaseValueList),+
                                ~($(MemoryBaseTextList),+
                                 $(Combo3Out)))
      endif
      ui pop 1
      Debug-Output "$(STF_CONTEXTINFNAME): After Dialog..."
      Debug-Output "$(STF_CONTEXTINFNAME): InterruptValue  == .$(InterruptValue)."
      Debug-Output "$(STF_CONTEXTINFNAME): IoBaseValue     == .$(IoBaseValue)."
      Debug-Output "$(STF_CONTEXTINFNAME): MemoryBaseValue == .$(MemoryBaseValue)."
      Debug-Output "$(STF_CONTEXTINFNAME): SlotValue       == .$(SlotValue)."
   else-ifstr(i) $(DLGEVENT) == "CANCEL"
      set CommonStatus = STATUS_USERCANCEL
      Debug-Output "$(STF_CONTEXTINFNAME): Dialog Action Exit. Bye."
      ui pop 1
      goto InstallOptionExit
   else
      set CommonStatus = STATUS_USERCANCEL
      ui pop 1
      Debug-Output "$(STF_CONTEXTINFNAME): Dialog Action Unknown.  Bye."
      goto InstallOptionExit
   endif

AddAdapterSoftwareToRegistry = +
   Ifstr(i) $(!NTN_InstallMode) == configure
      goto AddAdapterConfigurationToRegistry
   Endif
   ifint $(OldVersionExisted) == $(TRUE)
      goto AddAdapterHardwareToRegistry
   Endif
   Shell $(UtilityInf), +
         AddSoftwareComponent, +
         $(Manufacturer), +
         $(TccBaseName), +
         $(TccBaseName), +
         $(SoftwareTitle), +
         $(STF_CONTEXTINFNAME), +
         $(SoftwareImage), +
         "kernel", "NDIS", {}, "",+
         $(NetEventDLL)
   Set OEM_ABANDON_SOFTWARE = TRUE
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddSoftwareComponent
      goto ShellCodeError
   endif
   set RegistryErrorIndex = $($R0)
   Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
      EndWait
      Debug-Output $(STF_CONTEXTINFNAME)": AddAdapterSoftware - add component error"
      CloseRegKey $($R1)
      CloseRegKey $($R2)
      CloseRegKey $($R3)
      CloseRegKey $($R4)
      CloseRegKey $($R5)
      goto FatalRegistryError
   endif
   Set Key_SoftwareProduct    = $($R1)
   Set Key_SoftwareNetRules   = $($R2)
   CloseRegKey $($R3)
   CloseRegKey $($R4)
   CloseRegKey $($R5)
   set NewValueList = {+
       {SoftwareType, $(NoTitle), $(!REG_VT_SZ),    $(SoftwareType)},+
       {MajorVersion, $(NoTitle), $(!REG_VT_DWORD), $(SoftwareMajorVersion)},+
       {MinorVersion, $(NoTitle), $(!REG_VT_DWORD), $(SoftwareMinorVersion)},+
       {Title,        $(NoTitle), $(!REG_VT_SZ),    $(SoftwareTitle)},+
       {Description,  $(NoTitle), $(!REG_VT_SZ),    $(SoftwareDescription)},+
       {ServiceName,  $(NoTitle), $(!REG_VT_SZ),    $(TccBaseName)},+
       {InstallDate,  $(NoTitle), $(!REG_VT_DWORD), *($(Now),1)}+
       }
   Shell  $(UtilityInf), AddValueList, $(Key_SoftwareProduct), $(NewValueList)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddValueList
      goto ShellCodeError
   endif
   Set RegistryErrorIndex = $($R0)
   Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
      EndWait
      Debug-Output $(STF_CONTEXTINFNAME)": AddAdapterSoftware - add value list error"
      CloseRegKey $(Key_SoftwareProduct)
      CloseRegKey $(Key_SoftwareNetRules)
      goto FatalRegistryError
   endif
   Set NewValueList = {+
       {type,      $(NoTitle), $(!REG_VT_SZ),       $(NetRuleSoftwareType)},+
       {use,       $(NoTitle), $(!REG_VT_SZ),       $(NetRuleSoftwareUse)}, +
       {bindform,  $(NoTitle), $(!REG_VT_SZ),       $(NetRuleSoftwareBindForm)}, +
       {class,     $(NoTitle), $(!REG_VT_MULTI_SZ), $(NetRuleSoftwareClass)}, +
       {bindable,  $(NoTitle), $(!REG_VT_MULTI_SZ), $(NetRuleSoftwareBindable)}, +
       {InfOption, $(NoTitle), $(!REG_VT_SZ),       $(TccOption)}+
       }
   Shell  $(UtilityInf), AddValueList, $(Key_SoftwareNetRules), $(NewValueList)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddValueList
      goto ShellCodeError
   endif
   Set RegistryErrorIndex = $($R0)
   CloseRegKey $(Key_SoftwareProduct)
   CloseRegKey $(Key_SoftwareNetRules)
   Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
      EndWait
      Debug-Output $(STF_CONTEXTINFNAME)": AddAdapterSoftware - add NetRule error"
      goto FatalRegistryError
   endif

AddAdapterHardwareToRegistry = +
   Shell $(UtilityInf), +
         AddHardwareComponent, +
         $(ProductHdwrName), +
         $(STF_CONTEXTINFNAME), +
         $(KeyName_Software)
   ifint $($R4) != -1
      Set OEM_ABANDON_OPTIONS = >($(OEM_ABANDON_OPTIONS), $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$($R4))
   endif
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddHardwareComponent
      goto ShellCodeError
   endif
   set RegistryErrorIndex = $($R0)
   Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
      EndWait
      Debug-Output $(STF_CONTEXTINFNAME)": AddAdapterHardware - add component error"
      CloseRegKey $($R1)
      CloseRegKey $($R2)
      CloseRegKey $($R3)
      goto FatalRegistryError
   endif
   set Key_HardwareNetRules   = $($R2)
   set Key_HardwareParameters = $($R3)
   set AdapterNumber          = $($R4)
   set NewValueList = {+
       {Manufacturer, $(NoTitle), $(!REG_VT_SZ),    $(Manufacturer)},+
       {Title,        $(NoTitle), $(!REG_VT_SZ),    "["$($R4)"] "$(ProductHdwrTitle)},+
       {Description,  $(NoTitle), $(!REG_VT_SZ),    $(ProductHdwrDesc)},+
       {ProductName,  $(NoTitle), $(!REG_VT_SZ),    $(ProductHdwrName)},+
       {ServiceName,  $(NoTitle), $(!REG_VT_SZ),    $($R5)},+
       {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(ProductOpSupport)},+
       {InstallDate,  $(NoTitle), $(!REG_VT_DWORD), *($(Now),1)}+
       }
   Shell $(UtilityInf), AddValueList, $($R1),  $(NewValueList)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddValueList
      goto ShellCodeError
   endif
   CloseRegKey $($R1)
   set TempProdName = """"$(ProductHdwrName)$(AdapterNumber)""""
   set TempBindForm = $(TempProdName)$(NetRuleHardwareBindForm)
   set NewValueList = {+
       {type,      $(NoTitle), $(!REG_VT_SZ),       $(NetRuleHardwareType)},+
       {bindform,  $(NoTitle), $(!REG_VT_SZ),       $(TempBindForm)}, +
       {class,     $(NoTitle), $(!REG_VT_MULTI_SZ), $(NetRuleHardwareClass)}, +
       {InfOption, $(NoTitle), $(!REG_VT_SZ),       $(TccOption)}+
       }
   Shell  $(UtilityInf), AddValueList, $(Key_HardwareNetRules), $(NewValueList)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddValueList
      goto ShellCodeError
   endif
   set RegistryErrorIndex = $($R0)
   Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
      EndWait
      Debug-Output $(STF_CONTEXTINFNAME)": AddAdapterHardware - add NetRule error"
      CloseRegKey $(Key_HardwareParameters)
      CloseRegKey $(Key_HardwareNetRules)
      goto FatalRegistryError
   endif
   CloseRegKey $(Key_HardwareNetRules)
   goto AddAdapterConfigurationToRegistry

AddAdapterConfigurationToRegistry = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering AddAdapterConfigurationToRegistry"
   Shell $(UtilityInf),GetBusTypeDialog,$(ProductHardware$(Option)Description) $(BusInterfaceType) $(BusNumber)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      Shell $(UtilityInf), GetBusTypeNum
      ifint $($ShellCode) != $(!SHELL_CODE_OK)
         set ShellErrorSection = UtilityInf:GetBusTypeNum
         goto ShellCodeError
      else
         set BusTypeValue = $($R1)
         set BusNumberValue = 0
      endif
   else
      set BusTypeValue = $($R1)
      set BusNumberValue = $($R2)
   endif
   ifstr(i) $(TccOption) == "tc$arcnet"
      set NewValueList = {+
          {AdapterType,      $(NoTitle), $(!REG_VT_DWORD), $(NdisInterfaceIsa)},+
          {BusNumber,        $(NoTitle), $(!REG_VT_DWORD), $(BusNumberValue)},+
          {BusType,          $(NoTitle), $(!REG_VT_DWORD), $(BusTypeValue)},+
          {Interrupt,        $(NoTitle), $(!REG_VT_DWORD), $(InterruptValue)},+
          {IoBase,           $(NoTitle), $(!REG_VT_DWORD), $(IoBaseValue)},+
          {MediaType,        $(NoTitle), $(!REG_VT_DWORD), $(MediaTypeValue)},+
          {MemoryBase,       $(NoTitle), $(!REG_VT_DWORD), $(MemoryBaseValue)},+
          {PacketSize,       $(NoTitle), $(!REG_VT_DWORD), $(PacketSizeValue)},+
          }
   else-ifstr(i) $(TccOption) == "tc$tcns"
      set NewValueList = {+
          {AdapterType,      $(NoTitle), $(!REG_VT_DWORD), $(NdisInterfaceIsa)},+
          {BusNumber,        $(NoTitle), $(!REG_VT_DWORD), $(BusNumberValue)},+
          {BusType,          $(NoTitle), $(!REG_VT_DWORD), $(BusTypeValue)},+
          {Interrupt,        $(NoTitle), $(!REG_VT_DWORD), $(InterruptValue)},+
          {IoBase,           $(NoTitle), $(!REG_VT_DWORD), $(IoBaseValue)},+
          {MediaType,        $(NoTitle), $(!REG_VT_DWORD), $(MediaTypeValue)},+
          {MemoryBase,       $(NoTitle), $(!REG_VT_DWORD), $(MemoryBaseValue)},+
          {PacketSize,       $(NoTitle), $(!REG_VT_DWORD), $(PacketSizeValue)},+
          }
   else-ifstr(i) $(TccOption) == "tc$3147e"
      set NewValueList = {+
          {AdapterType,      $(NoTitle), $(!REG_VT_DWORD), $(NdisInterfaceEisa)},+
          {BusNumber,        $(NoTitle), $(!REG_VT_DWORD), $(BusNumberValue)},+
          {BusType,          $(NoTitle), $(!REG_VT_DWORD), $(BusTypeValue)},+
          {EisaCompressedId, $(NoTitle), $(!REG_VT_DWORD), $(Tc3147EisaIdValue)},+
          {MediaType,        $(NoTitle), $(!REG_VT_DWORD), $(MediaTypeValue)},+
          {PacketSize,       $(NoTitle), $(!REG_VT_DWORD), $(PacketSizeValue)},+
          {SlotNumber,       $(NoTitle), $(!REG_VT_DWORD), $(SlotNumberValue)},+
          }
   else
      set NewValueList = {+
          {AdapterType,      $(NoTitle), $(!REG_VT_DWORD), $(NdisInterfaceIsa)},+
          {BusNumber,        $(NoTitle), $(!REG_VT_DWORD), $(BusNumberValue)},+
          {BusType,          $(NoTitle), $(!REG_VT_DWORD), $(BusTypeValue)},+
          {Interrupt,        $(NoTitle), $(!REG_VT_DWORD), $(InterruptValue)},+
          {IoBase,           $(NoTitle), $(!REG_VT_DWORD), $(IoBaseValue)},+
          {MediaType,        $(NoTitle), $(!REG_VT_DWORD), $(MediaTypeValue)},+
          {MemoryBase,       $(NoTitle), $(!REG_VT_DWORD), $(MemoryBaseValue)},+
          {PacketSize,       $(NoTitle), $(!REG_VT_DWORD), $(PacketSizeValue)},+
          }
   Endif
   Shell  $(UtilityInf), AddValueList, $(Key_HardwareParameters), $(NewValueList)
   CloseRegKey $(Key_HardwareParameters)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:AddValueList
      goto ShellCodeError
   endif
   set RegistryErrorIndex = $($R0)
   Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
      Debug-Output $(STF_CONTEXTINFNAME)": AddAdapterConfiguration - add value list error"
      goto FatalRegistryError
   endif
   EndWait
   goto ProcessSuccessExit

CheckAdapterBinding =+
   Debug-Output "$(STF_CONTEXTINFNAME): Entering CheckAdapterBinding"
   set Error = "CheckAdapterBinding: not required for this adapter"
   goto FatalError

RemoveAdapterFromRegistry = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering RemoveAdapterFromRegistry"
   OpenRegKey $(!REG_H_LOCAL) "" $(KeyName_Software) $(MAXIMUM_ALLOWED) KeyToReferenceCount
   Ifstr $(KeyToReferenceCount) == ""
      Debug-Output "$(STF_CONTEXTINFNAME): Could not open Software Base Key"
      set RefCountBeforeRemove = 2
      goto InstallOptionExit
   endif
   GetRegValue $(KeyToReferenceCount),"RefCount", RefCountInfo
   set RefCountBeforeRemove = *($(RefCountInfo), 4)
   CloseRegKey $(KeyToReferenceCount)
   Debug-Output "$(STF_CONTEXTINFNAME): Removing Hardware Component"
   Shell $(UtilityInf), +
         RemoveHardwareComponent, +
         $(Manufacturer), +
         $(TccBaseName), +
         $(!NTN_RegBase)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:RemoveHardwareComponent
      goto ShellCodeError
   endif
   Ifstr(i) $($R0) != NO_ERROR
      Ifstr(i) $($R0) != REF_COUNT_NOT_ZERO
         goto FatalRegistryError
      endif
   endif
   ifint $(RefCountBeforeRemove) == 1
      OpenRegKey $(!REG_H_LOCAL) "" $(KeyName_SoftwareRoot) $(MAXIMUM_ALLOWED) Key_SoftwareRoot
      EnumRegKey $(Key_SoftwareRoot) KeyList
      EnumRegValue $(Key_SoftwareRoot) ValueList
      CloseRegKey $(Key_SoftwareRoot)
      Debug-Output "$(STF_CONTEXTINFNAME): Reg Key .$(KeyName_SoftwareRoot). opened"
      Debug-Output "$(STF_CONTEXTINFNAME): KeyList == .$(KeyList)."
      Debug-Output "$(STF_CONTEXTINFNAME): ValueList == .$(ValueList)."
      ifstr $(KeyList) == "{}"
         ifstr $(ValueList) == "{}"
            OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_SoftwareBase) $(MAXIMUM_ALLOWED) Key_SoftwareBase
            DeleteRegKey $(Key_SoftwareBase) $(Manufacturer)
            CloseRegKey $(Key_SoftwareBase)
         endif
      endif
   endif
   goto InstallOptionExit

UpgradeSoftware = +
   Debug-Output "$(STF_CONTEXTINFNAME): Entering UpgradeSoftware"
   ifstr(i) $(KeyName_Software) == $(!NTN_RegBase)
      OpenRegKey $(!REG_H_LOCAL) "" $(KeyName_Software) $(MAXIMUM_ALLOWED) Key_Product
      Ifstr $(Key_Product) != $(Key_Null)
         GetRegValue $(Key_Product),"MajorVersion", VersionInfo
         set Version = *($(VersionInfo), 4)
         Shell $(UtilityInf), GetInfFileNameFromRegistry, $(Key_Product)
         ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set ShellErrorSection = UtilityInf:GetFileNameFromRegistry
            goto ShellCodeError
         endif
         set !UG_Filename = $($R0)
         ifstr(i) $(!UG_Filename) != ""
            install "Install-Update"
            ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
               goto FatalError
            endif
         endif
         SetRegValue $(Key_Product) {MajorVersion, $(NoTitle), $(!REG_VT_SZ), $(SoftwareMajorVersion)}
         SetRegValue $(Key_Product) {MinorVersion, $(NoTitle), $(!REG_VT_SZ), $(SoftwareMinorVersion)}
         ifint $(Version) != $(SoftwareVersion)
            Debug-Output "$(STF_CONTEXTINFNAME): Version .$(Version). != SoftwareVersion .$(SoftwareVersion)."
         endif
         CloseRegKey $(Key_Product)
      else
         goto FatalRegistryError
      endif
   else
      OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) NetworkCardKey
      Ifstr(i) $(NetworkCardKey) != $(Key_Null)
         GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
         set ServiceName = *($(ServiceNameInfo), 4)
         OpenRegKey $(NetworkCardKey) "" "NetRules" $(MAXIMUM_ALLOWED) NetRuleKey
         Ifstr(i) $(NetRuleKey) != $(Key_Null)
            Debug-Output "$(STF_CONTEXTINFNAME): NetRuleKey .$(NetRuleKey). != Key_Null .$(Key_Null)."
         else
            goto FatalRegistryError
         endif
         CloseRegKey $(NetRules)
         CloseRegKey $(NetworkCardKey)
      else
         goto FatalRegistryError
      endif
      OpenRegKey $(!REG_H_LOCAL) +
                 "" $(!NTN_ServiceBase)"\"$(ServiceName) +
                 $(MAXIMUM_ALLOWED) +
                 ServiceKey
      Ifstr(i) $(ServiceKey) != $(Key_Null)
         CloseRegKey $(ServiceKey)
      else
         goto FatalRegistryError
      endif
   endif

       ;
    ; Enumerate all netcards installed of this type and update them
    ;
    set iSearch = 1
nextnetcard = +
    Shell $(UtilityInf), FindNextNetworkCard, $(TccBaseName), $(iSearch)
    set KeyNetcard = $($R0)
    set iSearch = $($R1)
    Debug-Output "OemNadEp.Inf: FindNextNetworkCard "$(KeyNetcard)","$(iSearch)
    Ifstr $(KeyNetcard) != $(KeyNull)
        Debug-Output "OemNadEp.Inf: Setting OperationsSupport value"
        SetRegValue $(KeyNetcard) {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(ProductOpSupport)}
        CloseRegKey $(KeyNetcard)

        goto nextnetcard
    Endif

   goto InstallOptionExit

ProcessSuccessExit = +
   goto InstallOptionExit

ProcessAbandonInstall = +
   ForListDo $(OEM_ABANDON_OPTIONS)
      Shell $(UtilityInf), +
            RemoveHardwareComponent, +
            $(Manufacturer), +
            $(TccBaseName), +
            $($)
      ifint $($ShellCode) != $(!SHELL_CODE_OK)
         set ShellErrorSection = UtilityInf:RemoveHardwareComponent
         goto ShellCodeError
      endif
      set RegistryErrorIndex = $($R0)
      Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
         goto FatalRegistryError
      endif
   EndForListDo
   Ifstr(i) $(OEM_ABANDON_SOFTWARE) == TRUE
      Shell $(UtilityInf), +
            RemoveSoftwareComponent, +
            $(Manufacturer), +
            $(TccBaseName), +
            FALSE
      ifint $($ShellCode) != $(!SHELL_CODE_OK)
         set ShellErrorSection = UtilityInf:RemoveSoftwareComponent
         goto ShellCodeError
      endif
      set RegistryErrorIndex = $($R0)
      Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
         goto FatalRegistryError
      endif
   endif
   goto InstallOptionExit

ProcessWarningMessage = +
   Shell $(SubroutineInf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = SubroutineInf:SetupMessage
      goto ShellCodeError
   endif
   ifstr(i) $($R1) == "OK"
      goto $(to)
   else-ifstr(i) $($R1) == "CANCEL"
      goto $(from)
   else
      goto "InstallOptionExit"
   endif

SetNonFatalInfo = +
   Set CommonStatus = STATUS_USERCANCEL
   Set Severity = STATUS
   goto ProcessNonFatalMessage

ProcessNonFatalMessage = +
   ifstr(i) $(Error) == ""
      Set Severity = NONFATAL
      Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
      ifint $($ShellCode) != $(!SHELL_CODE_OK)
         set ShellErrorSection = UtilityInf:RegistryErrorString
         goto ShellCodeError
      endif
      set Error = $($R0)
   endif
   Shell $(SubroutineInf) SetupMessage, $(!STF_LANGUAGE), $(Severity), $(Error)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = SubroutineInf:SetupMessage
      goto ShellCodeError
   endif
   ifstr(i) $($R1) == "OK"
      goto $(from)
   else
      goto "InstallOptionExit"
   endif

FatalRegistryError = +
   Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:RegistryErrorString
      goto ShellCodeError
   endif
   set Error = $($R0)
   goto FatalError

FatalError = +
   ifstr(i) $(Error) == ""
      Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
      ifint $($ShellCode) != $(!SHELL_CODE_OK)
         set ShellErrorSection = UtilityInf:RegistryErrorString
         goto ShellCodeError
      endif
      set Error = $($R0)
   endif
   Shell $(SubroutineInf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
   ifint $($ShellCode) != $(!SHELL_CODE_OK)
      set ShellErrorSection = UtilityInf:SetupMessage
      goto ShellCodeError
   endif
   goto SetFailedStatusAndExit

ShellCodeError = +
   Debug-Output $(STF_CONTEXTINFNAME)": Shell error, $(ShellErrorSection)"
   set DlgType      = "MessageBox"
   set STF_MB_TITLE = "Error: "$(FunctionTitle)
   set STF_MB_TEXT  = "Shell Code Error"
   set STF_MB_TYPE  = 1
   set STF_MB_ICON  = 3
   set STF_MB_DEF   = 1
   ui start "Error Message"
   goto SetFailedStatusAndExit

SetFailedStatusAndExit = +
   set CommonStatus = STATUS_FAILED
   ifstr(i) $(OEM_ABANDON_ON) == TRUE
      set OEM_ABANDON_ON = FALSE
      goto ProcessAbandonInstall
   endif
   goto InstallOptionExit

InstallOptionExit = +
   Return $(CommonStatus)