;------------------------------------------------------------------------------
; OEMSETNT.INF
;   Megahertz Combo network card and driver SETUP INF file.
;	 Author: tscribne@mhz.com
;------------------------------------------------------------------------------
[Identification]
   OptionType = NetAdapter

[PlatformsSupported]
   PCMCIA

[LanguagesSupported]
   ENG

[Options]
   XJEM3288
;	XJEM1144
;	EM1144
	CC10BT

[OptionsTextENG]
   XJEM3288     = "Megahertz XJEM3288 Ethernet+Modem PCMCIA Adapter"
;	XJEM1144     = "Megahertz XJEM1144 Ethernet+Modem PCMCIA Adapter"
;	EM1144       = "Megahertz EM1144 Ethernet+Modem PCMCIA Adapter"
	CC10BT		 = "Megahertz CC10BT/2 Ethernet PCMCIA Adapter"

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

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

[ProductType]
   STF_PRODUCT  = Winnt
   STF_PLATFORM = I386

[Files-MHZ]
   1, mhzc9x.sys, SIZE=999


[Files-Dll]
   1, mhzc9x.dll, SIZE=999
   1, mhzc9x.hlp, SIZE=999

[Files-Detect]
   1, mhzncdet.dll, SIZE=999

[Files-Modem]
   1, mdmmhz.inf, SIZE=999
   1, mdmmhza.inf, SIZE=999

[Files-Inf]
   1, oemsetnt.inf, SIZE=999

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

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

[RegistryConstants]
   SoftwareType             = "driver"
   Manufacturer             = "Megahertz"
   ; Product Info  -------------------------------------------------
   ProductMajorVersion      = "1"
   ProductMinorVersion      = "21"
   ProductVersion           = $(ProductMajorVersion)"."$(ProductMinorVersion)
   ; Software  -----------------------------------------------------
   ProductSoftwareName      = "mhzc9x"
   ProductSoftwareTitle     = "Megahertz Ethernet Driver"
   ProductSoftwareDescription = "Megahertz Ethernet Driver"
   ProductSoftwareImagePath = "\SystemRoot\System32\drivers\mhzc9x.sys"
   NetRuleSoftwareType      = "Mhzc9xSys ndisDriver mhzc9xDriver"
   NetRuleSoftwareUse       = $(SoftwareType)
   NetRuleSoftwareBindForm  = """mhzc9xSys"" yes no container"
   NetRuleSoftwareClass     = {"mhzc9xDriver basic"}
   NetRuleSoftwareBindable  = {"mhzc9xDriver mhzc9xAdapter non exclusive 100"}
   ; Hardware  -----------------------------------------------------
   ProductHardwareName      = "mhzc9x"
   ProductHardwareXJEM3288Description = "Megahertz XJEM3288 PCMCIA Adapter"
   ProductHardwareXJEM3288Title = "Megahertz XJEM3288 PCMCIA Adapter"
	ProductHardwareXJEM1144Description = "Megahertz XJEM1144 PCMCIA Adapter"
	ProductHardwareXJEM1144Title = "Megahertz XJEM1144 PCMCIA Adapter"
	ProductHardwareEM1144Description = "Megahertz EM1144 PCMCIA Adapter"
	ProductHardwareEM1144Title = "Megahertz EM1144 PCMCIA Adapter"
	ProductHardwareCC10BTDescription = "Megahertz CC10BT/2 PCMCIA Adapter"
	ProductHardwareCC10BTTitle = "Megahertz CC10BT/2 PCMCIA Adapter"
   NetRuleHardwareType      = "mhzc9x mhzc9xAdapter"
   NetRuleHardwareBindForm  = " yes yes container"
   NetRuleHardwareClass     = {"mhzc9xAdapter basic"}
   ; Registry Key --------------------------------------------------
   ProductKeyName           = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(ProductSoftwareName)"\CurrentVersion"
   ParamKeyName             = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"

   ; PCMCIA Tuples -------------------------------------------------
   VERS1Product       = "CC/XJEM3288"
   VERS1Manufacturer  = "Megahertz"

[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 Megahertz XJEM3288 is not correctly installed.  "+
	  	 "Are you sure you want to cancel copying files?"
   ProCancelCap       = "Network Setup Message"
   ProText1           = "Copying:"
   ProText2           = "To:"
   FunctionTitle      = "Megahertz PCMCIA Card Setup"$(GenericInfVersion)
   DialogDllName      = "MHZC9X.DLL"
   IrqList           = ^(MhzIrqs, 1)                     
   IrqValues	      = ^(MhzIrqs, 2)
	MediaList			= ^(MhzMediaTypes,1)
	MediaValues   		= ^(MhzMediaTypes,2)
   IoBaseList        = ^(MhzIoBase, 1)
   IoBaseValues      = ^(MhzIoBase, 2)
   COMBaseList       = ^(MhzCOMBase, 1)
   COMBaseValues     = ^(MhzCOMBase, 2)
   COMPortList	      = ^(MhzCOMBase, 3)
   MemBaseList       = ^(MhzCISMemBase, 1)
   MemBaseValues     = ^(MhzCISMemBase, 2)
   SockList          = ^(MhzSocket, 1)
   SockValues        = ^(MhzSocket, 2)
   XmitList          = ^(MhzXmit, 1)
   XmitValues        = ^(MhzXmit, 2)

[MhzIrqs]
;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

[MhzIoBase]
   Base0  = "0x100", 256
	Base1  = "0x120"	288
   Base1  = "0x140", 320
   Base2  = "0x180", 384
	Base1  = "0x1A0",	416
   Base3  = "0x1C0", 448
	Base1  = "0x1E0",	480
   Base4  = "0x200", 512
	Base1  = "0x220",	544
	Base1  = "0x240",	576
	Base1  = "0x260",	608
   Base5  = "0x280", 640
	Base1  = "0x2A0",	672
	Base1  = "0x2C0",	704
	Base1  = "0x2E0",	736
   Base6  = "0x300", 768
	Base1  = "0x320",	800
   Base7  = "0x340", 832
	Base1  = "0x360",	864
   Base8  = "0x380", 896

[MhzMediaTypes]
	Media_0 = "10BaseT",0
	Media_1 = "10Base2",1


[MhzCOMBase]
   COMBase0 = "COM1", 1016, "COM1"
   COMBase1 = "COM2", 760, "COM2"
   COMBase2 = "COM3", 1000, "COM3"
   COMBase3 = "COM4", 744, "COM4"


[MhzCISMemBase]
	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


[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           = "MultiCombo"
   DlgTemplate       = $(Option)
   Caption           = $(FunctionTitle)
   Combo1Label       = "&IRQ Level:"
   Combo2Label       = "I/O &Port:"
   Combo3Label       = "Memory &Window:"
   Combo4Label       = "&Media Type:"
   Combo5Label       = "&Com Port:"
   Combo1List        = $(IrqList)
   Combo1Out         = $(InterruptNumber)
   Combo2List        = $(IoBaseList)
   Combo2Out         = $(IOBaseAddrValue)
	Combo3List			= $(MemBaseList)
	Combo3Out			= $(MemBaseAddrValue)
	Combo4List			= $(MediaList)
	Combo4Out			= $(MediaNumber)
   Combo5List        = $(COMBaseList)
   Combo5Out         = $(COMIoBaseAddrValue)
   ComboListItemsIn  = {Combo1List, Combo2List, Combo3List, Combo4List, Combo5List}
   ComboListItemsOut = {Combo1Out, Combo2Out, Combo3Out, Combo4Out, Combo5Out}
   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 Megahertz 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 = 1

   ;  Setup the default values

   set InterruptNumber     = *($(IrqList), 3)      ; LAN IRQ   = 5
   set IOBaseAddrValue     = *($(IoBaseList), 17)  ; IOBase address = 0x320
   set COMIoBaseAddrValue  = *($(COMBaseList), 3)  ; Modem IOBase address = (COM3)
   set MemBaseAddrValue    = *($(MemBaseList), 9) ; Memory address = 0xD0000
	set MediaNumber         = *($(MediaList),0)

   Ifstr(i) $(ActivateDetection) != TRUE
		Goto $(SubFunction)
   Endif
    
;    Set TypeList = {{IRQ, IRQ_List, InterruptNumber},+
;                    {IOADDR, IOADDR_Addr_List, IOBaseAddrValue},+
;    		    {TRANSCEIVER, TranceiverValueList, MediaValue},+
;		    {MEMADDR, MemBaseAddrDecList, MemBaseAddrValue},+
;		    {COMIOADDR, COM_IOADDR_Addr_List, COMIoBaseAddrValue}}
    
    Set TypeList = {{IRQ, IRQ_List, InterruptNumber},+
                    {IOADDR, IOADDR_Addr_List, IOBaseAddrValue},+
    		           {MEDIA, TranceiverValueList, MediaNumber},+
		              {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

	Ifstr(i) $(Option) == CC10BT

		ForListDo $(ValueList)
			set ValueItem = $($)
			set ValueName = *($(ValueItem),1)
			set ValueData = *($(ValueItem),4)
	
			Ifstr(i) $(ValueName) == "MediaType"
				set MediaValueIndex = $(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 IRQValueIndex = $(ValueData)
			else-ifstr(i) $(ValueName) == "IoBaseAddress"
				set IOBaseAddrIndex = $(ValueData)
			Endif
		EndForListDo
	Else
		ForListDo $(ValueList)
			set ValueItem = $($)
			set ValueName = *($(ValueItem),1)
			set ValueData = *($(ValueItem),4)
	
			Ifstr(i) $(ValueName) == "MediaType"
				set MediaValueIndex = $(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 IRQValueIndex = $(ValueData)
			else-ifstr(i) $(ValueName) == "IoBaseAddress_1"
				set IOBaseAddrIndex = $(ValueData)
			else-ifstr(i) $(ValueName) == "IoBaseAddress"
				set COMBaseIndex = $(ValueData)
			Endif
		EndForListDo

	Endif

   ifstr(i) $(!STF_GUI_UNATTENDED) == "YES"
       ifstr(i) $(!AutoNetInterfaceType) != ""
           set BusInterfaceType = $(!AutoNetInterfaceType)
       else
           set BusInterfaceType = 1    
       endif
       ifstr(i) $(!AutoNetBusNumber) != ""
           set BusNumber = $(!AutoNetBusNumber)
       else
           set BusNumber = 0
       endif
       goto adapterverify
   endif
 
   ;
   ;  Get the converted values
   ;
   set InterruptNumber = *($(IrqList), ~($(IrqValues),$(IRQValueIndex)))
   ifstr(i) $(InterruptNumber) == ""
		set InterruptNumber = *($(IrqList), 2)
   endif

	set MediaNumber = *($(MediaList),~($(MediaValues),$(MediaValueIndex)))
	ifstr(i) $(MediaNumber) == ""
		set MediaNumber = *($(MediaList),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


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

AdapterSetup = +

   Set from = AdapterSetup
	Debug-Output "AdapterSetup"
   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)mhzc9x.hlp 30100 30100

   set AdapterStatus = $(FALSE)


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

   LoadLibrary "disk 1" $(DialogDllName) DllHandle

RetryDialog =+

   ui start "InputDlg" $(DllHandle)

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

		set AdapterStatus = $(TRUE)

		set SLOTCOUNT = 8
		set SLOT = 0
		set SLOTFOUND = 1
		Goto slotcontinue

slotcontinue = +
		; Fall Through

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


   set IRQValueIndex      = $(Combo1Out)
   set IOBaseAddrIndex    = $(Combo2Out)
   set COMBaseIndex       = $(Combo5Out)
   set MemoryAddrIndex    = $(Combo3Out)
   set MediaValueIndex    = $(Combo4Out)


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

	Debug-Output "INF: Getting BusType"

   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

	Debug-Output "INF: Setting values"

   set MemBaseAddrValue  = *($(MemBaseValues), ~($(MemBaseList), $(MemoryAddrIndex)))
   set InterruptNumber   = *($(IrqValues), ~($(IrqList), $(IRQValueIndex)))
   set IOBaseAddrValue   = *($(IoBaseValues), ~($(IoBaseList), $(IOBaseAddrIndex)))
   set COMIoBaseAddrValue = *($(COMBaseValues), ~($(COMBaseList), $(COMBaseIndex)))
   set ComPortValue       = *($(COMPortList), ~($(COMBaseList), $(COMBaseIndex)))
	set MediaNumber        = *($(MediaValues), ~($(MediaList),$(MediaValueIndex)))
   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

	Debug-Output "INF: Verify Warning..."

;   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),"XJEM3288"}}
	
		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)
	; TES FIXED
   ;set Option          = "XJEM3288"

   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 = +

	Ifstr(i) $(Option) == CC10BT

	   Debug-Output "INF: Writing CC10BT"
		Set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusInterfaceType)},+
	                    {CardType,$(NoTitle),$(!REG_VT_DWORD),0},+
							  {MediaType,$(NoTitle),$(!REG_VT_DWORD),$(MediaNumber)},+
							  {BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNumber)},+
							  {InterruptNumber,$(NoTitle),$(!REG_VT_DWORD),$(InterruptNumber)},+
							  {IoBaseAddress,$(NoTitle),$(!REG_VT_DWORD),$(IOBaseAddrValue)},+
							  {IoLength,$(NoTitle),$(!REG_VT_DWORD),16},+
							  {PCCARDAttributeMemoryAddress,$(NoTitle),$(!REG_VT_DWORD),$(MemBaseAddrValue)},+
							  {PCCARDAttributeMemorySize,$(NoTitle),$(!REG_VT_DWORD),4096},+
							  {PCCARDAttributeMemoryOffset,$(NoTitle),$(!REG_VT_DWORD),0},+
							  {Pcmcia,$(NoTitle),$(!REG_VT_DWORD),1}}

	Else

	   Debug-Output "INF: Writing XJEM3288"

		Set NewValueList = {{BusType,$(NoTitle),$(!REG_VT_DWORD),$(BusInterfaceType)},+
	                    {CardType,$(NoTitle),$(!REG_VT_DWORD),1},+
							  {MediaType,$(NoTitle),$(!REG_VT_DWORD),$(MediaNumber)},+
							  {BusNumber,$(NoTitle),$(!REG_VT_DWORD),$(BusNumber)},+
							  {InterruptNumber,$(NoTitle),$(!REG_VT_DWORD),$(InterruptNumber)},+
							  {IoBaseAddress,$(NoTitle),$(!REG_VT_DWORD),$(COMIoBaseAddrValue)},+
							  {IoLength,$(NoTitle),$(!REG_VT_DWORD),8},+
							  {IoBaseAddress_1,$(NoTitle),$(!REG_VT_DWORD),$(IOBaseAddrValue)},+
							  {IoLength_1,$(NoTitle),$(!REG_VT_DWORD),16},+
							  {PCCARDAttributeMemoryAddress,$(NoTitle),$(!REG_VT_DWORD),$(MemBaseAddrValue)},+
							  {PCCARDAttributeMemorySize,$(NoTitle),$(!REG_VT_DWORD),4096},+
							  {PCCARDAttributeMemoryOffset,$(NoTitle),$(!REG_VT_DWORD),0},+
							  {Pcmcia,$(NoTitle),$(!REG_VT_DWORD),1},+
							  {ModemFunction,$(NoTitle),$(!REG_VT_DWORD),1}}
	Endif

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

   ;
   ; add the comm port info to the SYSTEM\CurrentControlSet\Services\Serial\Parameters section of the registry
   ; We no longer have to do the following, Bob took care of this with the
	; new pcmcia.sys driver for NT40 (is in the post beta 2)
	;

;   Ifcontains(i) $(Option) in {"XJEM3288"}
;		Ifstr(i) $(ComPortValue) != "None"
;			OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters\SerialMhz" $(MAXIMUM_ALLOWED) MyNewSerialHandle
;			Ifstr $(MyNewSerialHandle) == $(KeyNull)
;				OpenRegKey $(!REG_H_LOCAL) "" "SYSTEM\CurrentControlSet\Services\Serial\Parameters" $(MAXIMUM_ALLOWED) SerialKey
;				CreateRegKey $(SerialKey) {"SerialMhz",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
;				                 {Interrupt, $(NoTitle),$(!REG_VT_DWORD), $(InterruptNumber)},+	; Interrupt for MHZ modem
;				                 {PortAddress, $(NoTitle),$(!REG_VT_DWORD), $(COMIoBaseAddrValue)}}	; I/O Base address for 
;	      Shell  $(UtilityInf), AddValueList, $(MyNewSerialHandle), $(NewValueList)
;			CloseRegKey $(MyNewSerialHandle)
;
;			;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) {"SerialMhz",$(NoTitle),$(!REG_VT_SZ),$(ComPortValue)}
;			CloseRegKey $(MyNewSerialHandle)
;
;			; 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) "SerialMhz"
;			CloseRegKey $(MyNewSerialHandle)
;
;			OpenRegKey $(!REG_H_LOCAL) "" "HARDWARE\DEVICEMAP\SERIALCOMM" $(MAXIMUM_ALLOWED) MyNewSerialHandle
;			DeleteRegValue $(MyNewSerialHandle) "SerialMhz"
;         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
		OpenRegKey $(!REG_H_LOCAL) "" $(PCMCIADatabaseKeyName)"\Megahertz" $(MAXIMUM_ALLOWED) PCMCIADatabaseMegahertzKey

		Ifstr $(PCMCIADatabaseMegahertzKey) != $(NULL)
			Debug-Output "INF: Removing Megahertz Key..."
			; 
			;  Delete sub-tree if it was found
			;
			CloseRegKey $(PCMCIADatabaseMegahertzKey)
			DeleteRegTree $(PCMCIADatabaseKey) "Megahertz"
		Endif

		Debug-Output "INF: Creating Megahertz KEY"

		CreateRegKey $(PCMCIADatabaseKey) {"Megahertz", 0, 0} "" $(MAXIMUM_ALLOWED) "" PCMCIADatabaseMegahertzKey

		Debug-Output "INF: Adding Megahertz Keys..."
		; Do the Modem+Ethernet Cards ----------------------------------------------------------------------------------

		CreateRegKey $(PCMCIADatabaseMegahertzKey) {"CC/XJEM3288", 0, 0} "" $(MAXIMUM_ALLOWED) 0 PCMCIADatabaseMhzKey
		SetRegValue $(PCMCIADatabaseMhzKey) {Driver, 0, $(!REG_VT_SZ),"mhzc9x"}
		SetRegValue $(PCMCIADatabaseMhzKey) {AttributeMemorySize, 0, $(!REG_VT_DWORD),4096}
		SetRegValue $(PCMCIADatabaseMhzKey) {DeviceType, 0, $(!REG_VT_SZ),"NET"}
		CloseRegKey $(PCMCIADatabaseMhzKey)

		CreateRegKey $(PCMCIADatabaseMegahertzKey) {"XJEM1144/CCEM1144", 0, 0} "" $(MAXIMUM_ALLOWED) 0 PCMCIADatabaseMhzKey
		SetRegValue $(PCMCIADatabaseMhzKey) {Driver, 0, $(!REG_VT_SZ),"mhzc9x"}
		SetRegValue $(PCMCIADatabaseMhzKey) {AttributeMemorySize, 0, $(!REG_VT_DWORD),4096}
		SetRegValue $(PCMCIADatabaseMhzKey) {DeviceType, 0, $(!REG_VT_SZ),"NET"}
		CloseRegKey $(PCMCIADatabaseMhzKey)

		CreateRegKey $(PCMCIADatabaseMegahertzKey) {"EM1144-T", 0, 0} "" $(MAXIMUM_ALLOWED) 0 PCMCIADatabaseMhzKey
		SetRegValue $(PCMCIADatabaseMhzKey) {Driver, 0, $(!REG_VT_SZ),"mhzc9x"}
		SetRegValue $(PCMCIADatabaseMhzKey) {AttributeMemorySize, 0, $(!REG_VT_DWORD),4096}
		SetRegValue $(PCMCIADatabaseMhzKey) {DeviceType, 0, $(!REG_VT_SZ),"NET"}
		CloseRegKey $(PCMCIADatabaseMhzKey)

		CreateRegKey $(PCMCIADatabaseMegahertzKey) {"EM1144T", 0, 0} "" $(MAXIMUM_ALLOWED) 0 PCMCIADatabaseMhzKey
		SetRegValue $(PCMCIADatabaseMhzKey) {Driver, 0, $(!REG_VT_SZ),"mhzc9x"}
		SetRegValue $(PCMCIADatabaseMhzKey) {AttributeMemorySize, 0, $(!REG_VT_DWORD),4096}
		SetRegValue $(PCMCIADatabaseMhzKey) {DeviceType, 0, $(!REG_VT_SZ),"NET"}
		CloseRegKey $(PCMCIADatabaseMhzKey)

		CreateRegKey $(PCMCIADatabaseMegahertzKey) {"CC10BT/2", 0, 0} "" $(MAXIMUM_ALLOWED) 0 PCMCIADatabaseMhzKey
		SetRegValue $(PCMCIADatabaseMhzKey) {Driver, 0, $(!REG_VT_SZ),"mhzc9x"}
		SetRegValue $(PCMCIADatabaseMhzKey) {AttributeMemorySize, 0, $(!REG_VT_DWORD),4096}
		SetRegValue $(PCMCIADatabaseMhzKey) {DeviceType, 0, $(!REG_VT_SZ),"NET"}
		CloseRegKey $(PCMCIADatabaseMhzKey)


		CloseRegKey $(PCMCIADatabaseMegahertzKey)
		CloseRegKey $(PCMCIADatabaseKey)
   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

   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

   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-MHZ $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
;      AddSectionFilesToCopyList Files-MSOFT $(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-MHZ $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
;   AddSectionFilesToCopyList Files-MSOFT $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
   AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)
   AddSectionFilesToCopyList Files-Dll $(SrcDir) $(!STF_WINDOWSSYSPATH)
	AddSectionFilesToCopyList Files-Modem $(SrcDir) $(!STF_WINDOWSSYSPATH)\ras

   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
