***********************************************************************
;
;  ANDTOK.INF
;
;	ANDREW ISA IIA network card and driver SETUP INF file.
;
;
;  Copyright (c) 1993  DWB Associates Inc.  All Rights Reserved
;
;***********************************************************************


[Identification]
    OptionType = NetAdapter

[PlatformsSupported]
    ISA
    EISA

[LanguagesSupported]
    ENG

[Options]
    ANDTOK

[OptionsTextENG]
    ANDTOK     = "Andrew ISA IIA Token Ring Adapter"

[Source Media Descriptions]
    1   = "ANDTOK Install Diskette"
    2   = "Windows NT Setup CD-ROM Disk"

[Signature]
    FileType = MICROSOFT_DRVLIB_FILE
[GetSignature]
    read-syms Signature
    return $(FileType)

[Files-ANDTOK]
    1,andtok.sys, SIZE=40000
    1,eaglemac.bin, SIZE=40000

[Files-Dlg]
    1,andtok.dll, SIZE=40000
    1,andtok.hlp, SIZE=40000

[Files-Inf]
    1, oemsetup.inf, SIZE=20000, RENAME=$(!UG_Filename)

[Files-andncdet]
    1,andncdet.dll, SIZE=40000

[date]
    Now = {} ? $(!LIBHANDLE) GetSystemDate

[FileConstants]
    UtilityInf      = "UTILITY.INF"
    ParamInf        = "NCPARAM.INF"
    SubroutnInf     = "SUBROUTN.INF"
    NetEventDLL     = "%SystemRoot%\System32\netevent.dll"


[RegistryConstants]
    SoftwareType                     = "driver"
    Manufacturer                     = "ANDREW"
    ProductMajorVersion              = "3"
    ProductMinorVersion              = "1"
    ProductVersion                   = $(ProductMajorVersion)"."$(ProductMinorVersion)
    ProductSoftwareName              = "AndTok"
    ProductSoftwareTitle             = "AndTok Adapter Driver"
    ProductSoftwareImagePath         = "\SystemRoot\System32\drivers\andtok.sys"
    NetRuleSoftwareType              = "andtokSys ndisDriver andtokDriver"
    NetRuleSoftwareUse               = $(SoftwareType)
    NetRuleSoftwareBindForm          = """AndTokSys"" yes no container"
    NetRuleSoftwareClass             = {"andtokDriver basic"}
    NetRuleSoftwareBindable          = {"andtokDriver andtokAdapter non exclusive 100"}
    ProductHardwareName              = "AndTok"
    ProductHardwareANDTOKTitle       = "Andrew ISA IIA Adapter"
    NetRuleHardwareType              = "andtok andtokAdapter"
    NetRuleHardwareBindForm          = " yes yes container"
    NetRuleHardwareClass             = {"andtokAdapter basic"}
    ProductKeyName                   = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
    ParamKeyName                     = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"
    ProductSoftwareDescription       = "Andrew ISA IIA Adapter Driver"
    ProductHardwareANDTOKDescription = "Andrew ISA IIA Adapter"

[GeneralConstants]
    KeyNull            = ""
    MAXIMUM_ALLOWED    = 33554432
    KeyProduct         = ""
    KeyParameters      = ""
    TRUE               = 1
    FALSE              = 0
    NoTitle            = 0
    DriverPath         = $(!STF_NTPATH)\drivers

[FileConstantsENG]
    ProCaption    = "Windows NT Setup"
    ProCancel     = "Cancel"
    ProCancelMsg  = "Windows NT Networking is not correctly installed.  "+
                    "Are you sure you want to cancel copying files?"
    ProCancelCap  = "Network Setup Message"
    ProText1      = "Copying:"
    ProText2      = "To:"
    Cancel        = "Cancel"
    FunctionTitle = "Andrew ISA IIA Token Ring Adapter Card Setup"

[DownLoadInfo]
    DownFile = "eaglemac.bin"

[AndIrqs]
    IRQ0 = "3",3
    IRQ1 = "5",5
    IRQ2 = "6",6
    IRQ3 = "7",7
    IRQ4 = "9",9
    IRQ5 = "10",10
    IRQ6 = "11",11
    IRQ7 = "12",12

[AndDmaChan]
    DMA0 = "7",7
    DMA1 = "6",6
    DMA2 = "5",5
    DMA3 = "1",1

[AndIoBase]
    Base0 = "0x1A20",0x1A20
    Base1 = "0x2A20",0x2A20
    Base2 = "0x3A20",0x3A20
    Base3 = "0x3A40",0x3A40
    Base4 = "0x3A60",0x3A60
    Base5 = "0x3A80",0x3A80
    Base6 = "0x3AA0",0x3AA0
    Base7 = "0x4AE0",0x4AE0

[AndPioBase]
    Pio0 = "0x380",0x380
    Pio1 = "0x382",0x382
    Pio2 = "0x384",0x384
    Pio3 = "0x386",0x386
    Pio4 = "0x390",0x390
    Pio5 = "0x392",0x392
    Pio6 = "0x394",0x394
    Pio7 = "0x396",0x396

[AndIdBase]
    Base0x380 = "0"
    Base0x382 = "1"
    Base0x384 = "2"
    Base0x386 = "3"
    Base0x390 = "4"
    Base0x392 = "5"
    Base0x394 = "6"
    Base0x396 = "7"

[HexDigits]
    Hex0 = 0
    Hex1 = 1
    Hex2 = 2
    Hex3 = 3
    Hex4 = 4
    Hex5 = 5
    Hex6 = 6
    Hex7 = 7
    Hex8 = 8
    Hex9 = 9
    HexA = A
    HexB = B
    HexC = C
    HexD = D
    HexE = E
    HexF = F

[DialogConstantsENG]
    Help         = "&Help"
    Exit         = "Cancel"
    OK           = "OK"
    Continue     = "Continue"
    Cancel       = "Cancel"
    BadMaxFrame1 = "Maximum Frame Size must be at least 256"
    BadMaxFrame2 = "Maximum Frame Size must be no greater that 4472 for 4mbs"
    BadMaxFrame3 = "Maximum Frame Size must be no greater that 17800 for 16mbs"
    BadProdId1   = "Product Id must be 36 hexadecimal digits"
    BadProdId2   = "Product Id contains invalid hexadecimal digit: "
    BadAddr1     = "Network Address must be 12 hexadecimal digits"
    BadAddr2     = "Network Address contains invalid hexadecimal digit: "
    BadAddr3     = "Network Address invalid, must be between 4000 0000 0000 and 7fff ffff ffff"
    CardError1   = "AndTok card not installed in system"
    CardError2   = "AndTok card(s) are already installed"

[FileDependentDlgISA]
    DlgTemplate = "ANDISA"
    HelpContext = "30000"

[FileDependentDlgENG]
    DlgType            = "RadioCombination"
    Caption            = "Andrew ISA IIA Token Ring Adapter Card Setup"
    Label1             = "&IRQ Level"
    Label2             = "I/O &Base"
    Label3             = "&DMA Channel"
    Label4             = "&Adapter ID"
    Label5             = "&Maximum Frame Size"
    Label7             = "Add&ress"
    Group1             = "Ring &Speed"
    Group2             = "&Transfer Mode"
    Group3             = "N&ode Address"
    Group4             = "Advanced Options"
    Group5             = "Cloc&k Source"
    Radio1             = "16 MBS"
    Radio2             = "4 MBS"
    Radio3             = "Busmaster DMA"
    Radio4             = "Programmed I/O"
    Radio5             = "System"
    Radio6             = "8 MHz"
    Radio7             = "16 MHz"
    Check1             = "&Early Token Release"
    Check2             = "&Locally Administered"
    Check3             = "No &Wait States"
    Check4             = "Long B&urst"
    IrqList            = ^(AndIrqs, 1)
    IoBaseList         = ^(AndIoBase, 1)
    PioBaseList        = ^(AndIdBase, 1)
    DmaList            = ^(AndDmaChan, 1)
    SpeedValue         = 0
    DmaModeValue       = "dma"
    WaitStates         = 0
    LongBurst          = 0
    ClockSource        = 0
    Combo1List         = $(IrqList)
    Combo1Out          = $(InterruptNumber)
    Combo2List         = $(IoBaseList)
    Combo2Out          = $(IoBaseAddress)
    Combo3List         = $(DmaList)
    Combo3Out          = $(DmaChan)
    Combo4List         = $(PioBaseList)
    Combo4Out          = $(PioValue)
    ComboListItemsIn4  = {Combo1List, Combo2List, Combo3List, Combo4List}
    ComboListItemsOut4 = {Combo1Out, Combo2Out, Combo3Out, Combo4Out}
    CBOptionsGreyed    = {}
    NotifyFields       = {NO, NO, NO}
    EditTextLim        = {5, 12}
    EditFocusOn        = ""
    RCCtlFocusOn       = 403

[Identify]
    read-syms Identification
    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)
    Return $(Status) $(Identifier) $(Media)

[ReturnOptions]
set !DebugOutputControl = 1
    set OptionList     = ^(Options, 1)
    set OptionTextList = ^(OptionsText$($0), 1)
    set Status         = STATUS_SUCCESSFUL

    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
      ifstr(i) $($0) == ""
        set Status = STATUS_NOLANGUAGE
        goto ExitReturnOptions
      endif
    else
      set Status = STATUS_NOLANGUAGE
      goto ExitReturnOptions
    endif

    set PlatformList = ^(PlatformsSupported, 1)
    Ifcontains(i) $($1) in $(PlatformList)
      ifstr(i) $($1) == ""
        set Status = STATUS_NOTSUPPORTED
      endif
    else
      set Status = STATUS_NOTSUPPORTED
    endif

ExitReturnOptions = +
    Return $(Status) $(OptionList) $(OptionTextList)

[InstallOption]
    StartWait
set !DebugOutputControl = 1

    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)

    set LanguageList = ^(LanguagesSupported, 1)

    read-syms GeneralConstants
    read-syms FileConstants
    read-syms RegistryConstants
    read-syms FileDependentDlg$(!STF_LANGUAGE)
    read-syms DialogConstants$(!STF_LANGUAGE)
    read-syms FileConstants$(!STF_LANGUAGE)
    read-syms FileDependentDlgISA

    set NoArg = $(TRUE)
    Ifstr(i) $(!NTN_InstallMode) == deinstall
        set SubFunction = RemoveAdapter
    else-Ifstr(i) $(!NTN_InstallMode) == update
        set SubFunction = UpgradeSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == configure
        set NoArg = $(FALSE)
        set SubFunction = ConfigureAdapter
    else-Ifstr(i) $(!NTN_InstallMode) == install
        set NoArg = $(FALSE)
        set SubFunction = InstallAdapter
    else
        set SubFunction = NoWay
    endif

    ifint $(NoArg) == $(TRUE)
        Shell "" $(SubFunction)
    else
        Shell "" $(SubFunction) $(Option) $(DoCopy) $(AddCopy) $(SrcDir)
    endif

    EndWait
    return $($R0)

[InstallAdapter]
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms RegistryConstants
    read-syms DialogConstants$(!STF_LANGUAGE)
    read-syms FileDependentDlg$(!STF_LANGUAGE)

    set Option  = $($0)
    set DoCopy  = $($1)
    set AddCopy = $($2)
    set SrcDir  = $($3)

    detect date
    set CurrentTime = *($(Now),1)

    set KeyProduct = $(KeyNull)
    set DoSetup    = $(TRUE)

    set DetectedCard = $(FALSE)
    ifstr(i) $(!STF_NCDETECT) == YES
        ifstr(i) $(!STR_NCOPTION) == $(Option)
            set DetectedCard = $(TRUE)
        endif
    endif
    
    ifint $(DetectedCard) == $(TRUE)
        Set TypeList = {{IRQ,IRQ_List,IRQLevel},+
                        {IOADDR, IOBaseAddressDecList, IOBaseValue},+
                        {DMACHANNEL, DMAChannelList, DMAChannel}}
    
        Shell $(ParamInf) Param_BuildTypeLists $(Option) $(TypeList)
        Set Status = $($R0)
        ifstr(i) $(Status) != STATUS_SUCCESSFUL
            Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
            Shell "" FatalError $($R0)
            Return STATUS_FAILED
        Endif

        Shell $(ParamInf) Param_SetDefaults {}
    endif

    set OldVersionExisted = $(FALSE)
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

    Ifstr $(KeyProduct) != $(KeyNull)
        CloseRegKey $(KeyProduct)

        ifstr(i) $(!NTN_RegBase) == $(ProductKeyName)
            Shell $(UtilityInf) VerExistedDlg $(ProductSoftwareTitle) $(ProductVersion)
            ifstr(i) $($R1) != "OK"
                Return STATUS_FAILED
            endif
        else
            Shell $(UtilityInf) CardExistedDlg
            ifstr(i) $($R1) != "OK"
                Return STATUS_FAILED
            endif
            set OldVersionExisted = $(TRUE)
        endif
    endif

    ifint $(DetectedCard) == $(TRUE)
        shell $(ParamInf) Param_QueryCard $(!STF_NCDETCARD)
        ifstr(i) $($R0) == STATUS_SUCCESSFUL
            set DetectedParams = $($R1)
            shell $(ParamInf) Param_SetDefaults $(DetectedParams)
        endif
    endif

    ifint $(DoSetup) == $(TRUE)
        set TempList           = ^(AndIrqs, 1)
        set InterruptNumber    = *($(TempList), 1)
        set TempList           = ^(AndDmaChan, 1)
        set DmaChanValue       = *($(TempList), 1)
        set TempList           = ^(AndIoBase, 1)
        set IoBaseAddrValue    = *($(TempList), 1)
        set TempList           = ^(AndPioBase, 1)
        set PioBaseAddrValue   = *($(TempList), 1)
        set MaxFrame           = 4096
        set EarlyRelease       = 0
        set SoftAddress        = 0
        set NetAddress         = "000000000000"
        set BusNumber          = 0

        ifint $(DetectedCard) == $(TRUE)
            set InterruptNumber          = $(IRQLevel)
            set-dectohex IoBaseAddrValue = $(IOBaseValue)
            set DmaChanValue             = $(DMAChannel)
            set BusNumber                = *($(!STF_NCDETINFO), 6)
        endif

        set DLLPATH = ""
        ifstr(i) $(DoCopy) == "YES"
            OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

            Ifstr $(KeyProduct) != $(KeyNull)
                CloseRegKey $(KeyProduct)
                set DLLPATH = $(!STF_CWDDIR)
            else
                set BuiltIn = "YES"
                ifstr(i) $(!NTN_Origination) == "NCPA"
                    Set BuiltIn = "NO"
                endif
                Shell $(UtilityInf) DoAskSource $(!STF_CWDDIR) $(SrcDir) $(BuiltIn)
                set DLLPATH = $($R1)
                set SrcDir  = $($R1)
            endif
        endif

dowind =+
        set TempList       = ^(AndPioBase, 1)
        set PioValue       = *($(TempList), 1)
        set SpeedValue     = 16
        set SetAddress     = 0
        set WaitStates     = 1
        set LongBurst      = 1
        set ClockSource    = 0

        Shell "" AdapterSetup
        ifint $($R0) != $(TRUE)
            Return STATUS_USERCANCEL
        endif

        set IRQLevel    = $(NewIrq)
        set IOBaseValue = $(NewBase)
        set DMAChannel  = $(NewDma)

        Shell $(ParamInf) Param_SaveValues
        Set NewParamSettings = $($R0)

        Shell $(ParamInf) Param_VerifyResources $(NewParamSettings)
        Ifstr(i) $($R0) != STATUS_SUCCESSFUL
            Shell $(UtilityInf),RegistryErrorString,VERIFY_WARNING
            Shell "" VerifyError $($R0)
                ifstr(i) $($R0) != "OK"
                    goto dowind
                endif
            endif
        endif

        ifint $(OldVersionExisted) == $(FALSE)
            Shell "" SetCopy $(DoCopy) $(AddCopy) $(SrcDir)
            ifint $($R0) == $(TRUE)
                Shell "" SetSoftware $(CurrentTime)
                ifint $($R0) != $(TRUE)
                    Return STATUS_FAILED
                endif
            endif
        endif

        Shell "" SetHardware $(CurrentTime)

        ifint $($R0) == $(TRUE)
            Shell "" WriteParameters
        endif
    endif

    ifint $($R0) == $(TRUE)
        Return STATUS_SUCCESSFUL
    else
        Return STATUS_FAILED
    endif

[ConfigureAdapter]
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms RegistryConstants
    read-syms FileDependentDlg$(!STF_LANGUAGE)
    read-syms FileDependentDlgISA
    set Option = $($0)

    ifstr(i) $(!NTN_RegBase) == $(ProductKeyName)
        Shell $(UtilityInf) RegistryErrorString CANNOT_CONFIGURE_SOFTWARE
        Shell "" FatalError $($R0)
        Return STATUS_FAILED
    endif

    Set DetectedCard = $(FALSE)
    ifstr(i) $(!STF_NCDETECT) == YES
        ifstr(i) $(!STF_NCOPTION) == $(Option)
            set DetectedCard = $(TRUE)
        endif
    endif

    ifint $(DetectedCard) == $(TRUE)
        Set TypeList = {{IRQ,IRQ_List,IRQLevel},+
                        {IOADDR, IOBaseAddressDecList, IOBaseValue},+
                        {DMACHANNEL, DMAChannelList, DMAChannel}}
        Shell $(ParamInf) Param_BuildTypeLists $(Option) $(TypeList)
        Set Status = $($R0)
        ifstr(i) $(Status) != STATUS_SUCCESSFUL
            Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
            Shell "" FatalError $($R0)
            Return STATUS_FAILED
        Endif
    
        Shell $(ParamInf) Param_SetDefaults {}
    Endif

    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) KeyProduct

    Ifstr $(KeyProduct) == $(KeyNull)
        Shell $(UtilityInf) RegistryErrorString CANNOT_FIND_COMPONENT_SERVICE
        Shell "" FatalError $($R0)
        Return STATUS_FAILED
    endif

    Shell $(UtilityInf) FindService, $(KeyProduct)

    Ifstr(i) $($R0) != NO_ERROR
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return STATUS_FAILED
    endif

    Set !KeyParameters = $($R2)
    CloseRegKey $($R1)

    Ifstr $(!KeyParameters) == $(KeyNull)
        Shell $(UtilityInf) RegistryErrorString CANNOT_FIND_COMPONENT_SERVICE
        Shell "" FatalError $($R0)
        Return STATUS_FAILED
    endif

    set ValueName = ""
    set ValueData = ""
    set ValueStr  = ""
    set ValueList = {}

    EnumRegValue $(!KeyParameters) ValueList

    ForListDo $(ValueList)
        set ValueItem = $($)
        set ValueName = *($(ValueItem),1)
        set ValueData = *($(ValueItem),4)
        Ifstr(i) $(ValueName) == "Speed"
            set SpeedValue = $(ValueData)
        else-ifstr(i) $(ValueName) == "DmaMode"
            set DmaModeValue = $(ValueData)
        else-ifstr(i) $(ValueName) == "BusNumber"
            set BusNumber = $(ValueData)
        else-ifstr(i) $(ValueName) == "Interrupt"
            set InterruptNumber = $(ValueData)
        else-ifstr(i) $(ValueName) == "IoBase"
            set IoBaseAddrValue = $(ValueData)
        else-ifstr(i) $(ValueName) == "DmaChannel"
            set DmaChanValue = $(ValueData)
        else-ifstr(i) $(ValueName) == "PacketSize"
            set MaxFrame = $(ValueData)
        else-ifstr(i) $(ValueName) == "PioBase"
            set PioValue = $(ValueData)
        else-ifstr(i) $(ValueName) == "EarlyRelease"
            set EarlyRelease = $(ValueData)
        else-ifstr(i) $(ValueName) == "SetAddress"
            set SetAddress = $(ValueData)
        else-ifstr(i) $(ValueName) == "NetworkAddress"
            set NetworkAddress = $(ValueData)
        else-ifstr(i) $(ValueName) == "WaitStates"
            set WaitStates = $(ValueData)
        else-ifstr(i) $(ValueName) == "LongBurst"
            set LongBurst = $(ValueData)
        else-ifstr(i) $(ValueName) == "ClockSource"
            set ClockSource = $(ValueData)
        endif
    EndForListDo

    set-dectohex IoBaseAddrValue = $(IoBaseAddrValue)
    set-dectohex PioValue        = $(PioValue)

winagn =+
    set DLLPATH = $(!STF_CWDDIR)
    Shell "" AdapterSetup

    ifint $($R0) != $(TRUE)
        Return STATUS_USERCANCEL
    endif

    set IRQLevel    = $(NewIrq)
    set IOBaseValue = $(NewBase)
    set DMAChannel  = $(NewDma)

    ifstr(i) $(!STF_BUSTYPE) == ISA
        Shell $(ParamInf) Param_SaveValues
        Set NewParamSettings = $($R0)
        Shell $(ParamInf) Param_VerifyResources $(NewParamSettings)
        Ifstr(i) $($R0) != STATUS_SUCCESSFUL
            Shell $(UtilityInf),RegistryErrorString,VERIFY_WARNING
            Shell "" VerifyError $($R0)
            ifstr(i) $($R0) != "OK"
                goto winagn
            endif
        endif
    endif

    Shell "" WriteParameters

    ifint $($R0) == $(TRUE)
        Return STATUS_SUCCESSFUL
    else
        Return STATUS_FAILED
    endif

[NoWay]
    read-syms GeneralConstants
    Shell "" FatalError "NoWay"
    Return STATUS_FAILED

[RemoveAdapter]
    read-syms RegistryConstants
    read-syms GeneralConstants
    read-syms FileConstants

        Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
            $(ProductSoftwareName), $(!NTN_RegBase)

        ifstr(i) $($R0) != NO_ERROR
            Shell $(UtilityInf) RegistryErrorString $($R0)
            Shell "" FatalError $($R0)
            Return STATUS_FAILURE
        endif

        Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
            $(ProductSoftwareName)

        ifstr(i) $($R0) == REF_COUNT_NOT_ZERO
            Return STATUS_SUCCESSFUL
        endif

        ifstr(i) $($R0) != NO_ERROR
            Shell $(UtilityInf) RegistryErrorString $($R0)
            Shell "" FatalError $($R0)
            Return STATUS_FAILURE
        endif

    Return STATUS_SUCCESSFUL


[UpgradeSoftware]
    read-syms GeneralConstants
    read-syms RegistryConstants


    ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
        OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
        Ifstr $(KeyProduct) == $(KeyNull)
            Return STATUS_FAILED
        endif

        GetRegValue $(KeyProduct),"MajorVersion", VersionInfo
        set Version = *($(VersionInfo), 4)
        Split-String $(!NTN_Infname), "\", FilenameList
        QueryListSize ListSize $(FilenameList)
        set !UG_Filename = *($(FilenameList), $(ListSize))

        install "Install-Update"
        ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
            Return STATUS_FAILED
        endif

        SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
        SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}
        CloseRegKey $(KeyProduct)
    else
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) NetworkCardKey
        Ifstr(i) $(NetworkCardKey) == $(KeyNull)
            Return STATUS_FAILED
        endif

        GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
        set ServiceName = *($(ServiceNameInfo), 4)

        OpenRegKey $(NetworkCardKey) "" "NetRules" $(MAXIMUM_ALLOWED) NetRuleKey
        Ifstr(i) $(NetRuleKey) == $(KeyNull)
            Return STATUS_FAILED
        endif

        CloseRegKey $(NetRules)
        CloseRegKey $(NetworkCardKey)

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$(ServiceName) $(MAXIMUM_ALLOWED) ServiceKey
        Ifstr(i) $(ServiceKey) == $(KeyNull)
            Return STATUS_FAILED
        endif

        CloseRegKey $(ServiceKey)
    endif

    Return STATUS_SUCCESSFUL

[AdapterSetup]
    read-syms FileDependentDlg$(!STF_LANGUAGE)
    read-syms DialogConstants$(!STF_LANGUAGE)
    read-syms FileConstants$(!STF_LANGUAGE)
    read-syms FileConstants
    read-syms GeneralConstants
    read-syms FileDependentDlgISA

    set DLLPATH        = $(!p:DLLPATH)
    set Combo1Out      = $(!p:InterruptNumber)
    set Combo2Out      = $(!p:IoBaseAddrValue)
    set SpeedValue     = $(!p:SpeedValue)
    set Combo3Out      = $(!p:DmaChanValue)
    set Combo4Out      = $(!p:PioValue)
    set DmaModeValue   = $(!p:DmaModeValue)
    set MaxFrame       = $(!p:MaxFrame)
    set EarlyRelease   = $(!p:EarlyRelease)
    set SetAddress     = $(!p:SetAddress)
    set WaitStates     = $(!p:WaitStates)
    set LongBurst      = $(!p:LongBurst)
    set BusNumber      = $(!p:BusBumber)
    set ClockSource    = $(!p:ClockSource)

    set Combo4Out = #(AndIdBase, "Base"$(Combo4Out), 1)

    set ComboListItemsIn  = $(ComboListItemsIn4)
    set ComboListItemsOut = $(ComboListItemsOut4)

    ifint $(SetAddress) == 1
        set NetworkAddress = $(!p:NetworkAddress)
    else
        set NetworkAddress = "000000000000"
    endif


    SetHelpFile $(DLLPATH)\"andtok.hlp" 30000 30001

    set AdapterStatus = $(FALSE)

    ifint $(SpeedValue) == 16
        set FirstButton = 1
    else
        set FirstButton = 2
    endif

    ifstr(i) $(DmaModeValue) == "dma"
        set SecondButton = 3
    else
        set SecondButton = 4
    endif

    ifint $(ClockSource) == 0
        set ThirdButton = 5
    else-ifint $(ClockSource) == 1
        set ThirdButton = 6
    else
        set ThirdButton = 7
    endif
    set RadioIn = {$(FirstButton), $(SecondButton), $(ThirdButton)}

    ifint $(EarlyRelease) == 0
        set ReleaseState = "ON"
    else
        set ReleaseState = "OFF"
    endif

    ifint $(SetAddress) == 0
        set AddressState = "OFF"
    else
        set AddressState = "ON"
    endif

    ifint $(WaitStates) == 0
        set WaitState = "OFF"
    else
        set WaitState = "ON"
    endif

    ifint $(LongBurst) == 0
        set BurstState = "OFF"
    else
        set BurstState = "ON"
    endif

    set CheckItemsIn = {$(ReleaseState), $(AddressState), $(WaitState), $(BurstState)}

    set EditTextIn = {$(MaxFrame), $(NetworkAddress)}

    loadlibrary "AndTok Install Diskette" $(DLLPATH)\andtok.dll DllHandle

RetryDialog =+
    EndWait
    ui start "InputDlg" $(DllHandle)
    StartWait

    set NewMaxFrame  = *($(EditTextOut), 1)
    set NewNetworkAddress = *($(EditTextOut), 2)

    ifstr(i) $(DLGEVENT) == "CONTINUE"
        IfContains "1" IN $(RadioOut)
            set RingSpeed = 16
        else-IfContains "2" IN $(RadioOut)
            set RingSpeed = 4
        endif
        IfContains "3" IN $(RadioOut)
            set DmaModeType = "dma"
        else-IfContains "4" IN $(RadioOut)
            set DmaModeType = "dio"
        endif
        IfContains "5" IN $(RadioOut)
            set ClockType = 0
        else-IfContains "6" IN $(RadioOut)
            set ClockType = 1
        else-IfContains "7" IN $(RadioOut)
            set ClockType = 2
        endif

        IfContains "ON" IN *($(CheckItemsOut),1)
            set EarlyRelease = 0
        else
            set EarlyRelease = 1
        endif

        IfContains "ON" IN *($(CheckItemsOut),2)
            set SetAddress = 1
        else
            set SetAddress = 0
        endif

        IfContains "ON" IN *($(CheckItemsOut),3)
            set WaitStates = 1
        else
            set WaitStates = 0
        endif

        IfContains "ON" IN *($(CheckItemsOut),4)
            set LongBurst = 1
        else
            set LongBurst = 0
        endif

        set-hextodec Base = $(Combo2Out)

        ifint $(NewMaxFrame) < 256
            Shell "" WarnError $(BadMaxFrame1)
            goto RetryDialog
        else-ifint $(NewMaxFrame) > 4472
            ifint $(RingSpeed) == 4
                Shell "" WarnError $(BadMaxFrame2)
                goto RetryDialog
            else-ifint $(NewMaxFrame) > 17800
                Shell "" WarnError $(BadMaxFrame3)
                goto RetryDialog
            endif
        endif

        set AdapterStatus = $(TRUE)

        ifint $(SetAddress) == 1
            Split-String $(NewNetworkAddress), "0123456789ABCDEFabcdef", TempList
            set HexList = ^(HexDigits, 1)
            QueryListSize ListSize $(TempList)
            ifint $(ListSize) == 12
                set Index1 = 1
                set Loop   = 1
            else
                Shell "" WarnError $(BadAddr1)
                goto RetryDialog
            endif

NetAddrLoop =+
            set Temp1 = *($(TempList), $(Index1))
            ifcontains(i) $(Temp1) not-in $(HexList)
                Shell "" WarnError $(BadAddr2)$(Temp1)
                goto RetryDialog
            endif
            ifint $(Index1) == 1
                ifint $(Temp1) < 4
                    Shell "" WarnError $(BadAddr3)
                    goto RetryDialog
                endif
                ifint $(Temp1) > 7
                    Shell "" WarnError $(BadAddr3)
                    goto RetryDialog
                endif
            endif
    
            set-add Index1 = $(Index1), 1
            set-add Loop  = $(Loop), 1
            ifint $(Loop) < 13
                goto NetAddrLoop
            endif
        else
            set NewNetworkAddress = "000000000000"
        endif
    endif

    ui pop 1
    FreeLibrary $(DllHandle)

    set !p:NewBase              = $(Base)
    set !p:NewIrq               = $(Combo1Out)
    set !p:NewSpeed             = $(RingSpeed)
    set !p:NewDma               = $(Combo3Out)
    set !p:NewDmaMode           = $(DmaModeType)
    set !p:NewPio               = #(AndPioBase, "Pio"$(Combo4Out), 1)
    set-hextodec !p:NewPio      = $(!p:NewPio)
    set !p:NewMaxFrame          = $(NewMaxFrame)
    set !p:NewEarlyRelease      = $(EarlyRelease)
    set !p:SetAddress           = $(SetAddress)
    set !p:NetworkAddress       = $(NewNetworkAddress)
    set !p:NewClockSource       = $(ClockType)
    set !p:NewWaitStates        = $(WaitStates)
    set !p:NewLongBurst         = $(LongBurst)
    set !p:BusNumber            = $(BusNumber)
            
    return $(AdapterStatus)


[SetCopy]
    read-syms GeneralConstants
    read-syms FileConstants

    set DoCopy = $($0)
    set AddCopy = $($1)
    set SrcDir  = $($2)
    set Needcopy = $(FALSE)

    Ifstr(i) $(DoCopy) == "YES"
        set NeedCopy = $(TRUE)
    else-ifstr(i) $(AddCopy) == "YES"
        set NeedCopy = $(TRUE)
    else
        Return $(TRUE)
    endif

    set BuiltIn = "YES"
    ifstr(i) $(!NTN_Origination) == "NCPA"
        Set BuiltIn = "NO"
    endif

    Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) $(BuiltIn)

    Ifstr(i) $($R0) == STATUS_FAILED
        Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
        Shell "" FatalError $($R0)
        Return $(FALSE)
    Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
        Return $(FALSE)
    Endif

    Set SrcDir = $($R1)

    install "Install-Option"

    ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
        Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif
    Shell "" PrepareDetectionDll "ANDNCDET.DLL"
    Return $(TRUE)

[SetSoftware]
    read-syms RegistryConstants
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms date


    Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
          $(ProductSoftwareName), +
          $(ProductSoftwareName), +
          $(ProductSoftwareTitle), $(STF_CONTEXTINFNAME), +
          $(ProductSoftwareImagePath), "kernel", "NDIS", {}, "",+
          $(NetEventDLL)

    Ifstr(i) $($R0) != NO_ERROR
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif

        ;
        ;   At this point:
        ;     $R1 contains the product version key handle;
        ;     $R2 contains the NetRules subkey handle;
        ;     $R3 contains the new Services key handle; and
        ;     $R4 contains the Parameters key
        ;     $R5 contains the Linkage Key
        ;
    set KeyProduct      = $($R1)
    Set SoftNetRulesKey = $($R2)
    CloseRegKey $($R3)
    CloseRegKey $($R4)
    CloseRegKey $($R5)

    Ifstr(i) $($R0) != NO_ERROR
        CloseRegKey $(KeyProduct)
        CloseRegKey $(SoftNetRulesKey)
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif

    set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
                        {MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
                        {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
                        {Title,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareTitle)},+
                        {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareDescription)},+
                        {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(ProductSoftwareName)},+
                        {InstallDate,$(NoTitle),$(!REG_VT_DWORD),$($0)}}

    Shell  $(UtilityInf), AddValueList, $(KeyProduct), $(NewValueList)

    Ifstr(i) $($R0) != NO_ERROR
        CloseRegKey $(KeyProduct)
        CloseRegKey $(SoftNetRulesKey)
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    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),"ANDTOK"}}

    Shell  $(UtilityInf), AddValueList, $(SoftNetRulesKey), $(NewValueList)

    CloseRegKey $(KeyProduct)
    CloseRegKey $(SoftNetRulesKey)

    Ifstr(i) $($R0) != NO_ERROR
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif
    return $(TRUE)

[SetHardware]
    read-syms RegistryConstants
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms date


    Shell $(UtilityInf), AddHardwareComponent, $(ProductHardwareName),$(STF_CONTEXTINFNAME),$(ProductKeyName)

    Ifstr(i) $($R0) != NO_ERROR
        CloseRegKey $($R1)
        CloseRegKey $($R2)
        CloseRegKey $($R3)
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif

;
;   At this point:
;     $R1  Registry key variable for HARDWARE\Netcard\(n)
;     $R2  Registry key variable for HARDWARE\Netcard\(n)\\NetRules
;     $R3  Registry key handle for <service>\Parameters key
;     $R4  Adapter number assigned to adapter
;     $R5  Service name generated by combining svc name with adapter number
;
    set !KeyParameters   = $($R3)
    set KeyAdapterRules = $($R2)
    set AdapterNumber   = $($R4)
    set Option          = "ANDTOK"

    set NewValueList = {{Manufacturer,$(NoTitle),$(!REG_VT_SZ),$(Manufacturer)},+
                       {Title,$(NoTitle),$(!REG_VT_SZ),"["$($R4)"] "$(ProductHardware$(Option)Title)},+
                       {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductHardware$(Option)Description)},+
                       {ProductName,$(NoTitle),$(!REG_VT_SZ),$(ProductHardwareName)},+
                       {ServiceName,$(NoTitle),$(!REG_VT_SZ),$($R5)},+
                       {InstallDate,$(NoTitle),$(!REG_VT_DWORD),$($0)}}

    Shell  $(UtilityInf), AddValueList, $($R1), $(NewValueList)
    Ifstr(i) $($R0) != NO_ERROR
        CloseRegKey $($R1)
        CloseRegKey $($R2)
        CloseRegKey $($R3)
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif

    CloseRegKey $($R1)

    set TempProdName = """"$(ProductHardwareName)$(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),$(Option)}}

    Shell  $(UtilityInf), AddValueList, $(KeyAdapterRules), $(NewValueList)

    Ifstr(i) $($R0) != NO_ERROR
        CloseRegKey $(!KeyParameters)
        CloseRegKey $(KeyAdapterRules)
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif

    CloseRegKey $(KeyAdapterRules)
    return $(TRUE)

[WriteParameters]
    read-syms RegistryConstants
    read-syms FileConstants
    read-syms GeneralConstants
    read-syms DownLoadInfo

    set Base           = $(!p:NewBase)
    set Irq            = $(!p:NewIrq)
    set Speed          = $(!p:NewSpeed)
    set Dma            = $(!p:NewDma)
    set DmaMode        = $(!p:NewDmaMode)
    set Pio            = $(!p:NewPio)
    set MaxFrame       = $(!p:NewMaxFrame)
    set EarlyRelease   = $(!p:NewEarlyRelease)
    set SetAddress     = $(!p:SetAddress)
    set NetworkAddress = $(!p:NetworkAddress)
    set ClockSource    = $(!p:NewClockSource)
    set WaitStates     = $(!p:NewWaitStates)
    set LongBurst      = $(!p:NewLongBurst)
    set BusNumber      = $(!p:BusNumber)

    Shell $(UtilityInf), GetBusTypeNum
    set BusTypeNum = $($R1)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Shell "" FatalError "Cannot get bus number"
        Return $(FALSE)
    endif

    Set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusTypeNum)},+
                       {BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNumber)},+
                       {MediaType,$(NoTitle),$(!REG_VT_DWORD),2},+
                       {Speed,$(NoTitle),$(!REG_VT_DWORD),$(Speed)},+
                       {DmaMode,$(NoTitle),$(!REG_VT_SZ),$(DmaMode)},+
                       {Interrupt,$(NoTitle),$(!REG_VT_DWORD),$(Irq)},+
                       {DmaChannel,$(NoTitle),$(!REG_VT_DWORD),$(Dma)},+
                       {EarlyRelease,$(NoTitle),$(!REG_VT_DWORD),$(EarlyRelease)},+
                       {MacCode,$(NoTitle),$(!REG_VT_SZ),$(DownFile)},+
                       {PacketSize,$(NoTitle),$(!REG_VT_DWORD),$(MaxFrame)},+
                       {ProductId,$(NoTitle),$(!REG_VT_SZ),"0110F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0"},+
                       {IoBase,$(NoTitle),$(!REG_VT_DWORD),$(Base)},+
                       {SetAddress,$(NoTitle),$(!REG_VT_DWORD),$(SetAddress)},+
                       {NetworkAddress,$(NoTitle),$(!REG_VT_SZ),$(NetworkAddress)},+
                       {PioBase,$(NoTitle),$(!REG_VT_DWORD),$(Pio)},+
                       {ClockSource,$(NoTitle),$(!REG_VT_DWORD),$(ClockSource)},+
                       {WaitStates,$(NoTitle),$(!REG_VT_DWORD),$(WaitStates)},+
                       {LongBurst,$(NoTitle),$(!REG_VT_DWORD),$(LongBurst)}}


    Shell  $(UtilityInf), AddValueList, $(!KeyParameters), $(NewValueList)

    CloseRegKey $(!KeyParameters)

    Ifstr(i) $($R0) != NO_ERROR
        Shell $(UtilityInf) RegistryErrorString $($R0)
        Shell "" FatalError $($R0)
        Return $(FALSE)
    endif

    Return $(TRUE)


[FatalError]
    read-syms FileConstants

    ifstr(i) $($0) == ""
        set Message = "Unknown Error"
    else
        set Message = $($0)
    endif

    Shell $(SubroutnInf) SetupMessage $(!STF_LANGUAGE) FATAL $(Message)
    Return

[WarnError]
    read-syms FileConstants

    ifstr(i) $($0) == ""
        set Message = "Unknown Error"
    else
        set Message = $($0)
    endif

    Shell $(SubroutnInf) SetupMessage $(!STF_LANGUAGE) NONFATAL $(Message)
    Return

[VerifyError]
    read-syms FileConstants

    ifstr(i) $($0) == ""
        set Message = "Unknown Error"
    else
        set Message = $($0)
    endif

    Shell $(SubroutnInf) SetupMessage $(!STF_LANGUAGE) WARNING $(Message)
    Return $($R1)

[Install-Option]
    set STF_VITAL = ""
    ifstr(i) $(AddCopy) == "YES"
        AddSectionFilesToCopyList Files-andncdet $(SrcDir) $(!STF_WINDOWSSYSPATH)
        AddSectionFilesToCopyList Files-ANDTOK $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
        AddSectionFilesToCopyList Files-Dlg $(SrcDir) $(!STF_WINDOWSSYSPATH)
    endif
    ifstr(i) $(DoCopy) == "YES"
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    endif
    Exit

[Install-Update]
   set STF_VITAL        = ""
   set STF_OVERWRITE    = "VERIFYSOURCEOLDER"
   AddSectionFilesToCopyList Files-ANDTOK $(!SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
   AddSectionFilesToCopyList Files-Inf $(!SrcDir) $(!STF_WINDOWSSYSPATH)
   AddSectionFilesToCopyList Files-Dlg $(!SrcDir) $(!STF_WINDOWSSYSPATH)
   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList
   exit

[PrepareDetectionDll]
    Set NewDllName = $($0)
    Set Status = STATUS_FAILED
    read-syms GeneralConstants
    Set DllValueName = "NetcardDlls"
    OpenRegKey $(!REG_H_LOCAL) "" "System\Setup" $(MAXIMUM_ALLOWED) KeySetup
    Ifstr(i) $(KeySetup) == $(KeyNull)
        Goto PDD_Return
    Endif
    Set DllFound = 0
    GetRegValue $(KeySetup) $(DllValueName) DllNamesValue
    Ifint $(RegLastError) != $(!REG_ERROR_SUCCESS)
        Goto PDD_Return
    Endif

    Set DllNames = *($(DllNamesValue),4)
    ForListDo $(DllNames)
        Ifstr(i) $($) == $(NewDllName)
            Set DllFound = 1
        Endif
    EndForListDo
    Ifint $(DllFound) == 0
        Set DllNames = >($(DllNames),$(NewDllName))
        Set ValueInfo = {$(DllValueName), $(NoTitle), $(!REG_VT_MULTI_SZ), $(DllNames)}
        SetRegValue $(KeySetup) $(ValueInfo)
        Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
            Set Status = STATUS_SUCCESSFUL
        Endif
    Else
        Set Status = STATUS_USERCANCEL
    Endif
    CloseRegKey $(KeySetup)
PDD_Return = +
    Return $(Status)
