;===================================================================
;
;   Installation file for NLINK/NWNBLINK
;
;===================================================================
[Identification]
    OptionType = NetTransport

;-------------------------------------------------------------------
; OPTION LIST
; -----------
;
;       This is an internal name for the options we can install.
;-------------------------------------------------------------------
[Options]
    NWLNKIPX

;********************************************************************
;       CONSTANTS FOR USING DIALOGS
;********************************************************************
[FileConstants]
;
;-----  Product Info
;
Manufacturer            = "Microsoft"
ProductMajorVersion     = "4"
ProductMinorVersion     = "0"
ProductVersion  = $(ProductMajorVersion)"."$(ProductMinorVersion)
NWLNKIPXEventDLL   = "%SystemRoot%\System32\netevent.dll"

;-----  This is the entry for the service controller daemon
;
ProductNWLNKIPXName        = "NwlnkIpx"
ProductNWLNKIPXImagePath   = "\SystemRoot\System32\drivers\nwlnkipx.sys"
ProductNWLNKIPXSvcType     = "kernel"
ProviderImagePath          = "%SystemRoot%\System32\nwprovau.dll"

ProviderNameSpaces         = 1 ; NS_SAP
ProviderGUID               = "{e02daaf0-7e9f-11cf-ae5a-00aa00a7112b}"

ProductNWLNKIPXWshDllPath  = "%SystemRoot%\System32\wshisn.dll"

NetRuleNWLNKIPXType        = "nwlnkIpx ipxTransport"
NetRuleNWLNKIPXUse         = $(SoftwareType)" none none"
NetRuleNWLNKIPXBindForm    = """NwlnkIpx"" yes yes simple"
NetRuleNWLNKIPXBindable    = {"ipxnbTransport ipxTransport non non 100",+
                              "ipxTransport ndisDriver non non 100",+
                              "lmNetService ipxnbTransport non non 100",+
                              "nwcWorkstation ipxTransport non non 100",+
                              "lanmanServer ipxTransport non non 100"}
NetRuleNWLNKIPXClass       = {"ipxnbTransport basic yes", "ipxTransport basic yes"}
ProductNWLNKIPXOpSupport   = 134 ; 0x0086 ; Display,Removable,Properties,Not Updatable
;
;-----  This is the entry for the NetBIOS daemon
;
ProductNWLNKNBName         = "NwlnkNb"
ProductNWLNKNBImagePath    = "\SystemRoot\System32\drivers\nwlnknb.sys"
ProductNWLNKNBSvcType      = "kernel"

NetRuleNWLNKNBType         = "nwlnkNb ipxnbTransport"
NetRuleNWLNKNBUse          = "transport none no"
NetRuleNWLNKNBBindForm     = """NwlnkNb"" yes yes container"
ProductNWLNKNBOpSupport    = 128 ; 0x0080 ; Display,Not Removable,No Properties,Not Updatable
;
;-----  This is the entry for the SPX
;
ProductNWLNKSPXName         = "NwlnkSpx"
ProductNWLNKSPXImagePath    = "\SystemRoot\System32\drivers\nwlnkspx.sys"
ProductNWLNKSPXSvcType      = "kernel"
NetRuleNWLNKSPXType         = "nwlnkSpx spxTransport"
NetRuleNWLNKSPXBindable     = {"spxTransport ipxTransport non non 100"}
NetRuleNWLNKSPXClass        = {"spxTransport basic yes"}
NetRuleNWLNKSPXUse          = "transport none no"
NetRuleNWLNKSPXBindForm     = """NwlnkSpx"" yes yes container"

;
;----- Name of Novell's stack: they cannot both be present
;
CompetitorServiceName = "IPXSPXII"
CompetitorKeyName  = $(!NTN_ServiceBase)"\"$(CompetitorServiceName)

;--------------------------------------------------------------------
;       Entries for the registry
;--------------------------------------------------------------------
ProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"$(Product$(Option)Name)"\CurrentVersion"
NWLNKIPXNetRuleKeyName = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\NwlnkIpx\CurrentVersion\NetRules"
NWLNKNBNetRuleKeyName = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\NwlnkNb\CurrentVersion\NetRules"
NWLNKIPXKeyName = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\NwlnkIpx\CurrentVersion"
NWLNKNBKeyName = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\NwlnkNb\CurrentVersion"
OldProductKeyName  = $(!NTN_SoftwareBase)"\"$(Manufacturer)"\"Nwlinkipx"\CurrentVersion"
LinkageKeyName  = $(!NTN_ServiceBase)"\NwlnkIpx\Linkage"
RipKeyName  = $(!NTN_ServiceBase)"\Nwlnkrip"
ServiceNWLNKKeyName = $(!NTN_ServiceBase)"\NwlnkIpx"
ServiceNWLNKNBKeyName = $(!NTN_ServiceBase)"\NwlnkNB"
ServiceKeyName  = $(!NTN_ServiceBase)

;--------------------------------------------------------------------
;       Some nice general constants to have around
;--------------------------------------------------------------------
[GeneralConstants]
UtilityInf       = "UTILITY.INF"
subroutineinf    = "SUBROUTN.INF"
SoftwareType     = "transport"
Exit_Code        = 0
BillboardVisible = 0
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

;--------------------------------------------------------------------
; 1. date
;
;       This routine sets the variable "Now" to be:
;
;       1. Sec from 1-1-1970
;       2. Year
;       3. Month
;       4. Day
;       5. Hour
;       6. Minute
;       7. Second
;--------------------------------------------------------------------
[date]
    Now = {} ? $(!LIBHANDLE) GetSystemDate

;--------------------------------------------------------------------
;   Identify
;   --------
;
;       This is called to verify that this INF is used to install
;       the kind of program that the setup program wants.
;       (net transport, driver, ....).
;
;       INPUT:  None
;
;       OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL
;               $($R1): Option Type
;               $($R2): Diskette Descriptor
;--------------------------------------------------------------------
[Identify]
    read-syms Identification
    set Status     = STATUS_SUCCESSFUL
    set Identifier = $(OptionType)
    set Media      = #("Source Media Descriptions", 1, 1)
    Return $(Status) $(Identifier) $(Media)

;--------------------------------------------------------------------
;   ReturnOptions
;   -------------
;
;       This is called to return the option list supported by this
;       INF and the localized text list representing the options.
;       This is called from the setup program.
;
;       INPUT:  $($0):  Language used (ENG, FRN, ...)
;
;       OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL
;                               STATUS_NOLANGUAGE
;                               STATUS_FAILED
;               $($R1): Option List
;               $($R2): Option Text List
;--------------------------------------------------------------------
[ReturnOptions]
    set Status         = STATUS_FAILED
    set OptionList     = {}
    set OptionTextList = {}
;
;-----  Make sure the language passed is in our list
;
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) in $(LanguageList)
        goto returnoptions
    else
        set Status = STATUS_NOLANGUAGE
        goto finish_ReturnOptions
    endif
;
;-----  Build the list of options and the text for the options
;
returnoptions = +
    set OptionList     = ^(Options, 1)
    set OptionTextList = ^(OptionsText$($0), 1)
    set Status         = STATUS_SUCCESSFUL
;
;-----  Return the status
;
finish_ReturnOptions = +
    Return $(Status) $(OptionList) $(OptionTextList)

;--------------------------------------------------------------------
;   InstallOption
;   -------------
;
;       This is called to install the product.
;
;       INPUT:  $($0):  Language used (ENG, FRN, ...)
;               $($1):  Option ID to install
;               $($2):  Source Directory
;               $($3):  AddCopy  (YES | NO)
;               $($4):  DoCopy   (YES | NO)
;               $($5):  DoConfig (YES | NO)
;
;       OUTPUT: $($R0): STATUS: STATUS_SUCCESSFUL
;                               STATUS_NOLANGUAGE
;                               STATUS_USERCANCEL
;                               STATUS_FAILED
;               $($R1): Option List
;--------------------------------------------------------------------
[InstallOption]
    set Option   = $($1)
    set SrcDir   = $($2)
    set AddCopy  = $($3)
    set DoCopy   = $($4)
    set DoConfig = $($5)
    set InstallFromRas = $($6)
;
;-----  Make sure the language is supported
;
    Debug-Output "OEMNXPIP.INF: At InstallOption "$(Option)
    set LanguageList = ^(LanguagesSupported, 1)
    Ifcontains(i) $($0) NOT-IN $(LanguageList)
        return STATUS_NOLANGUAGE
    endif
;
;-----
;
    Debug-Output "OEMNXPIP.INF: STF_CWDIR is: "$(!STF_CWDIR)
    Debug-Output "OEMNXPIP.INF: STF_LANGUAGE is: "$(!STF_LANGUAGE)
;
;-----  Define all constants we need
;
    set-subst LF = "\n"
    read-syms GeneralConstants
    read-syms FileConstants
    read-syms DialogConstants$(!STF_LANGUAGE)
    read-syms FileConstants$(!STF_LANGUAGE)
    detect date
    set-title  $(FunctionTitle)
    set to   = Begin
    set from = Begin
    set CommonStatus = STATUS_SUCCESSFUL
;
;-----  Take down the hourglass
;
    EndWait
;
;----- Set the label to jump to according to what the user
;      wants done.
;
Begin = +
    Ifstr(i) $(!NTN_InstallMode) == deinstall
        set StartLabel = removeadapter
        set OEM_ABANDON_OPTIONS = {}
        set OEM_ABANDON_SOFTWARE = {+
            $(ProductNWLNKSPXName),+
            $(ProductNWLNKNBName),+
            $(ProductNWLNKIPXName)}
    else-Ifstr(i) $(!NTN_InstallMode) == Update
        set StartLabel = UpgradeSoftware
    else-Ifstr(i) $(!NTN_InstallMode) == configure
        set StartLabel = configureadapter
    else-Ifstr(i) $(!NTN_InstallMode) == bind
        set StartLabel = bindingadapter
    else
        set StartLabel = installadapter
        set OEM_ABANDON_SOFTWARE = {}
        set OEM_ABANDON_OPTIONS = {}
    endif
;
;-----  Jump to the label to execute the function needed
;
    set from = $(fatal)
    set to   = $(fatal)
    goto $(StartLabel)

;---------------------------------------------------------------------
;       This section handles the installation and setup of the driver
;---------------------------------------------------------------------
installadapter = +
    Debug-Output "OEMNXPIP.INF: At installadapter"
;
;-----  Open the key for the product
;
    Debug-Output "OEMNXPIP.INF: Opening key for the product"

    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
    Debug-Output "OEMNXPIP.INF: Back from opening key for the product"
;
;-----  If the key is already there, then tell the user that the
;       product is already installed.
;
    Ifstr $(KeyProduct) != $(KeyNull)
        CloseRegKey $(KeyProduct)
        Shell $(UtilityInf), VerExistedDlg, $(Product$(Option)Title),+
            $(ProductVersion)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error: cannot get an error string."
            goto ShellCodeError
        endif
        goto end
    endif
;
;-----  Verify that Novell's stack is not installed.
;
    OpenRegKey $(!REG_H_LOCAL) "" $(CompetitorKeyName) $(!REG_KEY_READ) BadKey
    Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
        Debug-Output "OEMNXPIP.INF:  Service "$(CompetitorServiceName)" exists.  CANNOT INSTALL!"
        GetRegValue $(BadKey) "DisplayName" DisplayList
        Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
            Set CompetitorDisplayName = *($(DisplayList),4)
        Endif
        CloseRegKey $(BadKey)
        read-syms FatalError1$(!STF_LANGUAGE)
        Goto fatal
    Endif

;
;-----  If we are to copy - then set it here
;
    Ifstr(i) $(!NTN_InstallMode) == "install"
        Ifstr(i) $(DoCopy) == "YES"

            Debug-Output "OEMNXPIP.INF: Calling DoAskSource 1"

            Shell $(UtilityInf), DoAskSource, $(!STF_CWDDIR), $(SrcDir) YES
            Ifint $($ShellCode) != $(!SHELL_CODE_OK)
               Goto ShellCodeError
            Else-Ifstr(i) $($R0) == STATUS_FAILED
               Shell $(UtilityInf) RegistryErrorString "ASK_SOURCE_FAIL"
               ifint $($ShellCode) != $(!SHELL_CODE_OK)
                  goto ShellCodeError
               endif
               set Error = $($R0)
               Goto fatal
            Else-Ifstr(i) $($R0) == STATUS_USERCANCEL
               Goto successful
            Endif
            Set SrcDir = $($R1)
        Endif
        install "Install-Option"
        ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
            Shell $(UtilityInf) RegistryErrorString "UNABLE_COPY_FILE"
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                goto ShellCodeError
            endif
            set Error = $($R0)
            goto fatal
        endif
    endif
;
;----- Get the string to use and put up a box that we are installing
;
    Debug-Output "OEMNXPIP.INF: Put up box that we are installing"
    set OEM_ABANDON_ON  = TRUE
    read-syms Billboard1$(!STF_LANGUAGE)
    Shell "subroutn.inf" PushBillboard NETSTATUSDLG $(Status)
    Set BillboardVisible = 1
;
;-----  Set the options that we are going to install
;
    Set DoNWLNKIPX   = FALSE
    Set DoNWLNKNB    = FALSE
    Set DoNWLNKSPX   = FALSE
    Ifstr(i) $(Option) == NWLNKIPX
        Set DoNWLNKIPX   = TRUE
        Set DoNWLNKNB    = TRUE
        Set DoNWLNKSPX   = TRUE
    Else
        Debug-Output "OEMNXPIP.INF: Unrecognized option"
    Endif
;
;-----  Put up the hourglass
;
    Debug-Output "OEMNXPIP.INF: Start the install"
    StartWait
;
;-----  Option to install NWLNK Service Controller Daemon
;
    ifstr(i) $(DoNWLNKIPX) == TRUE
        Set ThisOption = NWLNKIPX
        Set OEM_ABANDON_SOFTWARE = >($(OEM_ABANDON_SOFTWARE), $(Product$(ThisOption)Name))
        Debug-Output "OEMNXPIP.INF: installing NWLNKIPX."

        Shell $(UtilityInf), AddSoftwareComponent,+
            $(Manufacturer),+
            $(Product$(ThisOption)Name),+
            $(Product$(ThisOption)Name),+
            $(Product$(ThisOption)DisplayName),+
            $(STF_CONTEXTINFNAME),+
            $(Product$(ThisOption)ImagePath),+
            $(Product$(ThisOption)SvcType),+
            "PNP_TDI",+
            {},"",+
            $(NWLNKIPXEventDLL)

        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error, add software component"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add software components"
            CloseRegKey $($R1)
            CloseRegKey $($R2)
            CloseRegKey $($R3)
            CloseRegKey $($R4)
            CloseRegKey $($R5)
            goto fatalregistry
        endif
        ;
        ;-----  Set the return values to local vars
        ;
        Set NWLNKVersKeyHandle  = $($R1)
        Set NWLNKRulesKeyHandle = $($R2)
        Set NWLNKSvcKeyHandle   = $($R3)
        Set NWLNKParmKeyHandle  = $($R4)
        Set NWLNKLinkageHandle  = $($R5)
        ;
        ;----- Set the Version entry
        ;
; Save unattended flag
        set UnattendInstallMode = 0
 
        Ifstr(i) $(!STF_UNATTENDED) == "YES"
           set UnattendInstallMode = 1
           Debug-Output "IPX: UnattendInstallMode(1) = "$(UnattendInstallMode)
        endif

        Ifstr(i) $(!STF_GUI_UNATTENDED) == "YES"
           set UnattendInstallMode = 1
           Debug-Output "IPX: UnattendInstallMode(2) = "$(UnattendInstallMode)
        endif

        set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
                           {MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
                           {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
                           {Title,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Title)},+
                           {Description,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Description)},+
                           {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(Product$(ThisOption)OpSupport)},+
                           {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Name)},+
                           {Review,$(NoTitle),$(!REG_VT_DWORD),1},+
                           {STF_GUI_UNATTENDED,$(NoTitle),$(!REG_VT_SZ),$(!STF_GUI_UNATTENDED)},+
                           {Unattend,$(NoTitle),$(!REG_VT_SZ),$(UnattendInstallMode)},+
                           {AUTONETIPXFRAMETYPE,$(NoTitle),$(!REG_VT_DWORD),$(!AUTONETIPXFRAMETYPE)},+
                           {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
        Shell  $(UtilityInf), AddValueList, $(NWLNKVersKeyHandle), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error, add value list"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            CloseRegKey $(NWLNKVersKeyHandle)
            CloseRegKey $(NWLNKRulesKeyHandle)
            CloseRegKey $(NWLNKSvcKeyHandle)
            CloseRegKey $(NWLNKParmKeyHandle)
            CloseRegkey $(NWLNKLinkageHandle)
            goto fatalregistry
        Endif
        ;
        ;----- Set the NetRules entry
        ;
        set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)Type)},+
                            {use,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)Use)},+
                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)BindForm)},+
                            {bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRule$(ThisOption)Bindable)},+
                            {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRule$(ThisOption)Class)},+
                            {InfOption,$(NoTitle),$(!REG_VT_SZ),$(ThisOption)} }
        Shell  $(UtilityInf), AddValueList, $(NWLNKRulesKeyHandle), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        ;
        ;-----  Close up some handles
        ;
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            CloseRegKey $(NWLNKVersKeyHandle)
            CloseRegKey $(NWLNKRulesKeyHandle)
            CloseRegKey $(NWLNKParmKeyHandle)
            CloseRegKey $(NWLNKLinkageHandle)
            CloseRegKey $(NWLNKSvcKeyHandle)
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif
        ;
        ;----- Add the values to the Parameters key
        ;

        ifstr(i) $(!STF_PRODUCT) != "WINNT"
            set RipRoute = 1
        else
            set RipRoute = 0
        endif


        Shell $(UtilityInf) AddValueList, $(NWLNKParmKeyHandle),+
            {{"DedicatedRouter", $(NoTitle), $(!REG_VT_DWORD), 0} +
             {"InitDatagrams", $(NoTitle), $(!REG_VT_DWORD), 10} +
             {"MaxDatagrams", $(NoTitle), $(!REG_VT_DWORD), 50} +
             {"RipUsageTime", $(NoTitle), $(!REG_VT_DWORD), 15} +
             {"SourceRouteUsageTime", $(NoTitle), $(!REG_VT_DWORD), 15} +
             {"SocketUniqueness",   $(NoTitle), $(!REG_VT_DWORD), 8} +
             {"SocketStart",   $(NoTitle), $(!REG_VT_DWORD), 16384} +
             {"SocketEnd",   $(NoTitle), $(!REG_VT_DWORD), 24575} +
             {"VirtualNetworkNumber",$(NoTitle), $(!REG_VT_DWORD), 0} +
             {"RipRoute",       $(NoTitle), $(!REG_VT_DWORD), $(RipRoute)} +
             {"RipTimeout",       $(NoTitle), $(!REG_VT_DWORD), 1} +
             {"EnableWANRouter",  $(NoTitle), $(!REG_VT_DWORD), 0} +
             {"ReplaceConfigDialog",  $(NoTitle), $(!REG_VT_DWORD), 0} +
             {"RipCount",         $(NoTitle), $(!REG_VT_DWORD), 5}}

        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        ;
        ;-----  Close up some of the handles
        ;
        CloseRegKey $(NWLNKVersKeyHandle)
        CloseRegKey $(NWLNKRulesKeyHandle)
        CloseRegKey $(NWLNKParmKeyHandle)
        ;
        ;-----  If we got an error - get out
        ;
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            CloseRegKey $(NWLNKLinkageHandle)
            CloseRegKey $(NWLNKSvcKeyHandle)
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif
        ;
        ;--- Performance stuff
        ;
        CreateRegKey $(NWLNKSvcKeyHandle) {"Performance",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyPerformance
        ifstr(i) $(KeyPerformance) != ""
            Set NewValueList = {+
                {Close,$(NoTitle),$(!REG_VT_SZ),"CloseIPXPerformanceData"},+
                {Collect,$(NoTitle),$(!REG_VT_SZ),"CollectIPXPerformanceData"},+
                {Library,$(NoTitle),$(!REG_VT_SZ),"perfctrs.dll"},+
                {Open,$(NoTitle),$(!REG_VT_SZ),"OpenIPXPerformanceData"},+
                }
            Shell  $(UtilityInf), AddValueList, $(KeyPerformance), $(NewValueList)
            CloseRegKey $(KeyPerformance)
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "OEMNXPIP.INF: ShellCode error."
                goto ShellCodeError
            endif
        endif
        ;
        ;-----  Go create all the subkey stuff
        ;
        Shell "" CreateNWLNKConfiguration $(NWLNKSvcKeyHandle)
        ;
        ;-----  Close up and check for error
        ;
        CloseRegKey $(NWLNKSvcKeyHandle)
        Set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: Create NWLNK configuration."
            goto fatalregistry
        endif
        ;
        ; Set Winsock info
        ;
        Shell $(UtilityInf), AddWinsockInfo, +
             $(Product$(ThisOption)Name), +
             $(Product$(ThisOption)WshDllPath), +
             16,14

        Shell $(UtilityInf) AddMixRpcProtocol "Netbios" "nwlnkipx" "ncacn_nb_ipx" "rpcltccm.dll" "RpcLtScm.Dll"

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\Browser\Parameters" $(MAXIMUM_ALLOWED) BrowserParamKey
        ifstr(i) $(BrowserParamKey) != ""
            SetRegValue $(BrowserParamKey) {DirectHostBinding,$(NoTitle),$(!REG_VT_MULTI_SZ),{"\Device\NwlnkIpx","\Device\NwlnkNb"}}
            CloseRegKey $(BrowserParamKey)
        Endif
    Endif
    Ifstr(i) $(DoNWLNKNB) == TRUE
        Set ThisOption = NWLNKNB
        Set OEM_ABANDON_SOFTWARE = >($(OEM_ABANDON_SOFTWARE), $(Product$(ThisOption)Name))
        Debug-Output "OEMNXPIP.INF: installing NWLNKNB..."
        Shell $(UtilityInf), AddSoftwareComponent,+
            $(Manufacturer),+
            $(Product$(ThisOption)Name),+
            $(Product$(ThisOption)Name),+
            $(Product$(ThisOption)DisplayName),+
            $(STF_CONTEXTINFNAME),+
            $(Product$(ThisOption)ImagePath),+
            $(Product$(ThisOption)SvcType),+
            "PNP_TDI",+
            {},+
            "",+
            $(NWLNKIPXEventDLL)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add software components"
            CloseRegKey $($R1)
            CloseRegKey $($R2)
            CloseRegKey $($R3)
            CloseRegKey $($R4)
            CloseRegKey $($R5)
            goto fatalregistry
        endif
        Set NWLNKNBProductKey      = $($R1)
        Set NWLNKNBNetRuleKey      = $($R2)
        Set NWLNKNBServiceKey      = $($R3)
        Set NWLNKNBParameterKey    = $($R4)
        Set NWLNKNBLinkageKey      = $($R5)
        ;
        ;-----  Set the version info
        ;
        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),$(Product$(ThisOption)Title)},+
                           {Description,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Description)},+
                           {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(Product$(ThisOption)OpSupport)},+
                           {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Name)},+
                           {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
        Shell  $(UtilityInf), AddValueList, $(NWLNKNBProductKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            CloseRegKey $(NWLNKNBProductKey)
            CloseRegKey $(NWLNKNBNetRuleKey)
            CloseRegKey $(NWLNKNBServiceKey)
            CloseRegKey $(NWLNKNBParameterKey)
            CloseRegKey $(NWLNKNBLinkageKey)
            goto fatalregistry
        endif
        ;
        ;-----  Set the NetRules entry
        ;
        set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)Type)},+
                            {use,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)Use)},+
                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)BindForm)},+
                            {InfOption,$(NoTitle),$(!REG_VT_SZ),$(ThisOption)} }
        Shell  $(UtilityInf), AddValueList, $(NWLNKNBNetRuleKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            CloseRegKey $(NWLNKNBProductKey)
            CloseRegKey $(NWLNKNBNetRuleKey)
            CloseRegKey $(NWLNKNBServiceKey)
            CloseRegKey $(NWLNKNBParameterKey)
            CloseRegKey $(NWLNKNBLinkageKey)
            goto fatalregistry
        endif
        ;
        ;-----  Set the NbProvider Stuff
        ;
        Set NewValueList = {{NbProvider,$(NoTitle),$(!REG_VT_SZ),"_ipx"},+
                {EndPoint,$(NoTitle),$(!REG_VT_DWORD),1}}
        Shell  $(UtilityInf), AddValueList, $(NWLNKNBParameterKey), $(NewValueList)
        Ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        Endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            CloseRegKey $(NWLNKNBProductKey)
            CloseRegKey $(NWLNKNBNetRuleKey)
            CloseRegKey $(NWLNKNBServiceKey)
            CloseRegKey $(NWLNKNBParameterKey)
            CloseRegKey $(NWLNKNBLinkageKey)
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif
        ;
        ;----- Add the values to the Parameters key
        ;
        Shell $(UtilityInf) AddValueList, $(NWLNKNBParameterKey),+
            {{"KeepaliveTimeout", $(NoTitle), $(!REG_VT_DWORD), 60} +
             {"KeepaliveCount",   $(NoTitle), $(!REG_VT_DWORD), 8} +
             {"ConnectionTimeout",$(NoTitle), $(!REG_VT_DWORD), 2} +
             {"ConnectionCount",  $(NoTitle), $(!REG_VT_DWORD), 5} +
             {"BroadcastTimeout", $(NoTitle), $(!REG_VT_DWORD), 1} +
             {"BroadcastCount",   $(NoTitle), $(!REG_VT_DWORD), 3} +
             {"Internet",         $(NoTitle), $(!REG_VT_DWORD), 1}}

        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            CloseRegKey $(NWLNKNBProductKey)
            CloseRegKey $(NWLNKNBNetRuleKey)
            CloseRegKey $(NWLNKNBServiceKey)
            CloseRegKey $(NWLNKNBParameterKey)
            CloseRegKey $(NWLNKNBLinkageKey)
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif

        ;
        ;--- Performance stuff
        ;
        CreateRegKey $(NWLNKNBServiceKey) {"Performance",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyPerformance
        ifstr(i) $(KeyPerformance) != ""
            Set NewValueList = {+
                {Close,$(NoTitle),$(!REG_VT_SZ),"CloseNWNBPerformanceData"},+
                {Collect,$(NoTitle),$(!REG_VT_SZ),"CollectNWNBPerformanceData"},+
                {Library,$(NoTitle),$(!REG_VT_SZ),"perfctrs.dll"},+
                {Open,$(NoTitle),$(!REG_VT_SZ),"OpenNWNBPerformanceData"},+
                }
            Shell  $(UtilityInf), AddValueList, $(KeyPerformance), $(NewValueList)
            CloseRegKey $(KeyPerformance)
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "OEMNXPIP.INF: ShellCode error."
                goto ShellCodeError
            endif
            set RegistryErrorIndex = $($R0)
        endif
        ;
        ;-----  Close rest of handles
        ;
        CloseRegKey $(NWLNKNBProductKey)
        CloseRegKey $(NWLNKNBNetRuleKey)
        CloseRegKey $(NWLNKNBServiceKey)
        CloseRegKey $(NWLNKNBParameterKey)
        CloseRegKey $(NWLNKNBLinkageKey)
        ;
        ;-----
        ;
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif
    Endif

    Ifstr(i) $(DoNWLNKSPX) == TRUE
        Set ThisOption = NWLNKSPX
        Set OEM_ABANDON_SOFTWARE = >($(OEM_ABANDON_SOFTWARE), $(Product$(ThisOption)Name))
        Debug-Output "OEMNXPIP.INF: installing NWLNKSPX..."
        Shell $(UtilityInf), AddSoftwareComponent,+
            $(Manufacturer),+
            $(Product$(ThisOption)Name),+
            $(Product$(ThisOption)Name),+
            $(Product$(ThisOption)DisplayName),+
            $(STF_CONTEXTINFNAME),+
            $(Product$(ThisOption)ImagePath),+
            $(Product$(ThisOption)SvcType),+
            "",+
            {},"",+
            $(NWLNKIPXEventDLL)

        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error"
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add software components"
            CloseRegKey $($R1)
            CloseRegKey $($R2)
            CloseRegKey $($R3)
            CloseRegKey $($R4)
            CloseRegKey $($R5)
            goto fatalregistry
        endif
        Set NWLNKSPXProductKey      = $($R1)
        Set NWLNKSPXNetRuleKey      = $($R2)
        Set NWLNKSPXServiceKey      = $($R3)
        Set NWLNKSPXParameterKey    = $($R4)
        Set NWLNKSPXLinkageKey      = $($R5)
        ;
        ;-----  Set the version info
        ;
        set NewValueList = {{SoftwareType,$(NoTitle),$(!REG_VT_SZ),$(SoftwareType)},+
                           {MajorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMajorVersion)},+
                           {MinorVersion,$(NoTitle),$(!REG_VT_DWORD),$(ProductMinorVersion)},+
                           {Hidden,$(NoTitle),$(!REG_VT_DWORD),1},+
                           {Title,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Title)},+
                           {Description,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Description)},+
                           {ServiceName,$(NoTitle),$(!REG_VT_SZ),$(Product$(ThisOption)Name)},+
                           {InstallDate,$(NoTitle),$(!REG_VT_DWORD),*($(Now),1)}}
        Shell  $(UtilityInf), AddValueList, $(NWLNKSPXProductKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            CloseRegKey $(NWLNKSPXProductKey)
            CloseRegKey $(NWLNKSPXNetRuleKey)
            CloseRegKey $(NWLNKSPXServiceKey)
            CloseRegKey $(NWLNKSPXParameterKey)
            CloseRegKey $(NWLNKSPXLinkageKey)
            goto fatalregistry
        endif
        ;
        ;-----  Set the NetRules entry
        ;
        set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)Type)},+
                            {use,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)Use)},+
                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRule$(ThisOption)BindForm)},+
                            {bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRule$(ThisOption)Bindable)},+
                            {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRule$(ThisOption)Class)},+
                            {InfOption,$(NoTitle),$(!REG_VT_SZ),$(ThisOption)} }
        Shell  $(UtilityInf), AddValueList, $(NWLNKSPXNetRuleKey), $(NewValueList)
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            CloseRegKey $(NWLNKSPXProductKey)
            CloseRegKey $(NWLNKSPXNetRuleKey)
            CloseRegKey $(NWLNKSPXServiceKey)
            CloseRegKey $(NWLNKSPXParameterKey)
            CloseRegKey $(NWLNKSPXLinkageKey)
            goto fatalregistry
        endif
        ;
        ;----- Add the values to the Parameters key
        ;
        Shell $(UtilityInf) AddValueList, $(NWLNKSPXParameterKey),+
            {{"ConnectionCount", $(NoTitle), $(!REG_VT_DWORD), 5} +
             {"ConnectionTimeout",   $(NoTitle), $(!REG_VT_DWORD), 2} +
             {"InitPackets",$(NoTitle), $(!REG_VT_DWORD), 5} +
             {"MaxPackets",  $(NoTitle), $(!REG_VT_DWORD), 48} +
             {"InitialRetransmissionTime", $(NoTitle), $(!REG_VT_DWORD), 500} +
             {"KeepAliveCount",   $(NoTitle), $(!REG_VT_DWORD), 8} +
             {"WindowSize",   $(NoTitle), $(!REG_VT_DWORD), 4} +
             {"SpxSocketRangeStart",   $(NoTitle), $(!REG_VT_DWORD), 24576} +
             {"SpxSocketRangeEnd",   $(NoTitle), $(!REG_VT_DWORD), 32767} +
             {"SpxSocketUniqueness",   $(NoTitle), $(!REG_VT_DWORD), 1} +
             {"MaxPacketSize",   $(NoTitle), $(!REG_VT_DWORD), 4096} +
             {"RetransmissionCount",   $(NoTitle), $(!REG_VT_DWORD), 8} +
             {"KeepAliveTimeout",         $(NoTitle), $(!REG_VT_DWORD), 12}}

        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error."
            goto ShellCodeError
        endif
        set RegistryErrorIndex = $($R0)
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            CloseRegKey $(NWLNKSPXProductKey)
            CloseRegKey $(NWLNKSPXNetRuleKey)
            CloseRegKey $(NWLNKSPXServiceKey)
            CloseRegKey $(NWLNKSPXParameterKey)
            CloseRegKey $(NWLNKSPXLinkageKey)
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif

        ;
        ;--- Performance stuff
        ;
        CreateRegKey $(NWLNKSPXServiceKey) {"Performance",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyPerformance
        ifstr(i) $(KeyPerformance) != ""
            Set NewValueList = {+
                {Close,$(NoTitle),$(!REG_VT_SZ),"CloseSPXPerformanceData"},+
                {Collect,$(NoTitle),$(!REG_VT_SZ),"CollectSPXPerformanceData"},+
                {Library,$(NoTitle),$(!REG_VT_SZ),"perfctrs.dll"},+
                {Open,$(NoTitle),$(!REG_VT_SZ),"OpenSPXPerformanceData"},+
                }
            Shell  $(UtilityInf), AddValueList, $(KeyPerformance), $(NewValueList)
            CloseRegKey $(KeyPerformance)
            ifint $($ShellCode) != $(!SHELL_CODE_OK)
                Debug-Output "OEMNXPIP.INF: ShellCode error."
                goto ShellCodeError
            endif
            set RegistryErrorIndex = $($R0)
        endif
        ;
        ;-----  Close rest of handles
        ;
        CloseRegKey $(NWLNKSPXProductKey)
        CloseRegKey $(NWLNKSPXNetRuleKey)
        CloseRegKey $(NWLNKSPXServiceKey)
        CloseRegKey $(NWLNKSPXParameterKey)
        CloseRegKey $(NWLNKSPXLinkageKey)
        ;
        ;-----
        ;
        Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
            EndWait
            Debug-Output "OEMNXPIP.INF: Registry error: add value list."
            goto fatalregistry
        endif

        ;
        ; Set Winsock info
        ;
        Shell $(UtilityInf), AddWinsockInfo, +
             $(Product$(ThisOption)Name), +
             $(ProductNWLNKIPXWshDllPath), +
             16,14

    ;
    ; Add Name Space Provider 
    ;
    Shell $(UtilityInf), AddNameSpaceProvider, +
            $(ProductNWLNKIPXDisplayName), +
            $(ProviderImagePath), +
            $(ProviderNameSpaces), +
            TRUE, +
            $(ProviderGUID)

	;
	; Add Service Provider
	;
	Shell $(UtilityInf), AddServiceProvider, $(ProductNWLNKIPXName), +
	    $(ProviderImagePath), $(ProductNWLNKIPXDisplayName), 8


	;
	; Add Rpc Protocol
	;
        Shell $(UtilityInf) AddClientRpcProtocol "ncadg_ipx" "RpcLtCcm.Dll"
        Shell $(UtilityInf) AddClientRpcProtocol "ncacn_spx" "RpcLtCcm.Dll"
        Shell $(UtilityInf) AddServerRpcProtocol "ncadg_ipx" "RpcLtScm.Dll"
        Shell $(UtilityInf) AddServerRpcProtocol "ncacn_spx" "RpcLtScm.Dll"
    Endif
;
;-----  Take down the hourglass
;
    ;
    ; Display rebind ras message
    ;
    ifstr(i) $(!STF_GUI_UNATTENDED) != YES
        ifstr(i) $(InstallFromRas) != "YES"
            OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\RASMan" $(MAXIMUM_ALLOWED) RASKey
            ifstr(i) $(RASKey) != ""
                Shell $(subroutineinf) SetupMessage, $(!STF_LANGUAGE), "WARNING", $(RASRebindError)
                ifint $($ShellCode) != $(!SHELL_CODE_OK)
                    goto ShellCodeError
                endif
                CloseRegKey $(RASKey)
                ifstr(i) $($R1) == "OK"
                    set SaveNTN_InstallMode = $(!NTN_InstallMode)
                    set !NTN_InstallMode = configure
                    ; now invoke RAS setup to do the right thing
                    Shell "oemnsvra.inf" InstallOption $(!STF_LANGUAGE) "RAS" $(SrcDir) $(AddCopy) $(DoCopy) $(DoConfig) 
                    set !NTN_InstallMode = $(SaveNTN_InstallMode)
                endif
            endif
        endif
    endif


    ;
    ;  Set proper security on the nwlnkspx service so that normal users can
    ;  start the service.  Ignore any error; it's not fatal.
    ;
    LibraryProcedure DontCare $(!NCPA_HANDLE), CPlSetup $(!STF_HWND),+
              SECURESVC, $(ProductNWLNKSPXName), 3

    EndWait

;
;-----  If the billboard is up - take it down
;
    Ifint $(BillboardVisible) != 0
        Shell "subroutn.inf" PopBillboard
        Set BillboardVisible = 0
    Endif
;
;-----  Exit OK
;
    goto successful

;---------------------------------------------------------------------
;       This section handles the configuration of the driver
;---------------------------------------------------------------------
configureadapter = +
    Debug-Output "OEMNXPIP.INF: At ConfigureAdapter"

    ifstr(i) $(Option) == "NWLNKIPX"
        ;
        ;  Read the active bindings into a single list
        ;
        Set BindList = {}

        OpenRegKey $(!REG_H_LOCAL) "" $(LinkageKeyName) $(MAXIMUM_ALLOWED) LinkageKey

        ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
            GetRegValue $(LinkageKey) "Bind" BindList
            ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
               set BindList = *($(BindList),4)
            else
               Set BindList = {}
            endif
            CloseRegKey $(LinkageKey)
        endif

        ;  Check that we're bound to something

        ifstr(i) $(BindList) == {}
            debug-output "NWLNK.INF: no binding info; warning user"
            read-syms InfoDlgCantConfigure
            goto infomsg
        endif

        ;  Extract and validate the card names from the binding strings.

        Debug-Output "OEMNXPIP.INF: configureadapter, BindList = "$(BindList)

        set OldVersionExisted = $(TRUE)
        set CardList = ""

        ForListDo $(BindList)

            ;  Adapter name is the last element in binding string;
            ;    extract it.

            Split-String $($), "\", BindInfo
            QueryListSize BindElem $(BindInfo)
            Set BindName = *($(BindInfo),$(BindElem))

            ;  Validate it; append to string if OK

            OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\"$(BindName) $(MAXIMUM_ALLOWED) CardServiceKey
            ifstr(i) $(CardServiceKey) != ""
                CloseRegKey $(CardServiceKey)
                Set CardList = $(CardList)"@"$(BindName)
            endif
        EndForListDo

        ifstr(i) $(CardList) != ""

            Debug-Output "OEMNXPIP.INF: configureadapter, CardList = "$(CardList)

            LoadLibrary "x", $(!STF_WINDOWSSYSPATH)\ipxcfg.dll NWLNKLIB_HANDLE
            set FLibraryErrCtl = 1

	        ifstr(i) $(!STF_GUI_UNATTENDED) == "YES"
		    LibraryProcedure ResultList, $(NWLNKLIB_HANDLE), RunIpxDlg, $(!STF_HWND) $(!STF_PRODUCT) "YES" $(!AUTONETIPXFRAMETYPE)
	        else
	    	    LibraryProcedure ResultList, $(NWLNKLIB_HANDLE), RunIpxDlg, $(!STF_HWND) $(!STF_PRODUCT)
	        endif

            FreeLibrary $(NWLNKLIB_HANDLE)

            set FLibraryErrCtl = 0

            ;  Result list is of the form  {<0|1>,"name of active adapter"}

            Debug-Output "OEMNXPIP.INF: configureadapter, ResultList = "$(ResultList)
            Set Result = *($(ResultList),1)

            Ifint $(Result) == 0
                set CommonStatus = STATUS_USERCANCEL
            Else
                set CommonStatus = STATUS_REBOOT
            Endif
        else
            set CommonStatus = STATUS_USERCANCEL
        endif
    else
        Shell $(UtilityInf),RegistryErrorString,CANNOT_CONFIGURE_SOFTWARE
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            Debug-Output "OEMNXPIP.INF: ShellCode error: cannot get an error string."
            goto ShellCodeError
        endif
        set Error = $($R0)
        set from = end
        set to = end
        set CommonStatus = STATUS_USERCANCEL
        goto nonfatal
    endif
    goto end

;---------------------------------------------------------------------
;       This section handles the configuration of the driver
;---------------------------------------------------------------------
bindingadapter =+
    ;
    ; Reset or reload the unattend info
    ;
    set l_unattended = 0
    OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

    ifstr(i) $(KeyProduct) != ""

        GetRegValue $(KeyProduct) "STF_GUI_UNATTENDED" UnattendedList
	    Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
	        set !STF_GUI_UNATTENDED = *($(UnattendedList),4)
	        DeleteRegValue $(KeyProduct) "STF_GUI_UNATTENDED"
	    endif

        GetRegValue $(KeyProduct) "AUTONETIPXFRAMETYPE" FrameTypeList
	    Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
	        set !AUTONETIPXFRAMETYPE = *($(FrameTypeList),4)
	        DeleteRegValue $(KeyProduct) "AUTONETIPXFRAMETYPE"
	    endif

; Get unattend state
        GetRegValue $(KeyProduct) "Unattend" KeyUnattend
	    Ifint $(RegLastError) == $(!REG_ERROR_SUCCESS)
	        set l_unattended = *($(KeyUnattend),4)
	        DeleteRegValue $(KeyProduct) "Unattend"
	    endif

	    CloseRegKey $(KeyProduct)
    endif

    ;
    ; remove extra export string
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(LinkageKeyName) $(MAXIMUM_ALLOWED) KeyLinkage
    ifstr(i) $(KeyLinkage) != ""
        SetRegValue $(KeyLinkage) {Export,$(NoTitle),$(!REG_VT_MULTI_SZ),{"\Device\NwlnkIpx"}}
        CloseRegKey $(KeyLinkage)
    endif

    Shell "nbinfo.inf" CheckMixRpcProtocol "NwlnkNb" 7 "nwlnkipx" "ncacn_nb_ipx" "rpcltccm.dll" "RpcLtScm.Dll"

    LoadLibrary "x", $(!STF_WINDOWSSYSPATH)\ipxcfg.dll NWLNKLIB_HANDLE
    set FLibraryErrCtl = 1
    LibraryProcedure ResultList, $(NWLNKLIB_HANDLE), IPXCfgChk $(l_unattended)
    FreeLibrary $(NWLNKLIB_HANDLE)
    set FLibraryErrCtl = 0
    Set Result = *($(ResultList),1)
    ifint $(Result) == 0
        Debug-Output "OEMNXPIP.INF:  reconfiguration not required"
        set CommonStatus = STATUS_USERCANCEL
        goto successful
    else
        Debug-Output "OEMNXPIP.INF:  reconfiguration required"
    endif



    goto configureadapter

;---------------------------------------------------------------------
;       This section handles the removal of the driver
;---------------------------------------------------------------------
removeadapter = +
    Shell $(UtilityInf), IsRefCountEqualZero $(ProductKeyName)
    ifint $($R1) == 0
    
        read-syms InUse$(!STF_LANGUAGE)
        goto infomsg
    endif
    Debug-Output "OEMNXPIP.INF: At removeadapter"
    ;
    ; Remove Winsock information
    ;
    Shell $(UtilityInf), RemoveWinsockInfo, $(ProductNWLNKIPXName)
    Shell $(UtilityInf), RemoveWinsockInfo, $(ProductNWLNKSPXName)

    Shell $(UtilityInf) RemoveRpcProtocol "ncacn_nb_ipx"

    Shell $(UtilityInf) RemoveClientRpcProtocol "ncadg_ipx"
    Shell $(UtilityInf) RemoveClientRpcProtocol "ncacn_spx"
    Shell $(UtilityInf) RemoveServerRpcProtocol "ncadg_ipx"
    Shell $(UtilityInf) RemoveServerRpcProtocol "ncacn_spx"

    ForListDo $(OEM_ABANDON_SOFTWARE)
        DEBUG-OUTPUT "Remove component: "$($)
        Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), $($)
    EndForListDo
    ForListDo  $(OEM_ABANDON_OPTIONS)
        DEBUG-OUTPUT "Remove component: "$($)
        Set UseSvcctrl = "YES"
        Shell $(UtilityInf), RemoveService, $($), $(UseSvcctrl)
    EndForListDo

    Shell $(UtilityInf) RemoveServiceProvider $(ProductNWLNKIPXName)

    ;
    ; Remove Name Space Provider 
    ;
    Shell $(UtilityInf), RemoveNameSpaceProvider, $(ProviderGUID)

    OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\Browser\Parameters" $(MAXIMUM_ALLOWED) BrowserParamKey
    ifstr(i) $(BrowserParamKey) != ""
        DeleteRegValue $(BrowserParamKey) "DirectHostBinding"
        CloseRegKey $(BrowserParamKey)
    Endif
;
;-----
;
    goto end

;---------------------------------------------------------------------
;       This section handles the upgrade of the service
;---------------------------------------------------------------------
UpgradeSoftware = +
    ; Upgrade software component
    ;
    ; This inf is messed up, it has one option but creates 
    ; more than one entry in the software area of the registry. 
    ; Messes up upgrade. Since, the option NWLNKIPX does all 
    ; the work, we will ignore the rest

    Ifstr(i) $(Option) != NWLNKIPX
        set CommonStatus = STATUS_NO_EFFECT
        goto end
    endif
    OpenRegKey $(!REG_H_LOCAL) "" $(OldProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct

    Ifstr $(KeyProduct) != $(KeyNull)

        install "Install-Update"
        ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
            goto fatal
        endif

        ;
        ; Get reference count
        ;
        GetRegValue $(KeyProduct),"RefCount", RefCountInfo

        CloseRegKey $(KeyProduct)

        ;
        ; Remove old nwlnk
        ;
        set OEM_ABANDON_OPTIONS = {+
            "NWLINKSYS",+
            "NWLINKSPX",+
            "NWNBLINKSYS"}
        set OEM_ABANDON_SOFTWARE = {+
            "NWNBLINK",+
            "NWLINKIPX",+
            Streams}
        
        Debug-Output "OEMNXPIP.INF: At RemoveWinsockInfo"
        ;
        ; Remove Winsock information
        ;
        Shell $(UtilityInf), RemoveWinsockInfo, "NWLINKIPX"
        ;
        ;  Remove IPX NB info
        ;
        Shell $(UtilityInf) RemoveRpcProtocol "ncacn_nb_ipx"
        Ifstr(i) $($0) != NO_ERROR
            Debug-Output "OEMNXPIP.INF: ERROR deleting IPX RPC protocol data"
        Endif

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_SoftwareBase)"\Microsoft\NWCWorkstation" $(MAXIMUM_ALLOWED) NwcKey
	    ifstr(i) $(NwcKey) == ""
            ;
            ;  Remove IPX RPC info
            ;
            Shell $(UtilityInf) RemoveServerRpcProtocol "ncadg_ipx"
            Ifstr(i) $($0) != NO_ERROR
                Debug-Output "OEMNXPIP.INF: ERROR deleting IPX RPC protocol data"
            Endif
            ;
            ;  Remove SPX RPC info
            ;
            Shell $(UtilityInf) RemoveServerRpcProtocol "ncacn_spx"
            Ifstr(i) $($0) != NO_ERROR
                Debug-Output "OEMNXPIP.INF: ERROR deleting SPX RPC protocol data"
            Endif
        else
            CloseRegKey $(NwcKey)
        endif
        
        ForListDo $(OEM_ABANDON_SOFTWARE)
            DEBUG-OUTPUT "Remove component: "$($)
            ifstr(i) $($) == "Streams"
                Shell $(UtilityInf), RemoveStreams
            else
                Shell $(UtilityInf), RemoveSoftwareComponent, $(Manufacturer), $($), FALSE
            endif
        EndForListDo
        ForListDo  $(OEM_ABANDON_OPTIONS)
            DEBUG-OUTPUT "Remove component: "$($)
            ifstr(i) $($) != "NWLINKSPX"
                Set UseSvcctrl = "YES"
            else
                Set UseSvcctrl = "NO"
            endif
            Shell $(UtilityInf), RemoveService, $($), $(UseSvcctrl)
        EndForListDo
        
        ;
        ; Install new nwlnk driver
        ;
        set OldInstallMode = $(!NTN_InstallMode)
        set !NTN_InstallMode = install

        Shell "" "InstallOption" $(!STF_LANGUAGE) "NWLNKIPX" +
           $(!STF_SRCDIR) "NO" "NO" $(DoConfig)

        set !NTN_InstallMode = $(OldInstallMode)

        OpenRegKey $(!REG_H_LOCAL) "" $(ProductKeyName) $(MAXIMUM_ALLOWED) KeyProduct
        ifstr(i) $(KeyProduct) != ""
            SetRegValue $(KeyProduct), $(RefCountInfo)
            CloseRegKey $(KeyProduct)
        endif
    else
        ;
        ; Cannot Open old software key, Just upgrade the file
        ;
        install "Install-Update"
        ifstr(i) $(STF_INSTALL_OUTCOME) != STF_SUCCESS
            goto fatal
        endif

        CloseRegKey $(KeyProduct)

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_ServiceBase)"\NwlnkIpx\Parameters" $(MAXIMUM_ALLOWED) KeyParameters

        ifstr(i) $(KeyParameters) != ""
            GetRegValue $(KeyParameters), "ReplaceConfigDialog", ReplaceInfo
            Debug-Output "GetRegValue returned "$(RegLastError)
            ifint $(RegLastError) != $(!REG_ERROR_SUCCESS)
	    	SetRegValue $(KeyParameters) {ReplaceConfigDialog,$(NoTitle),$(!REG_VT_DWORD),0}
            endif
            CloseRegKey $(KeyParameters)
        endif

        ;
        ; Add SPX bind rule
        ;
        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_SoftwareBase)"\"$(Manufacturer)"\NwlnkSpx\CurrentVersion\NetRules" $(MAXIMUM_ALLOWED) KeyNetRules

        ifstr(i) $(KeyNetRules) != ""
            set NewValueList = {{type,$(NoTitle),$(!REG_VT_SZ),$(NetRuleNWLNKSPXType)},+
                            {bindable,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleNWLNKSPXBindable)},+
                            {class,$(NoTitle),$(!REG_VT_MULTI_SZ),$(NetRuleNWLNKSPXClass)},+
                            {use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleNWLNKSPXUse)},+
                            {bindform,$(NoTitle),$(!REG_VT_SZ),$(NetRuleNWLNKSPXBindForm)}}
            Shell  $(UtilityInf), AddValueList, $(KeyNetRules), $(NewValueList)
            CloseRegKey $(KeyNetRules)
        endif

    ;
    ; Add Name Space Provider 
    ;
    Shell $(UtilityInf), AddNameSpaceProvider, +
            $(ProductNWLNKIPXDisplayName), +
            $(ProviderImagePath), +
            $(ProviderNameSpaces), +
            TRUE, +
            $(ProviderGUID)

    	;
	; Add Service Provider
	;
	Shell $(UtilityInf), AddServiceProvider, $(ProductNWLNKIPXName), +
	    $(ProviderImagePath), 8

        OpenRegKey $(!REG_H_LOCAL) "" $(!NTN_SoftwareBase)"\Microsoft\NWCWorkstation" $(MAXIMUM_ALLOWED) NwcKey
	    ifstr(i) $(NwcKey) == ""
	        Shell $(UtilityInf) RemoveServerRpcProtocol "ncadg_ipx"
            Shell $(UtilityInf) RemoveServerRpcProtocol "ncacn_spx"
        else
            CloseRegKey $(NwcKey)
        endif
        Shell $(UtilityInf) AddClientRpcProtocol "ncadg_ipx" "RpcLtCcm.Dll"
        Shell $(UtilityInf) AddClientRpcProtocol "ncacn_spx" "RpcLtCcm.Dll"
    endif

    ;
    ;  Set proper security on the nwlnkspx service so that normal users can
    ;  start the service.  Ignore any error; it's not fatal.
    ;
    LibraryProcedure DontCare $(!NCPA_HANDLE), CPlSetup $(!STF_HWND),+
              SECURESVC, $(ProductNWLNKSPXName), 3

    Set MappingOption = NWLNKIPX
    Shell $(UtilityInf) UpdateWinsockMappings $(Product$(MappingOption)Name) $(ProductNWLNKIPXWshDllPath)

    Set MappingOption = NWLNKSPX
    Shell $(UtilityInf) UpdateWinsockMappings $(Product$(MappingOption)Name) $(ProductNWLNKIPXWshDllPath)

    set RegistryErrorIndex = $($R0)
    Ifstr(i) $(RegistryErrorIndex) != NO_ERROR
        Debug-Output "OEMNXPIP.INF: Registry error: UpdateWinsockInfo."
    Endif

;
; Cache away the unattend state for bindings
;
    set UnattendInstallMode = 0
 
    Ifstr(i) $(!STF_UNATTENDED) == "YES"
       set UnattendInstallMode = 1
       Debug-Output "IPX: UnattendInstallMode(3) = "$(UnattendInstallMode)
    endif

    Ifstr(i) $(!STF_GUI_UNATTENDED) == "YES"
       set UnattendInstallMode = 1
       Debug-Output "IPX: UnattendInstallMode(4) = "$(UnattendInstallMode)
    endif

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

    ifstr(i) $(UnattendProduct) != ""
;
; Set unattend state
;
        SetRegValue $(UnattendProduct) {Unattend,$(NoTitle),$(!REG_VT_DWORD),$(UnattendInstallMode)}
        CloseRegKey $(UnattendProduct)

    endif



    ;
    ; Update load order group membership
    ;
    OpenRegKey $(!REG_H_LOCAL) "" $(ServiceNWLNKKeyName) $(MAXIMUM_ALLOWED) NWLNKKeyService
    Ifstr $(NWLNKKeyService) != $(KeyNull)
        SetRegValue $(NWLNKKeyService) {Group,$(NoTitle),$(!REG_VT_SZ),"PNP_TDI"}
        CloseRegKey $(NWLNKKeyService)
    endif

    OpenRegKey $(!REG_H_LOCAL) "" $(ServiceNWLNKNBKeyName) $(MAXIMUM_ALLOWED) NWLNKNBKeyService
    Ifstr $(NWLNKNBKeyService) != $(KeyNull)
        SetRegValue $(NWLNKNBKeyService) {Group,$(NoTitle),$(!REG_VT_SZ),"PNP_TDI"}
        CloseRegKey $(NWLNKNBKeyService)
    endif

        ;
        ; Update NetRules Keys for NwlnkIpx and NwlnkNb.
        ;
        OpenRegKey $(!REG_H_LOCAL) "" $(NWLNKIPXNetRuleKeyName) $(MAXIMUM_ALLOWED) NWLNKIPXKeyNetRules

        Ifstr $(NWLNKIPXKeyNetRules) != $(KeyNull)
            SetRegValue $(NWLNKIPXKeyNetRules) {use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleNWLNKIPXUse)}
            CloseRegKey $(NWLNKIPXKeyNetRules)
        endif

        OpenRegKey $(!REG_H_LOCAL) "" $(NWLNKNBNetRuleKeyName) $(MAXIMUM_ALLOWED) NWLNKNBKeyNetRules

        Ifstr $(NWLNKNBKeyNetRules) != $(KeyNull)
            SetRegValue $(NWLNKNBKeyNetRules) {use,$(NoTitle),$(!REG_VT_SZ),$(NetRuleNWLNKNBUse)}
            CloseRegKey $(NWLNKNBKeyNetRules)
        endif

        ;
        ; Update Current version Keys for NwlnkIpx and NwlnkNb.
        ;
        OpenRegKey $(!REG_H_LOCAL) "" $(NWLNKIPXKeyName) $(MAXIMUM_ALLOWED) NWLNKIPXKey

        Ifstr $(NWLNKIPXKey) != $(KeyNull)
            SetRegValue $(NWLNKIPXKey) {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductNWLNKIPXDescription)}
            SetRegValue $(NWLNKIPXKey) {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(ProductNWLNKIPXOpSupport)}
            CloseRegKey $(NWLNKIPXKey)
        endif

        OpenRegKey $(!REG_H_LOCAL) "" $(NWLNKNBKeyName) $(MAXIMUM_ALLOWED) NWLNKNBKey

        Ifstr $(NWLNKNBKey) != $(KeyNull)
            SetRegValue $(NWLNKNBKey) {Description,$(NoTitle),$(!REG_VT_SZ),$(ProductNWLNKNBDescription)}
            SetRegValue $(NWLNKNBKey) {OperationsSupport,$(NoTitle),$(!REG_VT_DWORD),$(ProductNWLNKNBOpSupport)}
            CloseRegKey $(NWLNKNBKey)
        endif

        ; Add RPC server protocols.

        Shell $(UtilityInf) AddServerRpcProtocol "ncadg_ipx" "RpcLtScm.Dll"
        Shell $(UtilityInf) AddServerRpcProtocol "ncacn_spx" "RpcLtScm.Dll"


    goto end
;
;----- Everything was OK
;
successful = +
    goto end
;
;-----
;
infomsg =+
   read-syms InfoDlg
   ui start "Warning"
   set CommonStatus = STATUS_USERCANCEL
   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
;
;-----
;
nonfatal = +
    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), "NONFATAL", $(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 = +
    ifstr(i) $(Error) == ""
        Shell $(UtilityInf) RegistryErrorString "SETUP_FAIL"
        ifint $($ShellCode) != $(!SHELL_CODE_OK)
            goto ShellCodeError
        endif
        set Error = $($R0)
    endif
    Ifint $(BillboardVisible) != 0
        Shell "subroutn.inf" PopBillboard
        Set BillboardVisible = 0
    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)

;**********************************************************************
;       Create the configuration
;**********************************************************************
[CreateNWLNKConfiguration]
    read-syms GeneralConstants
    Set NWLNKSvcKeyHandle = $($0)
    Debug-Output "NWLNK.INF: installing NWLNK configuration:"
;
;-----  Create the NetConfig Entry
;
    CreateRegKey $(NWLNKSvcKeyHandle) {"NetConfig",$(NoTitle),GenericClass} "" $(MAXIMUM_ALLOWED) "" KeyNetConfig
;
;-----  Close the NetConfig key
;
    CloseRegKey $(KeyNetConfig)
;
;-----  All Done
;
CreateNWLNKConfigDone = +
    Debug-Output "NWLNK.INF: installing NWLNK.....done."
    Return NO_ERROR

;********************************************************************
;********************************************************************
[Install-Option]
    set STF_VITAL = ""
;
;----- Add files to the copy list
;
    ifstr(i) $(AddCopy) == "YES"
        Debug-Output "NWLNK.INF: Adding files to copy list"
        AddSectionFilesToCopyList Files-$(Option) $(SrcDir) $(!STF_WINDOWSSYSPATH)\drivers
        AddSectionFilesToCopyList Files-NWLNKEXE $(SrcDir) $(!STF_WINDOWSSYSPATH)
    endif
;
;-----  Copy the files over
;
    ifstr(i) $(DoCopy) == "YES"
       Debug-Output "NWLNK.INF: Copying Files"
       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-NWLNKEXE $(SrcDir) $(!STF_WINDOWSSYSPATH)
;
;-----
;
   Exit


[RipDialog]
    DlgType      = "MessageBox"
    STF_MB_TITLE = $(ProCaption)
    STF_MB_TEXT  = $(InstallRip)
    STF_MB_TYPE  = 3
    STF_MB_ICON  = 1
    STF_MB_DEF   = 1