OEMNADVN.INF Driver File Contents (v5091.exe)

;AT&T Global Network Services
;
;Developed in Tampa, FL copyright 1999, 2000, 2001
;Broadband/Narrowband support
;****************************************************************************

[Identification]
OptionType              = NetService

[Options]
"IPSec VPN Drivers" 

[FileConstants]
NoNdisWanSupport        = 0
UtilityInf              = "UTILITY.INF"
subroutineinf           = "SUBROUTN.INF"
DLL_ERROR_INDICATOR     = "Script Error"	
SoftwareType            = "service"
Exit_Code               = 0
NetEventDLL             = "%SystemRoot%\System32\netevent.dll"
;Manufacturer            = "AT&T Global Network"
Manufacturer            = "AGNS"


ProductMajorVersion     = "1"
ProductMinorVersion     = "3"
ProductVersion          = $(ProductMajorVersion)"."$(ProductMinorVersion)
ProductSoftwareName     = ADVPNNT  ;Don't forget to update length too in SelectNIC/NDISWan

;ProductDeviceNameNarrow = ADVPN
;ProductDeviceNameBroad  = ABVPN
ProductDeviceNameNarrow = "NetClient\NetVPN"
ProductDeviceNameBroad  = "NetClient\NetVPN"

ProductSoftwareImagePath = "\SystemRoot\System32\drivers\ADVPNNT.SYS"
ProductDriverFile       = "ADVPNNT.SYS"
ProductDLLFile          = "ADVNDINT.DLL"

ProductSoftKey          = $(!NTN_SoftwareBase)"\"$(Manufacturer)                        ;SOFTWARE\AGNS
ProductKeyName          = $(ProductSoftKey)"\"$(ProductSoftwareName)"\CurrentVersion"   ;SOFTWARE\AGNS\ADVPNNT\CurrentVersion
ProductKeyInfoNarrow    = $(ProductSoftKey)"\"$(ProductDeviceNameNarrow)                ;SOFTWARE\AGNS\NetClient\NetVPN
ProductKeyInfoBroad     = $(ProductSoftKey)"\"$(ProductDeviceNameBroad)                 ;SOFTWARE\AGNS\NetClient\NetVPN
                         
ProductHardwareSupport  = 0
ProductSoftwareSupport  = 132

InstallTypeValue        = "InstallType"
InstallBroadband        = "BROADBAND"
InstallNarrowband       = "DIAL"
InstallAll              = "ALL"
InterfaceValue          = "BindToAdapter"


IMTransports           	= {imTransport,+
                           imTcpipTransport,+
                           imIpxTransport,+
                           imNetBiosTransport,+
                           imrasCapableTransport,+
                           imnetbtTransport,+
                          }

SupportedTransports     = {ndisTransport,+
                           tcpipTransport,+
                           ipxTransport,+
                           netBiosTransport,+
                           rasCapableTransport,+
                           netbtTransport,+
                          }

IMDrivers              	= {imDriver}
SupportedDrivers        = {ndisDriver}
NdisWanSupportedDrivers = {ndisWanAdapterDialOut,+
                           ndisWanAdapterDialOutIP }
IMAdapters              = {imAdapter}

NetRuleSoftwareType     = $(ProductSoftwareName)" "*($(\IMDrivers),1)" "*($(IMTransports),1)
NetRuleSoftwareUse      = $(SoftwareType)" yes yes"
NetRuleSoftwareClass    = {*($(IMDrivers),1)" basic",*($(IMTransports),1)" basic"}
NetRuleHardwareClass    = {*($(IMAdapters),1)" basic"}

NetRuleSoftwareBindable = {*($(IMTransports),1)" "*($(SupportedDrivers),1)" non non 100",+
                          *($(IMTransports),1)" "*($(NdisWanSupportedDrivers),2)" non non 100" }


NetRuleSoftwareBindForm = " yes no simple"       
NetRuleHardwareBindForm = " yes yes container"       
ProductSoftwareReview   = "1" 

MicroSW                 = $(!NTN_SoftwareBase)"\Microsoft\"
CVNetRules              = "\CurrentVersion\NetRules"

;
; TCPIP and Nbf protocols only
;
NetRuleDriverKeys       = {{$(MicroSW)"Tcpip"$(CVNetRules),1}}
NetRuleTransportKeys    = {{$(MicroSW)"Ndiswan"$(CVNetRules),2}}
TransportServiceKeys    = {$(!NTN_ServiceBase)"\Tcpip",+
                           $(!NTN_ServiceBase)"\NetBT"}
NetBTServiceKey         = $(!NTN_ServiceBase)"\NetBT\Adapters"
IMServiceKeyName        = $(!NTN_ServiceBase)"\"$(ProductSoftwareName) 
IMLinkageKeyName        = $(IMServiceKeyName)"\Linkage"
NtCurrentVersion        = $(MicroSW)"Windows NT\CurrentVersion"
NtCurrentSP             = "CSDVersion"
NetworkCardsKeyName     = $(NtCurrentVersion)"\NetworkCards"

ServiceOrder            = "SYSTEM\CurrentControlSet\Control\ServiceGroupOrder"
ReviewProgram           = "SOFTWARE\Microsoft\Ncpa\CurrentVersion"
IMSoftwareKey           = "SOFTWARE\"$(Manufacturer)"\"
NetRules                = $(IMSoftwareKey)$(ProductSoftwareName)$(CVNetRules)
RunOnce                 = $(!NTN_SoftwareBase)+
                          "\Microsoft\Windows\CurrentVersion\RunOnce"
FixupServices           = {$(!NTN_ServiceBase)"\LanmanServer\Linkage",+
                          $(!NTN_ServiceBase)"\LanmanWorkstation\Linkage"}

[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

[date]
    ifstr(i) $(!LIBHANDLE) == ""
        LoadLibrary "x" setupdll.dll !LIBHANDLE
    endif
    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)
	  goto returnoptions
    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)

[Shell Commands]
    set-title "Ndis Intermediate Driver Sample Setup"
    exit

[InstallOption]
    set !G:DebugOutputControl = 1 ; turn on debugging. Set to 0 to turn off debug prints
    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 "ADVPN: STF_CWDDIR is: "$(!STF_CWDDIR)
    Debug-Output "ADVPN: STF_LANGUAGE is: "$(!STF_LANGUAGE)
    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  $(FunctionTitle)
    set to   = Begin
    set from = Begin
    set CommonStatus = STATUS_SUCCESSFUL
   ;JEM 3/31 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) == cleanup
        set StartLabel = cleanupSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == configure
	Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
	ifint $($ShellCode) != $(!SHELL_CODE_OK)
	    Debug-Output "OEMSETNT.INF: ShellCode error: no error string."
	    goto ShellCodeError
	endif
	set Error = $($R0)
	set from = end
	set to = end
	goto nonfatalinfo
    else
	set StartLabel = installadapter
    endif
    set RadioDefault = 2
    set RadioIn = {$(RadioDefault)}
    set Size = 2        ;
    set from = $(fatal)
    set to = $(fatal)
    goto $(StartLabel)
installadapter = +
    ;CCL** Allow user to select from dialog box.
    Debug-Output "ADVPN: Loading ADVNDINT.DLL"
    ifstr(i) $(!PRUNEHANDLE) == ""
       LoadLibrary "x" advndint.dll !PRUNEHANDLE
    endif

    set IM_NT_SERVICE_PACK = ""
    set IM_NT_VERSION = ""
    Shell "" GetNtVersion
    ifstr $($R0) != "4.0"
      Debug-Output "ADVPN: Wrong NT Version!"
      Debug-Output "ADVPN: Loading ADVNDINT.DLL"
      read-syms ErrorMessages
      ifstr(i) $(!PRUNEHANDLE) == ""
        LoadLibrary "x" advndint.dll !PRUNEHANDLE
      endif
      Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_WRONG_VERSION"
      LibraryProcedure Result $(!PRUNEHANDLE) +
                       BmGetDefaultLanguageString "IDS_NT_WRONG_VERSION_WARNING" +
                       $(szWrongVersionWarning)
      Debug-Output "ADVPN: Return From DLL: "$(Result)
      Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Result)
      set CommonStatus = STATUS_FAILED
      goto end
    EndIf
    Shell "" GetNtServicePack
    ifint $($R0) < 3 
      Debug-Output "ADVPN: Wrong Service Pack!"
      Debug-Output "ADVPN: Loading ADVNDINT.DLL"
      read-syms ErrorMessages
      ifstr(i) $(!PRUNEHANDLE) == ""
        LoadLibrary "x" advndint.dll !PRUNEHANDLE
      endif
      Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_WRONG_SP"
      LibraryProcedure Result $(!PRUNEHANDLE) +
                       BmGetDefaultLanguageString "IDS_NT_WRONG_SERVICE_PACK_WARNING" +
                       $(szWrongServicePackWarning)
      Debug-Output "ADVPN: Return From DLL: "$(Result)
      Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", $(Result)
      set CommonStatus = STATUS_FAILED
      goto end
   EndIf

;CCL 7/10/2000
;
;Removed SelectInterfaces Call because we now determine interface dynamically
;

    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
    Debug-Output "ADVPN: installadapter:"
        GetRegValue $(KeyProduct) MajorVersion major
        GetRegValue $(KeyProduct) MinorVersion minor
        CloseRegKey $(KeyProduct)

        ifstr $(major) == ""
            goto noVersionCheck
        endif
        ifstr $(minor) == ""
            goto noVersionCheck
        endif

        ifint *($(major),4) > $(ProductMajorVersion)
            CloseRegKey $(KeyProduct)
            goto versionOlder
        endif

        ifint *($(major),4) == $(ProductMinorVersion)
            ifint *($(minor),4) > $(ProductMinorVersion)
                CloseRegKey $(KeyProduct)
                goto versionOlder
            endif
        endif

        ifstr *($(major),4) == $(ProductMajorVersion)
            ifstr *($(minor),4) == $(ProductMinorVersion)
                goto versionExist
            endif
        endif
    endif

noVersionCheck = +

    goto installproduct 

versionExist = +
    Debug-Output "ADVPN: current version already exists"
    ;Don't want to tell user, because it may just be an interfaces update
    ;Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
    ;	$(ProductSoftwareTitle)" "*($(major),4)"."*($(minor),4)+
    ;	" is already installed."
    ;ifint $($ShellCode) != $(!SHELL_CODE_OK)
    ;    Debug-Output "ShellCode error: cannot get an error string."
    ;    goto ShellCodeError
    ;endif
    goto end

versionOlder = +
    Debug-Output "ADVPN: older version already exists"
    ;Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
    ;	$(ProductSoftwareTitle)" "*($(major),4)"."*($(minor),4)+
    ;	" is already installed.  Upgrading to version "+
    ;	$(ProductMajorVersion)"."$(ProductMinorVersion)" is not allowed."
    ;ifint $($ShellCode) != $(!SHELL_CODE_OK)
    ;    Debug-Output "ShellCode error: cannot get an error string."
    ;    goto ShellCodeError
    ;endif
    goto end

installproduct = +
    StartWait

    ifint $(OldVersionExisted) == $(FALSE)
	Ifstr(i) $(DoCopy) == "YES"

           set SrcKey = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\TCPIP"

           OpenRegKey $(!REG_H_LOCAL) "" $(SrcKey) $(MAXIMUM_ALLOWED) KeyHandle
           Ifstr $(KeyHandle) != $(KeyNull)
               GetRegValue $(KeyHandle) Path value
               ifint $(RegLastError) == 0
                   ;set SrcDir = *($(value),4)
                   
                   set paths = {*($(value),4)}
                   set names = {ADVPNNT.SYS}
             	   Debug-Output "ADVPN: Shelling CheckIfCopyNecessary "
             	   Shell $(UtilityInf) CheckIfCopyNecessary $(paths) $(names)

	           Ifint $($ShellCode) == $(!SHELL_CODE_OK)
                       Ifstr $($R0) == STATUS_SUCCESSFUL
                           set SrcDir = *($(value),4)
	                   CloseRegKey $(KeyHandle)
                           goto skip_DoAskSource 
                       endif
                   endif
               endif
	       CloseRegKey $(KeyHandle)
           endif

	   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

skip_DoAskSource = +
        Debug-Output "ADVPN: skip_DoAskSource"
	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
	set OEM_ABANDON_ON = TRUE
        Debug-Output "ADVPN: Calling add SoftwareComponent (1)"
	Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $(ProductSoftwareName), +
	    $(ProductSoftwareDisplayName), $(STF_CONTEXTINFNAME), +
	    $(ProductSoftwareImagePath), "kernelautostart", +
            $(ProductSoftwareGroup), "", "", $(NetEventDLL)
	set RegistryErrorIndex = $($R0)
	
	Ifstr(i) $(RegistryErrorIndex) !=  NO_ERROR
            ;
            ; Try to recover
            ;
             Debug-Output "ADVPN: Trying to recover"
            
            OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName)"\NetRules" +
			$(MAXIMUM_ALLOWED) SoftNetRuleKey
            
            Ifstr $(SoftNetRuleKey) != $(KeyNull)
                OpenRegKey $(!REG_H_LOCAL) "" +
				$(ProductSoftKey)"\"$(ProductSoftwareName) +
				$(MAXIMUM_ALLOWED) SoftProductKey
                
                Ifstr $(SoftProductKey) != $(KeyNull)
                    OpenRegKey $(!REG_H_LOCAL) "" $(IMServiceKeyName) +
					$(MAXIMUM_ALLOWED) sHandle
                    
                    Ifstr $(sHandle) != $(KeyNull)
                        CloseRegKey $(sHandle)
                        goto continueInstall
                    else
                        CloseRegKey $(SoftProductKey)
                        CloseRegKey $(SoftNetRuleKey)
                        read-syms ErrorMessages
                        Debug-Output "ADVPN: Loading ADVNDINT.DLL"
                        ifstr(i) $(!PRUNEHANDLE) == ""
                          LoadLibrary "x" advndint.dll !PRUNEHANDLE
                        endif
                        Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_PREVIOUSLY"
                        LibraryProcedure Result $(!PRUNEHANDLE) +
                                    BmGetDefaultLanguageString "IDS_NT_PREVIOUSLY_INSTALLED_WARNING" +
                                    $(szPreviouslyInstalledWarning)
                        Debug-Output "ADVPN: Return From DLL: "$(Result)
                        Shell $(subroutineinf) SetupMessage,+
						$(!STF_LANGUAGE),"FATAL",+
                                                $(Result)
	                	CloseRegKey $($R1)
	                	CloseRegKey $($R2)
	                	CloseRegKey $($R3)
	                	CloseRegKey $($R4)
	                	CloseRegKey $($R5)
	                	goto fatal
                    endif
                
                else
                    CloseRegKey $(SoftNetRuleKey)
                endif
            endif
           
	    EndWait
	    CloseRegKey $($R1)
	    CloseRegKey $($R2)
	    CloseRegKey $($R3)
	    CloseRegKey $($R4)
	    CloseRegKey $($R5)
	    goto fatalRegistry
	endif
	
	Set SoftProductKey      = $($R1)
	Set SoftNetRuleKey      = $($R2)
	Set SoftServiceKey      = $($R3)
	set KeyParameters       = $($R4)
	Set SoftLinkageKey      = $($R5)

continueInstall = +
        Debug-Output "ADVPN: continueInstall"
 	    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)},+
			{Review,$(NoTitle),$(!REG_VT_DWORD),+
		 	$(ProductSoftwareReview)},+
			{OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),+
			 $(ProductSoftwareSupport)},+
			{InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
			 *($(Now),1)}}
 		
 		Shell  $(UtilityInf), AddValueList, $(SoftProductKey), $(NewValueList)
		set RegistryErrorIndex = $($R0)
		
		Ifstr $(RegistryErrorIndex) != NO_ERROR
	    	CloseRegKey $(SoftProductKey)
	    	CloseRegKey $(SoftNetRuleKey)
	    	CloseRegKey $(SoftServiceKey)
	    	CloseRegKey $(SoftLinkageKey)
	    	CloseRegKey $(KeyParameters)
	    	goto fatalRegistry
		endif

        set-subst NetRuleSoftwareBindForm = "\042"$(ProductSoftwareName)"\042"+
						$(NetRuleSoftwareBindForm)
		set NewValueList = { +
        	  {type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareType)}, +
          	{use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareUse)}, +
          	{class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareClass)},+   
          	{bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleSoftwareBindForm)},+
	  		{bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleSoftwareBindable)},+
          	{InfOption,$(NoTitle),$(!REG_VT_SZ),$(Option)}}
 	
 		Shell  $(UtilityInf), AddValueList, $(SoftNetRuleKey), $(NewValueList)
		
		set RegistryErrorIndex = $($R0)
		
		Ifstr $(RegistryErrorIndex) != NO_ERROR
	    	CloseRegKey $(SoftProductKey)
	    	CloseRegKey $(SoftNetRuleKey)
	    	CloseRegKey $(SoftServiceKey)
	    	CloseRegKey $(SoftLinkageKey)
	    	CloseRegKey $(KeyParameters)
	    	goto fatalRegistry
		endif

		CloseRegKey $(SoftProductKey)
		CloseRegKey $(SoftNetRuleKey)
		CloseRegKey $(SoftServiceKey)
		CloseRegKey $(SoftLinkageKey)
    endif

    ;
    ; Modify Driver NetRules
    ;
    ForListDo $(NetRuleDriverKeys) ; currently, only TCPIP

        Shell "" ChangeNetRules *($($),1) *($(SupportedDrivers),*($($),2)) +
		*($(IMDrivers),*($($),2)) Bindable
        Ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set RegistryErrorIndex = $($ShellCode)
            goto fatalRegistry
        endif
        Ifstr $($R0) != STATUS_SUCCESS
            set RegistryErrorIndex = $($R0)
            goto fatalRegistry
        endif
    EndForListDo

    ;
    ; Modify Transport NetRules  currently only ndiswan
    ;
    Shell "" NdisWanSupport
    ifint $($R0) != 1
       ForListDo $(NetRuleTransportKeys)
         Shell "" ChangeNetRules *($($),1) +
	    *($(SupportedTransports),*($($),2)) +
	    *($(IMTransports),*($($),2))  Bindable
         Ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set RegistryErrorIndex = $($ShellCode)
            goto fatalRegistry
         endif
         Ifstr $($R0) != STATUS_SUCCESS
            Ifstr $($R0) != CANNOT_FIND_COMPONENT_SERVICE
               set RegistryErrorIndex = $($R0)
               goto fatalRegistry
            endif
         endif
       endForListDo
    endif

    ;
    ; Add Protocol parameters and NetworkCard settings
    ;

    Debug-Output "ADVPN: Shelling SetAdapterParameter with "$(Option)
    Shell "", SetAdapterParameter $(Option) FORCE
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set RegistryErrorIndex = $($ShellCode)
        goto fatal
    endif
    Ifstr $($R0) != STATUS_SUCCESSFUL
        Ifstr $($R0) != STATUS_REBIND
            set RegistryErrorIndex = $($R0)
            goto fatal
        endif
    endif

    ;
    ; Add install file to ReviewPrograms
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(NetRules) $(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
        GetRegValue $(KeyProduct),"InfName", infName
        ifint $(RegLastError) == 0
            Shell "" AddToList *($(infName),4) OEMNSVRA.INF +
			$(ReviewProgram) ReviewPrograms
            ifint $($ShellCode) == $(!SHELL_CODE_OK)
                ifstr $($R0) != STATUS_SUCCESSFUL
                    Shell "" AddToList *($(infName),4) NBINFO.INF +
				$(ReviewProgram) ReviewPrograms BEFORE
                endif
            endif
        endif
        CloseRegKey $(KeyProduct)
    endif

    ;
    ; Add our Group to the service group list
    ;
    Shell "" AddToList $(ProductSoftwareGroup) NDIS $(ServiceOrder) List

    goto writeparameters
writeparameters = +
 Debug-Output "ADVPN: writeparameters"
    CloseRegKey $(KeyParameters)
    EndWait
    goto successful
bindingadapter =+
    ;
    ; Delete IM DependOnGroup and DependOnService
    ;
    Debug-Output "ADVPN: bindingadapter"
    OpenRegKey $(!REG_H_LOCAL) "" $(IMServiceKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$(IMServiceKeyName)" empty!"
        goto fatal
    Endif
    DeleteRegValue $(KeyProduct) DependOnGroup
    DeleteRegValue $(KeyProduct) DependOnService
    CloseRegKey $(KeyProduct)


    ;
    ; Modify Driver NetRules
    ;
    ForListDo $(NetRuleDriverKeys) ; currently, only TCPIP
        Shell "" ChangeNetRules *($($),1) *($(SupportedDrivers),*($($),2)) +
		*($(IMDrivers),*($($),2)) Bindable
        Ifint $($ShellCode) != $(!SHELL_CODE_OK)
            set RegistryErrorIndex = $($ShellCode)
            goto fatalRegistry
        endif
        ;It's not ok if TCP/IP is not found at this point.  We want to  
        ;uninstall and wait for TCP/IP to be installed again.
        Ifstr $($R0) == CANNOT_FIND_COMPONENT_SERVICE
           Debug-Output "ADVPN: TCP/IP is missing!"
           read-syms ErrorMessages
           Debug-Output "ADVPN: Loading ADVNDINT.DLL"
           ifstr(i) $(!PRUNEHANDLE) == ""
              LoadLibrary "x" advndint.dll !PRUNEHANDLE
           endif
           Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_NO_TCPIP"
           LibraryProcedure Result $(!PRUNEHANDLE) +
                       BmGetDefaultLanguageString "IDS_NT_NO_TCPIP_WARNING" +
                       $(szNOTCPIPWarning)
           Debug-Output "ADVPN: Return From DLL: "$(Result)
           Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "STATUS", $(Result)
           Shell "" RemoveIM
        else-ifstr $($R0) != STATUS_SUCCESS
           set RegistryErrorIndex = $($R0)
           goto fatalRegistry
        endif
    EndForListDo


    ;
    ; Modify Transport NetRules
    ;
    set bindType = 1
    Shell "" NdisWanSupport
    ifint $($R0) != 1
        ForListDo $(NetRuleTransportKeys)
            Shell "" ChangeNetRules *($($),1) +
		*($(SupportedTransports),*($($),2)) +
		*($(IMTransports),*($($),2)) Bindable
            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                set RegistryErrorIndex = $($ShellCode)
                goto fatal
            endif
            Ifstr $($R0) != STATUS_SUCCESS
                Ifstr $($R0) != CANNOT_FIND_COMPONENT_SERVICE
                    set RegistryErrorIndex = $($R0)
                    goto fatal
                endif
            endif
            Ifstr $($R1) == 0 ;IM is installed before RAS
                set bindType = 2
            endif
        endForListDo
    endif

    
    ;
    ; Remove IM from Transport's DependOnService
    ;
    Shell "" FixupTransportDependOnService

    set rebind = FALSE

    ;
    ; Add Protocol parameters and NetworkCard settings
    ;

    Debug-Output "ADVPN: Shelling SetAdapterParameter number 2 with "$(Option)
    Shell "" SetAdapterParameter $(Option)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set RegistryErrorIndex = $($ShellCode)
        goto fatal
    endif
    Ifstr $($R0) == STATUS_REBIND
        set rebind = TRUE
    else-ifstr $($R0) != STATUS_SUCCESSFUL
        set RegistryErrorIndex = $($R0)
        goto fatal
    endif

    ;
    ; Remove no longer used IM cards
    ;
    Shell "" RemoveIMCards UNWANTED
    Ifstr $($R0) == STATUS_REBIND
        set rebind = TRUE
    endif

    ;
    ; Fixup binding now that we might have added/removed some adapters
    ;
    Shell "" NdisWanSupport
    ifint $($R0) != 1
        Shell "" FixupBindings
    endif

    ifstr $(rebind) == TRUE
        OpenRegKey $(!REG_H_LOCAL) "" $(IMServiceKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
        Ifstr $(KeyProduct) == $(KeyNull)
            set RegistryErrorIndex = CANNOT_FIND_COMPONENT_SERVICE
            Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$(IMServiceKeyName)" empty!"
            goto fatal
        endif

        SetRegValue $(KeyProduct) +
		{Rebind,$(NoTitle),$(!REG_VT_DWORD),$(bindType)}
        ifint $(RegLastError) != 0
            Debug-Output "ADVPN: Registry Error Setting bind type."
            set RegistryErrorIndex = $(RegLastError)
            goto fatal
        endif

        CloseRegKey $(KeyProduct)
    endif

    ;
    ; Reconfig protocol since some adapter information may have changed
    ;
    ;shell "oemnxptc.inf",InstallOption,$($0),TC,$($2),$($3),+
			;$($4),$($5),$($6),$($7),$($8)

    ;
    ; add our installation file to ReviewPrograms
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(NetRules) $(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
        GetRegValue $(KeyProduct),"InfName", infName
        ifint $(RegLastError) == 0
            Shell "" AddToList *($(infName),4) OEMNSVRA.INF +
			$(ReviewProgram) ReviewPrograms
            ifint $($ShellCode) == $(!SHELL_CODE_OK)
                ifstr $($R0) != STATUS_SUCCESSFUL
                    Shell "" AddToList *($(infName),4) NBINFO.INF +
				$(ReviewProgram) ReviewPrograms BEFORE
                endif
            endif
        endif
        CloseRegKey $(KeyProduct)
    endif

    ;
    ; Add our Group to the service group list
    ;
    Shell "" AddToList $(ProductSoftwareGroup) NDIS $(ServiceOrder) List

    goto successful

removeadapter = +
    Debug-Output "ADVPN: RemoveAdapter"
    Shell "" RemoveIM
    goto end

UpgradeSoftware = +
    ifstr(i) $(ProductKeyName) == $(!NTN_RegBase)
	OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
	Ifstr $(KeyProduct) != $(KeyNull)
	    GetRegValue $(KeyProduct),"MajorVersion", VersionInfo
	    set Version = *($(VersionInfo), 4)
	    Shell $(UtilityInf), GetInfFileNameFromRegistry, $(KeyProduct)
	    ifint $($ShellCode) != $(!SHELL_CODE_OK)
		Debug-Output "ShellCode error"
	        CloseRegKey $(KeyProduct)
		goto ShellCodeError
	    endif
	    set !UG_Filename = $($R0)
            Debug-Output "CCL - Upgrading software UG_Filename is "$(!UG_Filename)
	    ifstr(i) $(!UG_Filename) != ""
		install "Install-Update"
		ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
	            CloseRegKey $(KeyProduct)
		    goto fatal
		endif
	    endif
	    SetRegValue $(KeyProduct) {MajorVersion,$(NoTitle),$(!REG_VT_SZ),+
			$(ProductMajorVersion)}
	    SetRegValue $(KeyProduct) {MinorVersion,$(NoTitle),$(!REG_VT_SZ),+
			$(ProductMinorVersion)}
	    ifint $(Version) != $(ProductVersion)
	    endif
	    CloseRegKey $(KeyProduct)
	else
	    goto fatalregistry
	endif
    endif
    goto end
cleanupSoftware = +
    Shell "" RemoveBobcatINFs
    goto end
successful = +
    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) == ""
	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
fatal = +
    Shell "" RemoveIM
    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 removeadapter
    endif
    goto end
end = +
    goto term
term = +
    Return $(CommonStatus)
[BindingsReview]
    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)

    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    OpenRegKey $(!REG_H_LOCAL) "" $(IMServiceKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        Return STATUS_USERCANCEL
    endif

    GetRegValue $(KeyProduct) Rebind rebind
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Registry Error Getting Rebind Value."
        goto bindingsReview_cont
    endif

    DeleteRegValue $(KeyProduct) Rebind

    CloseRegKey $(KeyProduct)

    ifint *($(rebind),4) == 1
       Shell "" GetImSampPath
       ifstr $($R0) == STATUS_SUCCESSFUL
         set cmd = $($R1)"\wgagent.dll,ReviewBindings"
         read-syms ErrorMessages
         Debug-Output "ADVPN: Loading ADVNDINT.DLL"
         ifstr(i) $(!PRUNEHANDLE) == ""
           LoadLibrary "x" advndint.dll !PRUNEHANDLE
         endif
         Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_REDO_NETWORK"
         LibraryProcedure Result $(!PRUNEHANDLE) +
                          BmGetDefaultLanguageString "IDS_NT_REDO_NETWORK_WARNING" +
                          $(szRedoNetworkWarning)
         Debug-Output "ADVPN: Return From DLL: "$(Result)
         Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "NONFATAL" $(Result) 

         StartDetachedProcess ExitCode "x" "" +
			$(!STF_WINDOWSSYSPATH)"\rundll32.exe" $(cmd)
         ifstr $(ExitCode) != "ERROR"
           Return STATUS_SUCCESSFUL
         else
           Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "FATAL" +
        		"Unable to start detached process"
           Return STATUS_USERCANCEL
         endif
       endif
    else-ifint *($(rebind),4) == 2
       Shell "" GetImSampPath
       ifstr $($R0) == STATUS_SUCCESSFUL
         set cmd = $($R1)"\wgagent.dll,ReviewBindings"
        
         read-syms ErrorMessages 
         Debug-Output "ADVPN: Loading ADVNDINT.DLL"
         ifstr(i) $(!PRUNEHANDLE) == ""
           LoadLibrary "x" advndint.dll !PRUNEHANDLE
         endif
         Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_REDO_NETWORK"
         LibraryProcedure Result $(!PRUNEHANDLE) +
                          BmGetDefaultLanguageString "IDS_NT_REDO_NETWORK_RAS_WARNING" +
                          $(szRedoNetworkRASWarning)

         Debug-Output "ADVPN: Return From DLL: "$(Result)
         Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "NONFATAL" $(Result)
         Shell "" RemoveIM

         StartDetachedProcess ExitCode "x" "" +
            $(!STF_WINDOWSSYSPATH)"\rundll32.exe" $(cmd)
         ifstr $(ExitCode) == "ERROR"
             Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "FATAL" +
        		"Unable to start detached process"
             Return STATUS_USERCANCEL
         endif

         ;
         ; Install new IM after next reboot
         ;
         OpenRegKey $(!REG_H_LOCAL) "" $(RunOnce) +
			$(MAXIMUM_ALLOWED) runHandle
         ifstr $(runHandle) == $(KeyNull)
            CreateRegKey $(!REG_H_LOCAL) {$(RunOnce),0,GenericClass} +
			"" $(MAXIMUM_ALLOWED) "" runHandle
         endif

         ifstr $(runHandle) == $(KeyNull)
            Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "FATAL" +
        		"Unable to add IM auto-install"
            Return STATUS_USERCANCEL
         endif

         SetRegValue $(runHandle) {InstallIM,0,+
		$(!REG_VT_SZ),"rundll32 wgagent.dll,DllRegisterServer"}
         ifint $(RegLastError) != 0
           Debug-Output "ADVPN: Registry Error Setting DLLRegisterServer."
           CloseRegKey $(runHandle)
           Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "FATAL" +
        		"Unable to install IM auto-install"
           Return STATUS_USERCANCEL
         endif

         CloseRegKey $(runHandle)
         Return STATUS_SUCCESSFUL
       endif
    endif

bindingsReview_cont = +
    ;
    ; NDISWAN 
    ;
    Shell "" NdisWanSupport
    ifint $($R0) != 1
        ifstr(i) $(!LIBHANDLE) == ""
            LoadLibrary "x" setupdll.dll !LIBHANDLE
            ifstr(i) $(!LIBHANDLE) == ""
                read-syms ErrorMessages
                Debug-Output "ADVPN: Loading ADVNDINT.DLL"
                ifstr(i) $(!PRUNEHANDLE) == ""
                  LoadLibrary "x" advndint.dll !PRUNEHANDLE
                endif
                Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_SETUP_DLL"
                LibraryProcedure Result $(!PRUNEHANDLE) +
                          BmGetDefaultLanguageString "IDS_NT_SETUP_DLL_WARNING" +
                          $(szSetupDLLWarning)
                Debug-Output "ADVPN: Return From DLL: "$(Result)
                Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "FATAL" $(Result)

                Return STATUS_USERCANCEL
            endif
        endif

        Shell "" SetRasArpBindValueFromTcpIP
        Shell "" UpdateLLInterface
    endif

     ;clean up the IM bindings
     Debug-Output "ADVPN: Loading ADVNDINT.DLL"
     ifstr(i) $(!PRUNEHANDLE) == ""
       LoadLibrary "x" advndint.dll !PRUNEHANDLE
     endif
     Debug-Output "ADVPN: Calling ImPruneBindings"
     LibraryProcedure Result $(!PRUNEHANDLE) ImPruneBindings
     Debug-Output "ADVPN: Binding pruning complete"
     Return STATUS_SUCCESSFUL


[Install-Option]
    Debug-Output "CCL - Install-Option section"
    Debug-Output "CCL - UG_Filename is "$(UG_Filename)
    set STF_VITAL = ""
    
    ifstr(i) $(AddCopy) == "YES"
	AddSectionFilesToCopyList Files-$(Option) $(SrcDir) +
				$(!STF_WINDOWSSYSPATH)\drivers
        AddSectionFilesToCopyList Files-$(Option)-DLL $(SrcDir) +
				$(!STF_WINDOWSSYSPATH)
    endif
    
    ifstr(i) $(DoCopy) == "YES"
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    endif
    
    ifstr(i) $(DoConfig) == "YES"
    endif
    
    Exit


[Install-Update]
   Debug-Output "CCL - Install-Update section"
   Debug-Output "CCL - UG_Filename is "$(UG_Filename)
   set STF_VITAL        = ""
   set STF_OVERWRITE    = "VERIFYSOURCEOLDER"
   
   AddSectionFilesToCopyList Files-$(Option) $(SrcDir) +
				$(!STF_WINDOWSSYSPATH)\drivers
   AddSectionFilesToCopyList Files-$(Option)-DLL $(SrcDir) +
				$(!STF_WINDOWSSYSPATH)
   AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)
   
   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   
   CopyFilesInCopyList
   
   exit

[Source Media Descriptions]
    1  = "ADVPN Installation Disk"  , TAGFILE = disk1

[ProductType]
STF_PRODUCT  = Winnt
STF_PLATFORM = I386              ;should be able to detect automatically?

[Files-Inf]
1,ADVNDINT.DLL,SIZE=2000
2,oemsetnt.inf,SIZE=2000,RENAME=$(!UG_Filename) 

[Files-IPSec VPN Drivers]
1,ADVPNNT.SYS,SIZE=2000  

[Files-IPSec VPN Drivers-DLL]
1,ADVNDINT.DLL,SIZE=2000  


;***********************************************************************************
;
; LANGUAGE SPECIFIC CONSTANTS
;
;***********************************************************************************
[LanguagesSupported]
    ENG

[OptionsTextENG]
    NDISPERF     = "IPSec VPN Drivers"

[FileConstantsENG]
ProCaption   = "Net Firewall Setup"  ;This shows as the title of the 
                                                         ; NT Copy Files Dialog
ProCancel    = "Cancel"                                  ;This shows on the cancel button?

                                                         ;This is displayed if the user selects
                                                         ; Cancel during file copy 
ProCancelMsg = "Net Firewall is not correctly installed.  "+
	       "Are you sure you want to cancel copying files?"
ProCancelCap = "Network Setup Message"                   ;This is shown as the title for any 
                                                         ; pop-ups during install?
ProText1     = "Copying:"
ProText2     = "To:"
FunctionTitle   = "Net Firewall"                         ;Used for caption of dialogs
	                                                 ;Used for description section in NCPA.
ProductSoftwareDescription = "Net Firewall"
                                                         ;Not sure diff between display name
                                                         ; and title
ProductSoftwareDisplayName = "Net Firewall"
                                                         ;This is the name displayed in the NCPA 
                                                         ; for the device, and it is concated 
	                                                 ; to the NIC we are bound to for our
                                                         ; description/title for our network
                                                         ; card entry 
ProductSoftwareTitle    = "Net Firewall"

ProductSoftwareGroup    = "NDISWAN"
ShellCodeErrorTitle     = "Error: "$(FunctionTitle)
ShellCodeErrorText      = "Shell Code Error."

[DialogConstantsENG]
Help        = "&Help"
Exit        = "Cancel"
OK          = "OK"
HelpContext = ""
Continue    = "Continue"
Cancel      = "Cancel"
[FileDependentDlgENG]
GroupLabel = "Optimization:"
Radio1 = "&Minimize Memory Used"
Radio2 = "&Balance"
Radio3 = "M&aximize Throughput && Connections"
DlgType = "Radio"               
DlgTemplate = "NBF"             
Caption = $(FunctionTitle)
OptionsGreyed = {}
HelpContext = $(!IDH_DB_OEMSETNT_INS)


[ErrorMessages]
szPreviousVersionWarning = "Setup has removed a previous version of the"+
                        "Net Firewall.  A reboot is required before"+
			"the new Net Firewall can be added."+ 
			"On the next reboot, the new Net Firewall "+
			"will be installed automatically."

szSetupDLLWarning       = "Dial-Up Networking setup was unable "+
			"to load setupdll.dll in the system32 "+
			"directory.  Please make sure this file is "+
			"present on your computer. Setup will now exit."

szRedoNetworkWarning   = "Net Firewall has discovered newly added"+
			 "or removed adapter(s).  It is necessary to redo the network "+
			 "bindings.  The current series of dialog windows will "+
			 "again be displayed.  Don't reboot the system until "+
			 "the binding process is completed."

szRedoNetworkRASWarning = "Net Firewall has discovered newly added RAS "+
			"adapter(s).  It is necessary to remove and reinstall "+
			"Net Firewall.  The current series of dialog windows "+
			"will again be displayed to remove Net Firewall.  Don't reboot "+
			"the system until the binding process is completed.  "+
			"After the reboot, Net Firewall will be installed automatically."

szPreviouslyInstalledWarning   =  $(ProductSoftwareTitle)" has recently been "+
			   "removed.  You must reboot before installing "+
			   "it again."
szWrongVersionWarning     = "Net Firewall is only supported for Windows NT"+
                          " Version 4.0! The current version of Windows NT is unsupported for"+
                          " Net Firewall."

szWrongServicePackWarning   = "Net Firewall is only supported for Windows NT"+
                          " 4.0 Service Pack 3 or later! The current service pack version"+ 
                          " is unsupported for Net Firewall. Please install"+
                          " Microsoft Windows NT 4.0 Service Pack 3 or later before attempting"+
                          " to install Net Firewall."

szSelectInterfacesWarning= "Net Firewall installation/configuration failed!"+
                          " Please check your network configuration and install"+
                          " again.   Note: TCP/IP is required.  Your Remote Access Service"+
                          " and/or your network card must be installed and configured to use"+
                          " TCP/IP."
szNOTCPIPWarning	= "TCP/IP has been removed.  Net Firewall"+
                          " requires TCP/IP and will not function properly"+
                          " without TCP/IP installed as a protocol. Net Firewall will be"+
                          " removed.  You must re-install Net Firewall after TCP/IP to use the"+
                          " secure VPN network connection."
szNTRASDisplay          = "Remote Access Service with Dial-Up Networking"

;*************************************************************************
;
;     SECTION:   FixupBindings
;
;     PURPOSE:   <fixup the bindings after added/deleted some adapters>
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[FixupBindings]

    Debug-Output "ADVPN: FixupBindings"
    read-syms GeneralConstants
    read-syms FileConstants

    set status = STATUS_SUCCESSFUL
    set temp = "temp"

    set tcpDisableLinkages = {}
    set KeyProduct = ""
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\Tcpip\Linkage\Disabled" +
		$(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
        Debug-Output "ADVPN: Able to open Tcpip\Linkage\Disabled"
        GetRegValue $(KeyProduct) Bind tcpDisableLinkage
        ifint $(RegLastError) == 0
            set tcpDisableLinkages = *($(tcpDisableLinkage),4)
        endif
        CloseRegKey $(KeyProduct)
    endif

    set NbfFlag = 0
    set NbfHandle = ""
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\Nbf" +
               $(!REG_KEY_READ) NbfHandle
    Ifstr $(NbfHandle) != $(KeyNull)
        Debug-Output "ADVPN: NetBEUI is installed."
        set NbfFlag = 1
        CloseRegKey $(NbfHandle)
    else
        set NbfFlag = 0
        Debug-Output "ADVPN: NetBEUI is NOT installed."
    endif

    set NetBTFlag = 0
    set NetBTHandle = ""
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NetBT" +
               $(!REG_KEY_READ) NetBTHandle
    ifstr $(NetBTHandle) != $(KeyNull)
        Debug-Output "ADVPN: NetBT is installed."
        set NetBTFlag = 1
        CloseRegKey $(NbfHandle)
    else
        set NetBTFlag = 0
        Debug-Output "ADVPN: NetBT is NOT installed."
    endif

    set IPXFlag = 0
    set IPXHandle = ""
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NwlnkIpx" +
               $(!REG_KEY_READ) IPXHandle
    ifstr $(IPXHandle) != $(KeyNull)
        Debug-Output "ADVPN: IPX is installed."
        set IPXFlag = 1
        CloseRegKey $(IPXHandle)
    else
        set IPXFlag = 0
        Debug-Output "ADVPN: IPX is NOT installed."
    endif

    set NbIPXFlag = 0
    set NbIPXHandle = ""
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NwlnkNb" +
               $(!REG_KEY_READ) NbIPXHandle
    ifstr $(NbIPXHandle) != $(KeyNull)
        Debug-Output "ADVPN: NbIPX is installed."
        set NbIPXFlag = 1
        CloseRegKey $(NbIPXHandle)
    else
        set NbIPXFlag = 0
        Debug-Output "ADVPN: NbIPX is NOT installed."
    endif

    ;-----------------------------------------------------------------
    ; 2001-02-02 Determine if  Novell Client is installed
    ;-----------------------------------------------------------------
    set NovellFlag = 0
    set NovellHandle = ""
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NetWareWorkstation" +
               $(!REG_KEY_READ) NovellHandle
    ifstr $(NovellHandle) != $(KeyNull)
        Debug-Output "ADVPN: Novell is installed."
        set NovellFlag = 1
        CloseRegKey $(NovellHandle)
    else
        set NovellFlag = 0
        Debug-Output "ADVPN: Novell is NOT installed."
    endif

    OpenRegKey $(!REG_H_LOCAL) "" $(IMLinkageKeyName)"\Disabled" +
		$(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        Return CANNOT_FIND_COMPONENT_SERVICE
    endif

    GetRegValue $(KeyProduct) Bind disableLinkage
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Registry Error Disabling Linkage."
        set disableLinkages = {}
    else
        set disableLinkages = *($(disableLinkage),4)
    endif
    CloseRegKey $(KeyProduct)

    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		CardsHandle
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Registry Error Opening Key for Network Cards."
        return STATUS_FAILED
    endif

    EnumRegKey $(CardsHandle) CardList
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Registry Error Enumerating Network Cards."
        CloseRegKey $(CardsHandle)
        return STATUS_FAILED
    endif

    CloseRegKey $(CardsHandle)

    set ImBind = {}
    set ImExport = {}
    set ImRoute = {}

    set TcpBind = {}
    set TcpExport = {}
    set TcpRoute = {}

    set NetBIOSBind = {}
    set NetBIOSExport = {}
    set NetBIOSRoute = {}

    set RasArpBind = {}

    set LanmanServerBind = {}
    set LanmanServerExport = {}
    set LanmanServerRoute = {}

    set LanmanWorkstationBind = {}
    set LanmanWorkstationExport = {}
    set LanmanWorkstationRoute = {}

    set NbfBind = {}
    set NbfExport = {}
    set NbfRoute = {}

    set NetBTBind = {}
    set NetBTRoute = {}
    set NetBTExport = {}

    set RemoteAccessBind = {}
    set RemoteAccessExport = {}
    set RemoteAccessRoute = {}

    ;-----------------------------------------------------------------
    ; NetWareWorkstation
    ;-----------------------------------------------------------------
    set NovellBind   = {}
    set NovellExport = {}
    set NovellRoute  = {}

    set RefCnt = 0
    set q = \042\042\042\042\042\042\042\042


    ifstr(i) $(!LIBHANDLE) == ""
        LoadLibrary "x" setupdll.dll !LIBHANDLE
    endif
    set compareSize = 0
    set compareString = $(ProductSoftwareName)"_NdisWan" 
    Split-String $(compareString) $(compareString) charList
    ForListDo $(charList)
        set-add compareSize = $(compareSize),1
    EndForListDo

    set adapterList = {}
    set origAdapterList = {}
    set ndiswanList = {}
    set ndiswanIPList = {}
    set ndiswanIPXList = {}
    set tcpipDisableList = {}


    ;-----------------------------------------------------------------
    ; Loop through the list of adapters installed.
    ;-----------------------------------------------------------------
        ForListDo $(CardList)

        Debug-Output "ADVPN: enumerating the Mircosoft\Windows NT\NetworkCards\xxxx: "$($)

        ;-----------------------------------------------------------------
        ; Open the Network cards key
        ;-----------------------------------------------------------------
        OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
        $(MAXIMUM_ALLOWED) CardHandle
        ifint $(RegLastError) != 0
            Debug-Output "ADVPN: Registry Error Opening Network Cards Key. "$(RegLastError)
            return STATUS_FAILED
        endif

        ;-----------------------------------------------------------------
        ; Read the Service Name
        ;-----------------------------------------------------------------
        GetRegValue $(CardHandle) ServiceName value
        ifint $(RegLastError) != 0
            Debug-Output "ADVPN: Registry Error Getting Registry Value for Service Name."$(RegLastError)
            CloseRegKey $(CardHandle)
            return STATUS_FAILED
        endif

        ;-----------------------------------------------------------------
        ; Parse the value read from the registry and save it into name

        ;
        ; value = {..., ..., ..., ADVPNT_ADAPTERSERVICE}
        ; name  = {ADVPN, ADAPTER}
        ;-----------------------------------------------------------------
        Split-String *($(value),4) "_" name

        Debug-Output "ADVPN: ServiceName value from registry for current card is "$(value)
        Debug-Output "ADVPN: setting name to "$(name)

        ;-----------------------------------------------------------------
        ; Check if it is an adapter with us bound to it
        ;-----------------------------------------------------------------
        ifstr *($(name),1) == $(ProductSoftwareName)
            set disable = 0
            set currentCard = "\Device\"*($(value),4)  ; e.g. \Device\IM_NdisWan4

            Debug-Output "ADVPN: this is an adapter we are bound to"

            ;-----------------------------------------------------------------
            ; Check to see if this adapter is in the list of disabled adapters
            ;-----------------------------------------------------------------
            ForListDo $(disableLinkages)
                ifstr(i) $($) == $(currentCard)
                    set disable = 1
                    Debug-Output "ADVPN: found this adapter in the list of disabled adapters"
                endif
            EndForListDo

            ;-----------------------------------------------------------------
            ; If we're not marked as disabled then add the adapter to either 
            ; the ndiswanIPList or (origAdapterList and adapterList)
            ;-----------------------------------------------------------------
            ifint $(disable) == 0
                ;Compare against NdisWan card name
                LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp *($(value),4) $(compareString) $(compareSize)

                ifint $(Result) == 0
                    ;
                    ;Read the Product Name
                    ;
                    ; GetRegValue $(CardHandle) ProductName ProductValue 
                    ; ifint $(RegLastError) != 0
                    ;   Debug-Output "ADVPN: Registry Error Getting Product Name."
                    ;   CloseRegKey $(CardHandle)
                    ;   return STATUS_FAILED
                    ; endif
                    ;
                    ; We should only receive dialoutIp cards, but check again to be sure
                    ;
                    ; Had to remove if check when fixed 720 error 
                    ; CCL 5/2000
                    ; ifstr(i) *($(ProductValue),4) == "NdisWanDialOutIP"  

                    set ndiswanIPList = >($(ndiswanIPList),*($(name),3))
                    Debug-Output "ADVPN: added "*($(name),3)" to ndiswanIpList"
                    ;  endif
                else
                    set adapterList = >($(adapterList),*($(value),4))
                    Debug-Output "ADVPN: added "*($(value),4)" to adapterList"

                    ; Make list with original name for Nbf
                    set origAdapterList = >($(origAdapterList),*($(name),3))
                    Debug-Output "ADVPN: added "*($(name),3)" to OrigAdapterList"
                endif
            else
                ;-----------------------------------------------------------------
                ; Scan the tcpDisabledLinkages list for the currentCard,
                ; if it is found set the disable flag to 2 to indicate that it
                ; should not be added to the disabled list. Otherwise, add it to
                ; the tcpDisabledLinkages list
                ;-----------------------------------------------------------------
                ForListDo $(tcpDisableLinkages)
                    ifstr(i) $($) == $(currentCard)
                        set disable = 2
                        Debug-Output "ADVPN: "$(currentCard)" already in the tcpDisableLinkages list"
                    endif
                EndForListDo
                ifint $(disable) == 1
                    set tcpipDisableList = >($(tcpipDisableList),*($(value),4))
                    Debug-Output "ADVPN: added "*($value,4)" to the tcpDisableLinkages list"
                endif
            endif

            ;-----------------------------------------------------------------
            ; Increment $(RefCnt) counter -- this is recorded in the registry
            ; later, exactly for is not clear.
            ;-----------------------------------------------------------------
            set-add RefCnt = $(RefCnt), 1

        else
            ;-----------------------------------------------------------------
            ; Check if it is NdisWanDialinoutIPX or NdisWanDialOut
            ; if it is, add it to ndiswanlist so that the Nbf bindings get 
            ; added correctly.
            ;-----------------------------------------------------------------
            Debug-Output "ADVPN: we are not bound to this adapter"

            ;-----------------------------------------------------------------
            ; Read the Product Name
            ;-----------------------------------------------------------------
            GetRegValue $(CardHandle) ProductName ProductValue 
            ifint $(RegLastError) != 0
                Debug-Output "ADVPN: Registry Error Getting Product Name: "$(RegLastError)
                CloseRegKey $(CardHandle)
                return STATUS_FAILED
            endif
            
            Debug-Output "ADVPN: the ProductName for the adapter is: "$(ProductValue)

            ;-----------------------------------------------------------------
            ; Check if the current adapter is a NdisWanDialinoutIPX or 
            ; NdisWanDialOut type, if it is add it to the ndiswanList
            ;-----------------------------------------------------------------
            ifstr(i) *($(ProductValue),4) == "NdisWanDialinoutIPX"
                set ndiswanIPXList = >($(ndiswanList),*($(value),4))
                Debug-Output "ADVPN: adapter is NdisWanDialinoutIPX added to the ndiswanList: "*($(value),4)
            else-ifstr(i) *($(ProductValue),4) == "NdisWanDialOut"  
               ifstr(i) *($(ProductValue),4) != "NdisWanDialOutIP"
                   set ndiswanList = >($(ndiswanList), *($(value),4))
                   Debug-Output "ADVPN: adapter is NdisWanDialOutIP added to the ndiswanList: "*($(value),4)
               endif
            else
               Debug-Output "ADVPN: this adapter is not NdisWanDialinoutIPX or NdisWanDialOut and is not bound to us"
            endif
        endif

        CloseRegKey $(CardHandle)
    EndForListDo


    ifstr $(!IM_NDISWAN) == ""
        set !IM_NDISWAN = {}
    endif

    ;-----------------------------------------------------------------
    ; If Novell is installed, setup NetWareWorkstation linkages
    ;-----------------------------------------------------------------
    ifint $(NovellFlag) == 1

        Debug-Output "ADVPN: Novell installed, updating linkages"  

        ;-----------------------------------------------------------------
        ; Setup Tcpip linkages for Novell
        ;-----------------------------------------------------------------
        ForListDo $(adapterList)

            Debug-Output "ADVPN: Setting up Tcpip linkages for the Novell adapter "$($)

            set tmp = "\Device\Tcpip\"$($)
            set NovellBind = >($(NovellBind), $(tmp))

            set tmp = "\Device\Nwfs\Tcpip\"$($)
            set NovellExport = >($(NovellExport), $(tmp))

            set tmp = $(q)"Tcpip"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
            set NovellRoute = >($(NovellRoute), $(tmp))
 
        EndForListDo

        ;-----------------------------------------------------------------
        ; Setup IPX linkages for Novell
        ;-----------------------------------------------------------------
        ;ForListDo $(adapterList) - novell only uses one adapter for IPX

        ifint $(IPXFlag) == 1

            Debug-Output "ADVPN: Setting up IPX linkages for the Novell adapter "$($)

            set NovellBind   = >($(NovellBind)  , "\Device\NwlnkIpx"     )
            set NovellExport = >($(NovellExport), "\Device\Nwfs\NwlnkIpx")
            
            ; Novell only puts one route to an adapter for IPX reguardless of the
            ; number of adapters installed (I don't why, could it be a mistake?)
            
            set tmp = $(q)"NwlnkIpx"$(q)" "$(q)*($(adapterList), 1)$(q)
            set NovellRoute = >($(NovellRoute), $(tmp))

        endif

        ;EndForListDo
    endif

    ;
    ; If IPX is installed, setup IPX parameters
    ;
    ifint $(IPXFlag) == 1
      set RemoteAccessBind = >($(RemoteAccessBind),"\Device\NwlnkIpx")
      set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\NwlnkIpx")
      set LanmanServerBind = >($(LanmanServerBind),"\Device\NwlnkIpx")
      set LanmanServerExport = >($(LanmanServerExport),+
                                  "\Device\LanmanServer\NwlnkIpx")
     
      QueryListSize ListSize $(ndiswanIPXList)
      ifint $(ListSize) > 0
        ForListDo $(ndiswanIPXList)
          set tmp = $(q)"NwlnkIpx"$(q)" "$(q)$($)$(q)
          set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
          set tmp = $(q)"NwlnkIpx"$(q)" "$(q)$($)$(q)
          set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
        EndForListDo
      else
        ForListDo $(origAdapterList)
          set ProductValue = ""
          set CardToMatch = $($)
          ForListDo $(CardList)
            ;
            ; Open the Network cards key
            ;
            OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
                 $(MAXIMUM_ALLOWED) CardHandle
            ifint $(RegLastError) != 0
              Debug-Output "ADVPN: Registry Error Opening Network Cards Key."
              return STATUS_FAILED
            endif
            ;
            ;Read the Service Name
            ;
            GetRegValue $(CardHandle) ServiceName value
            ifint $(RegLastError) != 0
              Debug-Output "ADVPN: Registry Error Getting Registry Value for Service Name."
              CloseRegKey $(CardHandle)
              return STATUS_FAILED
            endif
            Debug-Output "ADVPN: Value is "*($(value),4)
            Debug-Output "ADVPN: CardToMatch is "$(CardToMatch)
   
            ifstr *($(value),4) == $(CardToMatch)
              ;Read the Product Name
              ;
              Debug-Output "ADVPN: Match found, reading ProductName"
              GetRegValue $(CardHandle) ProductName ProductValue 
              ifint $(RegLastError) != 0
                Debug-Output "ADVPN: Registry Error Getting Product Name."
                CloseRegKey $(CardHandle)
                return STATUS_FAILED
              endif
            endif

            CloseRegKey $(CardHandle)
          EndForListDo
    
          set tmp = $(q)"NwlnkIpx"$(q)" "$(q)*($(ProductValue),4)$(q)
          set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
          set tmp = $(q)"NwlnkIpx"$(q)" "$(q)*($(ProductValue),4)$(q)
          set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
        EndForListDo
      endif
    endif

    ;
    ; If NbIPX is installed, setup NbIPX parameters
    ;
    ifint $(NbIPXFlag) == 1
      set LanmanServerBind = >($(LanmanServerBind),"\Device\NwlnkNb")
      set LanmanServerExport = >($(LanmanServerExport),+
                                  "\Device\LanmanServer\NwlnkNb")
      set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\NwlnkNb")
      set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                  "\Device\LanmanWorkstation\NwlnkNb")
      set NetBIOSBind = >($(NetBIOSBind),"\Device\NwlnkNb")
      set NetBIOSExport = >($(NetBIOSExport),"\Device\NetBios\NwlnkNb")
       
      set tmp = $(q)"NwlnkNb"$(q)" "$(q)"NwlnkIpx"$(q)
      set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
      set tmp = $(q)"NwlnkNb"$(q)" "$(q)"NwlnkIpx"$(q)
      set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
      set tmp = $(q)"NwlnkNb"$(q)" "$(q)"NwlnkIpx"$(q)
      set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
    endif

    ;
    ; ndiswan list should only contain original NdisWanDialOut Cards, not any of our cards
    ;
    Debug-Output "ADVPN: ndiswanList is "$(ndiswanList)
    ifint $(NbfFlag) == 1
      ForListDo $(ndiswanList)
        set NbfBind = >($(NbfBind), "\Device\"$($))
        set NbfExport = >($(NbfExport),"\Device\Nbf_"$($))

        set NetBIOSBind = >($(NetBIOSBind),"\Device\Nbf_"$($))
        set NetBIOSExport = >($(NetBIOSExport),"\Device\Netbios\Nbf_"$($))

        set RemoteAccessBind = >($(RemoteAccessBind),"\Device\Nbf_"$($))
        set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\Nbf_"$($))

        set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\Nbf_"$($))
        set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                                "\Device\LanmanWorkstation\Nbf_"$($))

        set LanmanServerBind = >($(LanmanServerBind),"\Device\Nbf_"$($))
        set LanmanServerExport = >($(LanmanServerExport),+
                                                "\Device\LanmanServer\Nbf_"$($))

        set tmp = $(q)"Nbf"$(q)" "$(q)$($)$(q)
        set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
        set tmp = $(q)"Nbf"$(q)" "$(q)$($)$(q)
        set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
        set tmp = $(q)"Nbf"$(q)" "$(q)$($)$(q)
        set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
        set tmp = $(q)"Nbf"$(q)" "$(q)$($)$(q)
        set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
        set tmp = $(q)$($)$(q)
        set NbfRoute = >($(NbfRoute), $(tmp))
      EndForListDo
    endif

    ;
    ; origAdapter list should only contain original Cards, not any of our cards
    ; Form  Card# = ProductInfo  i.e. IBMTOK41=IBMTOK4
    ;
    ifint $(NbfFlag) == 1
      Debug-Output "ADVPN: origAdapterList is "$(origAdapterList)
      ForListDo $(origAdapterList)
        set ProductValue = ""
        set CardToMatch = $($)
        Debug-Output "ADVPN: Card List is "$(CardList)
        ForListDo $(CardList)
          ;
          ; Open the Network cards key
          ;
          OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
                   $(MAXIMUM_ALLOWED) CardHandle
          ifint $(RegLastError) != 0
            Debug-Output "ADVPN: Registry Error Opening Network Cards Key."
            return STATUS_FAILED
          endif
	  ;
          ;Read the Service Name
          ;
          GetRegValue $(CardHandle) ServiceName value
          ifint $(RegLastError) != 0
            Debug-Output "ADVPN: Registry Error Getting Registry Value for Service Name."
            CloseRegKey $(CardHandle)
            return STATUS_FAILED
          endif
          Debug-Output "ADVPN: Value is "*($(value),4)
          Debug-Output "ADVPN: CardToMatch is "$(CardToMatch)
	   
          ifstr *($(value),4) == $(CardToMatch)
            ;Read the Product Name
            ;
            Debug-Output "ADVPN: Match found, reading ProductName"
            GetRegValue $(CardHandle) ProductName ProductValue 
            ifint $(RegLastError) != 0
               Debug-Output "ADVPN: Registry Error Getting Product Name."
               CloseRegKey $(CardHandle)
               return STATUS_FAILED
            endif
          endif

          CloseRegKey $(CardHandle)
        EndForListDo
     
        Debug-Output "ADVPN: Product Value is "$(ProductValue) 
        ifstr $(ProductValue) == ""
        Debug-Output "ADVPN: Product Name Undefined."
        return STATUS_FAILED
        endif

        set NbfBind = >($(NbfBind), "\Device\"$($))
        set NbfExport = >($(NbfExport),"\Device\Nbf_"$($))

        set NetBIOSBind = >($(NetBIOSBind),"\Device\Nbf_"$($))
        set NetBIOSExport = >($(NetBIOSExport),"\Device\Netbios\Nbf_"$($))

        set RemoteAccessBind = >($(RemoteAccessBind),"\Device\Nbf_"$($))
        set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\Nbf_"$($))

        set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\Nbf_"$($))
        set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                                "\Device\LanmanWorkstation\Nbf_"$($))
        set LanmanServerBind = >($(LanmanServerBind),"\Device\Nbf_"$($))
        set LanmanServerExport = >($(LanmanServerExport),+
                                                "\Device\LanmanServer\Nbf_"$($))

        set tmp = $(q)"Nbf"$(q)" "$(q)*($(ProductValue),4)$(q)" "$(q)$($)$(q)
        set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
        set tmp = $(q)"Nbf"$(q)" "$(q)*($(ProductValue),4)$(q)" "$(q)$($)$(q)
        set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
        set tmp = $(q)"Nbf"$(q)" "$(q)*($(ProductValue),4)$(q)" "$(q)$($)$(q)
        set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
        set tmp = $(q)"Nbf"$(q)" "$(q)*($(ProductValue),4)$(q)" "$(q)$($)$(q)
        set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
        set tmp = $(q)*($(ProductValue),4)$(q)" "$(q)$($)$(q)
        set NbfRoute = >($(NbfRoute), $(tmp))
      EndForListDo
    endif
 
    ;
    ; For NdisWan type cards, Nbf_ bindings only occur to NdisWanDialOut type
    ; NetBT_ bindings only occur to NdisWanDialOutIP type
    ; NdisWanDialOut types also shouldn't update TCP/IP Bind types
    ;
    Debug-Output "ADVPN: IM_NDISWAN is "$(!IM_NDISWAN)
    ForListDo $(!IM_NDISWAN)
    ;    set currentCard = $(ProductSoftwareName)"_"$($)
        set currentCard = $($)
        Debug-Output "ADVPN: ndiswanIPList is "$(ndiswanIPList)
        ForListDo $(ndiswanIPList)
            ifstr $(currentCard) == $($)
                set ImBind = >($(ImBind), "\Device\"$(ProductSoftwareName)"_"$($))
                set ImExport = >($(ImExport), "\Device\"$(ProductSoftwareName)"_"$($))
                set ImRoute = >($(ImRoute), $(q)$(ProductSoftwareName)"_"$($)$(q))
               
                set TcpBind = >($(TcpBind), "\Device\"$(ProductSoftwareName)"_"$($))
                set TcpExport = >($(TcpExport), "\Device\Tcpip\"$(ProductSoftwareName)"_"$($))
 
                set RasArpBind = >($(RasArpBind),"\Device\"$(ProductSoftwareName)" "$($))
                ifint $(NetBTFlag) == 1
                  set NetBTBind = >($(NetBTBind), "\Device\"$($))
                  set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
                  set tmp = $(q)$($)$(q)
                  set NetBTRoute = >($(NetBTRoute), $(tmp))

                  set NetBIOSBind = >($(NetBIOSBind),"\Device\NetBT_"$($))
                  set NetBIOSExport = >($(NetBIOSExport),"\Device\Netbios\NetBT_"$($))

                  set RemoteAccessBind = >($(RemoteAccessBind),"\Device\NetBT_"$($))
                  set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\NetBT_"$($))
                  set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\NetBT_"$($))
                  set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                                "\Device\LanmanWorkstation\NetBT_"$($))
                  set LanmanServerBind = >($(LanmanServerBind),"\Device\NetBT_"$($))
                  set LanmanServerExport = >($(LanmanServerExport),+
                                                "\Device\LanmanServer\NetBT_"$($))

                  set tmp = $(q)"NetBT"$(q)" "$(q)$($)$(q)
                  set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
                  set tmp = $(q)"NetBT"$(q)" "$(q)$($)$(q)
                  set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
                  set tmp = $(q)"NetBT"$(q)" "$(q)$($)$(q)
                  set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
                  set tmp = $(q)"NetBT"$(q)" "$(q)$($)$(q)
                  set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
                endif
                set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
                set TcpRoute = >($(TcpRoute), $(tmp))
            endif
        EndForListDo
    EndForListDo

fixupBindings_cont = +

    ;
    ; Regular full NIC cards support bindings to both Nbf and NetBT
    ; Although, Nbf should go directly to NIC, since that is NetBEUI traffic
    ; and not IP traffic, taken care of with origAdapterList
    ;
    Debug-Output "ADVPN: adapterList is "$(adapterList)
    ForListDo $(adapterList)
        set ImBind = >($(ImBind), "\Device\"$($))
        set ImExport = >($(ImExport), "\Device\"$($))
        set ImRoute = >($(ImRoute), $(q)$($)$(q))
        set TcpBind = >($(TcpBind), "\Device\"$($))
        set TcpExport = >($(TcpExport), "\Device\Tcpip\"$($))

        ifint $(NetBTFlag) == 1
          set NetBTBind = >($(NetBTBind), "\Device\"$($))
          set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
          set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set NetBTRoute = >($(NetBTRoute), $(tmp))

          set NetBIOSBind = >($(NetBIOSBind),"\Device\NetBT_"$($))
          set NetBIOSExport = >($(NetBIOSExport),"\Device\Netbios\NetBT_"$($))
          set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\NetBT_"$($))
          set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                         "\Device\LanmanWorkstation\NetBT_"$($))

          set LanmanServerBind = >($(LanmanServerBind),"\Device\NetBT_"$($))
          set LanmanServerExport = >($(LanmanServerExport),+
                                         "\Device\LanmanServer\NetBT_"$($))

          set RemoteAccessBind = >($(RemoteAccessBind),"\Device\NetBT_"$($))
          set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\NetBT_"$($))

          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
        endif
        set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
        set TcpRoute = >($(TcpRoute), $(tmp))
    EndForListDo


    Debug-Output "ADVPN: tcpipDisableList is "$(tcpipdisableList)
    ForListDo $(tcpipDisableList)
        set TcpBind = >($(TcpBind), "\Device\"$($))
        set TcpExport = >($(TcpExport), "\Device\Tcpip\"$($))

        ifint $(NetBTFlag) == 1
          set NetBTBind = >($(NetBTBind), "\Device\"$($))
          set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
          set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set NetBTRoute = >($(NetBTRoute), $(tmp))

          set NetBIOSBind = >($(NetBIOSBind),"\Device\NetBT_"$($))
          set NetBIOSExport = >($(NetBIOSExport),"\Device\Netbios\NetBT_"$($))

          set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\NetBT_"$($))
          set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                         "\Device\LanmanWorkstation\NetBT_"$($))

          set LanmanServerBind = >($(LanmanServerBind),"\Device\NetBT_"$($))
          set LanmanServerExport = >($(LanmanServerExport),+
                                         "\Device\LanmanServer\NetBT_"$($))

          set RemoteAccessBind = >($(RemoteAccessBind),"\Device\NetBT_"$($))
          set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\NetBT_"$($))

          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
          set tmp = $(q)"NetBT"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
        endif
        ifint $(NbfFlag) == 1
          set NbfBind = >($(NbfBind), "\Device\"$($))
          set NbfExport = >($(NbfExport),"\Device\Nbf_"$($))
          set NetBIOSBind = >($(NetBIOSBind),"\Device\Nbf_"$($))
          set NetBIOSExport = >($(NetBIOSExport),"\Device\Netbios\Nbf_"$($))
          set LanmanWorkstationBind = >($(LanmanWorkstationBind),"\Device\Nbf_"$($))
          set LanmanWorkstationExport = >($(LanmanWorkstationExport),+
                                         "\Device\LanmanWorkstation\Nbf_"$($))
          set LanmanServerBind = >($(LanmanServerBind),"\Device\Nbf_"$($))
          set LanmanServerExport = >($(LanmanServerExport),+
                                         "\Device\LanmanServer\Nbf_"$($))
          set RemoteAccessBind = >($(RemoteAccessBind),"\Device\Nbf_"$($))
          set RemoteAccessExport = >($(RemoteAccessExport),"\Device\RasServer\Nbf_"$($))

          set tmp = $(q)"Nbf"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set NetBIOSRoute = >($(NetBIOSRoute), $(tmp))
          set tmp = $(q)"Nbf"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set LanmanWorkstationRoute = >($(LanmanWorkstationRoute), $(tmp))
          set tmp = $(q)"Nbf"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set LanmanServerRoute = >($(LanmanServerRoute), $(tmp))
          set tmp = $(q)"Nbf"$(q)" "$(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set RemoteAccessRoute = >($(RemoteAccessRoute), $(tmp))
          set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
          set NbfRoute = >($(NbfRoute), $(tmp))
        endif
        set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
        set TcpRoute = >($(TcpRoute), $(tmp))
    EndForListDo

    OpenRegKey $(!REG_H_LOCAL) "" $(IMServiceKeyName) $(MAXIMUM_ALLOWED) +
		IMHandle  
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Error Opening Service Key"
        return STATUS_FAILED
    endif

fixupBindings_CreateTempKey = +

    CreateRegKey $(IMHandle) {$(temp),$(NoTitle),GenericClass} "" +
		$(MAXIMUM_ALLOWED) "" TempHandle
    ifint $(RegLastError) == 1011 ; key already exist
        Debug-Output "ADVPN: Key already exists."
        DeleteRegTree $(IMHandle) $(temp)
        goto fixupBindings_CreateTempKey
    else-ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Error creating Key (3)"
        CloseRegKey $(IMHandle)
        return STATUS_FAILED
    endif

    ;
    ;Update ADVPNNT Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(ImBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(ImExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(ImRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),$(IMServiceKeyName),+
		Linkage,$(NoTitle),GenericClass,FORCE

    ;
    ;Update TCP/IP Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(TcpBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(TcpExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(TcpRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\Tcpip",Linkage,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update Novell Linkage
    ;
    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NovellBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NovellExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NovellRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\NetWareWorkstation",Linkage,$(NoTitle),+
		GenericClass,FORCE


    ;
    ;Update NetBT Linkage
    ;

    ifint $(NetBTFlag) == 1
      set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBTBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBTExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBTRoute)}}

      Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
      Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
      Endif
      Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
      Endif

      Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\NetBT",Linkage,$(NoTitle),+
		GenericClass,FORCE
    endif


    ;
    ;Update LanmanWorkstation Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(LanmanWorkstationBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(LanmanWorkstationExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(LanmanWorkstationRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\LanmanWorkstation",Linkage,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update LanmanServer Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(LanmanServerBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(LanmanServerExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(LanmanServerRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\LanmanServer",Linkage,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update RemoteAccess Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(RemoteAccessBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(RemoteAccessExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(RemoteAccessRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\RemoteAccess",Linkage,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update NetBIOS Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBIOSBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBIOSExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBIOSRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\NetBIOS",Linkage,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update NetBIOSInformation Linkage
    ;

    set-subst NewValueList = {+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBIOSRoute)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    DeleteRegValue $(TempHandle) "Bind"
    DeleteRegValue $(TempHandle) "Export"

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\NetBIOSInformation",Parameters,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update RasArp Linkage
    ;

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(RasArpBind)}}

    Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
    Endif
    DeleteRegValue $(TempHandle) "Route"
    DeleteRegValue $(TempHandle) "Export"

    Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
		$(!NTN_ServiceBase)"\RasArp",Linkage,$(NoTitle),+
		GenericClass,FORCE

    ;
    ;Update Nbf Linkage
    ;

    ifint $(NbfFlag) == 1
      set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NbfBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NbfExport)},+
		{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NbfRoute)}}

      Shell $(UtilityInf) AddValueList $(TempHandle) $(NewValueList)
      Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        set status = STATUS_FAILED
        goto fixupBindings_exit
      Endif
      Ifstr(i) $($R0) != NO_ERROR
        set status = STATUS_FAILED
        goto fixupBindings_exit
      Endif

      Shell "",CopyRegTree,$(IMServiceKeyName)"\"$(temp),+
	 	$(!NTN_ServiceBase)"\Nbf",Linkage,$(NoTitle),+
		GenericClass,FORCE
    endif

    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) SoftKey
    Ifstr $(SoftKey) != $(KeyNull)
        SetRegValue $(SoftKey) {RefCount,$(NoTitle),$(!REG_VT_DWORD),$(RefCnt)}
        CloseRegKey $(SoftKey)
    endif

fixupBindings_exit = +

    DeleteRegTree $(IMHandle) $(temp)
    CloseRegKey $(IMHandle)
    CloseRegKey $(TempHandle)
    return $(status)

;*************************************************************************
;
;     SECTION:   GetImSampPath
;
;     PURPOSE:   <Get the ImSamp path>
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - STATUS_SUCCESSFUL/STATUS_FAILED
;                $R1 - ImSamp path
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[GetImSampPath]
    Debug-Output "ADVPN: GetImSampPath"

    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(IMSoftwareKey)"TCPIP" +
			$(MAXIMUM_ALLOWED) KeySoftware
    Ifstr $(KeySoftware) != $(KeyNull)
        GetRegValue $(KeySoftware) Path value
        ifint $(RegLastError) == 0
            CloseRegKey $(KeySoftware)
            return STATUS_SUCCESSFUL, *($(value),4)
        endif
        CloseRegKey $(KeySoftware)
    endif

    Debug-Output "ADVPN:GetImSampPath returning FAILED"
    return STATUS_FAILED

;*************************************************************************
;
;     SECTION:   ReplaceText
;
;     PURPOSE:   <Replace string1 with string2 in text>
;
;   ARGUMENTS:   $0 - text
;                $1 - string1
;                $2 - string2
;
;     RETURNS:   $R0 - STATUS_SUCCESSFUL/STATUS_FAILED
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[ReplaceText]

    Debug-Output "ADVPN: ReplaceText - Text "$(0)
    Debug-Output "ADVPN: ReplaceText - String 1 "$(1)
     Debug-Output "ADVPN: ReplaceText - String 2 "$(2)
    read-syms GeneralConstants
    read-syms FileConstants

    Shell "" GetImSampPath
    ifstr $($R0) != STATUS_SUCCESSFUL
        Debug-Output "ADVPN: GetImSampPath was unsuccessful"
        return $($R0)
    endif

    ifstr(i) $(!myLIBHANDLE) == ""
        LoadLibrary "x" $($R1)"\wgagent.dll" !myLIBHANDLE
    endif
    LibraryProcedure Result $(!myLIBHANDLE),ReplaceTxt,$($0),$($1),$($2)
    ;FreeLibrary $(myLIBHANDLE)

    ifint *($(Result),1) == 0
        return STATUS_SUCCESSFUL, *($(Result),2)
    else
        return STATUS_FAILED
    endif

;*************************************************************************
;
;     SECTION:   FindNetworkCardProductName
;
;     PURPOSE:   <Find network card's product name from the service name
;
;   ARGUMENTS:   $0 - service name
;
;     RETURNS:   $R0 - STATUS_SUCCESSFUL/STATUS_FAILED
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[FindNetworkCardProductName]

    Debug-Output "ADVPN: FindNetworkCardProductName - Service name = "$($0)
    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		KeyHandle
    Ifstr $(KeyHandle) != $(KeyNull)
        EnumRegKey $(KeyHandle) KeyList
        ifint $(RegLastError) == 0
            ForListDo $(KeyList)
                OpenRegKey $(!REG_H_LOCAL) "" +
			$(NetworkCardsKeyName)"\"*($($),1) +
			$(MAXIMUM_ALLOWED) kHandle
                Ifstr $(kHandle) != $(KeyNull)
                    GetRegValue $(kHandle) ServiceName value
                    ifint $(RegLastError) == 0
                        ifstr *($(value),4) == $($0)
                            GetRegValue $(kHandle) ProductName value
                            ifint $(RegLastError) == 0
                                CloseRegKey $(kHandle)
                                CloseRegKey $(KeyHandle)
                                return STATUS_SUCCESSFUL, *($(value),4)
                            endif
                        endif
                    endif
                    CloseRegKey $(kHandle)
                endif
            EndForListDo
        endif
        CloseRegKey $(KeyHandle)
    endif

    return STATUS_FAILED

;*************************************************************************
;
;     SECTION:   FixupBindingsAfterRemove
;
;     PURPOSE:   <fixup the bindings after IM is removed
;
;   ARGUMENTS:   $0 - service bindings to fixup
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[FixupBindingsAfterRemove]

 Debug-Output "ADVPN: FixupBindingsAfterRemove"
    read-syms GeneralConstants
    read-syms FileConstants

    set status = STATUS_SUCCESSFUL

    OpenRegKey $(!REG_H_LOCAL) "" $($0) $(MAXIMUM_ALLOWED) TcpHandle
    Ifstr $(TcpHandle) == $(KeyNull)
        return STATUS_FAILED
    endif

    set routeList = {}

    GetRegValue $(TcpHandle) Bind value
    ifint $(RegLastError) == 0
	set list = {}
	ForListDo *($(value),4)
            Shell "" ReplaceText $($) $(ProductSoftwareName)"_" ""
            ifstr $($R0) == STATUS_SUCCESSFUL
                set list = >($(list),$($R1))
                Split-String $($R1) "\" temp
                set routeList = >($(routeList),*($(temp),4))
            endif
        EndForListDo
        ifstr $(list) != {}
            set NewValue = {Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(list)}
            SetRegValue $(TcpHandle) $(NewValue)
        endif
    endif

    GetRegValue $(TcpHandle) Export value
    ifint $(RegLastError) == 0
        set list = {}
        ForListDo *($(value),4)
            Shell "" ReplaceText $($) $(ProductSoftwareName)"_" ""
            ifstr $($R0) == STATUS_SUCCESSFUL
                set list = >($(list),$($R1))
            endif
        EndForListDo
        ifstr $(list) != {}
            set NewValue = {Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(list)}
            SetRegValue $(TcpHandle) $(NewValue)
        endif
    endif

    set route = {}
    set q = \042\042\042\042\042\042\042\042
    ForListDo $(routeList)
        Shell "" FindNetworkCardProductName $($)
        ifstr $($R0) == STATUS_SUCCESSFUL 
            set temp = $(q)$($R1)$(q)" "$(q)$($)$(q)
            set route = >($(route), $(temp))
        endif
    EndForListDo

    ifstr $(route) != {}
        set-subst NewValue = {{Route,$(NoTitle),$(!REG_VT_MULTI_SZ),$(route)}}
        Shell $(UtilityInf) AddValueList $(TcpHandle) $(NewValue)
    endif

    CloseRegKey $(TcpHandle)
    return STATUS_SUCCESSFUL

;*************************************************************************
;
;     SECTION:   FixupAdaptersAfterRemove
;
;     PURPOSE:   <fixup the adapters after IM is removed
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[FixupAdaptersAfterRemove]
    Debug-Output "ADVPN: FixupAdaptersAfterRemove"  
    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		KeyHandle
    Ifstr $(KeyHandle) != $(KeyNull)

        EnumRegKey $(KeyHandle) KeyList
        ifint $(RegLastError) == 0

            ForListDo $(KeyList)
                set deleteSrcKey = NO
                set oldInstance = *($($),1)
                set srcKey = $(NetworkCardsKeyName)"\"$(oldInstance)
                OpenRegKey $(!REG_H_LOCAL) "" $(srcKey) +
			$(MAXIMUM_ALLOWED) kHandle
                Ifstr $(kHandle) != $(KeyNull)

                    GetRegValue $(kHandle) ProductName product
                    ifint $(RegLastError) == 0

                        GetRegValue $(kHandle) ServiceName service
                        ifint $(RegLastError) == 0

                            set productStr = *($(product),4)
                            set serviceStr = *($(service),4)
                            Split-String $(productStr) $(productStr) product
                            Split-String $(serviceStr) $(serviceStr) service
                            QueryListSize productSize $(product)
                            QueryListSize serviceSize $(service)

                            ifint $(serviceSize) > $(productSize)
                                set count = 0
                                set instance = 0
                                ForListDo $(service)
                                    set-add count = $(count),1
                                    ifint $(count) > $(productSize)
                                        set-mul instance = $(instance),10
                                        set-add instance = $(instance),$($)
                                    endif
                                EndForListDo

                                ifint $(oldInstance) != $(instance)
                                    Shell "",CopyRegTree,$(srcKey),+
					$(NetworkCardsKeyName),$(instance),+
					$(NoTitle),GenericClass,FORCE
                                    Ifint $($ShellCode) == $(!SHELL_CODE_OK)
                                        Ifstr $($R0) == STATUS_SUCCESSFUL
                                            set deleteSrcKey = YES
                                        endif
                                    endif
                                endif
                            endif
                        endif
                    endif

                    CloseRegKey $(kHandle)

                    ifstr $(deleteSrcKey) == YES
                        OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) +
				$(MAXIMUM_ALLOWED) kHandle
                        Ifstr $(kHandle) != $(KeyNull)
                            DeleteRegTree $(kHandle) $(oldInstance)
                            CloseRegKey $(kHandle)
                        endif
                    endif

                endif
            EndForListDo
        endif
    Endif

    return STATUS_SUCCESSFUL

;*************************************************************************
;
;     SECTION:   FixupTransportsAfterRemove
;
;     PURPOSE:   <fixup the transports after IM is removed
;                Removes the additional NetBT adapters created for the
;                advpn drivers.
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[FixupTransportsAfterRemove]
    Debug-Output "ADVPN: FixupTransportsAfterRemove"
    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(NetBTServiceKey) +
		$(MAXIMUM_ALLOWED) Transport
    Ifstr $(Transport) == $(KeyNull)
        return STATUS_FAILED
    endif

    EnumRegKey $(Transport) CardList
    ifint $(RegLastError) != 0
        CloseRegKey $(Transport)
        return STATUS_FAILED
    endif

    ForListDo $(CardList)
        set source = *($($),1)
        Split-String $(source) "_" name
        ifstr *($(name),1) == $(ProductSoftwareName)
            Debug-Output $(name)
            ifstr *($(name),2) == "_"
                set card = ""
                ForListDo $(name)
                    ifint $(#) > 2
                        set card = $(card)$($)
                    endif
                EndForListDo

                Shell "",CopyRegTree,$(NetBTServiceKey)"\"$(source),+
			$(NetBTServiceKey),$(card),+
			$(NoTitle),GenericClass,FORCE

                DeleteRegTree $(Transport) $(source)
            endif
        endif
    EndForListDo

    CloseRegKey $(Transport)


    return STATUS_SUCCESSFUL

;*************************************************************************
;
;     SECTION:   FixupServicesAfterRemove
;
;     PURPOSE:   <fixup the services after IM is removed
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************

[FixupServicesAfterRemove]
    Debug-Output "ADVPN: FixupServicesAfterRemove"
    read-syms GeneralConstants
    read-syms FileConstants

    ForListDo $(FixupServices)

        OpenRegKey $(!REG_H_LOCAL) "" $($) $(MAXIMUM_ALLOWED) Service
        Ifstr $(Service) != $(KeyNull)

            GetRegValue $(Service) Bind value
            ifint $(RegLastError) == 0
                set outValue = {}
                ForListDo *($(value),4)
                    Split-String $($) "\_" name
                    ifstr *($(name),6) != $(ProductSoftwareName)
                        set outValue = >($(outValue), $($))
                    else
                        set out = ""
                        ForListDo $(name)
                            ifint $(#) != 6
                                ifint $(#) != 7
                                    set out = $(out)$($)
                                endif
                            endif
                        EndForListDo
                        set outValue = >($(outValue), $(out))
                    endif
                EndForListDo
                set value = {{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(outValue)}}
                Shell  $(UtilityInf), AddValueList, $(Service), $(value)
            endif

            GetRegValue $(Service) Export value
            ifint $(RegLastError) == 0
                set outValue = {}
                ForListDo *($(value),4)
                    Split-String $($) "\_" name
                    ifstr *($(name),8) != $(ProductSoftwareName)
                        set outValue = >($(outValue), $($))
                    else
                        set out = ""
                        ForListDo $(name)
                            ifint $(#) != 8
                                ifint $(#) != 9
                                    set out = $(out)$($)
                                endif
                            endif
                        EndForListDo
                        set outValue = >($(outValue), $(out))
                    endif
                EndForListDo
                set value = {{Export,$(NoTitle),+
				$(!REG_VT_MULTI_SZ),$(outValue)}}
                Shell  $(UtilityInf), AddValueList, $(Service), $(value)
            endif

            GetRegValue $(Service) Route value
            ifint $(RegLastError) == 0
                set outValue = {}
                set q = \042\042\042\042\042\042\042\042
                set-subst quote = "\042"

                ForListDo *($(value),4)
                    Shell "" ReplaceText $($), $(quote), ""
                    ifstr $($R0) == STATUS_SUCCESSFUL
                        Split-String $($R1) " " name
                        Split-String *($(name),3) "_" product

                        ifstr *($(product),1) != $(ProductSoftwareName)
                            set out = ""
                            ForListDo $(name)
                                ifstr $($) == " "
                                    set out = $(out)$($)
                                else
                                    set out = $(out)$(q)$($)$(q)
                                endif
                            EndForListDo
                            Shell "" ReplaceText $(out), $(quote), ""
                            set outValue = >($(outValue), $($R1))
                        else
                            set serviceName = ""
                            ForListDo $(product)
                                ifint $(#) > 2
                                    set serviceName = $(serviceName)$($)
                                endif
                            EndForListDo

                            LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
				        $(serviceName) "NdisWan" 7
                            ifint $(Result) == 0
                                set out = $(q)*($(name),1)$(q)" "+
						$(q)$(serviceName)$(q)
                                set outValue = >($(outValue), $(out))
                            else
                                Shell "" FindNetworkCardProductName +
					$(serviceName)
                                ifstr $($R0) == STATUS_SUCCESSFUL 
                                    set out = $(q)*($(name),1)$(q)" "+
						$(q)$($R1)$(q)" "+
						$(q)$(serviceName)$(q)
                                    set outValue = >($(outValue), $(out))
                                endif
                            endif
                        endif
                    endif
                EndForListDo
                set-subst value = {{Route,$(NoTitle),+
					$(!REG_VT_MULTI_SZ),$(outValue)}}
                Shell  $(UtilityInf), AddValueList, $(Service), $(value)
            endif

        endif

    EndForListDo

    return STATUS_SUCCESSFUL


;*************************************************************************
;
;     SECTION:   NdisWanSupport
;
;     PURPOSE:   Support NdisWan adapters
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - 0 for yes, 1 for no
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[NdisWanSupport]
Debug-Output "ADVPN: NdisWanSupport"

    read-syms FileConstants

    return $(NoNdisWanSupport)

;*************************************************************************
;
;     SECTION:   GetNtVersion
;
;     PURPOSE:   Get Windows NT Version
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - NT version or return code
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[GetNtVersion]

    ifstr $(!IM_NT_VERSION) != ""
        return $(!IM_NT_VERSION)
    endif

    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(NtCurrentVersion) $(MAXIMUM_ALLOWED) Handle 
    ifint $(RegLastError) != 0
        return STATUS_FAILED
    endif

    GetRegValue $(Handle) CurrentVersion value
    ifint $(RegLastError) != 0
        CloseRegKey $(Handle)
        return STATUS_FAILED
    endif

    CloseRegKey $(Handle)
    set !IM_NT_VERSION = *($(value),4)
    return $(!IM_NT_VERSION)

;*************************************************************************
;
;     SECTION:   GetNtServicePack
;
;     PURPOSE:   Get Windows NT Service Pack 
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - NT service pack
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[GetNtServicePack]
    Debug-Output "ADVPN: GetNtServicePack"

    ifstr $(!IM_NT_SERVICE_PACK) != ""
       Debug-Output "ADVPN: Service Pack already set to "$(!IM_NT_SERVICE_PACK)
       return $(!IM_NT_SERVICE_PACK)
    endif

    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(NtCurrentVersion) $(MAXIMUM_ALLOWED) Handle 
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Couldn't open Current Version Key"
        return 0 
    endif

    GetRegValue $(Handle) $(NtCurrentSP) value
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Couldn't open Current SP"
        CloseRegKey $(Handle)
        return 0 
    endif

    CloseRegKey $(Handle)

    Debug-Output "ADVPN: Read Value of "$(value)
    Split-String *($(value),4) " " spvalue 
    Debug-Output "ADVPN: Split_string Value of "$(spvalue)
    
    set !IM_NT_SERVICE_PACK = *($(spvalue),5)
    Debug-Output "ADVPN: Service Pack Version is "$(!IM_NT_SERVICE_PACK)

    return $(!IM_NT_SERVICE_PACK)

;*************************************************************************
;
;     SECTION:   CopyRegTree
;
;     PURPOSE:   <duplicate registry tree>
;
;   ARGUMENTS:   $0 - Source Tree
;                $1 - Destination Base
;                $2 - Destination Key Name
;                $3 - Destination Key Index
;                $4 - Destination Key Class
;                $5 - FORCE overwrite or not
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[CopyRegTree]
Debug-Output "ADVPN: CopyRegTree"
    read-syms GeneralConstants
    read-syms FileConstants

    Shell "" GetImSampPath
    ifstr $($R0) != STATUS_SUCCESSFUL
        goto previous_CopyRegTree
    endif

    ifstr(i) $(!myLIBHANDLE) == ""
        LoadLibrary "x" $($R1)"\wgagent.dll" !myLIBHANDLE
    endif
    LibraryProcedure Result $(!myLIBHANDLE),CopyRegTree,$($0),$($1),$($2),+
			$($3),$($4),$($5)
    ;FreeLibrary $(myLIBHANDLE)

    ifint *($(Result),1) == 0
        return STATUS_SUCCESSFUL
    else
        return STATUS_FAILED
    endif

previous_CopyRegTree = +

    Shell "" GetNtVersion

new_CopyRegTree = +

    OpenRegKey $(!REG_H_LOCAL) "" $($0) $(MAXIMUM_ALLOWED) srcHandle  
    ifint $(RegLastError) != 0
        return STATUS_FAILED
    endif

    OpenRegKey $(!REG_H_LOCAL) "" $($1) $(MAXIMUM_ALLOWED) dstHandle  
    ifint $(RegLastError) != 0
        CloseRegKey $(srcHandle)
        return STATUS_FAILED
    endif

    CreateRegKey $(dstHandle) {$($2),$($3),$($4)} "" $(MAXIMUM_ALLOWED) "" dst  

    ifint $(RegLastError) == 0
        CloseRegKey $(dstHandle)
    else-ifint $(RegLastError) == 1011 ; key already exist
        CloseRegKey $(dstHandle)
        OpenRegKey $(!REG_H_LOCAL) "" $($1)"\"$($2) $(MAXIMUM_ALLOWED) dst
        ifint $(RegLastError) != 0
            CloseRegKey $(srcHandle)
            return STATUS_FAILED
        endif
    else
        CloseRegKey $(dstHandle)
        CloseRegKey $(srcHandle)
        return STATUS_FAILED
    endif

    LibraryProcedure CopyResult $(!NCPA_HANDLE),RegCopyTree,$(srcHandle),$(dst) 
    Set CopyError = *($(CopyResult),1)
    CloseRegKey $(srcHandle)
    CloseRegKey $(dst)
    Ifint $(CopyError) != 0
        return STATUS_FAILED
    endif

    return STATUS_SUCCESSFUL

;
; Old CopyRegTree routine.  There is limitation/bug in EnumRegValue in that
; it can't always read all the registry values.  The library procedure in
; NCPA don't seem to have this problem!
;

old_CopyRegTree = +
;   Shell $(subroutineinf) SetupMessage,$(!STF_LANGUAGE), "NONFATAL", +
;	$($0)" "$($1)" "$($2)" "$($3)" "$($4)

    OpenRegKey $(!REG_H_LOCAL) "" $($0) $(MAXIMUM_ALLOWED) KeyHandle  
    ifint $(RegLastError) != 0
        goto error_copyTree
    endif

    EnumRegValue $(KeyHandle) ValueList
;   ifint $(RegLastError) != 0
;       CloseRegKey $(KeyHandle)
;       goto error_copyTree
;   endif

    EnumRegKey $(KeyHandle) KeyList
    ifint $(RegLastError) != 0
        CloseRegKey $(KeyHandle)
        goto error_copyTree
    endif

    CloseRegKey $(KeyHandle)

    OpenRegKey $(!REG_H_LOCAL) "" $($1) $(MAXIMUM_ALLOWED) KeyHandle  
    ifint $(RegLastError) != 0
        goto error_copyTree
    endif

    set NewKey = {$($2),$($3),$($4)}
;   Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "NONFATAL", $(NewKey)
    CreateRegKey $(KeyHandle) $(NewKey) "" $(MAXIMUM_ALLOWED) "" +
		NewKeyHandle  

    ifint $(RegLastError) == 0
        CloseRegKey $(KeyHandle)
        goto addValueList_copyTree
    else-ifint $(RegLastError) == 1011 ; key already exist
        CloseRegKey $(KeyHandle)
        goto openRegKey_copyTree
    else
        CloseRegKey $(KeyHandle)
        goto error_copyTree
    endif

openRegKey_copyTree = +

    OpenRegKey $(!REG_H_LOCAL) "" $($1)"\"$($2) $(MAXIMUM_ALLOWED) +
		NewKeyHandle
    ifint $(RegLastError) != 0
        goto error_copyTree
    endif

addValueList_copyTree = +

    ifstr $(ValueList) != ""
        ForListDo $(ValueList)
            ifstr $($5) == FORCE
                SetRegValue $(NewKeyHandle) $($)
            else
                GetRegValue $(NewKeyHandle) *($($),1) value
                ifint $(RegLastError) != 0
                    SetRegValue $(NewKeyHandle) $($)
                endif
            endif
        EndForListDo
    endif

    CloseRegKey $(NewKeyHandle)

    ForListDo $(KeyList)
        set NewKey = *($($),1)
        Shell "",CopyRegTree,$($0)"\"$(NewKey),$($1)"\"$($2),$(NewKey),+
			*($($),2),*($($),3),$($5)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto error_copyTree
        endif
        ifstr $($R0) != STATUS_SUCCESSFUL
            goto error_copyTree
        endif
    EndForListDo
    return STATUS_SUCCESSFUL

error_copyTree = +
;   Shell $(subroutineinf) SetupMessage,$(!STF_LANGUAGE),"NONFATAL",errCopyTree
    OpenRegKey $(!REG_H_LOCAL) "" $($1) $(MAXIMUM_ALLOWED) KeyHandle  
    ifint $(RegLastError) == 0
        DeleteRegTree $(KeyHandle) $($2)
    endif
    CloseRegKey $(KeyHandle)
    return STATUS_FAILED

;*************************************************************************
;
;     SECTION:   RemoveIMServices
;
;     PURPOSE:   <remove IM services>
;
;   ARGUMENTS:
;
;     RETURNS:
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[RemoveIMServices]
Debug-Output "ADVPN: RemoveIMServices"
    read-syms GeneralConstants
    read-syms FileConstants

    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase) $(MAXIMUM_ALLOWED) +
		KeyHandle
    Ifstr $(KeyHandle) != $(KeyNull)
        EnumRegKey $(KeyHandle) KeyList
        Ifint $(RegLastError) == 0
            ForListDo $(KeyList)
                Split-String *($($),1) "_" KeyCheck
                ifstr *($(KeyCheck),1) == $(ProductSoftwareName)
		    Debug-Output $(KeyCheck)
                    ifstr *($(KeyCheck),2) == "_"
		        Debug-Output *($($),1)
                        DeleteRegTree $(KeyHandle) *($($),1)
                    endif
                endif
            EndForListDo
        Endif
        CloseRegKey $(KeyHandle)
    endif
    return

;*************************************************************************
;
;     SECTION:   RemoveIMCards
;
;     PURPOSE:   <remove IM cards>
;
;   ARGUMENTS:   $0 - if "UNWANTED" then only remove unused IM cards
;
;     RETURNS:   $R0 - STATUS_SUCCESSFUL or STATUS_REBIND
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[RemoveIMCards]
Debug-Output "ADVPN: RemoveIMCards"
    read-syms GeneralConstants
    read-syms FileConstants

    set status = STATUS_SUCCESSFUL

    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		KeyHandle
    Ifstr $(KeyHandle) != $(KeyNull)
        EnumRegKey $(KeyHandle) KeyList
        ifint $(RegLastError) == 0
            ForListDo $(KeyList)
                OpenRegKey $(!REG_H_LOCAL) "" +
			$(NetworkCardsKeyName)"\"*($($),1) +
			$(MAXIMUM_ALLOWED) kHandle
                Ifstr $(kHandle) != $(KeyNull)
                   GetRegValue $(kHandle) ServiceName value
                    ifint $(RegLastError) == 0

                    Split-String *($(value),4) "_" name
                    Debug-Output "ADVPN: RemoveIMCards - value = "$(value)" name = "*($(name),1)
        		    ifstr *($(name),1) == $(ProductSoftwareName)
				         set skipDelete = NO

                          GetRegValue $(kHandle) ServiceName value
                          ifint $(RegLastError) == 0
                            ifstr $($0) == UNWANTED
                              Split-String *($(value),4) "_" name
                              ifstr *($(name),1) == $(ProductSoftwareName)
                                ForListDo $(KeyList)
                                  OpenRegKey $(!REG_H_LOCAL) "" +
					$(NetworkCardsKeyName)"\"*($($),1) +
					$(MAXIMUM_ALLOWED) rHandle
                                  ifstr $(rHandle) != $(KeyNull)
                                    GetRegValue $(rHandle) ServiceName service
                                    ifint $(RegLastError) == 0
                                      set svc = ""
                                      ForListDo $(name)
                                        ifint $(#) > 2
                                          set svc = $(svc)$($)
                                        endif
                                      EndForListDo
                                      ifstr *($(service),4) == $(svc)
                                        set skipDelete = YES
                                      endif
                                    endif
                                    CloseRegKey $(rHandle)
                                  endif
                                EndForListDo
                              endif
                            endif
                          endif

                          ifstr $(skipDelete) == NO
                            ;
                            ; delete the corresponding service too
                            ;
                            OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase) +
					$(MAXIMUM_ALLOWED) rHandle
                            ifstr $(rHandle) != $(KeyNull)
                              DeleteRegTree $(rHandle) *($(value),4)
                              CloseRegKey $(rHandle)
                            endif

                            Debug-Output $($)
                            DeleteRegTree $(KeyHandle) *($($),1)

                            set status = STATUS_REBIND
                          endif
                        endif
                    endif
                    CloseRegKey $(kHandle)
                endif
            EndForListDo
        endif
        CloseRegKey $(KeyHandle)
    endif
    return $(status)

;*************************************************************************
;
;     SECTION:   AddIMCard
;
;     PURPOSE:   <add IM card>
;
;   ARGUMENTS:   $0 - card to add
;                $1 - parent key name
;                $2 - InfOption
;                $3 - card instance
;                $4 - NDISWAN?
;		 $5 - productName
;     RETURNS:   $R0: STATUS_FAILED, STATUS_SUCCESSFUL, STATUS_REBIND
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[AddIMCard]
Debug-Output "ADVPN: AddIMCard"
Debug-Output "ADVPN: AddIMCard - Card to add "$($0)
Debug-Output "ADVPN: AddIMCard - Parent Key Name "$($1)
Debug-Output "ADVPN: AddIMCard - INF Option "$($2)
Debug-Output "ADVPN: AddIMCard - Card Instance is "$($3)
Debug-Output "ADVPN: AddIMCard - NDISWAN is "$($4)
Debug-Output "ADVPN: AddIMCard - Product Name is "$($5)

    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    OpenRegKey $(!REG_H_LOCAL) "" $($1) $(MAXIMUM_ALLOWED) KeyCard
    Ifstr $(KeyCard) == $(KeyNull)
        return STATUS_FAILED
    Endif

    EnumRegKey $(KeyCard) cardList
    Ifint $(RegLastError) != 0
        CloseRegKey $(KeyCard)
        return STATUS_FAILED
    Endif

    ForListDo $(cardList)
        set Card = $($1)"\"*($($),1)
	set ImProductName = $(ProductSoftwareName)
        OpenRegKey $(!REG_H_LOCAL) "" $(Card) $(MAXIMUM_ALLOWED) kHandle
        Ifstr $(kHandle) != $(KeyNull)
            GetRegValue $(kHandle) ServiceName serviceName
            Ifint $(RegLastError) == 0
                Ifstr *($(serviceName),4) == $(ProductSoftwareName)"_"$($0)
                    CloseRegKey $(KeyCard)
                    CloseRegKey $(kHandle)
                    return STATUS_SUCCESS ;Card already exist
                Endif
            Endif
            CloseRegKey $(kHandle)
        Endif
    EndForListDo

;CCL:...The adapter entry for each imsamp adapter is created here, matching
;    the network card each is bound to, ex. E100B1 and im_E100B1 will both
;    have entries as network cards.  E100B1 is the actual NIC, im_E100B1
;    is the imsamp adapter bound to E100B1.

    ForListDo $(cardList)
        set Card = $($1)"\"*($($),1)
        OpenRegKey $(!REG_H_LOCAL) "" $(Card) $(MAXIMUM_ALLOWED) kHandle
        Ifstr $(kHandle) != $(KeyNull)
            GetRegValue $(kHandle) ServiceName serviceName
            Ifint $(RegLastError) == 0
                Ifstr *($(serviceName),4) == $($0)
                    ;
                    ; get a new instance value
                    ;
                    Shell $(UtilityInf),AssignAdapterNumber,"",1
                    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                        set NewCardInstance = 9*($($),1)
                    Else-Ifstr(i) $($R0) != NO_ERROR
                        set NewCardInstance = 8*($($),1)
                    Else
                        set NewCardInstance = $($R1)
                    Endif

                    CreateRegKey $(KeyCard) +
			{$(NewCardInstance),$(NoTitle),GenericClass} "" +
			$(MAXIMUM_ALLOWED) "" newHandle
                    Ifstr $(newHandle) != $(KeyNull)
                        GetRegValue $(kHandle) Title title
                        GetRegValue $(kHandle) Description desc
                        set serviceName = $(ProductSoftwareName)"_"$($0)

                        detect date

                        Ifint $($4) == 0
                          set NewValueList = {+
				  {Title,$(NoTitle),$(!REG_VT_SZ),+
				  ;CCL: "["$(NewCardInstance)"] "+
				  $(ProductSoftwareTitle)" -> "+
				   *($(title),4)},+
				  {Description,$(NoTitle),$(!REG_VT_SZ),+
				   $(ProductSoftwareTitle)" -> "*($(desc),4)},+
				  {Manufacturer,$(NoTitle),$(!REG_VT_SZ),+
				   $(Manufacturer)},+
				  {ProductName,$(NoTitle),$(!REG_VT_SZ),+
				   $(ImProductName)},+
				  {ServiceName,$(NoTitle),$(!REG_VT_SZ),+
				   $(serviceName)},+
				  {OperationsSupport,$(NoTitle),+
				   $(!REG_VT_DWORD),$(ProductHardwareSupport)},+
				  {InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
				   *($(Now),1)}}
                        else
	                  ;set ImProductName = "ATTModemCard" 
                          set NewValueList = {+
				  {Title,$(NoTitle),$(!REG_VT_SZ),+
				  ;CCL: "["$(NewCardInstance)"] "+
				  $(ProductSoftwareTitle)" -> "+
				   *($(title),4)},+
				  {Description,$(NoTitle),$(!REG_VT_SZ),+
				   $(ProductSoftwareTitle)" -> "*($(desc),4)},+
				  {Manufacturer,$(NoTitle),$(!REG_VT_SZ),+
				   $(Manufacturer)},+
				  {ProductName,$(NoTitle),$(!REG_VT_SZ),+
				   $(ImProductName)},+
				  {ServiceName,$(NoTitle),$(!REG_VT_SZ),+
				   $(serviceName)},+
				  {Hidden,$(NoTitle),$(!REG_VT_DWORD),1},+
				  {InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
				   *($(Now),1)}}
                        endif

                        Shell  $(UtilityInf), AddValueList, $(newHandle),+
				$(NewValueList)

                        CreateRegKey $(newHandle) +
				{NetRules,$(NoTitle),GenericClass} "" +
				$(MAXIMUM_ALLOWED) "" netHandle
                        Ifstr $(netHandle) != $(KeyNull)
                            set-subst bindform = "\042"$(serviceName)"\042"+
						$(NetRuleHardwareBindForm)
                            Shell $(UtilityInf),ReduceInfPath,+
						$(STF_CONTEXTINFNAME)
                            set NewValueList = {+
				{bindform,$(NoTitle),$(!REG_VT_SZ),+
				 $(bindform)},+
				{class,$(NoTitle),$(!REG_VT_MULTI_SZ),+
				 $(NetRuleHardwareClass)},+
				{type,$(NoTitle),$(!REG_VT_SZ),+
				 $(serviceName)" "*($(IMAdapters),1)},+
				{InfOption,$(NoTitle),$(!REG_VT_SZ),+
				 $($2)},+
				{InfName,$(NoTitle),$(!REG_VT_SZ),+
				 $($R0)}}
                            Shell  $(UtilityInf), AddValueList, +
					$(netHandle), $(NewValueList)
                            CloseRegKey $(netHandle)
                        Endif

                        CloseRegKey $(newHandle)
                    Endif
                Endif
            Endif
            CloseRegKey $(kHandle)
        Endif
    EndForListDo


    CloseRegKey $(KeyCard)
    return STATUS_REBIND

;*************************************************************************
;
;     SECTION:   ChangeListText
;
;     PURPOSE:   <change text in list string>
;
;   ARGUMENTS:   $0 - input string
;                $1 - string to be substitued
;                $2 - string to substitue with
;
;     RETURNS:   $R0 - output string
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[ChangeListText]
Debug-Output "ADVPN: ChangeListText"
Debug-Output "ADVPN: ChangeListText - Input String = "$($0)
Debug-Output "ADVPN: ChangeListText - Sting to be substituted = "$($1)
Debug-Output "ADVPN: ChangeListText - Substitute String = "$($2)
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    ;Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "NONFATAL", $($0)" "$($1)" "$($2)
    set returnList = {}
    set noChange = 1
    ForListDo $($0)
        set newList = ""
        Split-String $($) " " stringList
        ForListDo $(stringList)
            Ifstr $($) == $($1)
                set newList = $(newList)$($2)
                set noChange = 0
            Else
                set newList = $(newList)$($)
            Endif
        EndForListDo
        set returnList = >($(returnList),$(newList))
    ;Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "NONFATAL", $(returnList)
    EndForListDo
    Debug-Output "ADVPN: ChangeListText - Return String = "$(returnList)
    return $(returnList) $(noChange)

;*************************************************************************
;
;     SECTION:   ChangeNetRules
;
;     PURPOSE:   <change netRules>
;
;   ARGUMENTS:   $0 - netRules key
;                $1 - string to be substitued
;                $2 - string to substitue with
;                $3 - registry text
;
;     RETURNS:   $R0 - return status
;                $R1 - no change status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[ChangeNetRules]
    Debug-Output "ADVPN: ChangeNetRules"
    Debug-Output "ADVPN: ChangeNetRules String to be substituted = "$($1)
    Debug-Output "ADVPN: ChangeNetRules String to substitute with "$($2)
    Debug-Output "ADVPN: ChangeNetRules Registry Text "$($3)

    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG
	
    OpenRegKey $(!REG_H_LOCAL) "" $($0) $(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        return CANNOT_FIND_COMPONENT_SERVICE
    Endif

    GetRegValue $(KeyProduct) $($3) bindText
    Ifint $(RegLastError) != 0
        CloseRegKey $(KeyProduct)
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$($0)"\Bindable not found!"
        return CANNOT_FIND_COMPONENT_SERVICE
    Endif

    shell "" ChangeListText *($(bindText),4) $($1) $($2)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        CloseRegKey $(KeyProduct)
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$($ShellCode)": ChangeListText shell error!"
        return $($ShellCode)
    endif
    set noChange = $($R1)

    set NewValueList = {{*($(bindText),1),*($(bindText),2),*($(bindText),3),+
			$($R0)}}
    Shell $(UtilityInf), AddValueList, $(KeyProduct), $(NewValueList)
    CloseRegKey $(KeyProduct)
    Ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$($ShellCode)": AddValueList shell error!"
        return $($ShellCode)
    Endif
    Ifstr(i) $($R0) != NO_ERROR
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$($R0)": AddValueList returns error!"
        return $($R0)
    Endif

    return STATUS_SUCCESS $(noChange)

;*************************************************************************
;
;     SECTION:   FixupTransportDependOnService
;
;     PURPOSE:   Remove IM from DependOnService
;
;   ARGUMENTS:
;
;     RETURNS:   
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[FixupTransportDependOnService]
Debug-Output "ADVPN: FixupTransportDependOnService"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    ForListDo $(TransportServiceKeys)
        OpenRegKey $(!REG_H_LOCAL) "" $($) $(MAXIMUM_ALLOWED) KeyProduct
        Ifstr $(KeyProduct) != $(KeyNull)
            GetRegValue $(KeyProduct) DependOnService dependOnList
            Ifint $(RegLastError) == 0
                set TransportBindList = {}
                ForListDo *($(dependOnList),4)
                    Ifstr $($) != $(ProductSoftwareName)
                        set TransportBindList = >($(TransportBindList),$($))
                    endif
                EndForListDo
                set NewValueList = {DependOnService,$(NoTitle),+
					$(!REG_VT_MULTI_SZ),+
					$(TransportBindList)}
                SetRegValue $(KeyProduct) $(NewValueList)
                Ifint $(RegLastError) != 0
                    set RegistryErrorIndex = $(RegLastError)
                    CloseRegKey $(KeyProduct)
                    goto fatal
                endif
            endif
            CloseRegKey $(KeyProduct)
        Endif
    EndForListDo

    return

;*************************************************************************
;
;     SECTION:   AddToList
;
;     PURPOSE:   Add new value to list.  If new value is already in the
;                order list, it is taken out.
;
;   ARGUMENTS:   $0 - value to add
;                $1 - reference value
;                $2 - key where list resides
;                $3 - name of list
;                $4 - add BEFORE or AFTER reference value
;
;     RETURNS:   $R0 - return status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[AddToList]
Debug-Output "ADVPN: AddToList"
Debug-Output "ADVPN: AddToList - Value to add = "$($0)
Debug-Output "ADVPN: AddToList - Reference value "$($1)
Debug-Output "ADVPN: AddToList - Name of List "$($3)
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    set Status = STATUS_FAILURE

    OpenRegKey $(!REG_H_LOCAL) "" $($2) $(MAXIMUM_ALLOWED) KeyGroup
    set OldList = {}
    Ifstr(i) $(KeyGroup) != $(KeyNull)
        GetRegValue  $(KeyGroup) $($3) TmpList
        ifint $(RegLastError) == 0
            ForListDo *($(TmpList), 4)
                set OldList = >($(OldList), $($))
            EndForListDo
        endif
        Debug-Output "AddToList current list "$(OldList)
        set NewGroupList = {}
        ForListDo $(OldList)
            ifstr(i) $($) != $($0)
                ifstr(i) $($4) == BEFORE
                    ifstr(i) $($) == $($1)
                        set NewGroupList = >($(NewGroupList), $($0) )
                        set Status = STATUS_SUCCESSFUL
                    endif
                    set NewGroupList = >($(NewGroupList), $($))
                else
                    set NewGroupList = >($(NewGroupList), $($))
                    ifstr(i) $($) == $($1)
                        set NewGroupList = >($(NewGroupList), $($0) )
                        set Status = STATUS_SUCCESSFUL
                    endif
                endif
            endif
        EndForListDo
        Debug-Output "AddToList new list "$(NewGroupList)
        SetRegValue $(KeyGroup) {$($3),$(NoTitle),$(!REG_VT_MULTI_SZ),+
					$(NewGroupList)}
        CloseRegKey $(KeyGroup)
    else
        Debug-Output "AddToList error open ServiceGroupOrder key"
    endif

    return $(Status)



;*************************************************************************
;
;     SECTION:   SelectInterfaces
;
;     PURPOSE:   Select NdisWan and NIC interfaces to use for IPSec trans 
;                
;
;   ARGUMENTS:   
;                
;
;     RETURNS:   $R0 - return status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[SelectInterfaces]
Debug-Output "ADVPN: SelectInterfaces"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    ;Read what version is being installed from the registry.  The autoinstall
    ;updates this value when it starts and deletes it when it's done.
    ;The auto-install does not consider it a fatal error not to be able to
    ;update the key, if the key can not be read, or it not an expected value,
    ;assume install both to be safe.

    set Status = STATUS_SUCCESSFUL

    ;The interfaces value type is always put under main AT&T Global Network Key 
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductSoftKey) $(MAXIMUM_ALLOWED) KeyHandle
    Ifstr $(KeyHandle) != $(KeyNull)
      Debug-Output "ADVPN: Opened install type key"
      GetRegValue $(KeyHandle) $(InstallTypeValue) value
      ifint $(RegLastError) == 0
        Debug-Output "ADVPN: Read install type value"
        set curType = *($(value),4)
        ifstr(i) $(curType) == $(InstallBroadband)
          Debug-Output "ADVPN: Broadband! Shelling SelectNICAdapter"
          Shell "", SelectNICAdapter 
          ifstr $($R0) != STATUS_SUCCESSFUL
            set Status = $($R0) 
          endIf
        else-ifstr(i) $(curType) == $(InstallNarrowband)
          Debug-Output "ADVPN: Narrowband! Shelling SelectNdisWanAdapter"
          Shell "", SelectNdisWanAdapter 
          Ifstr $($R0) != STATUS_SUCCESSFUL
            set Status = $($R0) 
          EndIf
        else
          Debug-Output "ADVPN: Value Unknown - Installing ALL!"
          Debug-Output "ADVPN: Shelling SelectNdisWanAdapter"
          Shell "", SelectNdisWanAdapter 
          Ifstr $($R0) != STATUS_SUCCESSFUL
            set Status = $($R0) 
          EndIf
          Debug-Output "ADVPN: Shelling SelectNICAdapter"
          Shell "", SelectNICAdapter 
          ifstr $($R0) != STATUS_SUCCESSFUL
            set Status = $($R0) 
          endIf
        endif
      else
      ; install all if the key can't be read
        Debug-Output "ADVPN: Key Can't be Read - Installing ALL!"
        Debug-Output "ADVPN: Shelling SelectNdisWanAdapter"
        Shell "", SelectNdisWanAdapter 
        Ifstr $($R0) != STATUS_SUCCESSFUL
          set Status = $($R0) 
        EndIf
        Debug-Output "ADVPN: Shelling SelectNICAdapter"
        Shell "", SelectNICAdapter 
        ifstr $($R0) != STATUS_SUCCESSFUL
          set Status = $($R0) 
        endIf
      endif
      CloseRegKey $(KeyHandle)
    else
      ;if key can't be read, assume install all versions
      Debug-Output "ADVPN: Key Can't be Opened - Installing ALL!"
      Debug-Output "ADVPN: Shelling SelectNdisWanAdapter"
      Shell "", SelectNdisWanAdapter 
      Ifstr $($R0) != STATUS_SUCCESSFUL
        set Status = $($R0) 
      EndIf
      Debug-Output "ADVPN: Shelling SelectNICAdapter"
      Shell "", SelectNICAdapter 
      ifstr $($R0) != STATUS_SUCCESSFUL
        set Status = $($R0) 
      endIf
    endif

    return $(Status)
   

;*************************************************************************
;
;     SECTION:   SelectNICAdapter
;
;     PURPOSE:   Display a list of Network Adapters for the user to chose. 
;
;   ARGUMENTS:   
;               
;
;     RETURNS:   $R0 - return status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[SelectNICAdapter]
Debug-Output "ADVPN: SelectNICAdapter"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    set status = STATUS_SUCCESSFUL
    ;
    ;ASK USER WHAT NIC TO USE IF THEY HAVE MORE THAN ONE
    ;
    Debug-Output "ADVPN: Before we start, ask user to chose NIC"
    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$(NetworkCardsKeyName)" empty!"
        Return CANNOT_FIND_COMPONENT_SERVICE
    Endif

    EnumRegKey $(KeyProduct) KeyList
    Ifint $(RegLastError) != 0
        CloseRegKey $(KeyProduct)
        Return $(RegLastError)
    Endif
    CloseRegKey $(KeyProduct)

    ;Allow only NIC Cards, no NDISWAN including AsyncMac 
    ;This loop is driven off
    ;of service name instead of product name as was previously the 
    ;case for narrowband version 
    ;
    Debug-Output "ADVPN: Allow only NIC cards"
    set FinalCardList = {}
    set RASInList = 0 
    ForListDo $(KeyList)
        OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
			$(MAXIMUM_ALLOWED) NetCardHandle
        Ifstr $(NetCardHandle) != $(KeyNull)
            GetRegValue $(NetCardHandle) ServiceName CardService
            ifint $(RegLastError) == 0
               ;LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
               ;*($(CardService),4) "NdisWan" 7
               ;ifint $(Result) != 0
                   ;Strip out AsyncMac
                   LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
			        *($(CardService),4) "AsyncMac" 7
                   ifint $(Result) != 0
                       ;Strip out our instances of our cards if this is run after narrowband
                       ;is already installed
                       LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
			        *($(CardService),4) $(ProductSoftwareName) 7
                       ifint $(Result) != 0
                         ;Now only allow DialOutIP adapter
                         GetRegValue $(NetCardHandle) ProductName CardProduct
                         ifint $(RegLastError) == 0
                           LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
                              *($(CardProduct),4) "NdisWan" 7 
                           ifint $(Result) == 0
                             Debug-Output "ADVPN: Matched on NdisWan"
                             LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
                                *($(CardProduct),4) "NdisWanDialoutIp" 16 
                             ifint $(Result) == 0
                               ;Don't allow IPX dialout
                               LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
                                  *($(CardProduct),4) "NdisWanDialoutIpx" 17 
                               ifint $(Result) != 0
                                 set RASInList = 1
                                 ;set FinalCardList = >($(FinalCardList),$($))
                                 Debug-Output "ADVPN: Final Card Match is "*($(CardService),4)
                               endif
                             endif
                           else 
                             set FinalCardList = >($(FinalCardList),$($))
                             Debug-Output "ADVPN: Final Card Match is "*($(CardService),4)
                           endif
                         endif
                       endif
                  endif
               ;endif
            Endif
        Endif
        CloseRegKey $(NetCardHandle)
    EndForListDo
    Debug-Output "ADVPN: Final Card List After Loop is "$(FinalCardList)

    ;Format for the dialog box (we need description and device name)
    set NICCardList = {}
    ForListDo $(FinalCardList)
        set CardInfo =  ""
        OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
			$(MAXIMUM_ALLOWED) NetCardHandle
        Ifstr $(NetCardHandle) != $(KeyNull)
            GetRegValue $(NetCardHandle) ServiceName CardService
            ifint $(RegLastError) == 0
              set CardInfo = $(CardInfo)*($(CardService),4)
            endif
            ;Use title so the instance number is shown
            GetRegValue $(NetCardHandle) Title CardTitle
            ifint $(RegLastError) == 0
              set CardInfo = $(CardInfo)"="*($(CardTitle),4)
            endif
            set NICCardList = >($(NICCardList),$(CardInfo))
        Endif
        CloseRegKey $(NetCardHandle)
    EndForListDo
    ;Check if DUN/RAS should be in list
    ifint $(RASInList) == 1
       Debug-Output "ADVPN: Loading ADVNDINT.DLL"
       read-syms ErrorMessages
       ifstr(i) $(!PRUNEHANDLE) == ""
         LoadLibrary "x" advndint.dll !PRUNEHANDLE
       endif
       Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_RAS"
       LibraryProcedure Result $(!PRUNEHANDLE) +
                        BmGetDefaultLanguageString "IDS_NT_RAS" +
                        $(szNTRASDisplay)
       Debug-Output "ADVPN: Return From DLL: "$(Result)
       set CardInfo = "NdisWanX="$(Result)
       ;set CardInfo = "NdisWanX=Remote Access Service with Dial-Up Networking"
       set NICCardList = >($(NICCardList),$(CardInfo))
    endif

    ;CCL** Allow user to select from dialog box.
    Debug-Output "ADVPN: Loading ADVNDINT.DLL"
    ifstr(i) $(!PRUNEHANDLE) == ""
       LoadLibrary "x" advndint.dll !PRUNEHANDLE
    endif
    Debug-Output "ADVPN: Calling BmDisplayAdapters"
    LibraryProcedure Result $(!PRUNEHANDLE) BmDisplayAdapters $(NICCardList) "Broadband"
    Debug-Output "ADVPN: Return From DLL: "$(Result)
    Split-String $(Result) ":" TokenResult
    ifstr(i) *($(TokenResult),1) == $(DLL_ERROR_INDICATOR)
       set status = STATUS_FAILED
       set !Error = $(Result)
       Debug-Output "ADVPN: Select Adapter Dialog Returned Fatal Error."
    endif

    Debug-Output "ADVPN: BmDisplayAdapters Complete"

    Return $(status)

;*************************************************************************
;
;     SECTION:   SelectNdisWanAdapter
;
;     PURPOSE:   This does not display a dialog box.  The ndiswan interface
;                is determined dynamically at logon time.  This function does
;                create the BindToAdapter key since that is how it is determined
;                if the dial build has been run yet. 
;
;   ARGUMENTS:   
;               
;
;     RETURNS:   $R0 - return status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[SelectNdisWanAdapter]
Debug-Output "ADVPN: SelectNdisWanAdapter"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    set status = STATUS_SUCCESSFUL
    Debug-Output "ADVPN: Setting Dummy NdisWan Card in BindToAdapter Key"
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyInfoNarrow) $(MAXIMUM_ALLOWED) SoftKey
    Ifstr $(SoftKey) != $(KeyNull)
        SetRegValue $(SoftKey) {"BindToAdapter",$(NoTitle),$(!REG_VT_SZ),"NdisWanX"}
        CloseRegKey $(SoftKey)
    endif

    Return $(status)



;*************************************************************************
;
;     SECTION:   SetAdapterParameter
;
;     PURPOSE:   Copy Transport Parameters from real adapters to
;                IM adapters.
;
;   ARGUMENTS:   $0 - InfOption
;                $1 - FORCE CopyRegTree or not
;
;     RETURNS:   $R0 - return status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[SetAdapterParameter]
Debug-Output "ADVPN: SetAdapterParameter"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    ;
    ; Copy Transport parameters using IM's bind list
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
		$(NetworkCardsKeyName)" empty!"
        Return CANNOT_FIND_COMPONENT_SERVICE
    Endif

    EnumRegKey $(KeyProduct) KeyList
    Ifint $(RegLastError) != 0
        CloseRegKey $(KeyProduct)
        Return $(RegLastError)
    Endif
    CloseRegKey $(KeyProduct)

    set status = STATUS_SUCCESSFUL
    set dialOutIp = {}
    set dialInIp = {}
    set !IM_NDISWAN = {}

    ForListDo $(KeyList)
        OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
			$(MAXIMUM_ALLOWED) kHandle
        Ifstr $(kHandle) != $(KeyNull)
            GetRegValue $(kHandle) ProductName productName
            ifint $(RegLastError) == 0
                ifstr *($(productName),4) != $(ProductSoftwareName)
                    GetRegValue $(kHandle) ServiceName value
                    ifint $(RegLastError) == 0

                        set ndiswan = 0;

                        ;
                        ; Check for NdisWan adapters
                        ;
                        ifstr(i) $(!LIBHANDLE) == ""
                            LoadLibrary "x" setupdll.dll !LIBHANDLE
                        endif
                        LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
			        *($(value),4) "NdisWan" 7
                        ifint $(Result) == 0
                            Shell "" NdisWanSupport
                            ifint $($R0) == 1
                                Debug-Output "ADVPN: This will NOT support NDISWAN adapters."
                                goto next_adapter
                            endif
                            ;
                            ; NdisWan DialOut IP adapters
                            ;
                            ifstr(i) *($(productName),4) == NdisWanDialOutIp

                                ifstr $(dialOutIp) == ""
                                    set dialOutIp = {}
                                endif
                                set dialOutIp = >($(dialOutIp),*($(value),4))

                                set ndiswan = 1;
                                goto continue_add_adapter
                            ;
                            ; NdisWan DialIn IP adapters
                            ;
                            else-ifstr(i) *($(productName),4) == NdisWanDialInIp

                                ifstr $(dialInIp) == ""
                                    set dialInIp = {}
                                endif
                                set dialInIp = >($(dialInIp),*($(value),4))

                                set ndiswan = 1;
                                goto continue_add_adapter

                            endif
                            
                            goto next_adapter
                        endif

check_hidden_adapter = +
                        ;
                        ; don't attach to hidden adapters
                        ;
                        GetRegValue $(kHandle) Hidden hidden
                        ifint $(RegLastError) == 0
                            ifint *($(hidden),4) == 1
                                goto next_adapter
                            endif
                        endif

                        ;
                        ; make sure adapter is a supported type
                        ;
                        GetRegValue $(kHandle) Manufacturer manu
                        ifint $(RegLastError) != 0
                            goto next_adapter
                        endif
                        OpenRegKey $(!REG_H_LOCAL) "" "SOFTWARE\"+
				*($(manu),4)"\"*($(productName),4)+
				"\CurrentVersion\NetRules" +
				$(MAXIMUM_ALLOWED) nHandle
                        Ifstr $(nHandle) == $(KeyNull)
                            goto next_adapter
                        endif
                        GetRegValue $(nHandle) type type
                        ifint $(RegLastError) != 0
                            goto next_adapter
                        endif
                        Split-String *($(type),4) " " driver
                        set addAdapter = 0
                        ForListDo $(SupportedDrivers) ; currently ndisDriver
                            ifstr(i) *($(driver),3) == $($)
                                set addAdapter = 1
                            endif
                        EndForListDo
                        ifint $(addAdapter) != 1
                            goto next_adapter
                        endif

continue_add_adapter = +
                        ;
                        ; add software component of IM adapter from
                        ;  real adapter
                        ;
                        set srcDev = *($(value),4)
                        set dstDev = $(ProductSoftwareName)"_"$(srcDev)

                        Shell "",CopyRegTree,$(!NTN_ServiceBase)"\"$(srcDev),+
				$(!NTN_ServiceBase),$(dstDev),+
				$(NoTitle),GenericClass,$($1)
                        Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                            CloseRegKey $(kHandle)
                            Return $($ShellCode)
                        endif
                        Ifstr $($R0) != STATUS_SUCCESSFUL
                            CloseRegKey $(kHandle)
                            Return $($R0)
                        endif

                        ifint $(ndiswan) == 0
			    ;
			    ; remove hardware parameters
			    ;
                            set parms = $(!NTN_ServiceBase)"\"+
					$(dstDev)"\Parameters"
                            OpenRegKey $(!REG_H_LOCAL) "" $(parms) +
				$(MAXIMUM_ALLOWED) KeyProduct
                            Ifstr $(KeyProduct) == $(KeyNull)
                                CloseRegKey $(kHandle)
                                Shell $(subroutineinf) SetupMessage, +
					$(!STF_LANGUAGE), "FATAL", +
					$(parms)" empty!"
                                Return CANNOT_FIND_COMPONENT_SERVICE
                            Endif

                            EnumRegValue $(KeyProduct) ValueList
                            ForListDo $(ValueList)
                                DeleteRegValue $(KeyProduct) *($($),1)
                            EndForListDo
                            CloseRegKey $(KeyProduct)
                        Endif

                        ;
                        ; add hardware component of IM adapter from
                        ;  real adapter
                        ;  3/31/99 added productName to AddIMCard parms 
                        Shell "" AddIMCard $(srcDev) $(NetworkCardsKeyName) +
				$($0) *($($),1) $(ndiswan) *($(productName),4)
                        ifstr $($R0) == STATUS_REBIND
                            set status = $($R0)
                        endif

                        ;
                        ; add WINS parameters
                        ;
                        set srcWINS = $(NetBTServiceKey)"\"$(srcDev)
                        OpenRegKey $(!REG_H_LOCAL) "" $(srcWINS) +
				$(MAXIMUM_ALLOWED) winsHandle
                        Ifstr $(winsHandle) != $(KeyNull)
                            Shell "",CopyRegTree,$(srcWINS),$(NetBTServiceKey),+
				$(dstDev),$(NoTitle),GenericClass,FORCE
                            CloseRegKey $(winsHandle)
                        endif

next_adapter = +
                    endif
                endif
            endif
            CloseRegKey $(kHandle)
        endif
    EndForListDo

    ForListDo $(dialOutIp)
        set !IM_NDISWAN = >($(!IM_NDISWAN),$($))
    EndForListDo
    ForListDo $(dialInIp)
        set !IM_NDISWAN = >($(!IM_NDISWAN),$($))
    EndForListDo

    Return $(status)

;*************************************************************************
;
;     SECTION:   ResetAdapterParameter
;
;     PURPOSE:   Copy Transport Parameters from IM adapters to
;                real adapters.
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - return status
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[ResetAdapterParameter]
Debug-Output "ADVPN: ResetAdapterParameter"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    ;
    ; Copy Transport parameters using IM's bind list
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(IMLinkageKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
;        Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "FATAL", +
;		$(IMLinkageKeyName)" empty!"
        Return CANNOT_FIND_COMPONENT_SERVICE
    Endif

    GetRegValue $(KeyProduct) Bind bindList
    Ifint $(RegLastError) != 0
        CloseRegKey $(KeyProduct)
        Return $(RegLastError)
    endif
    set devices = *($(bindList),4)

    ForListDo $(devices)
        Split-String *($($),1) "\" device
        set srcDev = *($(device),4)

        Split-String $(srcDev) "_" device
        set dstDev = ""
        ForListDo $(device)
            ifint $(#) > 2
                set dstDev = $(dstDev)$($)
            endif
        EndForListDo

        set srcTree = $(!NTN_ServiceBase)"\"$(srcDev)
        Shell "",CopyRegTree,$(srcTree),$(!NTN_ServiceBase),+
			$(dstDev),$(NoTitle),GenericClass,FORCE
    EndForListDo

    CloseRegKey $(KeyProduct)
    Return STATUS_SUCCESSFUL

;*************************************************************************
;
;     SECTION:   RemoveIM
;
;     PURPOSE:   Remove IM is called during remove adapter phase or
;                when any fatal error is detected.
;
;   ARGUMENTS:
;
;     RETURNS:
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[RemoveIM]
Debug-Output "ADVPN: RemoveIM"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) SoftKey
    Ifstr $(SoftKey) != $(KeyNull)
        SetRegValue $(SoftKey) {RefCount,$(NoTitle),$(!REG_VT_DWORD),0}
        CloseRegKey $(SoftKey)
    endif

    ;Remove the Info associated with the drivers, so the related programs
    ;(Install, Uninstall, Dialer, etc.) recognize it's no longer installed.
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyInfoBroad) $(MAXIMUM_ALLOWED) SoftKey
    Ifstr $(SoftKey) != $(KeyNull)
        DeleteRegValue $(SoftKey) $(InterfaceValue) 
        CloseRegKey $(SoftKey)
    endif
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyInfoNarrow) $(MAXIMUM_ALLOWED) SoftKey
    Ifstr $(SoftKey) != $(KeyNull)
        DeleteRegValue $(SoftKey) $(InterfaceValue) 
        CloseRegKey $(SoftKey)
    endif

    ;
    ; Remove install file from ReviewPrograms and delete install file
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(NetRules) $(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) == $(KeyNull)
        goto removeadapter_removeSoftwareComponent
    endif

    GetRegValue $(KeyProduct),"InfName", infName
    ifint $(RegLastError) != 0
        Debug-Output "ADVPN: Error trying to get RegValue for InfName"
        CloseRegKey $(KeyProduct)
        goto removeadapter_removeSoftwareComponent
    endif

    CloseRegKey $(KeyProduct)
    Shell "" AddToList *($(infName),4),,$(ReviewProgram),ReviewPrograms
    ;CCL: Not sure why this split string is here, I think we just want to add to
    ;delete list
    ;Split-String *($(infName),4) "0123456789" checkList
    ;Ifstr *($(checkList),1) != *($(infName),4)
        ;Debug-Output "ADVPN: Adding file to Delete List ["$(infName)"]"
        ;AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\"*($(infName),4)
        ;Debug-Output "ADVPN: Adding file to Delete List ["$(ProductDriverFile)"]"
        ;AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\drivers\"$(ProductDriverFile)
        ;Debug-Output "ADVPN: Adding file to Delete List ["$(ProductDLLFile)"]"
        ;AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\"$(ProductDLLFile)
    ;endif

    ;CCL: I have NO idea what this NEWT nonsense is all about
    ;Shell "" GetImSampPath
    ;ifstr $($R0) == STATUS_SUCCESSFUL
        ;ifstr(i) $(!LIBHANDLE) == ""
            ;LoadLibrary "x" setupdll.dll !LIBHANDLE
        ;endif
        ;set NEWT = $($R1)\newt32.exe
        ;LibraryProcedure stat,$(!LIBHANDLE),CheckFileExistance $(NEWT)
        ;ifstr(i) $(stat) != NO
            ;
            ; Remove Newt from 'Run' key in registry (CT 7/20/97)
            ;
            ;RunProgram ExitCode NEWT32 "" $(NEWT) -u

            ;
            ; Remove NEWT32 on the next bootup sequence
            ;
            ;AddFileToDeleteList $(NEWT)
        ;endif
    ;endif

removeadapter_removeSoftwareComponent = +
    Debug-Output "ADVPN: RemoveAdapter_RemoveSoftwareComponent."
    ;
    ; Copy back current adapter settings
    ;
    Shell "" ResetAdapterParameter 

    ;
    ; Remove software component
    ;
    Shell "" MyRemoveSoftwareComponent,$(Manufacturer),$(ProductSoftwareName),""

    ;
    ; Change NetRules back
    ;
    ForListDo $(NetRuleDriverKeys)
        Shell "" ChangeNetRules *($($),1) *($(IMDrivers),*($($),2)) +
		*($(SupportedDrivers),*($($),2)) Bindable
    EndForListDo
    ForListDo $(NetRuleTransportKeys)
      Shell "" ChangeNetRules *($($),1) +
               *($(IMTransports),*($($),2)) +
	       *($(SupportedTransports),*($($),2)) Bindable
    EndForListDo

    ;
    ; Remove IM services and cards
    ;
    ;Shell "" RemoveIMServices
    Shell "" RemoveIMCards ALL

    Shell "" FixupTransportsAfterRemove
    Shell "" FixupServicesAfterRemove

    return

;*************************************************************************
;
;     SECTION:   MyRemoveSoftwareComponent
;
;     PURPOSE:   Remove software component.
;
;   ARGUMENTS:   $0 - Manufacturer
;                $1 - Product software name
;                $2 - Product software name to upgrade to 
;                $3 - Inf name if this is a upgrade
;
;     RETURNS:
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[MyRemoveSoftwareComponent]
Debug-Output "ADVPN: MyRemoveSoftwareComponent"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG


    ifstr $($2) == ""

      Shell $(UtilityInf),RemoveSoftwareComponent,$($0),$($1)
      set status = STATUS_SUCCESSFUL

    else

      set status = STATUS_SUCCESSFUL

      OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_SoftwareBase)"\"$($0)"\"$($1) +
		$(MAXIMUM_ALLOWED) keyHandle
      ifstr $(keyHandle) != $(KeyNull)
        Debug-Output "Setting removeBobcatINFs to TRUE (3)."
        set removeBobcatINFs = TRUE
        CloseRegKey $(keyHandle)
        set status = STATUS_REBOOT
      endif

      OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$($1) +
		$(MAXIMUM_ALLOWED) keyHandle
      ifstr $(keyHandle) != $(KeyNull)
        Debug-Output "Setting removeBobcatINFs to TRUE (4)."
        set removeBobcatINFs = TRUE
        CloseRegKey $(keyHandle)
        set status = STATUS_REBOOT
      endif

      ifstr $(status) == STATUS_REBOOT
        Shell $(UtilityInf),RemoveSoftwareComponent,$($0),$($1)
        ;
        ; remove 4.0 rule
        ;
        ForListDo $(NetRuleDriverKeys)
          Shell "" ChangeNetRules *($($),1) NMFTRTransport +
		*($(SupportedDrivers),*($($),2)) Bindable
        EndForListDo
        ForListDo $(NetRuleTransportKeys)
          Shell "" ChangeNetRules *($($),1) +
		*($(IMTransports),*($($),2)) +
		*($(SupportedTransports),*($($),2)) Bindable
        EndForListDo

        ;
        ; Install new IM after next reboot
        ;
        OpenRegKey $(!REG_H_LOCAL) "" $(RunOnce) +
			$(MAXIMUM_ALLOWED) runHandle
        ifstr $(runHandle) == $(KeyNull)
          CreateRegKey $(!REG_H_LOCAL) {$(RunOnce),0,GenericClass} +
		"" $(MAXIMUM_ALLOWED) "" runHandle
        endif

        ifstr $(runHandle) != $(KeyNull)
          SetRegValue $(runHandle) {InstallIM,0,+
                      $(!REG_VT_SZ),"rundll32 wgagent.dll,DllRegisterServer"}
          CloseRegKey $(runHandle)
          read-syms ErrorMessages
          Debug-Output "ADVPN: Loading ADVNDINT.DLL"
          ifstr(i) $(!PRUNEHANDLE) == ""
            LoadLibrary "x" advndint.dll !PRUNEHANDLE
          endif
          Debug-Output "ADVPN: Calling BmGetDefaultLanguageString IDS_NT_PREVIOUS_VERSION"
          LibraryProcedure Result $(!PRUNEHANDLE) +
                           BmGetDefaultLanguageString "IDS_NT_PREVIOUS_VERSION_WARNING" +
                           $(szPreviousVersionWarning)
          Debug-Output "ADVPN: Return From DLL: "$(Result)
          Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE),+
		"NONFATAL", +
                 $(Result)
         endif
       endif
    endif

    ifstr $(removeBobcatINFs) == TRUE
        Debug-Output "ADVPN: Attempting to remove BobCat INFs"
        shell "" RemoveBobcatINFs
    else
        Debug-Output "ADVPN: No need to remove BobCat INFs"
    endif

    return $(status)

;*************************************************************************
;
;     SECTION:   RemoveBobcatINFs
;
;     PURPOSE:   Remove bobcat inf files.
;
;   ARGUMENTS:   
;
;     RETURNS:
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[RemoveBobcatINFs]

Debug-Output "ADVPN: RemoveBobcat INFs"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    set list = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,+
		10,11,12,13,14,15,16,17,18,19,+
		20,21,22,23,24,25,26,27,28,29,+
		30,31,32,33,34,35,36,37,38,39,+
		40,41,42,43,44,45,46,47,48,49,+
		50,51,52,53,54,55,56,57,58,59,+
		60,61,62,63,64,65,66,67,68,69,+
		70,71,72,73,74,75,76,77,78,79,+
		80,81,82,83,84,85,86,87,88,89,+
		90,91,92,93,94,95,96,97,98,99}
    ;
    ; Delete bobcat INF instances
    ;
    ForListDo $(list)
        set infName = OEMNSV$($).INF
        Shell $(infName),ReturnOptions ENG
        ifint $($ShellCode) == $(!SHELL_CODE_OK)
            ifstr $($R0) == STATUS_SUCCESSFUL
                ifstr *($($R2),1) == $(ProductSoftwareTitle)
                        AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\"$(infName)
                endif
            endif
        endif
    EndForListDo 

    return

;*************************************************************************
; taken from oemnsvra.inf for NDISWAN 
;*************************************************************************

[UpdateLLInterface]
Debug-Output "ADVPN: UpdateLLInterface"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    Debug-Output "UpdateLLInterface: entry"
    set Status = STATUS_FAILED
    set KeyNull = ""
    set LLInterface = "\Device\RASARP"
    set IPLinkageKeyName = $(!NTN_ServiceBase)"\TCPIP\Linkage"
    OpenRegKey $(!REG_H_LOCAL) "" $(IPLinkageKeyName) $(MAXIMUM_ALLOWED) +
		KeyIpLinkage
    ifstr $(KeyIpLinkage) == $(KeyNull)
       Debug-Output "IM: UpdateLLInterface: couldn't open IP Linkage key"
       goto UpdateLLInterfaceEnd
    endif

    set compareSize = 0
    set compareString = $(ProductSoftwareName)"_NdisWan"
    Split-String $(compareString) $(compareString) charList
    ForListDo $(charList)
        set-add compareSize = $(compareSize),1
    EndForListDo

    set NdisWanList = {}
    GetRegValue    $(KeyIpLinkage) "Bind" TmpList
    ForListDo *($(TmpList),4)
        Split-String $($), "\", BindList
        QueryListSize ListSize $(BindList)
        set ServiceName = *($(BindList), $(ListSize))
        LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp $(ServiceName) +
        	$(compareString) $(compareSize)
        ifint $(Result) == 0
            set NdisWanList = >($(NdisWanList), $(ServiceName))
        endif
    EndForListDo
    CloseRegKey $(KeyIpLinkage)
    QueryListSize ListSize $(NdisWanList)
    ifint $(ListSize) >= 1
	ForListDo $(NdisWanList)
        set ServiceKeyName = $(!NTN_ServiceBase)"\"$($)"\Parameters\TCPIP"
	    OpenRegKey $(!REG_H_LOCAL) "" $(ServiceKeyName) +
			$(MAXIMUM_ALLOWED) KeyNdisWan
	    ifstr $(KeyNdisWan) != $(KeyNull)
		    SetRegValue $(KeyNdisWan) {IPAddress, 0, +
                              $(!REG_VT_MULTI_SZ), {"0.0.0.0"}}
		    SetRegValue $(KeyNdisWan) {SubnetMask, 0, +
                              $(!REG_VT_MULTI_SZ), {"0.0.0.0"}}
		    SetRegValue $(KeyNdisWan) {DefaultGateway, 0, +
                              $(!REG_VT_MULTI_SZ), {""}}
		    SetRegValue $(KeyNdisWan) {LLInterface, $(NoTitle),+
                                         $(!REG_VT_SZ), $(LLInterface)}
		    SetRegValue $(KeyNdisWan) {EnableDHCP, 0, +
                                          $(!REG_VT_DWORD), 0}
        else
            CreateRegKey $(!REG_H_LOCAL) +
                         {$(ServiceKeyName),0,GenericClass} "" +
		                  $(MAXIMUM_ALLOWED) "" KeyNdisWan
            ifstr $(KeyNdisWan) != $(KeyNull)
		SetRegValue $(KeyNdisWan) {IPAddress, 0, +
					$(!REG_VT_MULTI_SZ), {"0.0.0.0"}}
		SetRegValue $(KeyNdisWan) {SubnetMask, 0, +
					$(!REG_VT_MULTI_SZ), {"0.0.0.0"}}
		SetRegValue $(KeyNdisWan) {DefaultGateway, 0, +
					$(!REG_VT_MULTI_SZ), {""}}
		SetRegValue $(KeyNdisWan) {LLInterface, 0,+
					$(!REG_VT_SZ), $(LLInterface)}
		SetRegValue $(KeyNdisWan) {EnableDHCP, 0,+
					$(!REG_VT_DWORD), 0}
		SetRegValue $(KeyNdisWan) {UseZeroBroadcast, 0, +
					$(!REG_VT_DWORD), 0}
            else
		Debug-Output "IM: UpdateLLInterface: couldn't "+
			"create NdisWan params-tcpip key"
                goto UpdateLLInterfaceEnd
            endif
        endif
	    CloseRegKey $(KeyNdisWan)
        EndForListDo
    endif
    set Status = STATUS_SUCCESSFUL
UpdateLLInterfaceEnd =+
    Debug-Output "UpdateLLInterface: exit"
    return $(Status)

[SetRasArpBindValueFromTcpIP]
Debug-Output "ADVPN: SetRasArpBindValueFromTcpIP"

    read-syms GeneralConstants
    read-syms FileConstants
    read-syms FileConstantsENG

    Debug-Output "SetRasArpBindValueFromTcpIP: entry"
    set Status = STATUS_FAILED
    set KeyNull = ""
    set IPLinkageKeyName = $(!NTN_ServiceBase)"\TCPIP\Linkage"
    OpenRegKey $(!REG_H_LOCAL) "" $(IPLinkageKeyName) $(MAXIMUM_ALLOWED) +
		KeyIpLinkage
    ifstr $(KeyIpLinkage) == $(KeyNull)
        Debug-Output "IM: SetRasArpBindValueFromTcpIP: can't open IP Linkage"
        goto SetRasArpBindValueFromTcpIPEnd
    endif

    set compareSize = 0
    set compareString = $(ProductSoftwareName)"_NdisWan"
    Split-String $(compareString) $(compareString) charList
    ForListDo $(charList)
        set-add compareSize = $(compareSize),1
    EndForListDo

    set NdisWanList = {}
    GetRegValue $(KeyIpLinkage) "Bind" TmpList
    ForListDo *($(TmpList),4)
        Split-String $($), "\", BindList
        QueryListSize ListSize $(BindList)
        set ServiceName = *($(BindList), $(ListSize))
        LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp $(ServiceName) +
        	$(compareString) $(compareSize)
        ifint $(Result) == 0
            set NdisWanList = >($(NdisWanList), $($))
        endif
    EndForListDo
    set RasArpLinkageKeyName = $(!NTN_ServiceBase)"\RASARP\Linkage"
    OpenRegKey $(!REG_H_LOCAL) "" $(RasArpLinkageKeyName) $(MAXIMUM_ALLOWED) +
		KeyRasArpLinkage
    ifstr $(KeyRasArpLinkage) != $(KeyNull)
        SetRegValue $(KeyRasArpLinkage) {Bind, 0, $(!REG_VT_MULTI_SZ), +
		$(NdisWanList)}
        CloseRegKey $(KeyRasArpLinkage)
    endif
    CloseRegKey $(KeyIpLinkage)
    set Status = STATUS_SUCCESSFUL
SetRasArpBindValueFromTcpIPEnd=+
    Debug-Output "SetRasArpBindValueFromTcpIP: entry"
    return $(Status)

;*************************************************************************
; end code taken from oemnsvra.inf for NDISWAN 
;*************************************************************************
Download Driver Pack

How To Update Drivers Manually

After your driver has been downloaded, follow these simple steps to install it.

  • Expand the archive file (if the download file is in zip or rar format).

  • If the expanded file has an .exe extension, double click it and follow the installation instructions.

  • Otherwise, open Device Manager by right-clicking the Start menu and selecting Device Manager.

  • Find the device and model you want to update in the device list.

  • Double-click on it to open the Properties dialog box.

  • From the Properties dialog box, select the Driver tab.

  • Click the Update Driver button, then follow the instructions.

Very important: You must reboot your system to ensure that any driver updates have taken effect.

For more help, visit our Driver Support section for step-by-step videos on how to install drivers for every file type.

server: web2, load: 1.17