;***********************************************************************
;
;  OEMSETUP.INF
;
;       OSITECH Trumpcard network card and driver OEMSETUP.INF file
;
;	Copyright (c) 1994-1995 OSITECH Communications, Inc.
;	All Rights Reserved.
;
; History:
;	Adapted by Frederick W. Bent
;
;   Nov. 28 1994  Rev 1.01	WinNT 3.50 Release Candidate
;   Feb.  2 1995  Rev 1.02	COM4 default for Modem and
;                               Auto Media Detect for Cable Type
;                               Added 100h for I/O Base address
;   Aug. 23 1995  Rev 1.03	WinNT 3.51 Updates #1
;				Made setup compatible with PCMCIA.SYS
;				and improved the Databook PCIC support
;                               Added COM port to the system automatically
;                               Make sure that COM port is removed correctly
;                               Changed the default resource settings
;				Added support for upto four PC Card sockets
;   Aug. 30 1995  Rev 1.04      Removed the PrepareDetectionDll section
;				and used UTILITY.INF functions instead
;                               Removed the modem resources from the TypeList
;				Updated the file sizes
;   Sep.  6 1995  Rev 1.05	Fixed for COM5
;				Made COM5 the default to bypass MS Enabler
;				hassles.
;
;
;***********************************************************************

[Identification]
    OptionType = NetAdapter

[PlatformsSupported]
    EISA
    ISA
    MCA
    PCI
    PCMCIA

[LanguagesSupported]
    ENG

[Options]
    OTCJODNT

[OptionsTextENG]
    OTCJODNT     = "Ositech Jack of Diamonds Trumpcard"

[Source Media Descriptions]
    1  = "Trumpcard Network Drivers Diskette"

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

[ProductType]
    STF_PRODUCT  = Winnt
    STF_PLATFORM = I386

[Files-OtcjodNT]
    1, otcjodnt.sys, SIZE=39584

[Files-Dll]
    1, otcjodnt.dll, SIZE=5632
    1, otcjodnt.hlp, SIZE=16407

[Files-Detect]
    1, otcncdet.dll, SIZE=15872

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

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

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

[RegistryConstants]
    SoftwareType             = "driver"
    Manufacturer             = "Ositech"
    ; Product Info  -------------------------------------------------
    ProductMajorVersion      = "1"
    ProductMinorVersion      = "21"
    ProductVersion           = $(ProductMajorVersion)"."$(ProductMinorVersion)
    ; Software  -----------------------------------------------------
    ProductSoftwareName      = "OtcjodNT"
    ProductSoftwareTitle     = "Ositech JoD Trumpcard NDIS Driver"
    ProductSoftwareDescription = "Ositech JoD Trumpcard Ethernet Driver"
    ProductSoftwareImagePath = "\SystemRoot\System32\drivers\otcjodnt.sys"
    NetRuleSoftwareType      = "OtcjodNTSys ndisDriver otcjodNTDriver"
    NetRuleSoftwareUse       = $(SoftwareType)
    NetRuleSoftwareBindForm  = """OtcjodNTSys"" yes no container"
    NetRuleSoftwareClass     = {"otcjodNTDriver basic"}
    NetRuleSoftwareBindable  = {"otcjodNTDriver otcjodNTAdapter non exclusive 100"}
    ; Hardware  -----------------------------------------------------
    ProductHardwareName      = "OtcjodNT"
    ProductHardwareOTCJODNTDescription = "Ositech Jack of Diamonds Adapter"
    ProductHardwareOTCJODNTTitle = "Ositech Jack of Diamonds"
    NetRuleHardwareType      = "otcjodNT otcjodNTAdapter"
    NetRuleHardwareBindForm  = " yes yes container"
    NetRuleHardwareClass     = {"otcjodNTAdapter basic"}
    ; Registry Key --------------------------------------------------
    ProductKeyName           = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
    ParamKeyName             = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"

    ; PCMCIA Tuples -------------------------------------------------
    VERS1Product       = "Trumpcard:Jack of Diamonds Modem+Ethernet"
    VERS1Manufacturer  = "Ositech"

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

[FileConstantsENG]
    ProCaption         = "Windows NT Setup"
    ProCancel          = "Cancel"
    ProCancelMsg       = "The Ositech Trumpcard is not correctly installed.  "+
			 "Are you sure you want to cancel copying files?"
    ProCancelCap       = "Network Setup Message"
    ProText1           = "Copying:"
    ProText2           = "To:"
    FunctionTitle      = "Ositech Trumpcard PCMCIA Card Setup"$(GenericInfVersion)
    DialogDllName      = "OTCJODNT.DLL"
    IrqList           = ^(OtcIrqs, 1)                     
    IrqValues	      = ^(OtcIrqs, 2)
    IoBaseList        = ^(OtcIoBase, 1)
    IoBaseValues      = ^(OtcIoBase, 2)
    COMBaseList       = ^(OtcCOMBase, 1)
    COMBaseValues     = ^(OtcCOMBase, 2)
    COMPortList	      = ^(OtcCOMBase, 3)
    COMIrqList        = ^(OtcCOMIrqs, 1)
    COMIrqValues      = ^(OtcCOMIrqs, 2)
    MemBaseList       = ^(OtcCISMemBase, 1)
    MemBaseValues     = ^(OtcCISMemBase, 2)
    SockList          = ^(OtcSocket, 1)
    SockValues        = ^(OtcSocket, 2)
    XmitList          = ^(OtcXmit, 1)
    XmitValues        = ^(OtcXmit, 2)

[OtcIrqs]
;Interrupts available on Intel   : { 3,4,5,7,9,10,11,12,14,15 }
;Interrupts available on Databook: { 3,4,5,7,10,14 }
    IRQ0 = " 3", 3
    IRQ1 = " 4", 4
    IRQ2 = " 5", 5
    IRQ3 = " 7", 7
    IRQ4 = " 9", 9
    IRQ5 = "10", 10
    IRQ6 = "11", 11
    IRQ7 = "12", 12
    IRQ8 = "14", 14
    IRQ9 = "15", 15

[OtcIoBase]
; Cannot use 240,2C0,3C0
; 240 = DataBook
; 2E8 = COM4, 2F8 = COM2
; 3E0 = Intel
    Base1  = "0x140", 320
    Base0  = "0x100", 256
    Base2  = "0x180", 384
    Base3  = "0x1C0", 448
    Base4  = "0x200", 512
    Base5  = "0x280", 640
    Base6  = "0x300", 768
    Base7  = "0x340", 832
    Base8  = "0x380", 896
    Base9  = "0x400", 1024
    Base10 = "0x440", 1088
    Base11 = "0x480", 1152
    Base12 = "0x4c0", 1216

[OtcCOMIrqs]
;Interrupts available on the Intel   : { 3,4,5,7,9,10,11,12,14,15 }
;Interrupts available on the Databook: { 3,4,5,7,10,14 }
    COMIRQ0 = " 3", 3
    COMIRQ1 = " 4", 4
    COMIRQ2 = " 5", 5
    COMIRQ3 = " 7", 7
    COMIRQ4 = " 9", 9
    COMIRQ5 = "10", 10
    COMIRQ6 = "11", 11
    COMIRQ7 = "12", 12
    COMIRQ8 = "14", 14
    COMIRQ9 = "15", 15

[OtcCOMBase]
    COMBase0 = "COM4 0x2e8", 744, "COM4"
    COMBase1 = "None", 0, "None"
    COMBase2 = "COM1 0x3f8", 1016, "COM1"
    COMBase3 = "COM3 0x3e8", 1000, "COM3"
    COMBase4 = "COM2 0x2f8", 760, "COM2"
    COMBase5 = "COM5 Lan+28h", 65535, "COM5"

[OtcSocket]
    Sock0 = "Auto Detect", 0
    Sock1 = "Socket 1", 1
    Sock2 = "Socket 2", 2
    Sock3 = "Socket 3", 3
    Sock4 = "Socket 4", 4

[OtcCISMemBase]
MemBase0 = "0xC8000", 819200
MemBase1 = "0xC9000", 823296
MemBase2 = "0xCA000", 827392
MemBase3 = "0xCB000", 831488
MemBase4 = "0xCC000", 835584
MemBase5 = "0xCD000", 839680
MemBase6 = "0xCE000", 843776
MemBase7 = "0xCF000", 847872
MemBase8 = "0xD0000", 851968
MemBase9 = "0xD1000", 856064
MemBase10 = "0xD2000", 860160
MemBase11 = "0xD3000", 864256
MemBase12 = "0xD4000", 868352
MemBase13 = "0xD5000", 872448
MemBase14 = "0xD6000", 876544
MemBase15 = "0xD7000", 880640
MemBase16 = "0xD8000", 884736
MemBase17 = "0xD9000", 888832
MemBase18 = "0xDA000", 892928
MemBase19 = "0xDB000", 897024
MemBase20 = "0xDC000", 901120
MemBase21 = "0xDD000", 905216
MemBase22 = "0xDE000", 909312
MemBase23 = "0xDF000", 913408
MemBase24 = "0xE0000", 917504
MemBase25 = "0xE1000", 921600
MemBase26 = "0xE2000", 925696
MemBase27 = "0xE3000", 929792
MemBase28 = "0xE4000", 933888
MemBase29 = "0xE5000", 937984
MemBase30 = "0xE6000", 942080
MemBase31 = "0xE7000", 946176
MemBase32 = "0xE8000", 950272
MemBase33 = "0xE9000", 954368
MemBase34 = "0xEA000", 958464
MemBase35 = "0xEB000", 962560
MemBase36 = "0xEC000", 966656
MemBase37 = "0xED000", 970752
MemBase38 = "0xEE000", 974848
MemBase39 = "0xEF000", 978944

[OtcXmit]
    Xmit0 = "1",1
    Xmit1 = "2",2
    Xmit2 = "3",3
    Xmit3 = "4",4
    Xmit4 = "5",5
    Xmit5 = "6",6
    Xmit6 = "7",7
    Xmit7 = "8",8
    Xmit8 = "9",9

[DisableLinkTestChoicesENG]
    Dis_1 = 1, "ON"
    Dis_2 = 0, "OFF"

[CardServicesChoicesENG]
    Card_1 = 1, "ON"
    Card_2 = 0, "OFF"

[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"
    HelpContext  = 30100
    Continue     = "Continue"
    Cancel       = "Cancel"
    BadAddr1     = "Network Address must be 12 hexadecimal digits in length"
    BadAddr2     = "Network Address contains the invalid hexadecimal digit: "
    BadAddr3     = "Network Address invalid, group bit must be 0"
    IRQConflict  = "The Modem and LAN function cannot share the same IRQ"
    IRQForced    = "The LAN function must be assigned IRQ 11 to ensure "+
                   "proper operation on a Databook PCIC"
    IRQInvalid   = "The Modem IRQ that has been selected is not supported "+
                   "when using a Databook PCIC"
    BadPCMCIA    = "Unable to determine the type of PCMCIA Interface Controller.  "+
		   "Do you want to continue?"
    PCICType     = "PCIC: "

[FileDependentDlgENG]
    DlgType           = "RadioCombination"
    DlgTemplate       = "OTCJODNT"
    ; Caption         = "Ositech JoD Trumpcard PCMCIA Card Setup"
    Caption           = $(FunctionTitle)
    Combo1Label       = "&IRQ Level:"
    Combo2Label       = "I/O &Port:"
    Combo3Label       = "IRQ &Level:"
    Combo4Label       = "Base I/O &Addr:"
    Combo5Label       = "Memory &Window:"
    Combo6Label       = "Soc&ket Number:"
    Combo7Label       = "Max Transmits:"
    CheckBox1         = "&Disable Link Test"
    CheckBox2         = "&Card Services"
    Radio1            = "10BASET"
    Radio2            = "10BASE2"
    Radio3            = "Auto Detect"
    Edit1Text         = "Network Address"
    Group1Label       = "LAN Configuration"
    Group2Label       = "Modem Configuration"
    Group3Label       = "Environment"
    Group4Label       = "Transceiver Type"
;    MediaValue        = 2
;    DisLinkValue      = 0
;    COMIOBaseValue    = 744
    Combo1List        = $(IrqList)
    Combo1Out         = $(InterruptNumber)
    Combo2List        = $(IoBaseList)
    Combo2Out         = $(IOBaseAddrValue)
    Combo3List        = $(COMIrqList)
    Combo3Out         = $(COMInterruptNumber)
    Combo4List        = $(COMBaseList)
    Combo4Out         = $(COMIoBaseAddrValue)
    Combo5List        = $(MemBaseList)
    Combo5Out         = $(MemBaseAddrValue)
    Combo6List        = $(SockList)
    Combo6Out         = $(SocketNumber)
    Combo7List        = $(XmitList)
    Combo7Out         = $(XmitNumber)
    ComboListItemsIn  = {Combo1List, Combo2List, Combo3List, Combo4List, Combo5List, Combo6List, Combo7List}
    ComboListItemsOut = {Combo1Out, Combo2Out, Combo3Out, Combo4Out, Combo5Out, Combo6Out, Combo7Out}
    CBOptionsGreyed   = {}
    RCCtlFocusOn      = 403


;---------------------------------------------------------------------------
; 1. Identify
;
; DESCRIPTION:   To verify that this INF deals with the same type of options
;                as we are choosing currently.
;
; INPUT:         None
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL
;                $($R1): Option Type (COMPUTER ...)
;                $($R2): Diskette description
;---------------------------------------------------------------------------

[Identify]
    read-syms Identification

    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)

    Return $(Status) $(Identifier) $(Media)

;------------------------------------------------------------------------
; 2. ReturnOptions:
;
; DESCRIPTION:   To return the option list supported by this INF and the
;                localised text list representing the options.
;
;
; INPUT:         $($0):  Language used. ( ENG | FRN | ... )
;
; OUTPUT:        $($R0): STATUS: STATUS_SUCCESSFUL |
;                                STATUS_NOLANGUAGE
;                                STATUS_FAILED
;                                STATUS_NOTSUPPORTED
;
;                $($R1): Option List
;                $($R2): Option Text List
;------------------------------------------------------------------------

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

    ;
    ; Check if the language requested is supported
    ;
    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

    ;
    ; Check if the platforms requested are supported
    ;
    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:
;
;      This section is shelled to by main installation processing
;      or by NCPASHEL.INF during reconfig, removal, update, etc.
;
;
; FUNCTION:  To copy files representing Options
;            To configure the installed option
;            To update the registry for the installed option
;
; INPUT:     $($0):  Language to use
;            $($1):  OptionID to install
;            $($2):  SourceDirectory
;            $($3):  AddCopy  (YES | NO)
;            $($4):  DoCopy   (YES | NO)
;            $($5):  DoConfig (YES | NO)
;
; OUTPUT:    $($R0): STATUS: STATUS_SUCCESSFUL |
;                            STATUS_NOLANGUAGE |
;                            STATUS_USERCANCEL |
;                            STATUS_FAILED
;
;------------------------------------------------------------------------

[InstallOption]
    ;
    ; Set default
    ;
    set Status   = STATUS_FAILED
    ;
    ; extract parameters
    ;
    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)

    Set !DebugOutputControl = 1

    ;
    ;  Check if the language requested is supported
    ;
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
       Return STATUS_NOLANGUAGE
    endif

    set-subst LF = "\n"

    read-syms GeneralConstants
    read-syms FileConstants
    read-syms RegistryConstants

    ifstr(i) $(!NTN_Origination) == "NCPA"
       set Continue = $(OK)
    endif

    read-syms DialogConstants$(!STF_LANGUAGE)
    read-syms FileConstants$(!STF_LANGUAGE)

    detect date

    set-title $(FunctionTitle)

    set to   = Begin
    set from = Begin
;
;  Assume all is well
;
    set CommonStatus = STATUS_SUCCESSFUL

    EndWait
;
;
;   Set up the operation-mode-based variables and welcome the user.
;   If the "install mode" variable is improperly set, assume that this
;   is a new installation.
;

Begin = +
   Set ActiveDetection = FALSE

    Ifstr(i) $(!NTN_InstallMode) == deinstall
	set SubFunction = RemoveAdapter
    else-Ifstr(i) $(!NTN_InstallMode) == install
	set SubFunction = InstallAdapter
	set OEM_ABANDON_OPTIONS = {}
	set OEM_ABANDON_SOFTWARE = FALSE
	set OEM_ABANDON_ON = TRUE
    else-Ifstr(i) $(!NTN_InstallMode) == Update
	set SubFunction = UpgradeSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == configure
	set SubFunction = ConfigureAdapter
	set ActivateDetection = TRUE
	;
	;  You cannot configure software component
	;
	Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
	    Debug-Output "INF: Cannot configure the Trumpcard server software."
	    Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
	    ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "INF: ShellCode error: cannot get an error string."
		goto ShellCodeError
	    endif
	    set Error = $($R0)
	    set from = end
	    set to = end
	    goto nonfatalinfo
	Endif

    else
	set SubFunction = NoWay
    Endif
    Debug-Output "INF: =================================================="
    Debug-Output "INF: STF_CWDIR is: "$(!STF_CWDIR)
    Debug-Output "INF: STF_LANGUAGE is: "$(!STF_LANGUAGE)
    Debug-Output "INF: Option is: "$(Option)
    Debug-Output "INF: !STF_NCDETECT  is: "$(!STF_NCDETECT)
    Debug-Output "INF: !STF_NCOPTION  is: "$(!STF_NCOPTION)
    Debug-Output "INF: !STF_NCDETCARD is: "$(!STF_NCDETCARD)
    Debug-Output "INF: !STF_NCDETINFO is: "$(!STF_NCDETINFO)
    Debug-Output "INF: =================================================="
    Set DetectedCard = FALSE
    ;
    ;  No PCMCIA support for now
    ;
    set PCMCIA = 0

    ;  Setup the default values

    set InterruptNumber     = *($(IrqList), 6)      ; LAN IRQ   = 10
    set IOBaseAddrValue     = *($(IoBaseList), 1)   ; LAN IOBase address = 0x100
    set COMIoBaseAddrValue  = *($(COMBaseList), 6)  ; Modem IOBase address = (COM5)
    set COMInterruptNumber  = *($(COMIrqList), 1)   ; Modem IRQ = 3
    set SocketNumber        = *($(SockList), 1)     ; Socketnumber   = Auto
    set MemBaseAddrValue    = *($(MemBaseList), 11) ; Memory address = 0xD2000
    set XmitNumber          = *($(XmitList), 1)
    set MediaValue          = 2			    ; LAN media = Auto
    set DisLink             = 0			    ; Enable 10BaseT link test

    Ifstr(i) $(ActivateDetection) != TRUE
        Goto $(SubFunction)
    Endif
    
;    Set TypeList = {{IRQ, IRQ_List, InterruptNumber},+
;                    {IOADDR, IOADDR_Addr_List, IOBaseAddrValue},+
;    		    {TRANSCEIVER, TranceiverValueList, MediaValue},+
;		    {MEMADDR, MemBaseAddrDecList, MemBaseAddrValue},+
;		    {COMIRQ, COM_IRQ_List, COMInterruptNumber},+
;		    {COMIOADDR, COM_IOADDR_Addr_List, COMIoBaseAddrValue}}
    
    Set TypeList = {{IRQ, IRQ_List, InterruptNumber},+
                    {IOADDR, IOADDR_Addr_List, IOBaseAddrValue},+
    		    {TRANSCEIVER, TranceiverValueList, MediaValue},+
		    {MEMADDR, MemBaseAddrDecList, MemBaseAddrValue}}
    
    Debug-Output "INF: Calling Param_BuildTypeLists"
    Shell $(ParamInf) Param_BuildTypeLists $(Option) $(TypeList)
    Set Status = $($R0)
    ifstr(i) $(Status) != STATUS_SUCCESSFUL
	goto fataldetect
    Endif

    Debug-Output "INF: Calling Param_SetDefaults"
    Shell $(ParamInf) Param_SetDefaults {}

    Set from = $(fatal)
    Set to   = $(fatal)
    Goto $(SubFunction)

;-----------------------------------------------
; Installation Section
;-----------------------------------------------

InstallAdapter = +
;
;  First, check for same version
;    
    set OldVersionExisted = $(FALSE)
    set KeyProduct = $(KeyNull)

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

    Ifstr $(KeyProduct) != $(KeyNull)
	;
	; Same version already existed in the local machine
	; Popup the dialog and ask the user whether he wants to continue
	;
	CloseRegKey $(KeyProduct)

	ifstr(i) $(!NTN_RegBase) == $(ProductKeyName)
	   ;
	   ; Cannot Install the same software again
	   ;
	    Shell $(UtilityInf), VerExistedDlg, $(ProductSoftwareTitle), +
		$(ProductVersion)
	    ifstr(i) $($R1) != "OK"
		goto End
	    endif

	    goto End

	else
	    ;
	    ; Add a new adapter card?
	    ;
	    Shell $(UtilityInf), CardExistedDlg

	    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	       Debug-Output "INF: ShellCode error: cannot get an error string."
	       goto ShellCodeError
	    Endif

	    Ifstr(i) $($R1) != "OK"
		goto End
	    Endif

	    Set OldVersionExisted = $(TRUE)
	endif
    endif

    Set CurrParamSettings = {}
;
;  dll load addition for NCDetect.dll
;
    Ifstr(i) $(OldVersionExisted) == $(FALSE)
        Ifstr(i) $(!NTN_InstallMode) == "install"
            Ifstr(i) $(DoCopy) == "YES"

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

                Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                    goto ShellCodeError
                Else-Ifstr(i) $($R0) == STATUS_FAILED
	            Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
	            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	                goto ShellCodeError
	            Endif
	            set Error = $($R0)
	            Goto fatal
                Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
	            Goto successful
                Endif

                Set SrcDir = $($R1)
	    Endif
            install "Install-Dll"
	    Ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
	        Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
		Ifint $($ShellCode) != $(!SHELL_CODE_OK)
		    goto ShellCodeError
		Endif
		set Error = $($R0)
		goto fatal
	    Endif
	    Shell $(UtilityInf) UpdateDetectionDllNames
        Endif
    Endif

    goto AdapterSetup

;-----------------------------------------------
; Configuration Section
;-----------------------------------------------
;
;   Get the current values of all the parameters
;
ConfigureAdapter = +
    Ifstr $(KeyProduct) == $(KeyNull)
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) KeyProduct
  	Ifstr $(KeyProduct) == $(KeyNull)
	    set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
	    Debug-Output "INF: Cannot find component product key"
	    goto fatalregistry
	Endif
    Endif

    ;
    ;  Get the other parameters; they are under serivce paramters
    ;
    Debug-Output "INF: Shelling to FindService"
    Shell $(UtilityInf) FindService, $(KeyProduct)

    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "INF: FindService shell failure"
        goto ShellCodeError
    Endif
    Ifstr(i) $($R0) != NO_ERROR
	Debug-Output "INF: FindService Shell error: "$($R0)
        Goto fatalregistry
    Endif

    Set KeyParameters = $($R2)

    ;
    ;  We don't need the services key, so close it.
    ;
    CloseRegKey $($R1)

    Ifstr $(KeyParameters) == $(KeyNull)
        set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
	Debug-Output "INF: Cannot find component product key"
	goto fatalregistry
    Endif

    set OldVersionExisted = $(TRUE)

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

    ;
    ; Get the old values from the Registry
    ; *********************************************************
    EnumRegValue $(KeyParameters) ValueList

    ForListDo $(ValueList)
	set ValueItem = $($)
	set ValueName = *($(ValueItem),1)
	set ValueData = *($(ValueItem),4)

	Ifstr(i) $(ValueName) == "Media"
	    set MediaValue = $(ValueData)
	else-ifstr(i) $(ValueName) == "BusNumber"
	    set BusNumber = $(ValueData)
	else-ifstr(i) $(ValueName) == "PCCARDAttributeMemoryAddress"
	    set MemoryAddrIndex = $(ValueData)
	else-ifstr(i) $(ValueName) == "PCCARDReadyInterrupt"
	    set IRQValueIndex = $(ValueData)
	else-ifstr(i) $(ValueName) == "InterruptNumber"
	    set COMInterruptNumberIndex = $(ValueData)
	else-ifstr(i) $(ValueName) == "IoBaseAddress_1"
	    set IOBaseAddrIndex = $(ValueData)
	else-ifstr(i) $(ValueName) == "IoBaseAddress"
	    set COMBaseIndex = $(ValueData)
	else-ifstr(i) $(ValueName) == "SetAddress"
	    set SetAddress = $(ValueData)
	else-ifstr(i) $(ValueName) == "NetworkAddress"
	    set NetworkAddress = $(ValueData)
	else-ifstr(i) $(ValueName) == "DisableLinkTest"
	    set DisLinkValue = $(ValueData)
	else-ifstr(i) $(ValueName) == "SocketNumber"
	    set SocketNumberIndex = $(ValueData)
	else-ifstr(i) $(ValueName) == "MaximumTransmitQueue"
	    set XmitNumber = $(ValueData)
	Endif
    EndForListDo

    ;
    ;  Get the converted values
    ;
    set InterruptNumber = *($(IrqList), ~($(IrqValues),$(IRQValueIndex)))
    ifstr(i) $(InterruptNumber) == ""
	set InterruptNumber = *($(IrqList), 2)
    endif

    set MemBaseAddrValue = *($(MemBaseList), ~($(MemBaseValues),$(MemoryAddrIndex)))
    ifstr(i) $(MemBaseAddrValue) == ""
	set MemBaseAddrValue = *($(MemBaseList), 2)
    endif

    set IOBaseAddrValue = *($(IoBaseList), ~($(IoBaseValues),$(IOBaseAddrIndex)))
    ifstr(i) $(IOBaseAddrValue) == ""
	set IOBaseAddrValue = *($(IoBaseList), 1)
    endif

    set COMIoBaseAddrValue = *($(COMBaseList), ~($(COMBaseValues),$(COMBaseIndex)))
    ifstr(i) $(COMIoBaseAddrValue) == ""
	set COMIoBaseAddrValue = *($(COMBaseList), 6)
    endif

    set COMInterruptNumber = *($(COMIrqList), ~($(COMIrqValues),$(COMInterruptNumberIndex)))
    ifstr(i) $(COMInterruptNumber) == ""
	set COMInterruptNumber = *($(COMIrqList), 1)
    endif

    set SocketNumber = *($(SockList), ~($(SockValues),$(SocketNumberIndex)))
    ifstr(i) $(SocketNumber) == ""
	set SocketNumber = *($(SockList), 1)
    endif

    Shell $(ParamInf) Param_SaveValues
    set CurrParamSettings = $($R0)

AdapterSetup = +

    Set from = AdapterSetup

    LoadLibrary "disk 1" $(DLLPATH)otcncdet.dll LibraryHandle
    LibraryProcedure Result $(LibraryHandle) TellMeChips

    set Text1 = $(PCICType)$(Result)

    set DatabookFound = $(FALSE)
    Ifstr(i) $(Result) == "Databook DB86082"
       set DatabookFound = $(TRUE)
       Ifint $(Combo1Out) == 11
       else
	  Shell "" WarnError $(IRQForced)
	  Set Combo1Out = "11"
       Endif
    Endif

    Ifstr(i) $(Result) == "Not found"

        Shell $(SubroutnInf) SetupMessage $(!STF_LANGUAGE) WARNING $(BadPCMCIA)

	Ifstr(i) $($R0) == "OK"
	    goto ContinueOperation
	Else-ifstr(i) $($R0) == "CANCEL"
	    FreeLibrary $(LibraryHandle)
	    goto End
	Endif
    Endif

    Set CONTROLLERTYPE = $(Result)
    Set from = AdapterOptions

AdapterOptions = +

    read-syms FileDependentDlg$(!STF_LANGUAGE)
    read-syms DialogConstants$(!STF_LANGUAGE)
    read-syms FileConstants$(!STF_LANGUAGE)
    set DLLPATH    = $(DLLPATH)

ContinueOperation =+

    SetHelpFile $(DLLPATH)otcjodnt.hlp 30100 30100

    set AdapterStatus = $(FALSE)

    Ifint $(SetAddress) == 1
	set NetworkAddress = $(NetworkAddress)
    else
	set NetworkAddress = ""
    Endif

    Ifint $(MediaValue) == 0
	Set RadioIn = {1}
    else-ifint $(MediaValue) == 1
	Set RadioIn = {2}
    else 
	Set RadioIn = {3}
    Endif

    ifint $(DisLinkValue) == 0
       Set CheckItemsIn = {"OFF","OFF"}
    Else
       Set CheckItemsIn = {"ON","OFF"}
    Endif

    set EditTextIn     = {$(NetworkAddress)}
    set NotifyFields   = {NO}
    set EditTextLim    = {12}
    set EditFocusOn    = ""

    LoadLibrary "disk 1" $(DialogDllName) DllHandle

RetryDialog =+

    ui start "InputDlg" $(DllHandle)

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

    ifstr(i) $(DLGEVENT) == "CONTINUE"

	set AdapterStatus = $(TRUE)

	set TransceiverTypeIndex = *($(RadioOut),1)
	Ifint $(TransceiverTypeIndex) == 1
	    Set MediaType = 0
	Else-ifint $(TransceiverTypeIndex) == 2
	    Set MediaType = 1
	Else
	    Set MediaType = 2
	Endif

	Set Chk = *($(CheckItemsOut), 1)
	Ifstr(i) $(Chk) == "ON"
	    Set DisLinkType = 1
	Else
	    Set DisLinkType = 0
	Endif

	Ifstr(i) $(NewNetworkAddress) == ""
	    set SetAddress = 0
	else
	    set SetAddress = 1
	Endif

        ;Interrupts available on the Intel   : { 3,4,5,7,9,10,11,12,14,15 }
        ;Interrupts available on the Databook: { 3,4,5,7,10,14 }
        Ifstr(i) $(CONTROLLERTYPE) == "Databook DB86082"
	    Ifcontains(i) $(Combo3Out) in { 9, 11, 12, 15 }
	        Shell "" WarnError $(IRQInvalid)
	        Goto RetryDialog
	    Endif
        Endif

	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) == 2
		ifcontains(i) $(Temp1) in { 1,3,5,7,9,b,d,f }
		    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 = ""
	endif

;	;
;	; DLLCODE
;	; Locate the slot with the Ositech Card in it
;	;
;	; LibraryProcedure CONFIG, $(LibraryHandle), GetPCMCIAConfig
	set SLOTCOUNT = 8
;	; set CONTROLLERTYPE = *($(CONFIG),3)
;	Debug-Output "INF: Slot_count="$(SLOTCOUNT)" controller type="$(CONTROLLERTYPE)
	set SLOT = 0
;
;    slotloop = +
;	LibraryProcedure INFO, $(LibraryHandle), GetVERS_1Tuple $(SLOT)      ;VERS_1
;	Debug-Output "INF: Slot "$(SLOT)
;	Debug-Output "INF: VERS_1 = "*($(INFO),3)
;	Debug-Output "INF: VERS_1 = "*($(INFO),4)
;	Debug-Output "INF: VERS_1 = "*($(INFO),5)
;	Debug-Output "INF: ---------------------"
;
;	Ifstr(i) *($(INFO),3) == $(VERS1Manufacturer)
;	    Ifstr(i) *($(INFO),4) == $(VERS1Product)
;	        Goto slotfound
;	    Endif
;	Endif
;
;	set-add SLOT = $(SLOT), 1
;	Ifint $(SLOT) == $(SLOTCOUNT)
;	    Goto slotnotfound
;	else
;	    Goto slotloop
;	Endif
;
;    slotfound = +
;	Debug-Output "INF: Ositech card found in slot "$(SLOT)
	set SLOTFOUND = 1
	Goto slotcontinue
;
;    slotnotfound = +
;	set SLOTFOUND = ""
;	Debug-Output "INF: Ositech card not found"

    slotcontinue = +
	; Fall Through

    else-ifstr(i) $(DLGEVENT) == "BACK"
        set CommonStatus = STATUS_USERCANCEL
	ui pop 1
	FreeLibrary $(DllHandle)
	FreeLibrary $(LibraryHandle)
	Debug-Output "INF: Action: BACK"
	goto End
    else
        set CommonStatus = STATUS_USERCANCEL
	ui pop 1
	FreeLibrary $(DllHandle)
	FreeLibrary $(LibraryHandle)
	Debug-Output "INF: Action: Unknown. Bye!"
	goto End
    endif

    ; 
    ; Make sure Modem and Lan not sharing same IRQ
    ;
    Ifint $(Combo1Out) == $(Combo3Out)
       Shell "" WarnError $(IRQConflict)
       goto RetryDialog
    Endif

    FreeLibrary $(DllHandle)
    ui pop 1

    ;
    ; Warn that the LAN should use IRQ11 on Databook
    ;
    Ifstr(i) $(CONTROLLERTYPE) == "Databook DB86082"
	Ifint $(Combo1Out) == 11
	Else
	    Shell "" WarnError $(IRQForced)
	    Set Combo1Out = "11"
	Endif
    Endif

    FreeLibrary $(LibraryHandle)
    
    set IRQValueIndex      = $(Combo1Out)
    set IOBaseAddrIndex    = $(Combo2Out)
    set COMInterruptNumberIndex = $(Combo3Out)
    set COMBaseIndex       = $(Combo4Out)
    set MemoryAddrIndex    = $(Combo5Out)
    set SocketNumberIndex  = $(Combo6Out)
    set XmitNumber         = $(Combo7Out)
    set MediaValue         = $(MediaType)
    set SetAddress         = $(SetAddress)
    set NetworkAddress     = $(NewNetworkAddress)
    set DisLinkValue       = $(DisLinkType)

    Shell $(UtilityInf), GetBusTypeNum
    set BusTypeNum = $($R1)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "INF: ShellCode error."
	goto ShellCodeError
    Endif

    Ifstr(i) $(!STF_NCDETINFO) == {}
       Ifint $(PCMCIA) != 1
	   Shell $(UtilityInf),GetBusTypeDialog,$(ProductHardware$(Option)Description) $(BusInterfaceType) $(BusNumber)
	   Ifint $(ShellCode) != $(!SHELL_CODE_OK)
	       goto ShellCodeError
	   Endif
	   set BusInterfaceType = $($R1)
	   set BusNumber = $($R2)
	else
	   set BusInterfaceType = 1
	   set BusNumber = 0
	Endif
    else
	set BusInterfaceType = *($(!STF_NCDETINFO),5)
	set BusNumber = *($(!STF_NCDETINFO),6)
    Endif
    ;  
    ;  If PCMCIA bus selected, then move to the ISA bus ...
    ;
    Ifint $(BusInterfaceType) == 8
       set BusInterfaceType = 1
       set PCMCIA = 1
    Endif

    set MemBaseAddrValue  = *($(MemBaseValues), ~($(MemBaseList), $(MemoryAddrIndex)))
    set InterruptNumber   = *($(IrqValues), ~($(IrqList), $(IRQValueIndex)))
    set IOBaseAddrValue   = *($(IoBaseValues), ~($(IoBaseList), $(IOBaseAddrIndex)))
    set COMIoBaseAddrValue = *($(COMBaseValues), ~($(COMBaseList), $(COMBaseIndex)))
    set COMInterruptNumber = *($(COMIrqValues), ~($(COMIrqList), $(COMInterruptNumberIndex)))
    set SocketNumber       = *($(SockValues), ~($(SockList), $(SocketNumberIndex)))
    set ComPortValue       = *($(COMPortList), ~($(COMBaseList), $(COMBaseIndex)))
    ;
    ;  If Ositech COM port, then determine I/O address ...
    ;
    Ifint $(COMIoBaseAddrValue) == 65535
       Set-add COMIoBaseAddrValue = $(IOBaseAddrValue), 40
       ; Set ComPortValue = "COM5"
    Endif

    Set IOLengthValue = 31

AdapterVerify =+
    Ifstr(i) $(DetectedCard) != TRUE
        Shell $(ParamInf) Param_SaveValues
        Set NewParamSettings = $($R0)
        Ifstr(i) $(CurrParamSettings) == {}
            Set DiffParamSettings = $(NewParamSettings)
        Else
            Shell $(ParamInf) Param_DiffValues $(CurrParamSettings)
	    Set DiffParamSettings = $($R0)
        Endif
        Debug-Output "INF: Calling Param_VerifyResources"
	Shell $(ParamInf) Param_VerifyResources $(DiffParamSettings)
        Ifstr(i) $($R0) == STATUS_SUCCESSFUL
            Debug-Output "INF: Param_VerifyResources succeeded"
	    Goto skipoptions
        Endif
    Else
        Set CardVerifyIndex = $(!STF_NCDETCARD)
        Debug-Output "INF: Calling Param_VerifyCard"
        Shell $(ParamInf) Param_VerifyCard $(!SFT_NCDETCARD)
        Ifstr(i) $($R0) == STATUS_SUCCESSFUL
            Debug-Output "INF: Param_VerifyCard succeeded"
	    Goto skipoptions
        Endif
    Endif
    Set from = AdapterOptions
    Set to = skipoptions
    Shell $(UtilityInf),RegistryErrorString,VERIFY_WARNING
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-output "Shellcode error: cannot get an error string."
	goto ShellCodeError
    Endif
    set Error = $($R0)
    Goto Warning
skipoptions =+
    Ifint $(OldVersionExisted) == $(TRUE)
	Ifstr(i) $(!NTN_InstallMode) == configure
	    Goto WriteParameters
	Endif
    Endif
    StartWait
    ;
    ; Add Software Components
    ;
    ifint $(OldVersionExisted) == $(FALSE)

	Ifstr(i) $(!NTN_InstallMode) == "install"
	   Ifstr(i) $(DoCopy) == "YES"

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

	      Ifint $($ShellCode) != $(!SHELL_CODE_OK)
		  Goto ShellCodeError
	      Else-Ifstr(i) $($R0) == STATUS_FAILED
		  Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
		  ifint $($ShellCode) != $(!SHELL_CODE_OK)
		      goto ShellCodeError
		  endif
		  set Error = $($R0)
		  Goto fatal
	      Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
		  Goto successful
	      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)
		  goto ShellCodeError
	      endif
	      set Error = $($R0)
	      goto fatal
	   endif
	Endif

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

        Set OEM_ABANDOND_SOFTWARE = TRUE

	Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    Goto ShellCodeError
	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 RegistryErrorIndex = $($R0)
        set KeyProduct      = $($R1)
        Set SoftNetRulesKey = $($R2)
        CloseRegKey $($R3)
        CloseRegKey $($R4)
        CloseRegKey $($R5)

        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    EndWait
	    Debug-Output "INF: Registry error: Add software components"
	    CloseRegKey $(KeyProduct)
	    CloseRegKey $(SoftNetRulesKey)
	    goto fatalregistry 
        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),*($(Now),1)}}

        Shell  $(UtilityInf), AddValueList, $(KeyProduct), $(NewValueList)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

        Ifstr(i) $($R0) != NO_ERROR
	    EndWait
	    Debug-Output "INF: Resgitry error: add value list."
            CloseRegKey $(KeyProduct)
            CloseRegKey $(SoftNetRulesKey)
	    goto fatalregistry
        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),"OTCJODNT"}}

        Shell  $(UtilityInf), AddValueList, $(SoftNetRulesKey), $(NewValueList)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

        CloseRegKey $(KeyProduct)
        CloseRegKey $(SoftNetRulesKey)

        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    EndWait
	    Debug-Output "INF: Resgitry error: add value list."
	    goto fatalregistry
        endif
    Endif
;
;   Create the HARDWARE\Netcard region and its corresponding service
;
    Shell $(UtilityInf), AddHardwareComponent, $(ProductHardwareName),$(STF_CONTEXTINFNAME),$(ProductKeyName)

    ifint $($R4) != -1
	Set OEM_ABANDON_OPTIONS = >($(OEM_ABANDON_OPTIONS), $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards\"$($R4))
    endif

    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "INF: Cannot add hardware component"
	goto ShellCodeError
    endif

    set RegistryErrorIndex = $($R0)
    
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        EndWait
	Debug-Output "INF: Registry Error: Add Hardware Component"
	CloseRegKey $($R1)
	CloseRegKey $($R2)
	CloseRegKey $($R3)
	goto fatalregistry
    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          = "OTCJODNT"

    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),*($(Now),1)}}

    Shell  $(UtilityInf), AddValueList, $($R1), $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "INF: ShellCode error"
	goto ShellCodeError
    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)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "INF: ShellCode error"
	goto ShellCodeError
    Endif

    set RegistryErrorIndex = $($R0)

    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	EndWait
	Debug-Output "INF: Resgitry error: add value list."
	CloseRegKey $(KeyParameters)
	CloseRegKey $(KeyAdapterRules)
	goto fatalregistry
    Endif

    CloseRegKey $(KeyAdapterRules)

    Goto WriteParameters
;
;   REQUIRED:   $(KeyParameters) contains service Parameters key handle
;
WriteParameters = +
    Ifint $(COMIoBaseAddrValue) == 0
        Set IOLengthValue = 0
    else
        Set IOLengthValue = 7
    Endif
    ; BUGBUGBUG
    ;
    ;  Ugly hack to get COM5 using MS Enabler ...
    ;
    Ifint $(PCMCIA) == 1
        Ifstr(i) $(ComPortValue) == "COM5"
            Set IOLengthValue_1 = 47
        Else
            Set IOLengthValue_1 = 31
        Endif
    Else
        Set IoLengthValue_1 = 31
    Endif

    Set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusInterfaceType)},+
		        {MediaType,$(NoTitle),$(!REG_VT_DWORD),1},+
			{BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNumber)},+
			{Media,$(NoTitle),$(!REG_VT_DWORD),$(MediaValue)},+
			{DisableLinkTest,$(NoTitle),$(!REG_VT_DWORD),$(DisLinkValue)},+
			{SocketNumber,$(NoTitle),$(!REG_VT_DWORD),$(SocketNumber)},+
			{MaximumTransmitQueue,$(NoTitle),$(!REG_VT_DWORD),$(XmitNumber)},+

			{InterruptNumber,$(NoTitle),$(!REG_VT_DWORD),$(COMInterruptNumber)},+
			{IoBaseAddress,$(NoTitle),$(!REG_VT_DWORD),$(COMIoBaseAddrValue)},+
		        {IoLength,$(NoTitle),$(!REG_VT_DWORD),$(IOLengthValue)},+

			{PCCARDReadyInterrupt,$(NoTitle),$(!REG_VT_DWORD),$(InterruptNumber)},+
			{IoBaseAddress_1,$(NoTitle),$(!REG_VT_DWORD),$(IOBaseAddrValue)},+
			{IoLength_1,$(NoTitle),$(!REG_VT_DWORD),$(IOLengthValue_1)},+

			{PCCARDAttributeMemoryAddress,$(NoTitle),$(!REG_VT_DWORD),$(MemBaseAddrValue)},+
			{PCCARDAttributeMemorySize,$(NoTitle),$(!REG_VT_DWORD),4096},+
			{PCCARDAttributeMemoryOffset,$(NoTitle),$(!REG_VT_DWORD),0},+
			
			{SetAddress,$(NoTitle),$(!REG_VT_DWORD),$(SetAddress)},+
			{NetworkAddress,$(NoTitle),$(!REG_VT_SZ),$(NetworkAddress)},+

			{DatabookFound,$(NoTitle),$(!REG_VT_DWORD),$(DatabookFound)}}

    Shell  $(UtilityInf), AddValueList, $(KeyParameters), $(NewValueList)
    ;
    ;  If PCMCIA then add the registry entry, otherwise remove it ...
    ;
    Ifint $(PCMCIA) == 1
        Set NewValueList = {{Pcmcia,$(NoTitle),$(!REG_VT_DWORD),1}}
        Shell  $(UtilityInf), AddValueList, $(KeyParameters), $(NewValueList)
	;
	;  If LAN only mode, then remove the modem entries
	;
        ;Ifint $(COMIoBaseAddrValue) == 0
	;    DeleteRegValue $(KeyParameters) "IoBaseAddress"
	;     DeleteRegValue $(KeyParameters) "IoLength"
	;    DeleteRegValue $(KeyParameters) "InterruptNumber"
	;Endif
    else
        DeleteRegValue $(KeyParameters) "Pcmcia"
    Endif
    CloseRegKey $(KeyParameters)

    ;
    ; OTCJODNT: add the comm port info to the SYSTEM\CurrentControlSet\Services\Serial\Parameters section of the registry
    ; 
    Ifcontains(i) $(Option) in {"OTCJODNT"}
        Ifstr(i) $(ComPortValue) != "None"
	    OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters\SerialOsitechJOD" $(MAXIMUM_ALLOWED) MyNewSerialHandle
	    Ifstr $(MyNewSerialHandle) == $(KeyNull)
		OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters" $(MAXIMUM_ALLOWED) SerialKey
		CreateRegKey $(SerialKey) {"SerialOsitechJOD",0,GenericClass} "" $(MAXIMUM_ALLOWED) "" MyNewSerialHandle
	 	CloseRegKey $(SerialKey)
	    Endif
	    Set NewValueList = {{DosDevices, $(NoTitle),$(!REG_VT_SZ), $(ComPortValue)},+		; "COMx"
	    			{ForceFifoEnable, $(NoTitle),$(!REG_VT_DWORD), 1},+			; Always true for JOD
				{Interrupt, $(NoTitle),$(!REG_VT_DWORD), $(COMInterruptNumber)},+	; Interrupt for JOD modem
				{PortAddress, $(NoTitle),$(!REG_VT_DWORD), $(COMIoBaseAddrValue)}}	; I/O Base address for JOD
	    Shell  $(UtilityInf), AddValueList, $(MyNewSerialHandle), $(NewValueList)
	    CloseRegKey $(MyNewSerialHandle)

	    ; JODNT: add comm port info to HARDWARE\DEVICEMAP\SERIALCOMM section
	    OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP\SERIALCOMM" $(MAXIMUM_ALLOWED) MyNewSerialHandle
	    Ifstr $(MyNewSerialHandle) == $(KeyNull)
		OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP" $(MAXIMUM_ALLOWED) SerialKey
		CreateRegKey $(SerialKey) {"SERIALCOMM",0,GenericClass} "" $(MAXIMUM_ALLOWED) "" MyNewSerialHandle
	  	CloseRegKey $(SerialKey)
	    Endif
	    SetRegValue $(MyNewSerialHandle) {"SerialOsitechJOD",$(NoTitle),$(!REG_VT_SZ),$(ComPortValue)}
	    CloseRegKey $(MyNewSerialHandle)

	    ; JODNT: add comm port info to SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports section
	    OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" $(MAXIMUM_ALLOWED) MyNewSerialHandle
	    Ifstr $(MyNewSerialHandle) == $(KeyNull)
		OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\Microsoft\Windows NT\CurrentVersion" $(MAXIMUM_ALLOWED) SerialKey
		CreateRegKey $(SerialKey) {"Ports",0,GenericClass} "" $(MAXIMUM_ALLOWED) "" MyNewSerialHandle
	  	CloseRegKey $(SerialKey)
	    Endif
	    SetRegValue $(MyNewSerialHandle) {$(ComPortValue)":",$(NoTitle),$(!REG_VT_SZ),"9600,n,8,1"}
	    CloseRegKey $(MyNewSerialHandle)
	Else
	    ;
	    ;  Remove the COM port
	    ;
	    OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters" $(MAXIMUM_ALLOWED) MyNewSerialHandle
	    DeleteRegTree $(MyNewSerialHandle) "SerialOsitechJOD"
	    CloseRegKey $(MyNewSerialHandle)

	    OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP\SERIALCOMM" $(MAXIMUM_ALLOWED) MyNewSerialHandle
	    DeleteRegValue $(MyNewSerialHandle) "SerialOsitechJOD"
            CloseRegKey $(MyNewSerialHandle)
        Endif
    Endif

    ;
    ; Write the parameters to the PCMCIA database section.
    ;
    set PCMCIADatabaseKeyName = $(!NTN_ServiceBase)"\Pcmcia\DataBase"
    ; Debug-Output "INF: Opening PCMICA database key "$(PCMCIADatabaseKeyName)
    OpenRegKey $(!REG_H_LOCAL) "" $(PCMCIADatabaseKeyName) $(MAXIMUM_ALLOWED) PCMCIADatabaseKey

    Ifstr $(PCMCIADatabaseKey) == $(NULL)    
	Debug-Output "INF: Pcmcia\DataBase not present"
    else
        ;
        ; Reprogram the PCMCIA slot with the new parameters.
        ;
        ; Should really only be done during first time installation of NT, and
        ; only if a Ositech card was found.  For now, we do it always ...
        ;
        ; Ifint $(SLOTFOUND) == 1
	    ; LoadLibrary "disk 1" $(DLLPATH)otcncdet.dll DllHandle
	    ; Debug-Output "INF: Enabling the network resources"
	    ; LibraryProcedure STATUS, $(DllHandle), SetupSlot $(SLOT) 0 $(InterruptNumber) $(IOBaseAddrValue) $(IOLengthValue) $(MemBaseAddrValue) 4096 0
	    ; Debug-Output "INF: SetupSlot status "$(STATUS)
	    ; FreeLibrary $(DllHandle)
        ; Endif
        ;
	; Try to open up the Ositech section
	;
	OpenRegKey $(!REG_H_LOCAL) "" $(PCMCIADatabaseKeyName)"\Ositech" $(MAXIMUM_ALLOWED) PCMCIADatabaseOsitechKey

	Ifstr $(PCMCIADatabaseOsitechKey) != $(NULL)
	    ;
	    ;  Delete sub-tree if it was found
	    ;
	    CloseRegKey $(PCMCIADatabaseOsitechKey)
	    DeleteRegTree $(PCMCIADatabaseKey) "Ositech"
	Endif
		
	CreateRegKey $(PCMCIADatabaseKey) {"Ositech", 0, 0} "" $(MAXIMUM_ALLOWED) "" PCMCIADatabaseOsitechKey

	; Do the Modem+Ethernet Cards ----------------------------------------------------------------------------------
	CreateRegKey $(PCMCIADatabaseOsitechKey) {"Trumpcard:Jack of Diamonds Modem+Ethernet", 0, 0} "" $(MAXIMUM_ALLOWED) 0 PCMCIADatabaseOsitechJODKey
	SetRegValue $(PCMCIADatabaseOsitechJODKey) {Driver, 0, $(!REG_VT_SZ),"otcjodnt"}
	SetRegValue $(PCMCIADatabaseOsitechJODKey) {AttributeMemorySize, 0, $(!REG_VT_DWORD),4096}
	CloseRegKey $(PCMCIADatabaseOsitechJODKey)
	
	CloseRegKey $(PCMCIADatabaseOsitechKey)
	CloseRegKey $(PCMCIADatabaseKey)
    Endif
    ;
    ; Inform Trumpcard user to manually add a serial port through control panel
    ;
    ;Ifstr(i) $(Option) == OTCJODNT
    ;    set InvokePortToolMsg   = "Ositech Trumpcard setup is complete.  Please remember to configure the Trumpcard "+
    ;                            "serial port by invoking the Ports tool in the Control Panel."
    ;    Shell "subroutn.inf" SetupMessage, $(!STF_LANGUAGE), "STATUS", $(InvokePortCPMsg)
    ;    IfInt $($ShellCode) != $(!SHELL_CODE_OK)
    ;        Debug-Output "INF: ShellCode error."
    ;        goto ShellCodeError
    ;    EndIf
    ;Endif

    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "INF: ShellCode error."
	goto ShellCodeError
    Endif

    set RegistryErrorIndex = $($R0)

    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	Debug-Output "INF: Registry error: Add value list"
	goto fatalregistry
    Endif

    EndWait

    Goto successful

NoWay =+
    set Error = "Sorry, not yet implemented."
    Goto fatal

;-----------------------------------------------
; Removeadapter section
;-----------------------------------------------

RemoveAdapter =+
    Ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
        ; Remove software components
	Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName)

	Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    Goto ShellCodeError
	Endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    Goto fatalregistry
	Endif
    else
	Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $(!NTN_RegBase)

	Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    Goto ShellCodeError
	Endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    Goto fatalregistry
	Endif

	;
	; OtcjodNT: delete the comm port info to the SYSTEM\CurrentControlSet\Services\Serial\Parameters section of the registry
	;
	Ifstr(i) $(Option) == OTCJODNT
		OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters" $(MAXIMUM_ALLOWED) MyNewSerialHandle
		DeleteRegTree $(MyNewSerialHandle) "SerialOsitechJOD"
		CloseRegKey $(MyNewSerialHandle)

		OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP\SERIALCOMM" $(MAXIMUM_ALLOWED) MyNewSerialHandle
		DeleteRegValue $(MyNewSerialHandle) "SerialOsitechJOD"
		CloseRegKey $(MyNewSerialHandle)
	Endif

    Endif

    Goto End

;-----------------------------------------------
; Upgrade Software section
;-----------------------------------------------

UpgradeSoftware =+
    ;
    ; First determine whether we want to do upgrade or update for software
    ; or hardware component. Then we will determine whether the Mode is
    ; update or upgrade.
    ;
    ; If the same version of the product existed in the registry, we do
    ; update. Otherwise, we will do a upgrade
    ;

    ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
	; Upgrade software component
	;
	; see whether the same version exist or not
	;
       OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
       Ifstr $(KeyProduct) != $(KeyNull)
           GetRegValue $(KeyProduct),"MajorVersion", VersionInfo
           set Version = *($(VersionInfo), 4)

	   ;
	   ; Update the binaries
	   ;
	   Shell $(UtilityInf), GetInfFileNameFromRegistry, $(KeyProduct)

	   Ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "INF: ShellCode error"
		Goto ShellCodeError
	   Endif

	   set !UG_Filename = $($R0)

	   Ifstr(i) $(!UG_Filename) != ""
		install "Install-Update"
		Ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
		    Goto fatal
		Endif
	   Endif

	   ; Upgrade the version number
	   ;
	   SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMajorVersion)}
	   SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),$(ProductMinorVersion)}

	   ;
	   ; do nothing for the update
	   ;
	   Ifint $(Version) != $(ProductVersion)
	       ;
	       ; If the major version number is not the same,
	       ; it is major upgrade. So let's Upgrade the product
	       ;
	       ;
	       ; make other upgrade change if necessary
	       ;
	   Endif
	   CloseRegKey $(KeyProduct)
       else
	   ;
	   ; Cannot Open software key, goto ERROR
	   ;
	   Goto fatalregistry
       Endif
    else
        ;
        ; upgrade/update hardware component
        ; There is no different between upgrade and update for hardware
	; component
	;
	; 1. Get the Service Name
	; 2. Change the NetRule section if necessary
	;
	OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) +
	      $(MAXIMUM_ALLOWED) NetworkCardKey
	Ifstr(i) $(NetworkCardKey) != $(KeyNull)
	    ;
	    ; Get Service name
	    ;
	    GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
	    set ServiceName = *($(ServiceNameInfo), 4)

	    ;
	    ; Change the NetRule if necessary
	    ;
	    OpenRegKey $(NetworkCardKey) "" "NetRules" +
		$(MAXIMUM_ALLOWED) NetRuleKey
	    Ifstr(i) $(NetRuleKey) != $(KeyNull)
		;
		; Make the change....
		;
	    else
		;
		; Error, cannot open net rules key
		;
		goto fatalregistry
	    endif

	    CloseRegKey $(NetRules)
	    CloseRegKey $(NetworkCardKey)
	else
	    ;
	    ; Error, cannot open network card key
	    ;
	    goto fatalregistry
	endif
	;
	; 3. Change the service section of the hardware. i.e.,
	;    ParameterName change, value change, etc.
	;
	OpenRegKey $(!REG_H_LOCAL) "" +
	      $(!NTN_ServiceBase)"\"$(ServiceName) +
	      $(MAXIMUM_ALLOWED) ServiceKey

	Ifstr(i) $(ServiceKey) != $(KeyNull)
	    ;
	    ; Get the ServiceKey to change the Start value
	    ; or Type value. Or open Parameters key to
	    ; change the hardware parameters if necessary.
	    ;
	    CloseRegKey $(ServiceKey)
	else
	    ;
	    ; Error, cannot open network card key
	    ;
	    goto fatalregistry
	Endif
    Endif

    Goto end
    ;
    ; End of Upgrade Software
    ;

;
;  Escape hatches
;
successful = +
    goto end

abandon = +
    ForListDo $(OEM_ABANDON_OPTIONS)
	Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $($)
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
	;
	; OtcjodNT: delete the COM port info in the SYSTEM\CurrentControlSet\Services\Serial\Parameters section of the registry
	;
	;Ifstr(i) $(Option) == OTCJODNT
		;OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters" $(MAXIMUM_ALLOWED) MyNewSerialHandle
		;DeleteRegTree $(MyNewSerialHandle) "SerialOsitechJOD"
		;CloseRegKey $(MyNewSerialHandle)
		;
		;OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP\SERIALCOMM" $(MAXIMUM_ALLOWED) MyNewSerialHandle
		;DeleteRegValue $(MyNewSerialHandle) "SerialOsitechJOD"
		;CloseRegKey $(MyNewSerialHandle)
	;Endif

    EndForListDo

    Ifstr(i) $(OEM_ABANDON_SOFTWARE) == TRUE
	; Remove Software Component
	Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), FALSE
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "INF: ShellCode error"
	    goto ShellCodeError
	endif

	set RegistryErrorIndex = $($R0)

	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	    goto fatalregistry
	endif
    endif

    goto end
;
; warning display
;
warning = +
    Shell $(SubroutnInf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
	goto $(to)
    else-ifstr(i) $($R1) == "CANCEL"
	goto $(from)
    else
	goto "end"
    endif
;
; non fatal error display
;
nonfatalinfo = +
    Set Severity = STATUS
    Set CommonStatus = STATUS_USERCANCEL
    goto nonfatalmsg
nonfatal = +
    Set Severity = NONFATAL
    goto nonfatalmsg
nonfatalmsg = +
    ifstr(i) $(Error) == ""
	Set Severity = NONFATAL
	Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    goto ShellCodeError
	endif
	set Error = $($R0)
    endif
    Shell $(SubroutnInf) SetupMessage, $(!STF_LANGUAGE), $(Severity), $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
	goto $(from)
    else
	goto end
    endif

;
;  Registry is broken
;
fatalregistry = +
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    Endif
    set Error = $($R0)
    goto fatal

;
;  Netcard detection failure
;
fataldetect = +
    Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	Debug-Output "INF: ShellCode error: cannot get an error string."
	goto ShellCodeError
    endif
    set Error = $($R0)
    Goto fatal
;
; fatal error display
;
fatal = +
    ifstr(i) $(Error) == ""
	Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    goto ShellCodeError
	endif
	set Error = $($R0)
    endif
    Shell $(SubroutnInf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	goto ShellCodeError
    endif

    goto setfailed

;
;  Shelling error
;
ShellCodeError = +
    set DlgType      = "MessageBox"
    set STF_MB_TITLE = $(ShellCodeErrorTitle)
    set STF_MB_TEXT  = $(ShellCodeErrorText) 
    set STF_MB_TYPE  = 1
    set STF_MB_ICON  = 3
    set STF_MB_DEF   = 1
    ui start "Error Message"
    goto setfailed

setfailed = +
    set CommonStatus = STATUS_FAILED
    ;
    ; if OEM_ABANDON_ON == TRUE, then remove the registry entries
    ;
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
	set OEM_ABANDON_ON = FALSE
	goto abandon
    endif
    goto end

end = +
    goto term

term = +

    Return $(CommonStatus)


[Install-Option]

    set ProCaption = $(!p:ProCaption)
    set ProCancel  = $(!p:ProCancel)
    set ProCancelMsg  = $(!p:ProCancelMsg)
    set ProCancelCap  = $(!p:ProCancelCap)
    set ProText1   = $(!p:ProText1)
    set ProText2   = $(!p:ProText2)

    set STF_VITAL  = ""

    Ifstr(i) $(AddCopy) == "YES"
	;
	; Add the files to the copy list
	;
        AddSectionFilesToCopyList Files-Detect $(SrcDir) $(!STF_WINDOWSSYSPATH)
        AddSectionFilesToCopyList Files-OtcjodNT $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
        AddSectionFilesToCopyList Files-Dll $(SrcDir) $(!STF_WINDOWSSYSPATH)
    Endif

    Ifstr(i) $(DoCopy) == "YES"
       ;
       ; Copy files in the copy list
       ;
       set !STF_NCPA_FLUSH_COPYLIST = $(!TRUE)
       CopyFilesInCopyList
    Endif

    Exit

[Install-Update]
   set STF_VITAL        = ""
   set STF_OVERWRITE    = "VERIFYSOURCEOLDER"
   ;set STF_VERSION	= "YES"

   AddSectionFilesToCopyList Files-Detect $(SrcDir) $(!STF_WINDOWSSYSPATH)
   AddSectionFilesToCopyList Files-OtcjodNT $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
   AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)
   AddSectionFilesToCopyList Files-Dll $(SrcDir) $(!STF_WINDOWSSYSPATH)

   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList
   
   Exit

[Install-Dll]
   set STF_VITAL        = ""

   AddSectionFilesToCopyList Files-Detect $(SrcDir) $(!STF_WINDOWSSYSPATH)
   AddSectionFilesToCopyList Files-Dll $(SrcDir) $(!STF_WINDOWSSYSPATH)

   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList

   Exit

[WarnError]
    read-syms FileConstants

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

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

    Return
