예제 #1
0
        public static void ReadRollbackRegistry(string fileName, List <RegChange> rollbackRegistry)
        {
            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                // Read back the file identification data, if any
                if (!ReadFiles.IsHeaderValid(fs, "IURURV1"))
                {
                    throw new Exception("Identifier incorrect");
                }

                byte bType = (byte)fs.ReadByte();
                while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:     //num of registry changes
                        rollbackRegistry.Capacity = ReadFiles.ReadInt(fs);
                        break;

                    case 0x8E:     //add RegChange
                        rollbackRegistry.Add(RegChange.ReadFromStream(fs));
                        break;

                    default:
                        ReadFiles.SkipField(fs, bType);
                        break;
                    }

                    bType = (byte)fs.ReadByte();
                }
            }
        }
예제 #2
0
        public static void ReadRollbackCOM(string fileName, List <UninstallFileInfo> rollbackList)
        {
            using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                if (!ReadFiles.IsHeaderValid(fileStream, "IURUCV1"))
                {
                    throw new Exception("Identifier incorrect");
                }
                UninstallFileInfo uninstallFileInfo = new UninstallFileInfo();
                byte b = (byte)fileStream.ReadByte();
                while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue))
                {
                    switch (b)
                    {
                    case 1:
                        uninstallFileInfo.Path = ReadFiles.ReadString(fileStream);
                        break;

                    case 2:
                        uninstallFileInfo.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fileStream);
                        break;

                    case 155:
                        rollbackList.Add(uninstallFileInfo);
                        uninstallFileInfo = new UninstallFileInfo();
                        break;

                    default:
                        ReadFiles.SkipField(fileStream, b);
                        break;
                    }
                    b = (byte)fileStream.ReadByte();
                }
            }
        }
예제 #3
0
        public static void ReadRollbackRegistry(string fileName, List <RegChange> rollbackRegistry)
        {
            using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                if (!ReadFiles.IsHeaderValid(fileStream, "IURURV1"))
                {
                    throw new Exception("Identifier incorrect");
                }
                byte b = (byte)fileStream.ReadByte();
                while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue))
                {
                    switch (b)
                    {
                    case 1:
                        rollbackRegistry.Capacity = ReadFiles.ReadInt(fileStream);
                        break;

                    case 142:
                        rollbackRegistry.Add(RegChange.ReadFromStream(fileStream));
                        break;

                    default:
                        ReadFiles.SkipField(fileStream, b);
                        break;
                    }
                    b = (byte)fileStream.ReadByte();
                }
            }
        }
예제 #4
0
        void Load(string filename)
        {
            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                if (!ReadFiles.IsHeaderValid(fs, "AUIF"))
                {
                    //free up the file so it can be deleted
                    fs.Close();
                    throw new Exception("Auto update state file ID is wrong.");
                }

                byte bType = (byte)fs.ReadByte();
                while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:     // Date last checked for update
                        LastCheckedForUpdate = ReadFiles.ReadDateTime(fs);
                        break;

                    case 0x02:     // update step on
                        UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fs);
                        break;

                    case 0x03:
                        AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fs);
                        break;

                    case 0x04:     // update succeeded
                        UpdateVersion = ReadFiles.ReadString(fs);
                        break;

                    case 0x05:
                        ChangesInLatestVersion = ReadFiles.ReadString(fs);
                        break;

                    case 0x06:
                        ChangesIsRTF = ReadFiles.ReadBool(fs);
                        break;

                    case 0x07:     // update failed
                        ErrorTitle = ReadFiles.ReadString(fs);
                        break;

                    case 0x08:
                        ErrorMessage = ReadFiles.ReadString(fs);
                        break;

                    default:
                        ReadFiles.SkipField(fs, bType);
                        break;
                    }

                    bType = (byte)fs.ReadByte();
                }
            }
        }
예제 #5
0
        private void Load(string filename)
        {
            using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                if (!ReadFiles.IsHeaderValid(fileStream, "AUIF"))
                {
                    fileStream.Close();
                    throw new Exception("Auto update state file ID is wrong.");
                }
                byte b = (byte)fileStream.ReadByte();
                while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue))
                {
                    switch (b)
                    {
                    case 1:
                        LastCheckedForUpdate = ReadFiles.ReadDateTime(fileStream);
                        break;

                    case 2:
                        UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fileStream);
                        break;

                    case 3:
                        AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fileStream);
                        break;

                    case 4:
                        UpdateVersion = ReadFiles.ReadString(fileStream);
                        break;

                    case 5:
                        ChangesInLatestVersion = ReadFiles.ReadString(fileStream);
                        break;

                    case 6:
                        ChangesIsRTF = ReadFiles.ReadBool(fileStream);
                        break;

                    case 7:
                        ErrorTitle = ReadFiles.ReadString(fileStream);
                        break;

                    case 8:
                        ErrorMessage = ReadFiles.ReadString(fileStream);
                        break;

                    default:
                        ReadFiles.SkipField(fileStream, b);
                        break;
                    }
                    b = (byte)fileStream.ReadByte();
                }
            }
        }
예제 #6
0
        public static UninstallFileInfo Read(Stream fs)
        {
            UninstallFileInfo tempUFI = new UninstallFileInfo();

            //read in the fileinfo

            byte bType = (byte)fs.ReadByte();

            while (!ReadFiles.ReachedEndByte(fs, bType, 0x9A)) //if end byte is detected, bail out
            {
                switch (bType)
                {
                case 0x01:     //file path
                    tempUFI.Path = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x02:     //delete the file?
                    tempUFI.DeleteFile = ReadFiles.ReadBool(fs);
                    break;

                case 0x03:     //un-NGEN the file?
                    tempUFI.UnNGENFile = ReadFiles.ReadBool(fs);
                    break;

                case 0x04:
                    tempUFI.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fs);
                    break;

                case 0x05:
                    tempUFI.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fs);
                    break;

                case 0x06:
                    tempUFI.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs);
                    break;

                default:
                    ReadFiles.SkipField(fs, bType);
                    break;
                }

                bType = (byte)fs.ReadByte();
            }

            return(tempUFI);
        }
예제 #7
0
        public static UninstallFileInfo Read(Stream fs)
        {
            UninstallFileInfo uninstallFileInfo = new UninstallFileInfo();
            byte b = (byte)fs.ReadByte();

            while (!ReadFiles.ReachedEndByte(fs, b, 154))
            {
                switch (b)
                {
                case 1:
                    uninstallFileInfo.Path = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 2:
                    uninstallFileInfo.DeleteFile = ReadFiles.ReadBool(fs);
                    break;

                case 3:
                    uninstallFileInfo.UnNGENFile = ReadFiles.ReadBool(fs);
                    break;

                case 4:
                    uninstallFileInfo.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fs);
                    break;

                case 5:
                    uninstallFileInfo.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fs);
                    break;

                case 6:
                    uninstallFileInfo.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs);
                    break;

                default:
                    ReadFiles.SkipField(fs, b);
                    break;
                }
                b = (byte)fs.ReadByte();
            }
            return(uninstallFileInfo);
        }
예제 #8
0
        public static void ReadRollbackCOM(string fileName, List <UninstallFileInfo> rollbackList)
        {
            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {
                // Read back the file identification data, if any
                if (!ReadFiles.IsHeaderValid(fs, "IURUCV1"))
                {
                    throw new Exception("Identifier incorrect");
                }

                UninstallFileInfo tempUpdateFile = new UninstallFileInfo();

                byte bType = (byte)fs.ReadByte();
                while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:
                        tempUpdateFile.Path = ReadFiles.ReadString(fs);
                        break;

                    case 0x02:
                        tempUpdateFile.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs);
                        break;

                    case 0x9B:    //end of file
                        rollbackList.Add(tempUpdateFile);
                        tempUpdateFile = new UninstallFileInfo();
                        break;

                    default:
                        ReadFiles.SkipField(fs, bType);
                        break;
                    }

                    bType = (byte)fs.ReadByte();
                }
            }
        }
        void LoadAutoUpdateData()
        {
            autoUpdateStateFile = Path.Combine(tempDirectory, "autoupdate");

            using (FileStream fs = new FileStream(autoUpdateStateFile, FileMode.Open, FileAccess.Read))
            {
                if (!ReadFiles.IsHeaderValid(fs, "IUAUFV1"))
                {
                    throw new Exception("Auto update state file ID is wrong.");
                }

                byte bType = (byte)fs.ReadByte();
                while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:

                        startStep = (UpdateStepOn)ReadFiles.ReadInt(fs);

                        break;

                    case 0x02:     // file to execute
                        updateHelper.FileOrServiceToExecuteAfterUpdate = ReadFiles.ReadString(fs);
                        break;

                    case 0x03:     // autoupdate ID
                        updateHelper.AutoUpdateID = ReadFiles.ReadString(fs);
                        break;

                    case 0x0C:
                        updateHelper.ExecutionArguments = ReadFiles.ReadString(fs);
                        break;

                    case 0x80:
                        updateHelper.IsAService = true;
                        break;

                    case 0x04:     // Server data file location
                        serverFileLoc = ReadFiles.ReadString(fs);

                        if (!File.Exists(serverFileLoc))
                        {
                            serverFileLoc = null;
                        }

                        break;

                    case 0x05:     // Client's server file location (self update server file)
                        clientSFLoc = ReadFiles.ReadString(fs);

                        if (!File.Exists(clientSFLoc))
                        {
                            clientSFLoc = null;
                        }
                        break;

                    case 0x06:     // Temp directory
                        oldAUTempFolder = ReadFiles.ReadString(fs);
                        break;

                    case 0x0B:
                        tempDirectory = ReadFiles.ReadString(fs);
                        break;

                    case 0x07:     // update filename
                        updateFilename = ReadFiles.ReadString(fs);
                        break;

                    case 0x08:
                        SelfUpdateState = (SelfUpdateState)ReadFiles.ReadInt(fs);
                        break;

                    case 0x09:
                        if (SelfUpdateState == SelfUpdateState.Downloaded)
                        {
                            updateFilename = ReadFiles.ReadString(fs);
                        }
                        else
                        {
                            newSelfLocation = ReadFiles.ReadString(fs);
                        }

                        break;

                    case 0x0A:
                        oldSelfLocation = ReadFiles.ReadString(fs);
                        break;

                    case 0x0D:     // load the self update file
                        LoadSelfUpdateData(ReadFiles.ReadString(fs));
                        break;

                    default:
                        ReadFiles.SkipField(fs, bType);
                        break;
                    }

                    bType = (byte)fs.ReadByte();
                }
            }

            // if the server file doesn't exist we need to download a new one
            if (serverFileLoc == null)
            {
                startStep = UpdateStepOn.Checking;
            }
            else
            {
                // load the server file
                LoadServerFile(true);

                // if frameOn != Frame.Checking - it means we're either up-to-date OR an error occurred.
                // We shouldn't under any circumstance StartNewSelfAndClose. Just remove temp files & exit.
                if (frameOn != Frame.Checking)
                {
                    // neither OnClosed nor OnClosing will be called because
                    // the form is being disposed in the constructor.

                    // Thus we need to cleanup the temp directory now.
                    RemoveTempDirectory();
                    return;
                }

                if (SelfUpdateState == SelfUpdateState.Extracted && !IsNewSelf)
                {
                    // launch new wyUpdate
                    StartNewSelfAndClose();
                }
                else if (SelfUpdateState == SelfUpdateState.WillUpdate || SelfUpdateState == SelfUpdateState.Downloaded)
                {
                    LoadClientServerFile();
                }
            }
        }
예제 #10
0
        void Load(string filename)
        {
#if !CLIENT
            // Disable filesystem redirection on x64 (mostly for Windows Services)
            if (Is32BitProcessOn64BitProcessor())
            {
                EnableWow64FSRedirection(false);
            }

            try
            {
#endif
            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                if (!ReadFiles.IsHeaderValid(fs, "AUIF"))
                {
                    //free up the file so it can be deleted
                    fs.Close();
                    throw new Exception("Auto update state file ID is wrong.");
                }

                byte bType = (byte)fs.ReadByte();
                while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:         // Date last checked for update
                        LastCheckedForUpdate = ReadFiles.ReadDateTime(fs);
                        break;

                    case 0x02:         // update step on
                        UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fs);
                        break;

                    case 0x03:
                        AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fs);
                        break;

                    case 0x04:         // update succeeded
                        UpdateVersion = ReadFiles.ReadString(fs);
                        break;

                    case 0x05:
                        ChangesInLatestVersion = ReadFiles.ReadString(fs);
                        break;

                    case 0x06:
                        ChangesIsRTF = ReadFiles.ReadBool(fs);
                        break;

                    case 0x07:         // update failed
                        ErrorTitle = ReadFiles.ReadString(fs);
                        break;

                    case 0x08:
                        ErrorMessage = ReadFiles.ReadString(fs);
                        break;

                    default:
                        ReadFiles.SkipField(fs, bType);
                        break;
                    }

                    bType = (byte)fs.ReadByte();
                }
            }
#if !CLIENT
        }

        finally
        {
            // Re-enable filesystem redirection on x64
            if (Is32BitProcessOn64BitProcessor())
            {
                EnableWow64FSRedirection(true);
            }
        }
#endif
        }