;
; KEYED SECTIONS.  These sections are provided for files where a selection
; is made from a set of files and the chosen one is copied under a generic
; name.  This can be used to update the hal.dll, ntoskrnl.exe, ntbootdd.sys,
; ntdetect.com.
;


[FileKeyedClasses]
    Hal            = hal.dll
    Ntoskrnl       = ntoskrnl.exe

[FilesKeyedSections]
    FilesHal       = $(STF_HALDEST)
    FilesNtoskrnl  = $(STF_WINDOWSSYSPATH)

[FilesHal]

    ; for x86

    ; hal      = 1, hal.dll      , RENAME=$(NEWFILE)
    ; halast   = 1, halast.dll   , RENAME=$(NEWFILE)
    ; halcbus  = 1, halcbus.dll  , RENAME=$(NEWFILE)
    ; hal486c  = 1, hal486c.dll  , RENAME=$(NEWFILE)
    ; halmca   = 1, halmca.dll   , RENAME=$(NEWFILE)
    ; halncr   = 1, halncr.dll   , RENAME=$(NEWFILE)
    ; haloli   = 1, haloli.dll   , RENAME=$(NEWFILE)
    ; halsm2   = 1, halsm2.dll   , RENAME=$(NEWFILE)
    ; halsp    = 1, halsp.dll    , RENAME=$(NEWFILE)
    ; halwyse7 = 1, halwyse7.dll , RENAME=$(NEWFILE)

    ; for mips

    ; hal      = 1, hal.dll      , RENAME=$(NEWFILE)
    ; haldti   = 1, haldti.dll   , RENAME=$(NEWFILE)
    ; halduomp = 1, halduomp.dll , RENAME=$(NEWFILE)
    ; halfxs   = 1, halfxs.dll   , RENAME=$(NEWFILE)
    ; halacr   = 1, halacr.dll   , RENAME=$(NEWFILE)

    ; for alpha



[FilesNtoskrnl]

    ; for x86, mips, alpha

;
; REGULAR SECTIONS.  These sections are provided for files where the file
; just needs to be copied to a known destination.
;

[FileSections]
    FilesPrimary        = C:
    FilesOsLoader       = $(STF_OSLDEST)
    FilesWinnt          = $(STF_WINDOWSPATH)
    FilesSystem32       = $(STF_WINDOWSSYSPATH)
    FilesSystem         = $(STF_WINDOWSPATH)\system
    FilesDrivers        = $(STF_WINDOWSSYSPATH)\drivers
    FilesConfig         = $(STF_WINDOWSSYSPATH)\config
    FilesWinspool       = $(STF_WINDOWSSYSPATH)\spool
    FilesPrnDriver      = $(STF_WINDOWSSYSPATH)\spool\drivers\$(!STF_PRNPLATFORM)
    FilesPrnProc        = $(STF_WINDOWSSYSPATH)\spool\prtprocs\$(!STF_PRNPLATFORM)



;
; FilesPrimary only covers ntldr.  For ntbootddd, a keyed section needs to
; be created.  Also this section is relevant only for x86.
;
[FilesPrimary]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

;
; FilesOsLoader only covers osloader.exe.  This is only relevant
;
[FilesOsLoader]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesWinnt]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesSystem32]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)
1 = 1, KRNL386.EXE, RENAME=$(NEWFILE)

[FilesSystem]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesDrivers]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesConfig]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesWinspool]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesPrnDriver]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)

[FilesPrnProc]
;    1 = 1, file1, RENAME=$(NEWFILE)
;    2 = 1, file2, RENAME=$(NEWFILE)


[ProcessorID]
    ProcessorID_I386  = I386
    ProcessorID_I486  = I486
    ProcessorID_I586  = I586
    ProcessorID_R4000 = R4000

[UiVars]
    STF_PLATFORMDET    = "" ? $(!LIBHANDLE) GetPlatform
    STF_CSDVER         = 2
    STF_BUILDVER       = 528

    STF_PRIMARY        = "C:"
    STF_NTDRIVE        = ""
    STF_WINDOWSPATH    = "" ? $(!LIBHANDLE) GetWindowsNtDir
    STF_WINDOWSSYSPATH = "" ? $(!LIBHANDLE) GetWindowsNtSysDir
    STF_CONTROLSET     = CurrentControlSet
    VolumeList         = {} ? $(!LIBHANDLE) GetHardDriveLetters
    VolumeFSList       = {} ? $(!LIBHANDLE) GetHardDriveFileSystems
    DisketteList       = {} ? $(!LIBHANDLE) GetFloppyDriveLetters
    AnyPrimaryFiles    = NO
    AnyWinntFiles      = NO

[NVRAMVars]
    SystemPartition = "" ? $(!LIBHANDLE) GetNVRAMVar SYSTEMPARTITION
    OsLoader        = "" ? $(!LIBHANDLE) GetNVRAMVar OSLOADER
    OsLoadPartition = "" ? $(!LIBHANDLE) GetNVRAMVar OSLOADPARTITION
    OsLoadFilename  = "" ? $(!LIBHANDLE) GetNVRAMVar OSLOADFILENAME

;
; INF LOGIC
;

[Shell Commands]

    set-title "Windows NT Setup"
    set-subst CR = "\r"
    set-subst LF = "\n"
    set STF_LANGUAGE = ENG
    read-syms Strings
    shell "subroutn.inf" PushBillboard STATUSDLG $(Billboard1)
    set BillboardPushed = TRUE

    set !LIBHANDLE      = ""
    set !PATCHLIBHANDLE = ""

    ;
    ; Initialize Library support for the inf
    ;

    install   LoadSetupLibrary

    ;
    ; find out the essential information about the installed hardware and
    ; software
    ;

    read-syms ProductType
    ifstr(i) $(!STF_PLATFORM) == I386
        set STF_PRNPLATFORM = "w32x86"
    else-ifstr(i) $(!STF_PLATFORM) == Mips
        set STF_PRNPLATFORM = "w32mips"
    else-ifstr(i) $(!STF_PLATFORM) == Alpha
        set STF_PRNPLATFORM = "w32alpha"
    endif

    read-syms UiVars
    detect    UiVars

    ;
    ; if the Platform is not the same as the one supported by this patch
    ; diskette, inform the user and quit
    ;
    ifstr(i) $(STF_PLATFORM) != $(STF_PLATFORMDET)
         ifstr(i) $(BillboardPushed) == TRUE
             shell "subroutn.inf" PopBillboard
             set BillboardPushed = FALSE
         endif
         shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "FATAL" $(String1)
         goto patchnotdone
    endif

    ;
    ; Check to make sure we have admin privileges, if not print fatal error
    ;

    shell "registry.inf" CheckSetupModify
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        ; DEBUG
        ;
        ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Failed to shell CheckSetupModify"
        ;
        ; DEBUG END
        ifstr(i) $(BillboardPushed) == TRUE
            shell "subroutn.inf" PopBillboard
            set BillboardPushed = FALSE
        endif

        Debug-Output "shelling CheckSetupModify failed"
        goto patchnotdone
    else-ifstr(i) $($R0) != STATUS_SUCCESSFUL
        ifstr(i) $(BillboardPushed) == TRUE
            shell "subroutn.inf" PopBillboard
            set BillboardPushed = FALSE
        endif
        shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) "FATAL" $(String4)
        goto patchnotdone
    endif


    ;
    ; Initialize the patch library support for the inf
    ;

    install   LoadPatchLibrary


    ;
    ; Get the build and patch version for the system.  If this is more than our patch
    ; version warn the user, allowing him to exit
    ;

    LibraryProcedure STATUS,$(!PATCHLIBHANDLE), CheckBuildVersion $(!STF_BUILDVER)
    ifstr(i) $(STATUS) == ERROR
        goto patchnotdone
    else-ifstr(i) $(STATUS) == NO
        shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) WARNING $(String8)
        ifstr(i) $($R1) == "OK"
            goto skip_patchvercheck
        else
            goto patchnotdone
        endif
    endif

    shell "" GetCSDVersion
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        ifstr(i) $(BillboardPushed) == TRUE
            shell "subroutn.inf" PopBillboard
            set BillboardPushed = FALSE
        endif
        Debug-Output "PATCH.INF: Shelling GetCSDVersion failed"
        goto patchnotdone
    endif

    ifstr(i) $($R0) != "STATUS_SUCCESSFUL"
        Debug-Output "PATCH.INF: GetCSDVersion failed to return a value"
    else
        ifint $($R1) > $(!STF_CSDVER)
            ifstr(i) $(BillboardPushed) == TRUE
                shell "subroutn.inf" PopBillboard
                set BillboardPushed = FALSE
            endif
            shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) WARNING $(String8)
            ifstr(i) $($R1) == "OK"
            else
                goto patchnotdone
            endif
        endif
    endif

skip_patchvercheck = +

    ;
    ; Get the NT DRIVE
    ;

    GetDriveInPath !STF_NTDRIVE $(!STF_WINDOWSSYSPATH)

    ;
    ; Find the hal and osloader destination on Mips and Alpha
    ;

    ifstr(i) $(!STF_PLATFORM) == I386
        set STF_HALDEST = $(!STF_WINDOWSSYSPATH)
        set STF_OSLDEST = C:\

    else

        read-syms NVRAMVars
        detect    NVRAMVars
        LibraryProcedure STATUS,$(!PATCHLIBHANDLE), GetOsLoaderDest         +
                                                         $(SystemPartition) +
                                                         $(OsLoader)        +
                                                         $(OsLoadPartition) +
                                                         $(OsLoadFilename)
        ifstr(i) $(STATUS) == ERROR
            goto patchnotdone
        else
            set STF_OSLDEST = $(STATUS)
            set STF_HALDEST = $(STATUS)
        endif
    endif

    ;
    ; Get the required information about keyed files
    ;

    set KeyedClassKeys  = ^(FileKeyedClasses, 0)
    set KeyedClassFiles = ^(FileKeyedClasses, 1)

    LibraryProcedure STATUS,$(!PATCHLIBHANDLE), GetFileTypes $(KeyedClassFiles)
    ifstr(i) $(STATUS) == ERROR
        goto patchnotdone
    else-ifstr(i) $(STATUS) == SETUPLOGNOTPRESENT
        shell "subroutn.inf" SetupMessage $(!STF_LANGUAGE) FATAL $(String11)
        goto patchnotdone
    else
        ForListDo $(KeyedClassKeys)
            set $($)Type = *($(STATUS), $(#))
        EndForListDo
    endif

    ;
    ; Warn the user about the patch process..
    ;

    ifstr(i) $(BillboardPushed) == TRUE
        shell "subroutn.inf" PopBillboard
        set BillboardPushed = FALSE
    endif

    shell "" QueryOkCancel $(String9)
    ifstr(i) $($R1) == "OK"
    else
        goto patchnotdone
    endif

    shell "subroutn.inf" PushBillboard STATUSDLG $(Billboard2)
    set BillboardPushed = TRUE

    ;
    ; Run through the directory list adding files to the copy list
    ;

    read-syms FileSections
    set FileSectionsList = ^(FileSections, 0)
    set MoveFileExList  = {}
    set FileCopiedList  = {}
    set NewFilePathList = {}

    set FileSource  = $(!STF_SRCDIR)

    ForListDo $(FileSectionsList)
        set FileSection = $($)
        set FileDest    = $($($))
        set FileList    = ^($(FileSection), 0)
        ForListDo $(FileList)
            set FileKey = $($)
            set File    = #($(FileSection), $(FileKey), 2)
            set FileDestFullPath = $(FileDest)\$(File)

            ;
            ; Check to see if file exists, if it is does not exist, it doesn't
            ; need to be copied over

            LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(FileDestFullPath)
            ifstr(i) $(STATUS) == YES


                ; DEBUG
                ;
                ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Examining to see if file opened excl: "$(FileDestFullPath)
                ;
                ; DEBUG END

                LibraryProcedure STATUS, $(!PATCHLIBHANDLE), IsFileOpenedExclusive $(FileDestFullPath)
                ifstr(i) $(STATUS) == ERROR
                    goto patchnotdone
                else
                    ifstr(i) $(STATUS) == "YES"
                        LibraryProcedure NEWFILE, $(!PATCHLIBHANDLE), GenerateTemporary $(FileDest)
                        ifstr(i) $(NEWFILE) == ERROR
                            goto patchnotdone
                        else
                            set FileComp = {$(FileDest)\$(NEWFILE), $(FileDestFullPath)}

                            ; DEBUG
                            ;
                            ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Adding to movefile ex list: "$(FileComp)
                            ;
                            ; DEBUG END

                            set MoveFileExList = >($(MoveFileExList), $(FileComp))
                        endif
                    else
                        set NEWFILE = $(File)
                    endif

                    ; DEBUG
                    ;
                    ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Copying File Section: "$(FileSection)" : Key: "$(FileKey)" Source: "$(FileSource)" Dest: "$(FileDest)" rename = "$(NEWFILE)
                    ;
                    ; DEBUG END

                    install Install-File
                    set FileCopiedList  = >($(FileCopiedList),  $(File))
                    set NewFilePathList = >($(NewFilePathList), $(FileDest)\$(NEWFILE))

                    ;
                    ; Check to see if the file installed was on the primary drive
                    ; or the winnt drive
                    ;
                    GetDriveInPath DestDrive $(FileDest)
                    ifstr(i) $(DestDrive) == $(!STF_NTDRIVE)
                        set AnyWinntFiles = YES
                    else-ifstr(i) $(DestDrive) == $(!STF_PRIMARY)
                        set AnyPrimaryFiles = YES
                    endif

                endif
            endif
        EndForListDo
    EndForListDO

    ;
    ; Add the keyed sections to the copy list
    ;

    read-syms FilesKeyedSections
    ForListDo $(KeyedClassKeys)
        set FileSection = Files$($)
        set FileDest    = $($(FileSection))
        set FileKey     = $($($)Type)

        set KeyedClassChoices = ^(Files$($), 0)
        ifcontains(i) $(FileKey) in $(KeyedClassChoices)
            set File             = #(FileKeyedClasses, $($), 1)
            set FileDestFullPath = $(FileDest)\$(File)
            ;
            ; Check to see if file exists, if it is does not exist, it doesn't
            ; need to be copied over

            LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(FileDestFullPath)
            ifstr(i) $(STATUS) == YES


                ; DEBUG
                ;
                ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Examining to see if file opened excl: "$(FileDestFullPath)
                ;
                ; DEBUG END

                LibraryProcedure STATUS, $(!PATCHLIBHANDLE), IsFileOpenedExclusive $(FileDestFullPath)
                ifstr(i) $(STATUS) == ERROR
                    goto patchnotdone
                else
                    ifstr(i) $(STATUS) == "YES"
                        LibraryProcedure NEWFILE, $(!PATCHLIBHANDLE), GenerateTemporary $(FileDest)
                        ifstr(i) $(NEWFILE) == ERROR
                            goto patchnotdone
                        else
                            set FileComp = {$(FileDest)\$(NEWFILE), $(FileDestFullPath)}

                            ; DEBUG
                            ;
                            ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Adding to movefile ex list: "$(FileComp)
                            ;
                            ; DEBUG END

                            set MoveFileExList = >($(MoveFileExList), $(FileComp))
                        endif
                    else
                        set NEWFILE = $(File)
                    endif

                    ; DEBUG
                    ;
                    ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "Copying File Section: "$(FileSection)" : Key: "$(FileKey)" Source: "$(FileSource)" Dest: "$(FileDest)" rename = "$(NEWFILE)
                    ;
                    ; DEBUG END

                    install Install-File
                    set FileCopiedList  = >($(FileCopiedList),  $(File))
                    set NewFilePathList = >($(NewFilePathList), $(FileDest)\$(NEWFILE))

                    ;
                    ; Check to see if the file installed was on the primary drive
                    ; or the winnt drive
                    ;
                    GetDriveInPath DestDrive $(FileDest)
                    ifstr(i) $(DestDrive) == $(!STF_NTDRIVE)
                        set AnyWinntFiles = YES
                    else-ifstr(i) $(DestDrive) == $(!STF_PRIMARY)
                        set AnyPrimaryFiles = YES
                    endif

                endif
            endif



        endif
    EndForListDo


    ifstr(i) $(BillboardPushed) == TRUE
        shell "subroutn.inf" PopBillboard
        set BillboardPushed = FALSE
    endif

    ;
    ; Do the copy
    ;

    read-syms ProgressCopy$(!STF_LANGUAGE)
    install   Install-DoCopy
    ifstr(i) $(STF_INSTALL_OUTCOME) == "STF_USERQUIT"
        goto patchnotdone
    else-ifstr(i) $(STF_INSTALL_OUTCOME) == "STF_FAILURE"
        goto patchnotdone
    endif

    ;
    ; set up for setacl conversion if any primary files were copied and the
    ; primary drive is NTFS or if any winnt files were copied and the winnt
    ; drive is NTFS
    ;
setaclsonfiles=+
    Debug-Output "SETUP.INF: Setting up for conversion and setacl if necessary."

    set Fs_C     = *($(VolumeFSList), ~($(VolumeList), $(!STF_PRIMARY)))
    set Fs_Winnt = *($(VolumeFSList), ~($(VolumeList), $(!STF_NTDRIVE)))

    shell "" SetAcls $(AnyPrimaryFiles) $(AnyWinntFiles) $(Fs_C) $(Fs_Winnt)

    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "SETUP.INF: Shelling SetAcls failed"
        goto patchnotdone
    else-ifstr(i) $($R0) != STATUS_SUCCESSFUL
        shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "NONFATAL" $(String5)
    endif

    ;
    ; Process MoveFileExList
    ;

    ForListDo $(MoveFileExList)
        ;
        set ExistingPath = *($($), 1)
        set NewPath      = *($($), 2)

        ; DEBUG
        ;
        ;shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "STATUS" "CopyFileOnReboot "$(ExistingPath)" to "$(NewPath)
        ;
        ; DEBUG END

        LibraryProcedure STATUS, $(!PATCHLIBHANDLE), CopyFileOnReboot $(ExistingPath) $(NewPath)
        ifstr(i) $(STATUS) == ERROR
            goto patchnotdone
        endif
    EndForListDo

    ;
    ; BUGBUG The repair disk update is not accurate so skip doing the
    ; repair stuff.
    ;

    goto patchdone

    ;
    ; patch the emergency repair diskette
    ;
    ;

    ; Make sure there is a floppy drive on the machine -- use the one with
    ; the lowest drive letter (usually A:).
    ;

    ifstr(i) $(DisketteList) == {}
        shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) NONFATAL $(String6)
        goto patchdone
    endif
    set RepairDiskette = *($(DisketteList),1)

    ;
    ; prompt for the emergency repair diskette
    ;

askrepair=+
    shell "" QueryOkCancel  $(String7)$(RepairDiskette)$(String10)
    ifstr(i) $($R1) == "OK"
    else
        goto patchdone
    endif

    ;
    ; check for the repair.inf file.  if not found tell the user and ask repair
    ; diskette again
    ;

    LibraryProcedure STATUS,$(!LIBHANDLE),CheckFileExistance $(RepairDiskette)\repair.inf
    ifstr(i) $(STATUS) == YES
    else
        goto askrepair
    endif

    shell "subroutn.inf" PushBillboard STATUSDLG $(Billboard3)
    set BillboardPushed = TRUE

    ;
    ; change the repair.inf on the diskette to fix the checksums
    ;

    LibraryProcedure STATUS, $(!PATCHLIBHANDLE), FixRepairInf $(RepairDiskette)\repair.inf $(FileCopiedList) $(NewFilePathList)
    ifstr(i) $(STATUS) == ERROR
        goto patchnotdone
    endif

patchdone =+
    ifstr(i) $(BillboardPushed) == TRUE
        shell "subroutn.inf" PopBillboard
        set BillboardPushed = FALSE
    endif

    ;
    ; store the patch version applied
    ;

    shell "" CSDVersionCreate $(!STF_CSDVER)
    read-syms SetupDoneDlg$(!STF_LANGUAGE)
    ui start "SetupDone"
    ifstr(i) $(DLGEVENT) == "CONTINUE"
        ui pop 1
        goto rebootend
    else
        ui pop 1
        goto finish1
    endif

patchnotdone =+
    ifstr(i) $(BillboardPushed) == TRUE
        shell "subroutn.inf" PopBillboard
        set BillboardPushed = FALSE
    endif

    shell "subroutn.inf" SetupMessage $(STF_LANGUAGE) "FATAL" $(String2)
    goto finish1

finish1 =+
    ;
    ; Free the library support
    ;

    install   FreeSetupLibrary

finish =+

    install   FreePatchLibrary
    exit

rebootend =+
    set Reboot = YES
    install   Install-Shutdown
    goto finish1
    exit

;-----------------------------------------------------------------------
;
; ROUTINE:     SetAcls
;
; DESCRIPTION: To set up registry for converting volumes and / or setting
;              acls if necessary
;
; INPUTS:      $($0): AnyPrimaryFiles
;              $($1): AnyWinntFiles
;              $($2): Fs_C
;              $($3): Fs_Winnt
;
; OUTPUTS:     $R0: STATUS: STATUS_SUCCESSFUL |
;                           STATUS_FAILED     |
;
;
;------------------------------------------------------------------------

[SetAcls]
    set Status = STATUS_FAILED
    set AnyPrimaryFiles = $($0)
    set AnyWinntFiles   = $($1)
    set Fs_C            = $($2)
    set Fs_Winnt        = $($3)

    set AutoLines = {}
    set SetAcl_C = NO
    set SetAcl_Winnt = NO

    ifstr(i) $(SetAcl_C) == NO
        ifstr(i) $(Fs_C) == NTFS
            set SetAcl_C =  YES
        endif
    endif

    ifstr(i) $(SetAcl_Winnt) == NO
        ifstr(i) $(Fs_Winnt) == NTFS
            set SetAcl_Winnt =  YES
        endif
    endif

    ifstr(i) $(AnyPrimaryFiles) != "YES"
        set SetAcl_C = NO
    endif

    ifstr(i) $(AnyWinntFiles) != "YES"
        set SetAcl_Winnt = NO
    endif


    ifstr(i) $(SetAcl_C) == YES
        ifstr(i) $(SetAcl_Winnt) == YES
            set AutoLines = >($(AutoLines), "setacl /a \DosDevices\"$(!STF_WINDOWSSYSPATH)"\winperms.txt \DosDevices\"$(!STF_NTDRIVE))
        else
            set AutoLines = >($(AutoLines), "setacl /c \DosDevices\"$(!STF_WINDOWSSYSPATH)"\winperms.txt")
        endif
    else-ifstr(i) $(SetAcl_Winnt) == YES
        set AutoLines = >($(AutoLines), "setacl /w \DosDevices\"$(!STF_WINDOWSSYSPATH)"\winperms.txt \DosDevices\"$(!STF_NTDRIVE))
    endif

    shell "registry.inf" AppendToBootExecute $(AutoLines)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        Debug-Output "SETUP.INF: Shelling AppendToBootExecute failed"
        goto finish_setacls
    endif

    ifstr(i) $($R0) != "STATUS_SUCCESSFUL"
        Debug-Output "SETUP.INF: AppendToBootExecute failed"
        goto finish_setacls
    endif

    set Status = STATUS_SUCCESSFUL
finish_setacls = +
    Return $(Status)



;-----------------------------------------------------------------------
; INSTALL HELPERS
;-----------------------------------------------------------------------

[LoadPatchLibrary]
    LoadLibrary "x" patchdll.dll !PATCHLIBHANDLE
    exit

[FreePatchLibrary]
    ifstr(i) $(!PATCHLIBHANDLE) != ""
        FreeLibrary $(!PATCHLIBHANDLE)
    endif
    exit

[LoadSetupLibrary]
    LoadLibrary "x" $(!STF_CWDDIR)setupdll.dll !LIBHANDLE
    exit

[FreeSetupLibrary]
    ifstr(i) $(!LIBHANDLE) != ""
        FreeLibrary $(!LIBHANDLE)
    endif
    exit

[Install-File]
    set STF_VITAL = ""
    AddSectionKeyFileToCopyList $(FileSection) $(FileKey) $(FileSource) $(FileDest)
    exit

[Install-DoCopy]
    CopyFilesInCopyList
    exit


[Install-Shutdown]
    ;
    LibraryProcedure STATUS,$(!LIBHANDLE),ShutdownSystem $(Reboot)
    exit

;-----------------------------------------------------------------------
; REGISTRY SUBROUTINES
;-----------------------------------------------------------------------

[RegistryConstants]

    MaskAllAccess          = 33554432
    NoTitle                = 0
    RegLastError           = $(!REG_ERROR_SUCCESS)

;-----------------------------------------------------------------------
; ROUTINE:      CSDVersionCreate
;
; DESCRIPTION:  Creates an entry for the WinNT software.
;
; INPUTS:       $0:  CSD Version #
;
; OUTPUTS:      $R0: Status: STATUS_SUCCESSFUL
;                            STATUS_FAILED
;
;------------------------------------------------------------------------

[CSDVersionCreate]

    set Status = STATUS_FAILED
    read-syms RegistryConstants

    ;
    ; Modify the software tree..

    ;
    ; Form the path up to the key
    ;

    set KeyPath   = { +
                     {SOFTWARE,       $(NoTitle), $(MaskAllAccess)}, +
                     {Microsoft,      $(NoTitle), $(MaskAllAccess)}, +
                     {"Windows NT",   $(NoTitle), $(MaskAllAccess)}, +
                     {CurrentVersion, $(NoTitle), $(MaskAllAccess)}  +
                    }

    ;
    ; Form the value info structures for the WinNT entry
    ;

    set KeyValues = { +
                     {CSDVersion, $(NoTitle), $(!REG_VT_DWORD), $($0) } +
                    }


    shell "registry.inf" CreateKey $(!REG_H_LOCAL) $(KeyPath) $(KeyValues)
    ifint $($ShellCode) != $(!SHELL_CODE_OK)
        goto endCSDVersionCreate
    endif
    ifstr(i) $($R0) != STATUS_SUCCESSFUL
        goto endCSDVersionCreate
    else
        CloseRegKey $($R1)
    endif

    set Status = STATUS_SUCCESSFUL
endCSDVersionCreate = +
    Return $(Status)




;-----------------------------------------------------------------------
; ROUTINE:      GetCSDVersion
;
; DESCRIPTION:  Reads the software entry to find out what the CSD Patch Version
;               is
;
; INPUTS:       $0:  None
;
; OUTPUTS:      $R0: Status: STATUS_SUCCESSFUL
;                            STATUS_FAILED
;
;               $R1: CSDVersion
;
;------------------------------------------------------------------------

[GetCSDVersion]

    set Status = STATUS_SUCCESSFUL
    read-syms RegistryConstants
    set CSDVersion = 0

    ;
    ; Open the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    ; key

    set KeyName = "Software\Microsoft\Windows NT\CurrentVersion"
    OpenRegKey $(!REG_H_LOCAL) "" $(KeyName) $(!REG_KEY_READ) KeyHandle
    ifint $(RegLastError) != $(!REG_ERROR_SUCCESS)
        Debug-Output "REGISTRY.INF: Couldn't open windows nt software key for read access"
        goto end_GetCSDVersion
    endif

    ;
    ; read the sourcepath entry
    ;

    GetRegValue $(KeyHandle) "CSDVersion" CSDVersionValue
    ifint $(RegLastError) != $(!REG_ERROR_SUCCESS)
        CloseRegKey $(KeyHandle)
        goto end_GetCSDVersion
    endif

    set CSDVersion =  *($(CSDVersionValue), 4)
    CloseRegKey $(KeyHandle)
end_GetCSDVersion = +
    Return $(Status) $(CSDVersion)

;-----------------------------------------------------------------------
; ROUTINE:      QueryOkCancel
;
; DESCRIPTION:  This routine lets the user query OK / Cancel giving OK as
;               default
;
; INPUTS:       $0:  MessageText.
;
; OUTPUTS:      $R0: STATUS:   STATUS_SUCCESSFUL |
;                              STATUS_NOLANGUAGE
;                              STATUS_FAILED
;
;               $R1: DLGEVENT: OK | CANCEL
;
;------------------------------------------------------------------------

[QueryOkCancel]

    set DlgText = $($0)
    read-syms QueryOKCancelDlg$(!STF_LANGUAGE)

    ui start "SetupMessage"
    ifstr(i) $(DLGEVENT) == "OK"
        set Status     = STATUS_SUCCESSFUL
        set UserAction = $(DLGEVENT)

    else-ifstr(i) $(DLGEVENT) == "CANCEL"
        set Status     = STATUS_SUCCESSFUL
        set UserAction = $(DLGEVENT)
    else
        set Status     = STATUS_FAILED
        set UserAction = "CANCEL"
    endif
    Return $(Status) $(UserAction)

[ProductType]
STF_PRODUCT  = Winnt
STF_PLATFORM = I386

;
; MEDIA AND FILE DESCRIPTIONS
;

[Source Media Descriptions]
    1  = "Windows NT 3.1 Update Disk #1"  , TAGFILE = disk1
    2  = "Windows NT 3.1 Update Disk #2"  , TAGFILE = disk2
    3  = "Windows NT 3.1 Update Disk #3"  , TAGFILE = disk3
    4  = "Windows NT 3.1 Update Disk #4"  , TAGFILE = disk4
    5  = "Windows NT 3.1 Update Disk #5"  , TAGFILE = disk5
    6  = "Windows NT 3.1 Update Disk #6"  , TAGFILE = disk6

[Strings]
    String1 = "This update disk cannot be used on this platform."
    String2 = "Setup failed to update the system."
    String3 = "Setup has successfully updated your system."
    String4 = "You do not have permission to update the system.  Please contact your system administrator."
    String5 = "Setup failed to setup your updated files for secure operation."
    String6 = "No floppy disk drive was found on your computer. "+
              "Setup cannot modify the Emergency Repair Disk."

    String7 =  "If you created an Emergency Repair Disk during the initial installation"+
               " of Windows NT, please insert it into Drive "

    String10 = " and click OK to update the repair disk.  If you cannot locate the repair"+
               " disk, select Cancel and Setup will complete the installation."

    String8 = "Setup has detected that the version of the system installed is "+
              "newer than the update you are applying to it.  The update can render "+
              "your system unstartable.  Press OK if you still wish to continue "+
              "or press Cancel to exit Setup."

    String9 = "Setup is going to update files on your system.  If you wish to "+
              "cancel the update process, please press Cancel or press OK to continue."

    String11 = "Setup couldn't find the setup.log file in your windows directory. "+
               "Setup cannot proceed to update your system.  Please copy the repair.inf "+
               "file from your Emergency Repair Disk to your windows directory under the "+
               "name setup.log and restart the update."

    Billboard1 = "Please wait..."
    Billboard2 = "Please wait while the files to be updated are determined..."
    Billboard3 = "Please wait while the Emergency Repair Disk is updated..."

[ProgressCopyENG]
    ProCaption   = "Windows NT Setup"
    ProCancel    = "Cancel"
    ProCancelMsg = "The Windows NT 3.1 files are not completely updated.  Are you sure you want "+
                   "to cancel copying files?"
    ProCancelCap = "Setup Message"
    ProText1     = "Copying:"
    ProText2     = "To:"


[SetupDoneDlgENG]
    Caption     = "Windows NT Setup"
    DlgText     = "Windows NT 3.1 has been updated."$(!LF)$(!LF)+
                  "Remove disks from the floppy disk drives and "+
                  "choose Restart Computer to run the updated system."
    Reboot      = "&Restart Computer"
    Windows     = "E&xit to Windows NT"
    DlgType     = "Info"
    DlgTemplate = "REBOOT"

[QueryOKCancelDlgENG]
    STF_MB_TITLE = "Setup Message"

    ;no translation needed after this

    DlgType      = "MessageBox"
    STF_MB_TEXT  = $(DlgText)
    STF_MB_TYPE  = 2
    STF_MB_ICON  = 4
    STF_MB_DEF   = 1
