[Identification]
    OptionType = NetAdapter
[PlatformsSupported]
    ISA
    EISA
		PCI
[Options]
		DigiSyncFR
[FileConstants]
ParamInf        = "NCPARAM.INF"
UtilityInf      = "UTILITY.INF"
subroutineinf   = "SUBROUTN.INF"
SoftwareType    = "driver"
Exit_Code       = 0
NetEventDLL     = "%SystemRoot%\System32\netevent.dll"
IoLogMsgDLL     = "%SystemRoot%\System32\IoLogMsg.dll"
Manufacturer    = "DigiBoard"
ProductMajorVersion     = "3"
ProductMinorVersion     = "51"
ProductVersion  = $(ProductMajorVersion)"."$(ProductMinorVersion)

ErrorControlValue = 1
DigiSupport = "Frame Relay"
DigiNumPorts = 2
;
DidIncrement = $(FALSE)

; Digi SXB driver Software parameters
sxbProductSoftwareName				= "DigiSxb"
sxbProductSoftwareImagePath		= "%SystemRoot%\System32\drivers\DigiSxb.sys"
sxbNetRuleSoftwareType     		= "DigiSxbSys DigiSxbDriver"
sxbProductServiceName					= "DigiSxb"
sxbNetRuleSoftwareUse      		= $(SoftwareType)
sxbNetRuleSoftwareBindForm 		= """"DigiSxbDriver""" yes no container"
sxbNetRuleSoftwareClass    		= {"DigiSxbDriver basic"}
sxbNetRuleSoftwareBindable		= {"DigiSxbDriver DigiSxbAdapter non exclusive 100"}
sxbProductSoftwareTitle				= "Digi SyncPort SXB Driver"
sxbProductSoftwareDescription	= "Digi SyncPort SXB Driver"
sxbSoftwareRefCount						= 0
sxbNetRuleInfOption        		= "DigiSyncFR"

sxbProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(sxbProductSoftwareName)"\CurrentVersion"

sxbTypeSupported        = 7
sxbEventFile = $(IoLogMsgDLL)";"$(sxbProductSoftwareImagePath)
sxbKeyProductHdwDriver  = ""
sxbGroup             = "NDIS"
sxbServiceFacility   = "Facility0"
sxbdevwans           = "/dev/wans" 
sxbWANS              = "WANS"
sxbNetworkAddress    = "53-52-43-44-47-32"
sxbSoftwareHiddenDriver = 1

; Digi Adapter NT NetCard install
AdapterHardwareName = "DigiSxb"
AdapterHardwareTitle       = "Digi SyncPort Adapter"
AdapterHardwareDescription = "Digi SyncPort Adapter"
AdapterNetRuleType         = "DigiSxb DigiSxbAdapter"
AdapterNetRuleBindForm     = " yes yes container"
AdapterNetRuleClass        = {"DigiSxbAdapter basic"}
AdapterNetRulesInfOption   =  "DigiSyncFR"
AdapterNetworkAddress = "44-49-47-49-30-31"
AdapterBiosImagePathISA  = "SxbBios.bin"
AdapterSXBImagePathISA   = "SxbFep.bin"
AdapterBiosImagePathPCI  = "SxbBios.pci"
AdapterSXBImagePathPCI   = "SxbFep.pci"
AdapterProductName    =  "DigiSxb"
AdapterInterruptNumber = 15
AdapterIOBaseAddress   = 808
AdapterMemoryAddress   = 851968
AdapterWindowSize      = 32768 

; Digi SXB Hardware parameters
ProductHardwareName     = "DigiSxb"
ProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(FRProductSoftwareName)"\CurrentVersion"
ParamKeyName    = $(!NTN_ServiceBase)"\"$(ProductHardwareName)"\Parameters"

; Digi Frame Relay driver software parameters
FRProductSoftwareName     = "DigiFr"
FRProductServiceName     = "DigiFr"
FRProductSoftwareTitle    = "Digi Frame Relay Driver"
FRProductSoftwareDescription    = "Digi Frame Relay Driver"
FRProductSoftwareImagePath = "%SystemRoot%\System32\drivers\DigiFr.sys"
FRNetRuleSoftwareType     = "DigiFrSys ndisDriver DigiFrDriver"
FRNetRuleSoftwareUse      = $(SoftwareType)
FRNetRuleSoftwareBindForm = """"DigiFrDriver""" yes no container"
FRNetRuleSoftwareClass    = {"DigiFrDriver basic"}
FRNetRuleSoftwareBindable = {"DigiFrDriver DigiFrAdapter non exclusive 100"}
FRSoftwareRefCount     = 0
FRNetRuleInfOption        =  "DigiSyncFR"
FRTypeSupported        = 7
FREventFile = $(IoLogMsgDLL)";"$(FRProductSoftwareImagePath)
FRGroup                = "NDIS"
FRProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(FRProductSoftwareName)"\CurrentVersion"
FRSoftwareHiddenDriver = 1

FRVirtualAdapterName = "DigiFr"
FRVirtualAdapterDescription = "Digi FR Virtual Adapter"
FRVirtualAdapterNetRuleType         = "DigiFr DigiFrAdapter"
FRVirtualAdapterNetRuleBindForm     = " yes yes container"
FRVirtualAdapterNetRuleClass        = {"DigiFrAdapter basic"}
FRVirtualAdapterBusType         = 5 
FRVirtualAdapterBusNumber       = 0

[GeneralConstants]
from      = ""
to        = ""
ExitCodeOk     = 0
ExitCodeCancel = 1
ExitCodeFatal  = 2
KeyNull         = ""
MAXIMUM_ALLOWED   = 33554432
RegistryErrorIndex = NO_ERROR
KeyProduct      = ""
KeyParameters   = ""
TRUE            = 1
FALSE           = 0
NoTitle            = 0
ExitState   = "Active"
OldVersionExisted = $(FALSE)
DriverPath      = $(!STF_NTPATH)\drivers

[UiVars]
    from      = ""
    to        = ""
    !STF_DISPLAYDEBUGOUTPUT = 0
    !STF_NTDRIVE        = ""
    !STF_NTPATH         = ""
    !STF_WINDOWSPATH    = "" ? $(!LIBHANDLE) GetWindowsNtDir
    !STF_WINDOWSSYSPATH = "" ? $(!LIBHANDLE) GetWindowsNtSysDir
    DriverPath      = $(!STF_NTPATH)"\drivers"

[DebugOptions]
    !DebugOutputControl = 0
    TraceConfig = 0
[date]
    Now = {} ? $(!LIBHANDLE) GetSystemDate
[Identify]
    read-syms Identification
    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)
    Return $(Status) $(Identifier) $(Media)
[ReturnOptions]
    set Status        = STATUS_FAILED
    set OptionList     = {}
    set OptionTextList = {}
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
        ifstr(i) $($1) == ""
           goto returnoptions
        endif
        set PlatformList = ^(PlatformsSupported, 1)
        Ifcontains(i) $($1) in $(PlatformList)
           goto returnoptions
        else
           set Status = STATUS_NOTSUPPORTED
           goto finish_ReturnOptions
        endif
    else
        set Status = STATUS_NOLANGUAGE
        goto finish_ReturnOptions
    endif
returnoptions = +
    set OptionList     = ^(Options, 1)
    set OptionTextList = ^(OptionsText$($0), 1)
    set Status         = STATUS_SUCCESSFUL
finish_ReturnOptions = +
    Return $(Status) $(OptionList) $(OptionTextList)
[InstallOption]
    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
        Return STATUS_NOLANGUAGE
    endif
    Debug-Output "OEMNADWD.INF: STF_CWDIR is: "$(!STF_CWDIR)
    Debug-Output "OEMNADWD.INF: STF_LANGUAGE is: "$(!STF_LANGUAGE)

    set OptionList = ^(Options, 1)
    Ifcontains(i) $(Option) NOT-IN $(OptionList)
			set Error = "The installation option is not supported"
			goto fatal
		endif

    set-subst LF = "\n"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms DialogConstants$(!STF_LANGUAGE)
    ifstr(i) $(!NTN_Origination) == "NCPA"
        set Continue = $(OK)
    endif
    read-syms FileConstants$(!STF_LANGUAGE)
    detect date
    set-title  $(Function$(Option)Title)
    set to   = Begin
    set from = Begin
    set CommonStatus = STATUS_SUCCESSFUL
    EndWait
Begin = +
    Ifstr(i) $(!NTN_InstallMode) == deinstall
        set StartLabel = removeadapter
    else-Ifstr(i) $(!NTN_InstallMode) == Update
        set StartLabel = UpgradeSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == bind
        set StartLabel = bindingadapter
    else-Ifstr(i) $(!NTN_InstallMode) == configure
        set CommonStatus = STATUS_REBOOT
        set StartLabel = configureadapter
        Ifstr(i) $(sxbProductKeyName) == $(!NTN_RegBase)
            Debug-Output "Cannot configure the Frame Relay driver software."
            Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "ShellCode error: cannot get an error string."
                goto ShellCodeError
            endif
            set Error = $($R0)
            set from = end
            set to = end
            goto nonfatalinfo
        endif
        Ifstr(i) $(FRProductKeyName) == $(!NTN_RegBase)
            Debug-Output "Cannot configure the Frame Relay driver software."
            Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "ShellCode error: cannot get an error string."
                goto ShellCodeError
            endif
            set Error = $($R0)
            set from = end
            set to = end
            goto nonfatalinfo
        endif
    else
        set StartLabel = installadapter
        set OEM_ABANDON_OPTIONS = {}
        set OEM_ABANDON_SOFTWARE = FALSE
        set OEM_ABANDON_ON = TRUE
    endif
    Debug-Output "OEMNADWD.INF: =================================================="
    Debug-Output "OEMNADWD.INF: STF_CWDIR is: "$(!STF_CWDIR)
    Debug-Output "OEMNADWD.INF: STF_LANGUAGE is: "$(!STF_LANGUAGE)
    Debug-Output "OEMNADWD.INF: Option is: "$(Option)
    Debug-Output "OEMNADWD.INF: !STF_NCDETECT  is: "$(!STF_NCDETECT)
    Debug-Output "OEMNADWD.INF: !STF_NCOPTION  is: "$(!STF_NCOPTION)
    Debug-Output "OEMNADWD.INF: !STF_NCDETCARD is: "$(!STF_NCDETCARD)
    Debug-Output "OEMNADWD.INF: !STF_NCDETINFO is: "$(!STF_NCDETINFO)
    Debug-Output "OEMNADWD.INF: =================================================="

		goto $(StartLabel)

installadapter = +
; don't install if X.25 present
		OpenRegKey $(!REG_H_LOCAL) "" "Software\DigiBoard\DigiX25"	$(MAXIMUM_ALLOWED) Key
		ifstr $(Key) != $(KeyNULL)
			set Error = "Frame Relay services cannot be installed while X.25 is installed"
			goto fatal
		endif

    OpenRegKey $(!REG_H_LOCAL) "" $(FRProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
        CloseRegKey $(KeyProduct)
        ifstr(i) !(NTN_RegBase) == $(FRProductKeyName)
           Shell $(UtilityInf), VerExistedDlg, $(FRProductSoftwareTitle),+
               $(ProductVersion)
           ifint $($ShellCode) != $(!SHELL_CODE_OK)
               Debug-Output "ShellCode error: cannot get an error string."
               goto ShellCodeError
           endif
           goto end
        else
			    OpenRegKey $(!REG_H_LOCAL) "" $(sxbProductKeyName) $(MAXIMUM_ALLOWED) sxbKeyProduct
  			  Ifstr $(sxbKeyProduct) != $(KeyNull)
      			CloseRegKey $(sxbKeyProduct)
          	Shell $(UtilityInf), CardExistedDlg
          	ifint $($ShellCode) != $(!SHELL_CODE_OK)
               Debug-Output "ShellCode error: cannot get an error string."
               goto ShellCodeError
          	endif
          	ifstr(i) $($R1) != "OK"
               Set CommonStatus = STATUS_USERCANCEL
               goto end
          	endif
					endif
      		CloseRegKey $(sxbKeyProduct)
          set OldVersionExisted = $(TRUE)
        endif
    endif

		ifint $(OldVersionExisted) == $(FALSE)
	    Debug-Output "Creating DigiSxb service"
			Shell $(UtilityInf), CreateService, $(sxbProductServiceName),$(sxbProductSoftwareTitle), +
						$(sxbProductSoftwareImagePath),"kernelautostart",$(sxbGroup),{},"",$(sxbEventFile),	+
						$(sxbTypeSupported), "",$(ErrorControlValue),$(sxbProductServiceName),"",""
    	
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
      	Debug-Output "ShellCode error."
        goto ShellCodeError
    	endif
			set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        goto fatalregistry
    	endif
    
	    Debug-Output "DigiSxb service created"

    	Set sxbSoftServiceKey      = $($R1)
    	Set sxbSoftParameterKey    = $($R2)
    	Set sxbSoftLinkageKey      = $($R3)

; // perfmon 
;    	CreateRegKey $(sxbSoftServiceKey) {Performance,$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" sxbPerfKey
;    	ifstr $(sxbPerfKey) == $(KeyNull)
;				goto fatalregistry
;			endif
;
;     set NewValueList =																											+
;	  			{	{Open,		$(NoTitle),$(!REG_VT_SZ),"OpenSxbPerformanceData"			},+
;	  				{Close,		$(NoTitle),$(!REG_VT_SZ),"CloseSxbPerformanceData"		},+
;	  				{Collect,	$(NoTitle),$(!REG_VT_SZ),"CollectSxbPerformanceData"	},+
;	  				{Library,	$(NoTitle),$(!REG_VT_SZ),"sxbperf.dll"								} +
;          }
;    
;    	Shell  $(UtilityInf), AddValueList, $(sxbPerfKey),$(NewValueList)
;    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
;     	goto ShellCodeError
;    	endif
;			set RegistryErrorIndex = $($R0)
;    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
;     	goto fatalregistry
;    	endif
;
; // perfmon 

   	SetRegValue $(sxbSoftParameterKey) {NetworkAddress,$(NoTitle),$(!REG_VT_SZ),$(sxbNetworkAddress)}

    	CreateRegKey $(sxbSoftParameterKey) {$(sxbServiceFacility),$(NoTitle),GenericClass} "" +
    							 $(MAXIMUM_ALLOWED) "" sxbServiceFacilityKey
    	
    	ifstr $(sxbServiceFacilityKey) == $(KeyNull)
      	OpenRegKey $(sxbSoftParameterKey) "" $(sxbServiceFacility) $(MAXIMUM_ALLOWED) sxbServiceFacilityKey
      	ifstr(i) $(sxbServiceFacilityKey) == $(KeyNull)
          Debug-Output "Unable to Open sxbServiceParametersKey"
          set RegistryErrorIndex = UNABLE_ACCESS_SOFTWARE_REG
          Debug-Output "Unable to Create or Open sxbServiceFacilityKey"
     			CloseRegKey $(sxbSoftServiceKey)
     			CloseRegKey $(sxbSoftParameterKey)
     			CloseRegKey $(sxbSoftLinkageKey)
          goto fatalregistry
       	endif
    	endif

    	set NewValueList =																				+
	  			{	{DevName,	$(NoTitle),$(!REG_VT_SZ),$(sxbdevwans)},+
            {Facility,$(NoTitle),$(!REG_VT_SZ),$(sxbWANS)}		+
          }
    
    	Shell  $(UtilityInf), AddValueList, $(sxbServiceFacilityKey),$(NewValueList)
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
     	  Debug-Output "ShellCode error: AddValueList FAILED! --"$(sxbServiceFacilityKey)
        goto ShellCodeError
    	endif
    
    	set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "Registry error: add value list."
        CloseRegKey $(sxbServiceFacilityKey)
     		CloseRegKey $(sxbSoftServiceKey)
     		CloseRegKey $(sxbSoftParameterKey)
     		CloseRegKey $(sxbSoftLinkageKey)
        goto fatalregistry
    	endif

    	FlushRegKey $(sxbServiceFacilityKey)
      FlushRegKey $(sxbSoftServiceKey)
      FlushRegKey $(sxbSoftParameterKey)
      FlushRegKey $(sxbSoftLinkageKey)
  
   		CloseRegKey $(sxbServiceFacilityKey)
      CloseRegKey $(sxbSoftServiceKey)
      CloseRegKey $(sxbSoftParameterKey)
      CloseRegKey $(sxbSoftLinkageKey)

	    Debug-Output "Creating DigiFr service"
			Shell $(UtilityInf), CreateService, $(FRProductServiceName),$(FRProductSoftwareTitle), +
						$(FRProductSoftwareImagePath),"kernel",$(FRGroup),{"DigiSxb"},"",$(FREventFile), +
						$(FRTypeSupported), "",$(ErrorControlValue),$(FRProductServiceName),"",""
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        goto ShellCodeError
    	endif
    	set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        goto fatalregistry
    	endif

 	    Debug-Output "DigiFr service created"
 	
 	  	Set FRSoftServiceKey      = $($R1)
    	Set FRSoftParameterKey    = $($R2)
    	Set FRSoftLinkageKey      = $($R3)

;			set NewValueList = +
;					{{DependOnService, $(NoTitle), $(!REG_VT_MULTI_SZ), {"DigiSxb"} }}
;			Shell  $(UtilityInf), AddValueList, $(FRSoftServiceKey), $(NewValueList)

	    set NewValueList = +
	        {{OtherDependencies, $(NoTitle), $(!REG_VT_MULTI_SZ), {"DigiSxb"} }}
	    Shell  $(UtilityInf), AddValueList, $(FRSoftLinkageKey), $(NewValueList)

;    	set NewValueList = 																															+
;	    		{{Group,						$(NoTitle),$(!REG_VT_SZ),				$(FRGroup)}							+
;	    		}
;
;    	Shell  $(UtilityInf), AddValueList, $(FRSoftServiceKey), $(NewValueList)
;    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
;        Debug-Output "ShellCode error: AddValueList FAILED!  --"$(FRSoftServiceKey)
;        goto ShellCodeError
;    	endif
;
;    	set RegistryErrorIndex = $($R0)
;    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
;        Debug-Output "Registry error: add value list."
;    		CloseRegKey $(FRSoftServiceKey)
;      	CloseRegKey $(FRSoftParameterKey)
;      	CloseRegKey $(FRSoftLinkageKey)
;        goto fatalregistry
; 	  	endif

    	FlushRegKey $(FRSoftServiceKey)
      FlushRegKey $(FRSoftParameterKey)
      FlushRegKey $(FRSoftLinkageKey)

    	CloseRegKey $(FRSoftServiceKey)
      CloseRegKey $(FRSoftParameterKey)
      CloseRegKey $(FRSoftLinkageKey)

		  Debug-Output "Creating DigiSxb software"
	    Shell $(UtilityInf), InstallSoftwareProduct $(Manufacturer) $(sxbProductSoftwareName) $(STF_CONTEXTINFNAME)
  	  ifint $($ShellCode) != $(!SHELL_CODE_OK)
  	      Debug-Output "ShellCode error."
  	      goto ShellCodeError
  		endif

      set OEM_ABANDON_SOFTWARE = TRUE

   		Set sxbSoftProductKey = $($R1)
   		Set sxbSoftNetRuleKey = $($R2)

    	set NewValueList =																															+
    		{	{SoftwareType,$(NoTitle),$(!REG_VT_SZ),		$(SoftwareType)},									+
        	{MajorVersion,$(NoTitle),$(!REG_VT_SZ),		$(ProductMajorVersion)},					+
        	{MinorVersion,$(NoTitle),$(!REG_VT_SZ),		$(ProductMinorVersion)},					+
        	{Title,				$(NoTitle),$(!REG_VT_SZ),		$(sxbProductSoftwareTitle)},			+
        	{Description,	$(NoTitle),$(!REG_VT_SZ),		$(sxbProductSoftwareDescription)},+
        	{ServiceName,	$(NoTitle),$(!REG_VT_SZ),		$(sxbProductServiceName)},				+
        	{hidden,			$(NoTitle),$(!REG_VT_DWORD),$(sxbSoftwareHiddenDriver)},			+
        	{InstallDate,	$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}, 										+
					{RefCount,		$(NoTitle),$(!REG_VT_DWORD),$(sxbSoftwareRefCount)}						+
				}

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

    	set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "Registry error: add value list."
        CloseRegKey $(sxbSoftProductKey)
        CloseRegKey $(sxbSoftNetRuleKey)
        goto fatalregistry
	    endif

			set sxbNetRuleInfNameSoftware = $(STF_CONTEXTINFNAME)

    	Shell $(UtilityInf), ReduceInfPath, $(sxbNetRuleInfNameSoftware)
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
    	    Debug-Output "ShellCode error: ReduceInfPath FAILED  -- "$(sxbNetRuleInfNameSoftware)
    	    goto ShellCodeError
   		endif
   
   		set sxbNetRuleInfNameSoftware = $($R0)

    	set NewValueList =																															+
	   		{	{type,			$(NoTitle),$(!REG_VT_SZ),				$(sxbNetRuleSoftwareType)},			+
          {use,				$(NoTitle),$(!REG_VT_SZ),				$(sxbNetRuleSoftwareUse)}, 			+
          {bindform,	$(NoTitle),$(!REG_VT_SZ),				$(sxbNetRuleSoftwareBindForm)}, +
          {class,			$(NoTitle),$(!REG_VT_MULTI_SZ),	$(sxbNetRuleSoftwareClass)}, 		+
          {bindable,	$(NoTitle),$(!REG_VT_MULTI_SZ),	$(sxbNetRuleSoftwareBindable)}, +
          {InfOption,	$(NoTitle),$(!REG_VT_SZ),				$(sxbNetRuleInfOption)} 				+
	    		{InfName,		$(NoTitle),$(!REG_VT_SZ),				$(sxbNetRuleInfNameSoftware)} 	+
	    	}

    	Shell  $(UtilityInf), AddValueList, $(sxbSoftNetRuleKey), $(NewValueList)
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
     	   Debug-Output "ShellCode error: AddValueList FAILED! --"$(sxbSoftNetRuleKey)
     	   goto ShellCodeError
    	endif
    
    	set RegistryErrorIndex = $($R0)
	    FlushRegKey $(sxbSoftProductKey)
 	  	FlushRegKey $(sxbSoftNetRuleKey)
    	CloseRegKey $(sxbSoftProductKey)
    	CloseRegKey $(sxbSoftNetRuleKey)
     	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
    	  Debug-Output "Registry error: add value list."
      	goto fatalregistry
    	endif

			Debug-Output "Creating DigiFr software"
			Shell $(UtilityInf), InstallSoftwareProduct $(Manufacturer) $(FRProductSoftwareName) $(STF_CONTEXTINFNAME)
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
      	 Debug-Output "ShellCode error."
       	 goto ShellCodeError
    	endif
    	Set FRSoftProductKey      = $($R1)
    	Set FRSoftNetRuleKey      = $($R2)

			set NewValueList =																															+
				{	{SoftwareType,$(NoTitle),$(!REG_VT_SZ),		$(SoftwareType)},									+
        	{MajorVersion,$(NoTitle),$(!REG_VT_SZ),		$(ProductMajorVersion)},					+
        	{MinorVersion,$(NoTitle),$(!REG_VT_SZ),		$(ProductMinorVersion)},					+
        	{Title,				$(NoTitle),$(!REG_VT_SZ),		$(FRProductSoftwareTitle)},				+
        	{Description,	$(NoTitle),$(!REG_VT_SZ),		$(FRProductSoftwareDescription)},	+
        	{ServiceName,	$(NoTitle),$(!REG_VT_SZ),		$(FRProductServiceName)},					+
        	{hidden,			$(NoTitle),$(!REG_VT_DWORD),$(FRSoftwareHiddenDriver)}, 			+
        	{InstallDate,	$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}, 										+
        	{Review,			$(NoTitle),$(!REG_VT_DWORD),$(TRUE)}, 												+
					{RefCount,		$(NoTitle),$(!REG_VT_DWORD),$(FRSoftwareRefCount)} 						+
				}

    	Shell  $(UtilityInf), AddValueList, $(FRSoftProductKey), $(NewValueList)
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error: AddValueList FAILED!  --"$(FRSoftProductKey)
        goto ShellCodeError
    	endif
    
    	set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "Registry error: add value list."
        CloseRegKey $(FRSoftProductKey)
        CloseRegKey $(FRSoftNetRuleKey)
        goto fatalregistry
    	endif

    	set FRNetRuleInfNameSoftware  =  $(STF_CONTEXTINFNAME)

    	Shell  $(UtilityInf), ReduceInfPath, $(FRNetRuleInfNameSoftware)
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
    	   Debug-Output "ShellCode error: ReduceInfPath FAILED  -- "$(FRNetRuleInfNameSoftware)
    	   goto ShellCodeError
    	endif

    	set FRNetRuleInfNameSoftware = $($R0)

    	set NewValueList =																															+
	   		{	{type,			$(NoTitle),$(!REG_VT_SZ),				$(FRNetRuleSoftwareType)},			+
          {use,				$(NoTitle),$(!REG_VT_SZ),				$(FRNetRuleSoftwareUse)}, 			+
          {bindform,	$(NoTitle),$(!REG_VT_SZ),				$(FRNetRuleSoftwareBindForm)}, 	+
          {class,			$(NoTitle),$(!REG_VT_MULTI_SZ),	$(FRNetRuleSoftwareClass)}, 		+
          {bindable,	$(NoTitle),$(!REG_VT_MULTI_SZ),	$(FRNetRuleSoftwareBindable)},	+
          {InfOption,	$(NoTitle),$(!REG_VT_SZ),				$(FRNetRuleInfOption)}, 				+
	   			{InfName,		$(NoTitle),$(!REG_VT_SZ),				$(FRNetRuleInfNameSoftware)} 		+
	   		}
			

    	Shell  $(UtilityInf), AddValueList, $(FRSoftNetRuleKey), $(NewValueList)
   		ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error: AddValueList FAILED! --"$(FRSoftNetRuleKey)
        goto ShellCodeError
    	endif
    
  	  set RegistryErrorIndex = $($R0)
	    FlushRegKey $(FRSoftProductKey)
  	  FlushRegKey $(FRSoftNetRuleKey)
  	  CloseRegKey $(FRSoftProductKey)
  	  CloseRegKey $(FRSoftNetRuleKey)
 
 	  	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	      Debug-Output "Registry error: add value list."
  	    goto fatalregistry
  	  endif


		endif

    ifstr(i) $(!STF_NCDETINFO) == {}
        Shell $(UtilityInf),GetBusTypeDialog,$(ProductHardwareDescription) $(BusInterfaceType) $(BusNumber)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error."
            goto ShellCodeError
        endif
        set BusInterfaceType = $($R1)
        set BusNumber = $($R2)
    else
        set BusInterfaceType = *($(!STF_NCDETINFO),5)
        set BusNumber = *($(!STF_NCDETINFO),6)
    endif

		ifstr $(BusInterfaceType) == 5
			set AdapterBiosImagePath = $(AdapterBiosImagePathPCI)
			set AdapterSXBImagePath  = $(AdapterSXBImagePathPCI)
		else
			set AdapterBiosImagePath = $(AdapterBiosImagePathISA)
			set AdapterSXBImagePath  = $(AdapterSXBImagePathISA)
		endif

	  Debug-Output "Creating DigiSxb adapter/service"
	  
	  Shell $(UtilityInf), AddHardwareComponent, $(AdapterHardwareName), $(STF_CONTEXTINFNAME), $(sxbProductKeyName)
    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 "Cannot add hardware component!"
        goto ShellCodeError
    endif

    set RegistryErrorIndex	 = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "Registry error: add hardware component"
        Debug-Output $(RegistryErrorIndex)
        CloseRegKey $($R1)
        CloseRegKey $($R2)
        CloseRegKey $($R3)
        goto fatalregistry
    endif
    
  	Debug-Output "DigiSxb adapter/service created"
   	
   	set AdapterKeyNetcard    = $($R1)
    set AdapterNetRulesKey   = $($R2)
    set AdapterKeyParameters = $($R3)
    set AdapterNumber        = $($R4)
    set AdapterServiceName   = $($R5)

    set NewValueList =																																						+
    	{	{ServiceName,	$(NoTitle),$(!REG_VT_SZ),		$(AdapterServiceName)},													+
		    {Manufacturer,$(NoTitle),$(!REG_VT_SZ),		$(Manufacturer)},																+
        {Title,				$(NoTitle),$(!REG_VT_SZ),		"["$(AdapterNumber)"] "$(AdapterHardwareTitle)},+
        {Description,	$(NoTitle),$(!REG_VT_SZ),		$(AdapterHardwareDescription)},									+
        {ProductName,	$(NoTitle),$(!REG_VT_SZ),		$(AdapterHardwareName)},												+
        {InstallDate,	$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}																		+
      }

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

    shell $(UtilityInf), IncrementRefCount, $(FRProductKeyName)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error."
        goto ShellCodeError
    endif

    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "AddAdapter: IncrementRefCount returned "$(RegistryErrorIndex)
    endif
 		set DidIncrement = $(TRUE)

    set AdapterNetRuleInfName = $(STF_CONTEXTINFNAME)
    Shell  $(UtilityInf), ReduceInfPath, $(AdapterNetRuleInfName)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error: ReduceInfPath FAILED  -- "$(AdapterNetRuleInfName)
        goto ShellCodeError
    endif
    set AdapterNetRuleInfName = $($R0)

    set AdapterNameNumber = $(AdapterServiceName)
    set TempProdName = """"$(AdapterHardwareName)$(AdapterNumber)""""
    set TempBindForm = $(TempProdName)$(AdapterNetRuleBindForm)

    set NewValueList = 																														+
    	{	{InfName,		$(NoTitle),$(!REG_VT_SZ),				$(AdapterNetRuleInfName)},		+
        {type,			$(NoTitle),$(!REG_VT_SZ),				$(AdapterNetRuleType)},				+
        {bindform,	$(NoTitle),$(!REG_VT_SZ),				$(TempBindForm)}, 						+
        {class,			$(NoTitle),$(!REG_VT_MULTI_SZ),	$(AdapterNetRuleClass)}, 			+
        {InfOption,	$(NoTitle),$(!REG_VT_SZ),				$(AdapterNetRulesInfOption)} 	+
      }

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

    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "Resgitry error: add value list."
        CloseRegKey $(AdapterKeyNetcard)
        CloseRegKey $(AdapterKeyParameters)
        CloseRegKey $(AdapterNetRulesKey)
        goto fatalregistry
    endif

    FlushRegKey $(AdapterKeyNetcard)
    FlushRegKey $(AdapterNetRulesKey)
    CloseRegKey $(AdapterKeyNetcard)
    CloseRegKey $(AdapterNetRulesKey)

    set NewValueList =																																		+
    	{	{MemoryMappedBaseAddress,	$(NoTitle),$(!REG_VT_DWORD),$(AdapterMemoryAddress)},		+
    		{IOBaseAddress,						$(NoTitle),$(!REG_VT_DWORD),$(AdapterIOBaseAddress)},		+
    		{InterruptNumber,					$(NoTitle),$(!REG_VT_DWORD),$(AdapterInterruptNumber)},	+
    		{HdwDeviceName,						$(NoTitle),$(!REG_VT_SZ),		$(AdapterProductName)},			+
    		{SXBImagePath,						$(NoTitle),$(!REG_VT_SZ),		$(AdapterSXBImagePath)},		+
    		{BiosImagePath,						$(NoTitle),$(!REG_VT_SZ),		$(AdapterBiosImagePath)},		+
    		{NetworkAddress,					$(NoTitle),$(!REG_VT_SZ),		$(AdapterNetworkAddress)},	+
    		{WindowSize,							$(NoTitle),$(!REG_VT_DWORD),$(AdapterWindowSize)},			+
    		{BusNumber,								$(NoTitle),$(!REG_VT_DWORD),$(BusNumber)},				+
    		{BusType,									$(NoTitle),$(!REG_VT_DWORD),$(BusInterfaceType)},					+
    		{ServiceName,							$(NoTitle),$(!REG_VT_SZ),		$(AdapterServiceName)},			+
    		{DigiSupport,							$(NoTitle),$(!REG_VT_SZ),		$(DigiSupport)},						+
				{DigiNumPorts,						$(NoTitle),$(!REG_VT_DWORD),$(DigiNumPorts)}						+
      }

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

    FlushRegKey $(AdapterKeyParameters)
		set ParamKey = $(AdapterKeyParameters)

    goto adapteroptions

configureadapter = +
    Debug-Output "OEMNADX.INF: Configure Adapter"	
    Ifstr $(!NTN_RegBase) != $(KeyNull)
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) SoftwareKey
        Ifstr $(SoftwareKey) == $(KeyNull)
          Debug-Output "Unable to open "$(!NTN_RegBase)" key!!!!"
          goto ShellCodeError
        Else
        	GetRegValue $(SoftwareKey), "ServiceName", ServiceNameList
          set AdapterNameNumber = *($(ServiceNameList),4)
          CloseRegKey $(SoftwareKey)
        Endif
    Endif

; set-up DigiSxb#\Paramters\FR\PVC(1-n)
		OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$(AdapterNameNumber)"\Parameters" $(MAXIMUM_ALLOWED) ParamKey

		Shell "" SetUpForConfig, $(ParamKey), "A", $(AdapterNameNumber)
		Shell "" SetUpForConfig, $(ParamKey), "B", $(AdapterNameNumber)

adapteroptions = +

    ifint $(OldVersionExisted) == $(FALSE)
        ifstr(i) $(!NTN_InstallMode) == "install"
           Ifstr(i) $(DoCopy) == "YES"
 badpath = +
              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)
                      Debug-Output"Shell code error: DoAskSource"
                      goto ShellCodeError
                  endif
                  set Error = $($R0)
                  Goto fatal
              Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
                  set CommonStatus = STATUS_USERCANCEL
                  Goto abandon
              Endif
              Set SrcDir = $($R1)
					    LibraryProcedure STATUS, $(!LIBHANDLE),CheckFileExistance $(SrcDir)"\digiwan.dl_"
							ifstr(i) $(STATUS) != YES
								goto badpath
							endif
           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

; perfmon
;					 StartDetachedProcess ExitCode ""  "" $(!STF_WINDOWSSYSPATH)"\lodctr.exe" $(SrcDir)"\sxbperf.ini"
; perfmon

        endif
    endif
    LoadLibrary "x" $(!STF_CWDDIR)setupdll.dll !LIBHANDLE
    Debug-Output "OEMNADX.INF: LIBHANDLE is "$(!LIBHANDLE)

    LibraryProcedure STATUS, $(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\digiwan.dll"
    ifstr(i) $(STATUS) != YES
      set Error = ""
      goto fatal
		endif

    Debug-Output "OEMNADX.INF: RegBase "$(!NTN_RegBase)
    LoadLibrary "x" $(!STF_CWDDIR)DIGIWAN.dll DIGIHANDLE
    Debug-Output "OEMNADX.INF: DIGIHANDLE is "$(DIGIHANDLE)
    Shell $(subroutineinf) PopBillboard
    LibraryProcedure Result $(DIGIHANDLE) DigiEntry $(AdapterNameNumber) $(!STF_HWND)
    Debug-Output "OEMNADX.INF: Dialog Result is "$(Result)

    FreeLibrary $(DIGIHANDLE)

    set JumpLabel = Successful

    Ifstr(i) $(Result) == "OK"
			Shell "" CreateVirtualAdapters $(ParamKey) "A" $(AdapterNameNumber)	"1"
      set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        goto fatalregistry
    	endif
			ifstr $($R1) == $(TRUE)
		    set CommonStatus = STATUS_SUCCESSFUL
			endif

			Shell "" CreateVirtualAdapters $(ParamKey) "B" $(AdapterNameNumber)	"2"
      set RegistryErrorIndex = $($R0)
   		Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        goto fatalregistry
    	endif
			ifstr $($R1) == $(TRUE)
		    set CommonStatus = STATUS_SUCCESSFUL
			endif

    else-Ifstr(i) $(Result) == "Cancel"
      ifstr(i) $(!NTN_InstallMode) == install
				set JumpLabel = fatal
			else
    		set JumpLabel = cancel
			endif
    else
	    set JumpLabel = fatal
    endif

		Shell "" CleanUpAfterConfig	$(ParamKey) "A"
		Shell "" CleanUpAfterConfig	$(ParamKey) "B"
		CloseRegKey $(ParamKey)

		goto $(JumpLabel)

bindingadapter =+
;	OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\DigiFr" $(MAXIMUM_ALLOWED) ServiceKey
;	set NewValueList = +
;			{{DependOnService, $(NoTitle), $(!REG_VT_MULTI_SZ), {"DigiSxb"} }}
;	Shell  $(UtilityInf), AddValueList, $(ServiceKey), $(NewValueList)
;	CloseRegKey $(ServiceKey)

	set AdapterNameList = {}
	set useTCPIPList = {}
	set useIPXList = {}
	set useEthernetList = {}

	set NetworkCardKeyName = $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards"

	OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) IE_KeyNetcards
	ifstr(i) $(IE_KeyNetcards) != ""    
		EnumRegKey $(IE_KeyNetcards) IE_KeyNameList
		ForListDo $(IE_KeyNameList)
			OpenRegKey $(IE_KeyNetcards) "" *($($),1) $(MAXIMUM_ALLOWED) NetworkCardKey
	    Ifstr(i) $(NetworkCardKey) != $(KeyNull)
				GetRegValue $(NetworkCardKey),"ProductName", ProductNameInfo
				set ProductName = *($(ProductNameInfo), 4)
	      Debug-Output "   ProductName = "$(ProductName)
	      ifstr(i) $(ProductName) != $(FRVirtualAdapterName)
	        goto nextnetcard
	      endif
	      GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
	      set ServiceName = *($(ServiceNameInfo), 4)
	      Debug-Output "   ServiceName = "$(ServiceName)
	      OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\"$(ServiceName)"\Parameters" $(MAXIMUM_ALLOWED) VAServiceKey
 
 				GetRegValue $(VAServiceKey),"TCPIP", TCPIPInfo
 				GetRegValue $(VAServiceKey),"IPX", IPXInfo
			 	GetRegValue $(VAServiceKey),"Ethernet", EthernetInfo

				set AdapterNameList	= >($(AdapterNameList), $(ServiceName))
				set useTCPIPList = >($(useTCPIPList), *($(TCPIPInfo), 4))
				set useIPXList = >($(useIPXList), *($(IPXInfo), 4))
				set useEthernetList = >($(useEthernetList), *($(EthernetInfo), 4))
								
				CloseRegKey $(VAServiceKey)
			endif
	nextnetcard = +
	  EndForListDo
	endif

	ForListDo $(AdapterNameList)

		set Transport = { "Tcpip", "Nbf", "NwlnkIpx", "AppleTalk", "DLC", "NetBT" }
		ForListDo $(Transport)
			OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\"$($)"\Linkage" $(MAXIMUM_ALLOWED) BindKey
	 		ifstr $(BindKey) != $(KeyNull)
	 			GetRegValue $(BindKey),"Bind", $($)BindList

				OpenRegKey $(BindKey) "" "Disabled" $(MAXIMUM_ALLOWED) DisabledBindKey
		 		ifstr $(DisabledBindKey) != $(KeyNull)
			 		GetRegValue $(DisabledBindKey),"Bind", $($)DisabledBindList
					CloseRegKey $(DisabledBindKey)
				endif

				CloseRegKey $(BindKey)
			endif

		EndForListDo
  
		set useTCPIP = *($(useTCPIPList),$(#))
		set useIPX = *($(useIPXList),$(#))
		set useEthernet = *($(useEthernetList),$(#))
		set AdapterName = $($)

		set Protocol = { "TCPIP", "Ethernet", "IPX", "Ethernet", "Ethernet", "TCPIP" }
		ForListDo $(Protocol)
			set Service =  *($(Transport), $(#))

			ifint	$(use$($)) == $(FALSE)
				set BindList = $($(Service)BindList)
				set Action = "deactivate"
			else
				set BindList = $($(Service)DisabledBindList)
				set Action = "activate"
			endif

			set BindList = *($(BindList), 4)

			ForListDo $(BindList)
				split-string $($) "\" BindSplit
								
				ifstr *($(BindSplit), 4) == $(AdapterName)
					Shell $(UtilityInf) ToggleBinding, $(Service), $(#), $(Action)
				endif
			EndForListDo
	
		EndForListDo

	EndForListDo

  goto end

removeadapter = +
    Ifstr $(!NTN_RegBase) != $(KeyNull)
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_RegBase) $(MAXIMUM_ALLOWED) SoftwareKey
        Ifstr $(SoftwareKey) == $(KeyNull)
          Debug-Output "Unable to open "$(!NTN_RegBase)" key!!!!"
          goto ShellCodeError
        Else
        	GetRegValue $(SoftwareKey), "ServiceName", ServiceNameList
          set AdapterNameNumber = *($(ServiceNameList),4)
          CloseRegKey $(SoftwareKey)
        Endif
    Endif

		Shell	"", RemoveVirtualAdapters, "A", $(AdapterNameNumber)
		Shell	"", RemoveVirtualAdapters, "B", $(AdapterNameNumber)

    Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
        $(sxbProductSoftwareName), $(!NTN_RegBase)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error"
        goto ShellCodeError
    endif
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        goto fatalregistry
    endif

    shell $(UtilityInf), DecrementRefCount, $(FRProductKeyName)
    Debug-Output "OEMNADX.INF: DecrementRefCount return value = "$($R0)
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $($R0) != NO_ERROR
        Debug-Output "OEMNADX.INF: DecrementRefCount != NO_ERROR"
    Endif

    shell $(UtilityInf), IsRefCountEqualZero, $(FRProductKeyName)
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $($R0) != NO_ERROR
        Debug-Output "UTILITY.INF: [RemoveAdapter] IsRefCountEqualZero returned "$($R0)
    endif
    Ifint $($R1) == $(TRUE)
	    Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
        $(FRProductSoftwareName), TRUE
    	ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error"
        goto ShellCodeError
   		endif
   		set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        goto fatalregistry
    	endif

; perfmon
;			StartDetachedProcess ExitCode ""  "" $(!STF_WINDOWSSYSPATH)"\unlodctr.exe" DigiSxb
; perfmon
      install RemoveFiles
    endif
removeadapterExit = +
    Debug-Output "OEMNADX.INF: Exiting removeadapter"
    goto end
UpgradeSoftware = +
    goto end
cancel = +
    set CommonStatus = STATUS_USERCANCEL
    goto end
Successful = +
    goto end
abandon = +
    ForListDo $(OEM_ABANDON_OPTIONS)
        Shell $(UtilityInf), RemoveHardwareComponent, $(Manufacturer), +
            $(sxbProductSoftwareName), $($)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            goto fatalregistry
        endif
    EndForListDo

		ifint $(DidIncrement) == $(TRUE)
			shell $(UtilityInf), DecrementRefCount, $(FRProductKeyName)
			Debug-Output "OEMNADX.INF: DecrementRefCount return value = "$($R0)
		  Ifstr(i) $($R0) != NO_ERROR
		  	Debug-Output "OEMNADX.INF: DecrementRefCount != NO_ERROR"
			Endif
		endif

    shell $(UtilityInf), IsRefCountEqualZero, $(FRProductKeyName)
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $($R0) != NO_ERROR
	  	goto ShellCodeError
    endif

		set DeleteFiles = $(FALSE)
    Ifint $($R1) == $(TRUE)
			set DeleteFiles = $(TRUE)
		endif

    Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), $(FRProductSoftwareName), TRUE
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "ShellCode error"
	    goto ShellCodeError
    endif
    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
    	goto fatalregistry
    endif

		ifstr $(DeleteFiles) == $(TRUE)
; perfmon
;			StartDetachedProcess ExitCode ""  "" $(!STF_WINDOWSSYSPATH)"\unlodctr.exe" DigiSxb
; perfmon
	    install RemoveFiles
		endif

    Ifstr(i) $(OEM_ABANDON_SOFTWARE) == TRUE
        Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), +
            $(sxbProductSoftwareName), TRUE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "ShellCode error"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            goto fatalregistry
        endif
    endif
    goto end
warning = +
    Shell $(subroutineinf) 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
nonfatalinfo = +
    Set CommonStatus = STATUS_USERCANCEL
    Set Severity = STATUS
    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 $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), $(Severity), $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    ifstr(i) $($R1) == "OK"
        goto $(from)
    else
        goto "end"
    endif
fatalregistry = +
    Shell $(UtilityInf) RegistryErrorString $(RegistryErrorIndex)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    set Error = $($R0)
    goto fatal
fataldetect = +
    Shell $(UtilityInf),RegistryErrorString,CANNOT_DETECT
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "ShellCode error: cannot get an error string."
        goto ShellCodeError
    endif
    set Error = $($R0)
    Goto fatal
fatal = +
    ifstr(i) $(Error) == ""
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto ShellCodeError
        endif
        set Error = $($R0)
    endif
    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Error)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto ShellCodeError
    endif
    goto setfailed
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
    ifstr(i) $(OEM_ABANDON_ON) == TRUE
        set OEM_ABANDON_ON = FALSE
        goto abandon
    endif
    goto end
end = +
    goto term
term = +
    Return $(CommonStatus)

[RemoveFiles]
   Debug-Output "******************Entering [RemoveFiles]******************"
   set RemoveList = {}
   set RenameList = {}
   OpenRegKey $(!REG_H_LOCAL) "" $(sxbProductKeyName) +
              $(MAXIMUM_ALLOWED) sxbKeyProductHdwDriver
   ifstr $(sxbKeyProductHdwDriver) == $(KeyNull)
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(sxbProductServiceName)".sys")
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(AdapterSXBImagePathISA))
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(AdapterBiosImagePathISA))
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(AdapterSXBImagePathPCI))
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(AdapterBiosImagePathPCI))

; perfmon
;     set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\sxbperf.dll")
; perfmon

   endif
   CloseRegKey $(sxbKeyProductHdwDriver)

   OpenRegKey $(!REG_H_LOCAL) "" $(FRProductKeyName) +
              $(MAXIMUM_ALLOWED) KeyProduct
   ifstr $(KeyProduct) == $(KeyNull)
      set RenameList = >($(RenameList), $(!STF_WINDOWSSYSPATH)"\drivers\"$(FRProductServiceName)".sys")
      set RemoveList = >($(RemoveList), $(!STF_WINDOWSSYSPATH)"\DIGIWAN.dll")
      set RemoveList = >($(RemoveList), $(!STF_WINDOWSSYSPATH)"\DIGIWAN.HLP")
   endif
   CloseRegKey $(KeyProduct)

   Debug-Output "RemoveList = "$(RemoveList)
   Debug-Output "RenameList = "$(RenameList)

   ForListDo $(RemoveList)
       Debug-Output "Removing "$($)
       LibraryProcedure Status , $(!LIBHANDLE), DelFile $($)
       Debug-Output "Status is "$(Status)
   EndForListDo
   ForListDo $(RenameList)
	   Debug-Output "RenameList entry = "$($)
	   Split-String $($) "\" FilePath
	   QueryListSize PathLen $(FilePath)
	   Split-String *($(FilePath),$(PathLen)) "." FullFileName
	   Set FileName = *($(FullFileName),1)
	   Debug-Output "FileName is "$(FileName)
	   LibraryProcedure STATUS, $(!LIBHANDLE),CheckFileExistance $(!STF_WINDOWSSYSPATH)"\DRIVERS\"$(FileName)".old"
	   Debug-Output "CheckFile Status = "$(STATUS)
	   ifstr(i) $(STATUS) == YES
	       LibraryProcedure STATUS, $(!LIBHANDLE), DelFile $(!STF_WINDOWSSYSPATH)"\DRIVERS\"$(FileName)".old"
	       Debug-Output "Delfile Status = "$(STATUS)
	       LibraryProcedure STATUS, $(!LIBHANDLE), DelFile $($)
	       Debug-Output "Delfile Status = "$(STATUS)
	   endif

	   Debug-Output "Renaming from "$($)
	   Debug-Output "Renaming to "$(!STF_WINDOWSSYSPATH)"\DRIVERS\"$(FileName)".old"
     LibraryProcedure STATUS, $(!LIBHANDLE),CheckFileExistance $($)
     ifstr(i) $(STATUS) == YES
		   LibraryProcedure Status1 , $(!LIBHANDLE), RenFile $($), $(!STF_WINDOWSSYSPATH)"\DRIVERS\"$(FileName)".old"
	   endif
	   Debug-Output "Status is "$(Status1)
	   AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\DRIVERS\"$(FileName)".old"
   EndForListDo
   exit
[Install-Option]
    Debug-Output "********************* Inside Install-Option *************************"
    Debug-Output "   AddCopy = "$(AddCopy)
    Debug-Output "   DoCopy = "$(DoCopy)
    Debug-Output "   DoConfig = "$(DoConfig)
    Debug-Output "   NTN_InstallPhase = "$(!NTN_InstallPhase)
    set STF_VITAL = ""
    ifstr(i) $(AddCopy) == "YES"
      AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
      AddSectionFilesToCopyList Files-DigiFr $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
			AddSectionFilesToCopyList Files-Dll $(SrcDir) $(!STF_WINDOWSSYSPATH)
			AddSectionFilesToCopyList Files-$(Option)-images $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
;      AddSectionFilesToCopyList Files-PerfMon $(SrcDir) $(!STF_WINDOWSSYSPATH)
    endif

		set STF_DECOMPRESS = 1

    ifstr(i) $(DoCopy) == "YES"
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    else-ifstr(i) $(!NTN_InstallPhase) == primary
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    endif
    Exit
[Source Media Descriptions]
    1 = "Window NT CD-ROM"
[Signature]
    FileType = MICROSOFT_DRVLIB_FILE
[GetSignature]
    read-syms Signature
    return $(FileType)
[ProductType]
    STF_PRODUCT  = Winnt
    STF_PLATFORM = I386

[Files-Inf]
    1, oemsetup.inf, SIZE=63725, RENAME=$(!UG_Filename)
[Files-DigiSyncFR-images]
    1,SxbFep.bin,  SIZE=385024, NODELETESOURCE
    1,SxbBios.bin, SIZE=25088,  NODELETESOURCE
    1,SxbFep.pci,  SIZE=385280, NODELETESOURCE
    1,SxbBios.pci, SIZE=26112,  NODELETESOURCE
[Files-DigiSyncFR]
    1,DigiSxb.sys, SIZE=66800,  NODELETESOURCE
[Files-DigiFr]
    1,DigiFr.sys,  SIZE=13872,  NODELETESOURCE
[Files-Dll]
    1,DigiWan.dll, SIZE=301568, NODELETESOURCE
    1,DigiWan.hlp, SIZE=16984,  NODELETESOURCE
    1,DigiWan.cnt, SIZE=705,    NODELETESOURCE

;[Files-PerfMon]
;		1,SxbPerf.dll, SIZE=34148, NODELETESOURCE

[LanguagesSupported]
    ENG
[OptionsTextENG]
		DigiSyncFR = "Digi SyncPort Frame Relay Adapter"
[FileConstantsENG]
ProCaption   = "Windows NT Setup"
ProCancel    = "Cancel"
ProCancelMsg = "Windows NT Networking is not correctly installed.  "+
               "Are you sure you want to cancel copying files?"
ProCancelCap = "Network Setup Message"
ProText1     = "Copying:"
ProText2     = "To:"
ShellCodeErrorTitle     = "Error: "$(Function$(Option)Title)
ShellCodeErrorText      = "Shell Code Error."
[DialogConstantsENG]
Help        = "&Help"
Exit        = "Cancel"
OK          = "OK"
HelpContext = ""
Continue    = "Continue"
Cancel      = "Cancel"
[SetUpForConfig]
	read-syms GeneralConstants
	read-syms FileConstants

	set ParamKey = $($0)
	set Port = $($1)
	set AdapterNameNumber = $($2)
	set Count = 1
  set RegistryErrorIndex = NO_ERROR

	OpenRegKey $(ParamKey) "" "Port"$(Port)"\FR" $(MAXIMUM_ALLOWED) FRKey

	set NetworkCardKeyName = $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards"
    
	OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) IE_KeyNetcards
	ifstr(i) $(IE_KeyNetcards) != ""    
		EnumRegKey $(IE_KeyNetcards) IE_KeyNameList
		ForListDo $(IE_KeyNameList)
			OpenRegKey $(IE_KeyNetcards) "" *($($),1) $(MAXIMUM_ALLOWED) NetworkCardKey
		  Ifstr(i) $(NetworkCardKey) != $(KeyNull)
				GetRegValue $(NetworkCardKey),"ProductName", ProductNameInfo
				set ProductName = *($(ProductNameInfo), 4)
 	    	Debug-Output "   ProductName = "$(ProductName)
  	  	ifstr(i) $(ProductName) != $(FRVirtualAdapterName)
  				goto nextnetcard
   	  	endif
   	  	GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
    		set ServiceName = *($(ServiceNameInfo), 4)
   	  	Debug-Output "   ServiceName = "$(ServiceName)
   	  	OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\"$(ServiceName)"\Parameters" $(MAXIMUM_ALLOWED) VAServiceKey
 
      	GetRegValue $(VAServiceKey), "Adapter", AdapterNameInfo  
      	set AdapterName = *($(AdapterNameInfo), 4)
      	ifstr(i) $(AdapterName) != $(AdapterNameNumber)
      	  goto nextnetcard
      	endif

      	GetRegValue $(VAServiceKey), "Port", AdapterPortInfo  
      	set AdapterPort = *($(AdapterPortInfo), 4)
      	ifstr(i) $(AdapterPort) != $(Port)
       		goto nextnetcard
      	endif

				GetRegValue $(NetworkCardKey),"Title", TitleInfo
      	set Desc = *($(TitleInfo), 4)

				SetRegValue $(VAServiceKey) {Desc,$(NoTitle),$(!REG_VT_SZ),$(Desc)}
				EnumRegValue $(VAServiceKey) NewValueList
				CreateRegKey $(FRKey) {"PVC"$(Count),$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" PVCKey

    		Shell $(UtilityInf), AddValueList, $(PVCKey), $(NewValueList)
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            goto SetUpForConfig_Err
        endif

				FlushRegKey $(PVCKey)
				CloseRegKey $(PVCKey)

				set-add Count = $(Count), 1
  	  endif
	nextnetcard = +
	  EndForListDo
	endif
	CloseRegKey $(FRKey)
	CloseRegKey $(IE_KeyNetcards)
SetUpForConfig_Err = +
	return $(RegistryErrorIndex)

[CleanUpAfterConfig]
	read-syms GeneralConstants
	read-syms FileConstants

	set ParamKey = $($0)
	set Port = $($1)
  set RegistryErrorIndex = NO_ERROR

	OpenRegKey $(ParamKey) "" "Port"$(Port)"\FR" $(MAXIMUM_ALLOWED) FRKey
	ifstr(i) $(FRKey) != $(KeyNull)    
		EnumRegKey $(FRKey) FRKeyList
		ForListDo $(FRKeyList)
			DeleteRegKey $(FRKey) *($($),1)
	  EndForListDo
	else
		set RegistryErrorIndex = UNABLE_ACCESS_SOFTWARE_REG
	endif
	CloseRegKey $(FRKey)
CleanUpAfterConfig_Err = +
	return $(RegistryErrorIndex)

[CreateVirtualAdapters]
	read-syms GeneralConstants
	read-syms FileConstants
	detect date

	set ParamKey = $($0)
	set Port = $($1)
	set AdapterNameNumber = $($2)
	set PortNum = $($3)

  set RegistryErrorIndex = NO_ERROR
	set NeedBindingReview = $(FALSE)

	OpenRegKey $(ParamKey) "" "Port"$(Port)"\FR" $(MAXIMUM_ALLOWED) FRKey
	ifstr(i) $(FRKey) == $(KeyNull)    
		set RegistryErrorIndex = UNABLE_ACCESS_SOFTWARE_REG
  	goto CreateVirtualAdapters_Err
	endif

	set DLCIList = {}
	set PVCKeyList = {}
	EnumRegKey $(FRKey) FRKeyList
	ForListDo $(FRKeyList)
		OpenRegKey $(FRKey) "" *($($),1) $(MAXIMUM_ALLOWED) PVCKey
	  GetRegValue $(PVCKey), "DLCI", DLCIInfo  
	  set DLCI = *($(DLCIInfo), 4)
		set DLCIList = >($(DLCIList), $(DLCI))
		set PVCKeyList = >($(PVCKeyList), $(PVCKey))
	EndForListDo
	
	set ProcessedDLCIList = {}
	
	set NetworkCardKeyName = $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards"
	    
	OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) IE_KeyNetcards
	ifstr(i) $(IE_KeyNetcards) != ""    
		EnumRegKey $(IE_KeyNetcards) IE_KeyNameList
		ForListDo $(IE_KeyNameList)
			OpenRegKey $(IE_KeyNetcards) "" *($($),1) $(MAXIMUM_ALLOWED) NetworkCardKey
	    Ifstr(i) $(NetworkCardKey) != $(KeyNull)
				GetRegValue $(NetworkCardKey),"ProductName", ProductNameInfo
				set ProductName = *($(ProductNameInfo), 4)
 	    	Debug-Output "   ProductName = "$(ProductName)
 	    	ifstr(i) $(ProductName) != $(FRVirtualAdapterName)
        	goto nextnetcard
      	endif
      	GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
      	set ServiceName = *($(ServiceNameInfo), 4)
      	Debug-Output "   ServiceName = "$(ServiceName)
      	OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\"$(ServiceName)"\Parameters" $(MAXIMUM_ALLOWED) VAServiceKey
 
      	GetRegValue $(VAServiceKey), "Adapter", AdapterNameInfo  
      	set AdapterName = *($(AdapterNameInfo), 4)
      	ifstr(i) $(AdapterName) != $(AdapterNameNumber)
       		goto nextnetcard
      	endif

      	GetRegValue $(VAServiceKey), "Port", AdapterPortInfo  
      	set AdapterPort = *($(AdapterPortInfo), 4)
      	ifstr(i) $(AdapterPort) != $(Port)
        	goto nextnetcard
      	endif

      	GetRegValue $(VAServiceKey), "DLCI", DLCIInfo  
      	set DLCI = *($(DLCIInfo), 4)

				ifcontains $(DLCI) in $(DLCIList)
		  		Shell "", SetFRParams, $(VAServiceKey), $(DLCI), $(DLCIList), $(PVCKeyList), $(NetworkCardKey)
	        set RegistryErrorIndex = $($R0)
 	      	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            goto CreateVirtualAdapters_Err
        	endif
					ifstr $($R1) == $(TRUE)
						set NeedBindingReview = $(TRUE)
					endif
				else
					Shell	$(UtilityInf) RemoveHardwareComponent, $(Manufacturer), $(FRProductSoftwareName), $(NetworkCardKeyName)"\"*($($),1)
	        set RegistryErrorIndex = $($R0)
 	      	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            goto CreateVirtualAdapters_Err
        	endif
					set NeedBindingReview = $(TRUE)
				endif


				set ProcessedDLCIList	= >($(ProcessedDLCIList), $(DLCI))
			endif
	nextnetcard = +
 		EndForListDo
	endif

	ForListDo $(FRKeyList)
		OpenRegKey $(FRKey) "" *($($),1) $(MAXIMUM_ALLOWED) PVCKey
		GetRegValue $(PVCKey), "DLCI", DLCIInfo  
		set DLCI = *($(DLCIInfo), 4)

		ifcontains $(DLCI) not-in $(ProcessedDLCIList)
			Shell $(UtilityInf), AssignAdapterNumber, "", "1000"
      set RegistryErrorIndex = $($R0)
	    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
     		goto CreateVirtualAdapters_Err
	    endif
			set AdapterNum = $($R1);

	  	Shell $(UtilityInf), AddHardwareComponent, $(FRVirtualAdapterName), $(STF_CONTEXTINFNAME), $(FRProductKeyName), "", "", $(AdapterNum)
      set RegistryErrorIndex = $($R0)
      Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        CloseRegKey $($R1)
        CloseRegKey $($R2)
        CloseRegKey $($R3)
     		goto CreateVirtualAdapters_Err
      endif
			set NeedBindingReview = $(TRUE)

	   	set AdapterKeyNetcard    = $($R1)
	    set AdapterNetRulesKey   = $($R2)
	    set AdapterKeyParameters = $($R3)
	    set AdapterNumber        = $($R4)
	    set AdapterServiceName   = $($R5)

			Split-String $(AdapterNameNumber) "b" splitList
			set RealAdapterNum = *($(splitList), 3)

	    set NewValueList =																																					   +
	    	{	{ServiceName,	$(NoTitle),$(!REG_VT_SZ),		$(AdapterServiceName)},													 +
			    {Manufacturer,$(NoTitle),$(!REG_VT_SZ),		$(Manufacturer)},																 +
	        {Title,				$(NoTitle),$(!REG_VT_SZ),		"["$(RealAdapterNum)"] Digi FR - Line "$(PortNum)", DLCI "$(DLCI)},+
	        {Description,	$(NoTitle),$(!REG_VT_SZ),		$(FRVirtualAdapterDescription)},								 +
 	      	{ProductName,	$(NoTitle),$(!REG_VT_SZ),		$(FRVirtualAdapterName)},												 +
        	{InstallDate,	$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)},																		 +
        	{Hidden,			$(NoTitle),$(!REG_VT_DWORD),$(TRUE)}																				 +
      	}

	    Shell $(UtilityInf), AddValueList, $(AdapterKeyNetcard), $(NewValueList)
      set RegistryErrorIndex = $($R0)
      Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
     		goto CreateVirtualAdapters_Err
      endif

	    set AdapterNetRuleInfName = $(STF_CONTEXTINFNAME)
	    Shell  $(UtilityInf), ReduceInfPath, $(AdapterNetRuleInfName)
  		set AdapterNetRuleInfName = $($R0)

	    set TempProdName = """"$(FRVirtualAdapterName)$(AdapterNumber)""""
	    set TempBindForm = $(TempProdName)$(FRVirtualAdapterNetRuleBindForm)

	    set NewValueList = 																														+
	    	{	{InfName,		$(NoTitle),$(!REG_VT_SZ),				$(AdapterNetRuleInfName)},		+
	        {type,			$(NoTitle),$(!REG_VT_SZ),				$(FRVirtualAdapterNetRuleType)},				+
	        {bindform,	$(NoTitle),$(!REG_VT_SZ),				$(TempBindForm)}, 						+
 		      {class,			$(NoTitle),$(!REG_VT_MULTI_SZ),	$(FRVirtualAdapterNetRuleClass)}, 			+
	        {InfOption,	$(NoTitle),$(!REG_VT_SZ),				$(AdapterNetRulesInfOption)} 	+
	      }

	    Shell $(UtilityInf), AddValueList, $(AdapterNetRulesKey), $(NewValueList)
     	set RegistryErrorIndex = $($R0)
      Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        CloseRegKey $(AdapterKeyNetcard)
        CloseRegKey $(AdapterKeyParameters)
        CloseRegKey $(AdapterNetRulesKey)
     		goto CreateVirtualAdapters_Err
      endif

	  	Shell "", SetFRParams, $(AdapterKeyParameters), $(DLCI), $(DLCIList), $(PVCKeyList), $(AdapterKeyNetcard)

	    set NewValueList =																													+
	    	{	{BusNumber,			$(NoTitle),$(!REG_VT_DWORD),$(FRVirtualAdapterBusNumber)},				+
	    		{BusType,				$(NoTitle),$(!REG_VT_DWORD),$(FRVirtualAdapterBusType)},					+
	    		{NetworkAddress,$(NoTitle),$(!REG_VT_SZ),		$(AdapterNetworkAddress)},	+
	    		{ServiceName,		$(NoTitle),$(!REG_VT_SZ),		$(AdapterServiceName)},			+
					{DLCI,					$(NoTitle),$(!REG_VT_DWORD),$(DLCI)},										+		
    			{Adapter,				$(NoTitle),$(!REG_VT_SZ),		$(AdapterNameNumber)},			+
      	  {Port,					$(NoTitle),$(!REG_VT_SZ),		$(Port)}										+
	      }

	    Shell  $(UtilityInf), AddValueList, $(AdapterKeyParameters), $(NewValueList)
    	set RegistryErrorIndex = $($R0)
    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
     		goto CreateVirtualAdapters_Err
    	endif

	  	FlushRegKey $(AdapterKeyNetcard)
		  FlushRegKey $(AdapterKeyParameters)
		  FlushRegKey $(AdapterNetRulesKey)
		  CloseRegKey $(AdapterKeyNetcard)
		  CloseRegKey $(AdapterKeyParameters)
		  CloseRegKey $(AdapterNetRulesKey)
		endif

		CloseRegKey $(PVCKey)
	EndForListDo
	CloseRegKey $(FRKey)

	ForListDo $(PVCKeyList)
		CloseRegKey $($)
	EndForListDo

	CloseRegKey $(IE_KeyNetcards)

CreateVirtualAdapters_Err = +
	return $(RegistryErrorIndex) $(NeedBindingReview)

[RemoveVirtualAdapters]
	read-syms GeneralConstants
	read-syms FileConstants

	set Port = $($0)
	set AdapterNameNumber = $($1)
  set RegistryErrorIndex = NO_ERROR

	set NetworkCardKeyName = $(!NTN_SoftwareBase)"\Microsoft\Windows NT\CurrentVersion\NetworkCards"

	OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardKeyName) $(MAXIMUM_ALLOWED) IE_KeyNetcards
	ifstr(i) $(IE_KeyNetcards) != ""    
		EnumRegKey $(IE_KeyNetcards) IE_KeyNameList
		ForListDo $(IE_KeyNameList)
			OpenRegKey $(IE_KeyNetcards) "" *($($),1) $(MAXIMUM_ALLOWED) NetworkCardKey
	    Ifstr(i) $(NetworkCardKey) != $(KeyNull)
				GetRegValue $(NetworkCardKey),"ProductName", ProductNameInfo
				set ProductName = *($(ProductNameInfo), 4)
	      Debug-Output "   ProductName = "$(ProductName)
	      ifstr(i) $(ProductName) != $(FRVirtualAdapterName)
	        goto nextnetcard
	      endif
	      GetRegValue $(NetworkCardKey),"ServiceName", ServiceNameInfo
	      set ServiceName = *($(ServiceNameInfo), 4)
	      Debug-Output "   ServiceName = "$(ServiceName)
	      OpenRegKey $(!REG_H_LOCAL) "" "System\CurrentControlSet\Services\"$(ServiceName)"\Parameters" $(MAXIMUM_ALLOWED) VAServiceKey

				ifstr $(VAServiceKey) != $(KeyNull) 
					GetRegValue $(VAServiceKey), "Adapter", AdapterNameInfo  
					set AdapterName = *($(AdapterNameInfo), 4)
					ifstr(i) $(AdapterName) != $(AdapterNameNumber)
						goto nextnetcard
					endif

					GetRegValue $(VAServiceKey), "Port", AdapterPortInfo  
					set AdapterPort = *($(AdapterPortInfo), 4)
					ifstr(i) $(AdapterPort) != $(Port)
						goto nextnetcard
					endif
				endif

				Shell	$(UtilityInf) RemoveHardwareComponent, $(Manufacturer), $(FRProductSoftwareName), $(NetworkCardKeyName)"\"*($($),1)
	    	set RegistryErrorIndex = $($R0)
	    	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
	     		goto RemoveVirtualAdapters_Err
	    	endif

				CloseRegKey $(VAServiceKey)
			endif
	nextnetcard = +
	  EndForListDo
	endif
RemoveVirtualAdapters_Err = +
	return $(RegistryErrorIndex)

[SetFRParams]
	read-syms GeneralConstants
	read-syms FileConstants

	set AdapterParametersKey = $($0)
	set DLCI = $($1)
	set DLCIList = $($2)
	set PVCKeyList = $($3)
	set NetCardKey = $($4)

  set RegistryErrorIndex = NO_ERROR
	set NeedBindingReview = $(FALSE)

	ForListDo	$(DLCIList)
		ifint $(DLCI) == $($)
			set ItemNumber = $(#)
		endif
	EndForListDo
	set PVCKey = *($(PVCKeyList), $(ItemNumber))

	GetRegValue $(PVCKey),"Desc", DescInfo
	set Desc = *($(DescInfo), 4)
	SetRegValue $(NetCardKey), {Title,$(NoTitle),$(!REG_VT_SZ),$(Desc)}

	set KeyList = { "TCPIP", "IPX", "Ethernet" }
	ForListDo $(KeyList)
		GetRegValue $(PVCKey), $($), Key1
		GetRegValue $(AdapterParametersKey), $($), Key2
		ifstr *($(Key1), 4) != *($(Key2), 4)
			set NeedBindingReview = $(TRUE)
		endif
	EndForListDo

	EnumRegValue $(PVCKey) NewValueList
	Shell  $(UtilityInf), AddValueList, $(AdapterParametersKey), $(NewValueList)
	set RegistryErrorIndex = $($R0)
	Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
		goto SetFRParams_Err
	endif

SetFRParams_Err = +
	return $(RegistryErrorIndex) $(NeedBindingReview)
