oemsetup.inf Driver File Contents (TMI.exe)

[Identification]
    OptionType = NetService
[Options]
    CBLSHIM
[FileConstants]
NoNdisWanSupport	= 0
UtilityInf              = "UTILITY.INF"
subroutineinf           = "SUBROUTN.INF"
SoftwareType            = "service"
Exit_Code               = 0
NetEventDLL             = "%SystemRoot%\System32\netevent.dll"
Manufacturer            = "Microsoft"
ProductMajorVersion     = "5"
ProductMinorVersion     = "1"
ProductVersion          = $(ProductMajorVersion)"."$(ProductMinorVersion)

ProductSoftwareName     = IM
ProductSoftwareName4.0  = CBLSHIM
ProductSoftwareImagePath = "\SystemRoot\System32\drivers\CBLSHIM.SYS"
ProductSoftKey          = $(!NTN_SoftwareBase)"\"$(Manufacturer)
ProductKeyName          = $(ProductSoftKey)"\"$(ProductSoftwareName)"\CurrentVersion"
ProductKeyName4.0       = $(ProductSoftKey)"\"$(ProductSoftwareName4.0)"\CurrentVersion"

ProductHardwareSupport  = 0
ProductSoftwareSupport  = 132


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

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

IMDrivers              	= {	imDriver }
SupportedDrivers        = {	ndisDriver}

IMAdapters				= {imAdapter}

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

;
; TCPIP protocol only
;
NetRuleSoftwareBindable = {+
			*($(IMTransports),1)" "*($(IMAdapters),1)" non non 100"}+
			*($(IMTransports),1)" "*($(ndisDrivers),1)" non non 100"}

;
; Multiprotocol (test)
;
;NetRuleSoftwareBindable = {+
;			*($(IMTransports),2)" "*($(IMAdapters),1)+
;			" non non 100",+
;			*($(IMTransports),3)" "*($(IMAdapters),1)+
;			" non non 100"}

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

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

;
; TCPIP protocol only
;
NetRuleDriverKeys       = {{$(MicroSW)"Tcpip"$(CVNetRules),1}}
NetRuleTransportKeys    = {{$(MicroSW)"Ndiswan"$(CVNetRules),2}}
TransportServiceKeys    = {$(!NTN_ServiceBase)"\Tcpip",+
			$(!NTN_ServiceBase)"\NetBT"}

;
; Multiprotocol (test)
;
;NetRuleDriverKeys       = {{$(MicroSW)"Tcpip"$(CVNetRules),1},+
;			{$(MicroSW)"NwlnkIpx"$(CVNetRules),1}}
;NetRuleTransportKeys    = {{$(MicroSW)"Ndiswan"$(CVNetRules),2},+
;			{$(MicroSW)"Ndiswan"$(CVNetRules),3}}
;TransportServiceKeys    = {$(!NTN_ServiceBase)"\Tcpip",+
;			$(!NTN_ServiceBase)"\NwlnkIpx"}

NetBTServiceKey         = $(!NTN_ServiceBase)"\NetBT\Adapters"
IMServiceKeyName       = $(!NTN_ServiceBase)"\"$(ProductSoftwareName) 
IMLinkageKeyName       = $(IMServiceKeyName)"\Linkage"
NtCurrentVersion        = $(MicroSW)"Windows NT\CurrentVersion"
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"
    set !G:DebugOutputControl = 1
    exit
[InstallOption]
    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
	Return STATUS_NOLANGUAGE
    endif
    Debug-Output "OEMSETNT.INF: STF_CWDDIR is: "$(!STF_CWDDIR)
    Debug-Output "OEMSETNT.INF: 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
    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 = +

;
;  dll load addition
;
    Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) NO

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

	Set SrcDir = $($R1)

    install "Install-Dll"

    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) +
		KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)

        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 = +
    ;
    ; remove 5.0 IM
    ;
    ;Shell "" RemoveIM

    ;
    ; remove 4.0 IM
    ;
    Shell "" MyRemoveSoftwareComponent,$(Manufacturer),+
		$(ProductSoftwareName4.0),$(ProductSoftwareName),+
	    	$(STF_CONTEXTINFNAME)

    ifstr $($R0) == STATUS_SUCCESSFUL
        goto installproduct
    endif

    goto end

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

           ;OpenRegKey $(!REG_H_LOCAL) "" +
		;"SOFTWARE\Microsoft\Windows Nt\CurrentVersion" +
		;$(MAXIMUM_ALLOWED) MSCVHandle
           ;Ifstr $(MSCVHandle) != $(KeyNull)
               ;set srcPath = ""
               ;GetRegValue $(MSCVHandle) SourcePath srcPath
           ;endif

           ;set SrcDir = $(!STF_WINDOWSSYSPATH)
           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 = {NMFTR.SYS}
                   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 = +
	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
	Shell $(UtilityInf), AddSoftwareComponent, $(Manufacturer), +
	    $(ProductSoftwareName), $(ProductSoftwareName), +
	    $(ProductSoftwareDisplayName), $(STF_CONTEXTINFNAME), +
	    $(ProductSoftwareImagePath), "kernelautostart", +
            $(ProductSoftwareGroup), "", "", $(NetEventDLL)
	set RegistryErrorIndex = $($R0)
	Ifstr(i) $(RegistryErrorIndex) !=  NO_ERROR
            ;
            ; Try 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)
                        Shell $(subroutineinf) SetupMessage,+
				$(!STF_LANGUAGE),"FATAL",+
				$(ProductSoftwareTitle)" has recently been "+
				"removed.  You must reboot before installing "+
				"it again."
	                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 = +

        Shell "" GetNtVersion
        ifstr $($R0) == "3.51"
	    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)},+
		{InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
		 *($(Now),1)}}
        else
	    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)}}
        endif

	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

    ;Ifstr $(MSCVHandle) != $(KeyNull)
        ;ifstr $(srcPath) != ""
            ;SetRegValue $(MSCVProduct) $(srcPath)
        ;endif
        ;CloseRegKey $(MSCVHandle)
    ;endif

    ;
    ; Modify Driver NetRules
    ;
    ForListDo $(NetRuleDriverKeys)
        ;
        ; upgrade from 4.0 rule first
        ;
        Shell "" ChangeNetRules *($($),1) IMSAMPTransport +
		*($(SupportedDrivers),*($($),2)) Bindable

        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
    ;
    Shell "" NdisWanSupport
    ifint $($R0) != 1
        Shell "" GetNtVersion
        ifstr $($R0) != "3.51"
            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
    endif

    ;
    ; Modify NetBT (WINS) class
    ;
    Shell "" ChangeNetRules $(MicroSW)"NetBT"$(CVNetRules) +
	*($(SupportedTransports),4) *($(IMTransports),1) Class
    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

    ;
    ; Add Protocol parameters and NetworkCard settings
    ;
    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 = +
    CloseRegKey $(KeyParameters)
    EndWait
    goto successful
bindingadapter =+
    ;
    ; Delete IM DependOnGroup and DependOnService
    ;
    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 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

    ;
    ; Modify NetBT (WINS) class
    ;
    Shell "" ChangeNetRules $(MicroSW)"NetBT"$(CVNetRules) +
	*($(SupportedTransports),4) *($(IMTransports),1) Class
    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

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

    set rebind = FALSE

    ;
    ; Add Protocol parameters and NetworkCard settings
    ;
    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
    else
        Shell "" GetNtVersion
        ifstr $($R0) == "3.51"
            Shell "" FixupBindings
        endif
    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
            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 = +
    Shell "" RemoveIM

    Shell "" GetNtVersion
    ifstr $($R0) == "3.51"
        Shell "" FixupBindingsAfterRemove $(!NTN_ServiceBase)"\Tcpip\Linkage"
        Shell "" FixupBindingsAfterRemove $(!NTN_ServiceBase)"\NetBT\Linkage"
        Shell "" FixupAdaptersAfterRemove
    endif
    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)
	    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
        goto bindingsReview_cont
    endif

    DeleteRegValue $(KeyProduct) Rebind

    CloseRegKey $(KeyProduct)

    ifint *($(rebind),4) == 1
        Shell "" GetNtVersion
        ifstr $($R0) == "4.0"
            Shell "" GetCblShimPath
            ifstr $($R0) == STATUS_SUCCESSFUL
                set cmd = $($R1)"\wgagent.dll,ReviewBindings"

                Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "NONFATAL" +
			"CBLSHIM 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."

                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
        endif
    else-ifint *($(rebind),4) == 2
        Shell "" GetNtVersion
        ifstr $($R0) == "4.0"
            Shell "" GetCblShimPath
            ifstr $($R0) == STATUS_SUCCESSFUL
                set cmd = $($R1)"\wgagent.dll,ReviewBindings"

                Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "NONFATAL" +
			"CBLSHIM has discovered newly added RAS "+
			"adapter(s).  It is necessary to remove and reinstall "+
			"IM.  The current series of dialog windows "+
			"will again be displayed to remove IM.  Don't reboot "+
			"the system until the binding process is completed.  "+
			"After the reboot, IM will be installed automatically."

                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
                    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
    endif

bindingsReview_cont = +
    ;
    ; NDISWAN 
    ;
    Shell "" NdisWanSupport
    ifint $($R0) != 1
        ifstr(i) $(!LIBHANDLE) == ""
            LoadLibrary "x" setupdll.dll !LIBHANDLE
            ifstr(i) $(!LIBHANDLE) == ""
                Shell subroutn.inf, SetupMessage $(!STF_LANGUAGE) "FATAL" +
        		"IM 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."
                Return STATUS_USERCANCEL
            endif
        endif

        Shell "" GetNtVersion
        ifstr $($R0) == "4.0"
            Shell "" SetRasArpBindValueFromTcpIP
        endif
        Shell "" UpdateLLInterface
    endif

    ;Shell "" GetCblShimPath
    ;ifstr $($R0) == STATUS_SUCCESSFUL
        ;
        ; Install Newt into 'Run' key in registry
        ;
        ;RunProgram ExitCode NEWT32 "" $($R1)\newt32.exe -i
    ;endif

  ;clean up the IM bindings
Debug-Output "OEMSETNT.INF: Loading BINDPRUNE.DLL"

     LoadLibrary "x" BindPrune.dll !PRUNEHANDLE
Debug-Output "OEMSETNT.INF: Calling ImPruneBindings"

	LibraryProcedure Result $(!PRUNEHANDLE) ImPruneBindings
Debug-Output "OEMSETNT.INF: Binding pruning complete"



    Return STATUS_SUCCESSFUL
[Install-Option]
    set STF_VITAL = ""
    ifstr(i) $(AddCopy) == "YES"
	AddSectionFilesToCopyList Files-$(Option) $(SrcDir) +
				$(!STF_WINDOWSSYSPATH)\drivers
    endif
    ifstr(i) $(DoCopy) == "YES"
       set !STF_NCPA_FLUSH_COPYLIST = TRUE
       CopyFilesInCopyList
    endif
    ifstr(i) $(DoConfig) == "YES"
    endif
    Exit
[Install-Update]
   set STF_VITAL        = ""
   set STF_OVERWRITE    = "VERIFYSOURCEOLDER"
   AddSectionFilesToCopyList Files-$(Option) $(SrcDir) +
				$(!STF_WINDOWSSYSPATH)\drivers
   AddSectionFilesToCopyList Files-Inf $(SrcDir) $(!STF_WINDOWSSYSPATH)
   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList
   exit


[Install-Dll]
   set STF_VITAL 	= ""
   AddSectionFilesToCopyList Files-Dll $(SrcDir) $(!STF_WINDOWSSYSPATH)
   set !STF_NCPA_FLUSH_COPYLIST = TRUE
   CopyFilesInCopyList
   exit


[Source Media Descriptions]
	1 = "CBLSHIM Installation Disk", TAGFILE = winnt\oemsetup.inf

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

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

[Files-CBLSHIM]
1,CBLSHIM.SYS,SIZE=2000  

[Files-Dll]
1,Bindprune.dll , SIZE=2000  
1,updtncpk.exe , SIZE=2000

[LanguagesSupported]
    ENG
[OptionsTextENG]
;    NDISPERF     = "CBLSHIM"
    NDISPERF     = "3Com CM Dial Up Protocol"
[FileConstantsENG]
ProCaption   = "Windows NT Setup"
ProCancel    = "Cancel"
ProCancelMsg = "Windows NT Networking is not correctly installed.  "+
	       "Are you sure you want to cancel copying files?"
ProCancelCap = "Network Setup Message"
ProText1     = "Copying:"
ProText2     = "To:"
FunctionTitle   = "CBLSHIM"
;ProductSoftwareDescription = "CBLSHIM"
ProductSoftwareDescription = "Redirects the Cable Modem upstream traffic to telco"
ProductSoftwareDisplayName = "3Com CM Dial Up Protocol"
;ProductSoftwareTitle    = "CBLSHIM"
ProductSoftwareTitle    = "3Com CM Dial Up Protocol"
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)

;*************************************************************************
;
;     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]

    read-syms GeneralConstants
    read-syms FileConstants

    set status = STATUS_SUCCESSFUL
    set temp = "temp"

    set tcpDisableLinkages = {}
    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\Tcpip\Linkage\Disabled" +
		$(MAXIMUM_ALLOWED) KeyProduct
    Ifstr $(KeyProduct) != $(KeyNull)
        GetRegValue $(KeyProduct) Bind tcpDisableLinkage
        ifint $(RegLastError) == 0
            set tcpDisableLinkages = *($(tcpDisableLinkage),4)
        endif
        CloseRegKey $(KeyProduct)
    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
        set disableLinkages = {}
    else
        set disableLinkages = *($(disableLinkage),4)
    endif
    CloseRegKey $(KeyProduct)

    OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName) $(MAXIMUM_ALLOWED) +
		CardsHandle
    ifint $(RegLastError) != 0
        return STATUS_FAILED
    endif

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

    CloseRegKey $(CardsHandle)

    set ImBind = {}
    set ImExport = {}
    set ImRoute = {}
    set TcpBind = {}
    set TcpExport = {}
    set TcpRoute = {}
    set NetBTExport = {}
    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 ndiswanList = {}
    set tcpipDisableList = {}
    ForListDo $(CardList)
        OpenRegKey $(!REG_H_LOCAL) "" $(NetworkCardsKeyName)"\"*($($),1) +
		$(MAXIMUM_ALLOWED) CardHandle
        ifint $(RegLastError) != 0
            return STATUS_FAILED
        endif

        GetRegValue $(CardHandle) ProductName value
        ifint $(RegLastError) != 0
            CloseRegKey $(CardHandle)
            return STATUS_FAILED
        endif

        ifstr *($(value),4) == $(ProductSoftwareName)
            GetRegValue $(CardHandle) ServiceName value
            ifint $(RegLastError) != 0
                CloseRegKey $(CardHandle)
                return STATUS_FAILED
            endif

            set disable = 0
            set currentCard = "\Device\"*($(value),4)

            ForListDo $(disableLinkages)
                ifstr(i) $($) == $(currentCard)
                    set disable = 1
                endif
            EndForListDo

            ifint $(disable) == 0
                LibraryProcedure Result $(!LIBHANDLE) SetupStrncmp +
		        *($(value),4) $(compareString) $(compareSize)
                ifint $(Result) == 0
                    set ndiswanList = >($(ndiswanList),*($(value),4))
                else
                    set adapterList = >($(adapterList),*($(value),4))
                endif
            else
                ForListDo $(tcpDisableLinkages)
                    ifstr(i) $($) == $(currentCard)
                        set disable = 2
                    endif
                EndForListDo
                ifint $(disable) == 1
                    set tcpipDisableList = >($(tcpipDisableList),*($(value),4))
                endif
            endif

            set-add RefCnt = $(RefCnt),1
        endif

        CloseRegKey $(CardHandle)
    EndForListDo

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

    Shell "" GetNtVersion
    ifstr $($R0) == "3.51"
        set disableLinkages = {}
        OpenRegKey $(!REG_H_LOCAL) "" +
		$(!NTN_ServiceBase)"\Tcpip\Linkage\Disabled" +
		$(MAXIMUM_ALLOWED) KeyProduct
        Ifstr $(KeyProduct) != $(KeyNull)
            GetRegValue $(KeyProduct) Bind disableLinkage
            ifint $(RegLastError) == 0
                set disableLinkages = *($(disableLinkage),4)
            endif
            CloseRegKey $(KeyProduct)
        endif

        ForListDo $(!IM_NDISWAN)
            set disable = 0
            set currentCard = "\Device\"$($)
            ForListDo $(disableLinkages)
                ifstr(i) $($) == $(currentCard)
                    set disable = 1
                endif
            EndForListDo
            ifint $(disable) == 0
                set TcpBind = >($(TcpBind), $(currentCard))
                set TcpExport = >($(TcpExport),"\Device\Tcpip\"$($))
                set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
                set tmp = $(q)NdisWan$(q)" "$(q)$($)$(q)
                set TcpRoute = >($(TcpRoute), $(tmp))
            endif
        EndForListDo
        goto fixupBindings_cont
    endif

    ForListDo $(!IM_NDISWAN)
        set currentCard = $(ProductSoftwareName)"_"$($)
        ForListDo $(ndiswanList)
            ifstr $(currentCard) == $($)
                set ImBind = >($(ImBind), "\Device\"$($))
                set ImExport = >($(ImExport), "\Device\"$($))
                set ImRoute = >($(ImRoute), $(q)$($)$(q))
                set TcpBind = >($(TcpBind), "\Device\"$($))
                set TcpExport = >($(TcpExport), "\Device\Tcpip\"$($))
                set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
                set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
                set TcpRoute = >($(TcpRoute), $(tmp))
            endif
        EndForListDo
    EndForListDo

fixupBindings_cont = +

    ForListDo $(adapterList)
        set ImBind = >($(ImBind), "\Device\"$($))
        set ImExport = >($(ImExport), "\Device\"$($))
        set ImRoute = >($(ImRoute), $(q)$($)$(q))
        set TcpBind = >($(TcpBind), "\Device\"$($))
        set TcpExport = >($(TcpExport), "\Device\Tcpip\"$($))
        set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
        set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
        set TcpRoute = >($(TcpRoute), $(tmp))
    EndForListDo

    ForListDo $(tcpipDisableList)
        set TcpBind = >($(TcpBind), "\Device\"$($))
        set TcpExport = >($(TcpExport), "\Device\Tcpip\"$($))
        set NetBTExport = >($(NetBTExport),"\Device\NetBT_"$($))
        set tmp = $(q)$(ProductSoftwareName)$(q)" "$(q)$($)$(q)
        set TcpRoute = >($(TcpRoute), $(tmp))
    EndForListDo

    OpenRegKey $(!REG_H_LOCAL) "" $(IMServiceKeyName) $(MAXIMUM_ALLOWED) +
		IMHandle  
    ifint $(RegLastError) != 0
        return STATUS_FAILED
    endif

fixupBindings_CreateTempKey = +

    CreateRegKey $(IMHandle) {$(temp),$(NoTitle),GenericClass} "" +
		$(MAXIMUM_ALLOWED) "" TempHandle
    ifint $(RegLastError) == 1011 ; key already exist
        DeleteRegTree $(IMHandle) $(temp)
        goto fixupBindings_CreateTempKey
    else-ifint $(RegLastError) != 0
        CloseRegKey $(IMHandle)
        return STATUS_FAILED
    endif

    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

    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

    set-subst NewValueList = {+
		{Bind,$(NoTitle),$(!REG_VT_MULTI_SZ),$(TcpBind)},+
		{Export,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetBTExport)},+
		{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)"\NetBT",Linkage,$(NoTitle),+
		GenericClass,FORCE

    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:   GetCblShimPath
;
;     PURPOSE:   <Get the CblShim path>
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - STATUS_SUCCESSFUL/STATUS_FAILED
;                $R1 - CblShim path
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[GetCblShimPath]

    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

    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]

    read-syms GeneralConstants
    read-syms FileConstants

    Shell "" GetCblShimPath
    ifstr $($R0) != STATUS_SUCCESSFUL
        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]

    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]

    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]

    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
;
;   ARGUMENTS:
;
;     RETURNS:   $R0 - 0 if success
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[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]

    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]

    Shell "" GetNtVersion
    ifstr $($R0) == "3.51"
        return 0
    endif

    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:   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]

    read-syms GeneralConstants
    read-syms FileConstants

    Shell "" GetCblShimPath
    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
    ifstr $($R0) == "3.51"
        goto old_CopyRegTree
    endif

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]

    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]

    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) ProductName value
                    ifint $(RegLastError) == 0
                        ifstr *($(value),4) == $(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?
;
;     RETURNS:   $R0: STATUS_FAILED, STATUS_SUCCESSFUL, STATUS_REBIND
;
;  REFERENCES:   <list of global or parent variables referenced>
;
;*************************************************************************
[AddIMCard]

    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)
        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

    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

                        Shell "" GetNtVersion
                        ifstr $($R0) == "3.51"

                            set NewValueList = {+
				{Title,$(NoTitle),$(!REG_VT_SZ),+
+;                               "["$(NewCardInstance)"] "+
				 $(ProductSoftwareTitle)" "+
				 *($(title),4)},+
				{Description,$(NoTitle),$(!REG_VT_SZ),+
				 $(ProductSoftwareTitle)" -> "*($(desc),4)},+
				{Manufacturer,$(NoTitle),$(!REG_VT_SZ),+
				 $(Manufacturer)},+
				{ProductName,$(NoTitle),$(!REG_VT_SZ),+
				 $(ProductSoftwareName)},+
				{ServiceName,$(NoTitle),$(!REG_VT_SZ),+
				 $(serviceName)},+
				{InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
				 *($(Now),1)}}
                        else
                            Ifint $($4) == 0
                                set NewValueList = {+
				  {Title,$(NoTitle),$(!REG_VT_SZ),+
+;				  "["$(NewCardInstance)"] "+
+;				  $(ProductSoftwareTitle)" -> "+
				   *($(title),4)},+
				  {Description,$(NoTitle),$(!REG_VT_SZ),+
				   $(ProductSoftwareTitle)" -> "*($(desc),4)},+
				  {Manufacturer,$(NoTitle),$(!REG_VT_SZ),+
				   $(Manufacturer)},+
				  {ProductName,$(NoTitle),$(!REG_VT_SZ),+
				   $(ProductSoftwareName)},+
				  {ServiceName,$(NoTitle),$(!REG_VT_SZ),+
				   $(serviceName)},+
				  {OperationsSupport,$(NoTitle),+
				   $(!REG_VT_DWORD),$(ProductHardwareSupport)},+
				  {InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
				   *($(Now),1)}}
                            else
                                set NewValueList = {+
				  {Title,$(NoTitle),$(!REG_VT_SZ),+
+;				  "["$(NewCardInstance)"] "+
+;				  $(ProductSoftwareTitle)" -> "+
				   *($(title),4)},+
				  {Description,$(NoTitle),$(!REG_VT_SZ),+
				   $(ProductSoftwareTitle)" -> "*($(desc),4)},+
				  {Manufacturer,$(NoTitle),$(!REG_VT_SZ),+
				   $(Manufacturer)},+
				  {ProductName,$(NoTitle),$(!REG_VT_SZ),+
				   $(ProductSoftwareName)},+
				  {ServiceName,$(NoTitle),$(!REG_VT_SZ),+
				   $(serviceName)},+
				  {Hidden,$(NoTitle),$(!REG_VT_DWORD),1},+
				  {InstallDate,$(NoTitle),$(!REG_VT_DWORD),+
				   *($(Now),1)}}
                            endif
                        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

    Shell "" GetNtVersion
    ifstr $($R0) == "3.51"
        ;
        ; swap card keys
        ;
        OpenRegKey $(!REG_H_LOCAL) "" $($1) $(MAXIMUM_ALLOWED) rHandle
        ifstr $(rHandle) != $(KeyNull)
            set temp = temp

            Shell "",CopyRegTree,$($1)"\"$($3),$($1),$(temp),+
		    $(NoTitle),GenericClass,FORCE

            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                CloseRegKey $(rHandle)
                Return $($ShellCode)
            endif
            Ifstr $($R0) != STATUS_SUCCESSFUL
                CloseRegKey $(rHandle)
                Return $($R0)
            endif

            Shell "",CopyRegTree,$($1)"\"$(NewCardInstance),$($1),$($3),+
		    $(NoTitle),GenericClass,FORCE

            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                CloseRegKey $(rHandle)
                Return $($ShellCode)
            endif
            Ifstr $($R0) != STATUS_SUCCESSFUL
                CloseRegKey $(rHandle)
                Return $($R0)
            endif

            Shell "",CopyRegTree,$($1)"\"$(temp),$($1),$(NewCardInstance),+
		    $(NoTitle),GenericClass,FORCE

            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
                CloseRegKey $(rHandle)
                Return $($ShellCode)
            endif
            Ifstr $($R0) != STATUS_SUCCESSFUL
                CloseRegKey $(rHandle)
                Return $($R0)
            endif

            DeleteRegTree $(rHandle) $(temp)

            CloseRegKey $(rHandle)
        endif
    endif

    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]

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

    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]

    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 first.
;
;   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]

    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:   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]

    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
                                goto next_adapter
                            endif
                            ;
                            ; NdisWan DialOut IP adapters
                            ;
                            ifstr(i) *($(productName),4) == NdisWanDialOutIp

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

                                Shell "" GetNtVersion
                                ifstr $($R0) != "3.51"
                                    set ndiswan = 1;
                                    goto continue_add_adapter
                                endif
                            ;
                            ; NdisWan DialIn IP adapters
                            ;
                            else-ifstr(i) *($(productName),4) == NdisWanDialInIp

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

                                Shell "" GetNtVersion
                                ifstr $($R0) != "3.51"
                                    set ndiswan = 1;
                                    goto continue_add_adapter
                                endif
                            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)
                            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
                        ;
                        Shell "" AddIMCard $(srcDev) $(NetworkCardsKeyName) +
				$($0) *($($),1) $(ndiswan)
                        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]

    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]

    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 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
        CloseRegKey $(KeyProduct)
        goto removeadapter_removeSoftwareComponent
    endif

    CloseRegKey $(KeyProduct)
    Shell "" AddToList *($(infName),4),,$(ReviewProgram),ReviewPrograms
    Split-String *($(infName),4) "0123456789" checkList
    Ifstr *($(checkList),1) != *($(infName),4)
        AddFileToDeleteList $(!STF_WINDOWSSYSPATH)"\"*($(infName),4)
    endif

    ;Shell "" GetCblShimPath
    ;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 = +
    ;
    ; 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
    Shell "" GetNtVersion
    ifstr $($R0) != "3.51"
        ForListDo $(NetRuleTransportKeys)
            Shell "" ChangeNetRules *($($),1) +
		*($(IMTransports),*($($),2)) +
		*($(SupportedTransports),*($($),2)) Bindable
        EndForListDo
    endif
    Shell "" ChangeNetRules $(MicroSW)"NetBT"$(CVNetRules) +
	*($(IMTransports),1) *($(SupportedTransports),4) Class

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

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

    Shell "" GetNtVersion
    ifstr $($R0) == "3.51"

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_SoftwareBase)"\"$($0) +
		$(MAXIMUM_ALLOWED) keyHandle
        ifstr $(keyHandle) != $(KeyNull)
            ifstr $($2) != ""
                ;
                ; try to set ServiceName Key first before CopyRegTree
                ;
                CreateRegKey $(keyHandle) {$($2),0,GenericClass} "" +
	                $(MAXIMUM_ALLOWED) "" driverHandle
                ifstr $(driverHandle) != $(KeyNull)
                    CreateRegKey $(driverHandle) +
				{CurrentVersion,0,GenericClass} "" +
	                	$(MAXIMUM_ALLOWED) "" cvHandle
                    ifstr $(cvHandle) != $(KeyNull)
		        SetRegValue $(cvHandle) {ServiceName, 0, +
				$(!REG_VT_SZ), $(ProductSoftwareName)}
		        SetRegValue $(cvHandle) {MajorVersion, 0, +
				$(!REG_VT_DWORD), $(ProductMajorVersion)}
		        SetRegValue $(cvHandle) {MinorVersion, 0, +
				$(!REG_VT_DWORD), $(ProductMinorVersion)}
                        CreateRegKey $(cvHandle) +
				{NetRules,0,GenericClass} "" +
	                	$(MAXIMUM_ALLOWED) "" nrHandle
                        ifstr $(nrHandle) != $(KeyNull)
	                    Shell $(UtilityInf),ReduceInfPath,$($3)
		            SetRegValue $(nrHandle) {InfName, 0, +
				$(!REG_VT_SZ), $($R0)}
                            CloseRegKey $(nrHandle)
                        endif
                        CloseRegKey $(cvHandle)
                    endif
                    CloseRegKey $(driverHandle)
                endif

                Shell "",CopyRegTree,$(!NTN_SoftwareBase)"\"$($0)"\"$($1),+
			$(!NTN_SoftwareBase)"\"$($0),$($2),+
			$(NoTitle),GenericClass

                set removeBobcatINFs = TRUE
            endif
            DeleteRegTree $(keyHandle) $($1)
            CloseRegKey $(keyHandle)
        endif

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase) +
		$(MAXIMUM_ALLOWED) keyHandle
        ifstr $(keyHandle) != $(KeyNull)
            ifstr $($2) != ""
                Shell "",CopyRegTree,$(!NTN_ServiceBase)"\"$($1),+
			$(!NTN_ServiceBase),$($2),+
			$(NoTitle),GenericClass
                set removeBobcatINFs = TRUE
            endif
            DeleteRegTree $(keyHandle) $($1)
            CloseRegKey $(keyHandle)
        endif

        set status = STATUS_SUCCESSFUL

    else

        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)
                set removeBobcatINFs = TRUE
                CloseRegKey $(keyHandle)
                set status = STATUS_REBOOT
            endif

            OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$($1) +
		$(MAXIMUM_ALLOWED) keyHandle
            ifstr $(keyHandle) != $(KeyNull)
                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
                Shell "" GetNtVersion
                ifstr $($R0) != "3.51"
                    ForListDo $(NetRuleTransportKeys)
                        Shell "" ChangeNetRules *($($),1) +
				*($(IMTransports),*($($),2)) +
				*($(SupportedTransports),*($($),2)) Bindable
                    EndForListDo
                endif
                Shell "" ChangeNetRules $(MicroSW)"NetBT"$(CVNetRules) +
			*($(IMTransports),1) *($(SupportedTransports),4) Class

                ;
                ; 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)

                    Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE),+
			"NONFATAL", +
			"Setup has removed a previous version of CblShim "+
			"IM.  A reboot is require before the new CblShim "+ 
			"IM can be added.  On the next reboot, the new "+
			"CblShim IM will be installed automatically."
                endif
            endif
        endif
    endif

    ifstr $(removeBobcatINFs) == TRUE
        shell "" RemoveBobcatINFs
    endif

    return $(status)

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

    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]
    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]
    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: web5, load: 0.81