Пример #1
0
        public static UpdateDetails Load(string fileName)   
#endif
        {
            UpdateDetails updtDetails = new UpdateDetails();

            try
            {
#if CLIENT
                using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
#endif
                {
                    // Read back the file identification data, if any
                    if (!ReadFiles.IsHeaderValid(fs, "IUUDFV2"))
                        throw new ArgumentException("Incorrect file identifier.");

                    UpdateFile tempUpdateFile = new UpdateFile();
                    int lastStartServiceArgOn = 0;

                    byte bType = (byte)fs.ReadByte();
                    while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                    {
                        switch (bType)
                        {
                            case 0x20://num reg changes
                                updtDetails.RegistryModifications = new List<RegChange>(ReadFiles.ReadInt(fs));
                                break;
                            case 0x21://num file infos
                                updtDetails.UpdateFiles = new List<UpdateFile>(ReadFiles.ReadInt(fs));
                                break;
                            case 0x8E:
                                updtDetails.RegistryModifications.Add(RegChange.ReadFromStream(fs));
                                break;
                            case 0x30:
                                updtDetails.PreviousCommonDesktopShortcuts.Add(ReadFiles.ReadDeprecatedString(fs));
                                break;
                            case 0x31:
                                updtDetails.PreviousCommonSMenuShortcuts.Add(ReadFiles.ReadDeprecatedString(fs));
                                break;
                            case 0x36:
                                updtDetails.PreviousCUserDesktopShortcuts.Add(ReadFiles.ReadString(fs));
                                break;
                            case 0x37:
                                updtDetails.PreviousCUserSMenuShortcuts.Add(ReadFiles.ReadString(fs));
                                break;
                            case 0x32: //service to stop
                                updtDetails.ServicesToStop.Add(ReadFiles.ReadString(fs));
                                break;
                            case 0x33: //service to start
                                updtDetails.ServicesToStart.Add(new StartService(ReadFiles.ReadString(fs)));
                                break;
                            case 0x34: // number of start arguments for the last service
                                updtDetails.ServicesToStart[updtDetails.ServicesToStart.Count - 1].Arguments =
                                    new string[ReadFiles.ReadInt(fs)];
                                lastStartServiceArgOn = 0;
                                break;
                            case 0x35:
                                updtDetails.ServicesToStart[updtDetails.ServicesToStart.Count - 1].Arguments[
                                    lastStartServiceArgOn] = ReadFiles.ReadString(fs);
                                lastStartServiceArgOn++;
                                break;
                            case 0x40:
                                tempUpdateFile.RelativePath = ReadFiles.ReadDeprecatedString(fs);
                                break;
                            case 0x41:
                                tempUpdateFile.Execute = ReadFiles.ReadBool(fs);
                                break;
                            case 0x42:
                                tempUpdateFile.ExBeforeUpdate = ReadFiles.ReadBool(fs);
                                break;
                            case 0x43:
                                tempUpdateFile.CommandLineArgs = ReadFiles.ReadDeprecatedString(fs);
                                break;
                            case 0x44:
                                tempUpdateFile.IsNETAssembly = ReadFiles.ReadBool(fs);
                                break;
                            case 0x45:
                                tempUpdateFile.WaitForExecution = ReadFiles.ReadBool(fs);
                                break;
                            case 0x8F:
                                tempUpdateFile.RollbackOnNonZeroRet = true;
                                break;
                            case 0x4D:
                                if (tempUpdateFile.RetExceptions == null)
                                    tempUpdateFile.RetExceptions = new List<int>();

                                tempUpdateFile.RetExceptions.Add(ReadFiles.ReadInt(fs));
                                break;
                            case 0x46:
                                tempUpdateFile.DeleteFile = ReadFiles.ReadBool(fs);
                                break;
                            case 0x47:
                                tempUpdateFile.DeltaPatchRelativePath = ReadFiles.ReadDeprecatedString(fs);
                                break;
                            case 0x48:
                                tempUpdateFile.NewFileAdler32 = ReadFiles.ReadLong(fs);
                                break;
                            case 0x49:
                                tempUpdateFile.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fs);
                                break;
                            case 0x4A:
                                tempUpdateFile.ProcessWindowStyle = (System.Diagnostics.ProcessWindowStyle)ReadFiles.ReadInt(fs);
                                break;
                            case 0x4E:
                                tempUpdateFile.ElevationType = (ElevationType)ReadFiles.ReadInt(fs);
                                break;
                            case 0x4B:
                                tempUpdateFile.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fs);
                                break;
                            case 0x4C:
                                tempUpdateFile.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fs);
                                break;
                            case 0x9B://end of file
                                updtDetails.UpdateFiles.Add(tempUpdateFile);
                                tempUpdateFile = new UpdateFile();
                                break;
                            case 0x8D:
                                updtDetails.ShortcutInfos.Add(ShortcutInfo.LoadFromStream(fs));
                                break;
                            case 0x60:
                                updtDetails.FoldersToDelete.Add(ReadFiles.ReadDeprecatedString(fs));
                                break;
                            default:
                                ReadFiles.SkipField(fs, bType);
                                break;
                        }

                        bType = (byte)fs.ReadByte();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("The update details file failed to open.\n\nFull details: " + ex.Message);
            }

            return updtDetails;
        }
Пример #2
0
        public static UpdateDetails Load(string fileName)
        {
            UpdateDetails updateDetails = new UpdateDetails();

            try
            {
                using (FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                {
                    if (!ReadFiles.IsHeaderValid(fileStream, "IUUDFV2"))
                    {
                        throw new ArgumentException("Incorrect file identifier.");
                    }
                    UpdateFile updateFile = new UpdateFile();
                    int        num        = 0;
                    byte       b          = (byte)fileStream.ReadByte();
                    while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue))
                    {
                        switch (b)
                        {
                        case 32:
                            updateDetails.RegistryModifications = new List <RegChange>(ReadFiles.ReadInt(fileStream));
                            break;

                        case 33:
                            updateDetails.UpdateFiles = new List <UpdateFile>(ReadFiles.ReadInt(fileStream));
                            break;

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

                        case 48:
                            updateDetails.PreviousCommonDesktopShortcuts.Add(ReadFiles.ReadDeprecatedString(fileStream));
                            break;

                        case 49:
                            updateDetails.PreviousCommonSMenuShortcuts.Add(ReadFiles.ReadDeprecatedString(fileStream));
                            break;

                        case 54:
                            updateDetails.PreviousCUserDesktopShortcuts.Add(ReadFiles.ReadString(fileStream));
                            break;

                        case 55:
                            updateDetails.PreviousCUserSMenuShortcuts.Add(ReadFiles.ReadString(fileStream));
                            break;

                        case 50:
                            updateDetails.ServicesToStop.Add(ReadFiles.ReadString(fileStream));
                            break;

                        case 51:
                            updateDetails.ServicesToStart.Add(new StartService(ReadFiles.ReadString(fileStream)));
                            break;

                        case 52:
                            updateDetails.ServicesToStart[updateDetails.ServicesToStart.Count - 1].Arguments = new string[ReadFiles.ReadInt(fileStream)];
                            num = 0;
                            break;

                        case 53:
                            updateDetails.ServicesToStart[updateDetails.ServicesToStart.Count - 1].Arguments[num] = ReadFiles.ReadString(fileStream);
                            num++;
                            break;

                        case 64:
                            updateFile.RelativePath = ReadFiles.ReadDeprecatedString(fileStream);
                            break;

                        case 65:
                            updateFile.Execute = ReadFiles.ReadBool(fileStream);
                            break;

                        case 66:
                            updateFile.ExBeforeUpdate = ReadFiles.ReadBool(fileStream);
                            break;

                        case 67:
                            updateFile.CommandLineArgs = ReadFiles.ReadDeprecatedString(fileStream);
                            break;

                        case 68:
                            updateFile.IsNETAssembly = ReadFiles.ReadBool(fileStream);
                            break;

                        case 69:
                            updateFile.WaitForExecution = ReadFiles.ReadBool(fileStream);
                            break;

                        case 143:
                            updateFile.RollbackOnNonZeroRet = true;
                            break;

                        case 77:
                            if (updateFile.RetExceptions == null)
                            {
                                updateFile.RetExceptions = new List <int>();
                            }
                            updateFile.RetExceptions.Add(ReadFiles.ReadInt(fileStream));
                            break;

                        case 70:
                            updateFile.DeleteFile = ReadFiles.ReadBool(fileStream);
                            break;

                        case 71:
                            updateFile.DeltaPatchRelativePath = ReadFiles.ReadDeprecatedString(fileStream);
                            break;

                        case 72:
                            updateFile.NewFileAdler32 = ReadFiles.ReadLong(fileStream);
                            break;

                        case 73:
                            updateFile.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fileStream);
                            break;

                        case 74:
                            updateFile.ProcessWindowStyle = (ProcessWindowStyle)ReadFiles.ReadInt(fileStream);
                            break;

                        case 78:
                            updateFile.ElevationType = (ElevationType)ReadFiles.ReadInt(fileStream);
                            break;

                        case 75:
                            updateFile.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fileStream);
                            break;

                        case 76:
                            updateFile.RegisterCOMDll = (COMRegistration)ReadFiles.ReadInt(fileStream);
                            break;

                        case 155:
                            updateDetails.UpdateFiles.Add(updateFile);
                            updateFile = new UpdateFile();
                            break;

                        case 141:
                            updateDetails.ShortcutInfos.Add(ShortcutInfo.LoadFromStream(fileStream));
                            break;

                        case 96:
                            updateDetails.FoldersToDelete.Add(ReadFiles.ReadDeprecatedString(fileStream));
                            break;

                        default:
                            ReadFiles.SkipField(fileStream, b);
                            break;
                        }
                        b = (byte)fileStream.ReadByte();
                    }
                    return(updateDetails);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("The update details file failed to open.\n\nFull details: " + ex.Message);
            }
        }
Пример #3
0
        public static UpdateDetails Load(string fileName)
#endif
        {
            UpdateDetails updtDetails = new UpdateDetails();

            try
            {
#if CLIENT
                using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
#endif
                {
                    // Read back the file identification data, if any
                    if (!ReadFiles.IsHeaderValid(fs, "IUUDFV2"))
                    {
                        throw new ArgumentException("Incorrect file identifier.");
                    }

                    UpdateFile tempUpdateFile        = new UpdateFile();
                    int        lastStartServiceArgOn = 0;

                    byte bType = (byte)fs.ReadByte();
                    while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
                    {
                        switch (bType)
                        {
                        case 0x20:    //num reg changes
                            updtDetails.RegistryModifications = new List <RegChange>(ReadFiles.ReadInt(fs));
                            break;

                        case 0x21:    //num file infos
                            updtDetails.UpdateFiles = new List <UpdateFile>(ReadFiles.ReadInt(fs));
                            break;

                        case 0x8E:
                            updtDetails.RegistryModifications.Add(RegChange.ReadFromStream(fs));
                            break;

                        case 0x30:
                            updtDetails.PreviousCommonDesktopShortcuts.Add(ReadFiles.ReadDeprecatedString(fs));
                            break;

                        case 0x31:
                            updtDetails.PreviousCommonSMenuShortcuts.Add(ReadFiles.ReadDeprecatedString(fs));
                            break;

                        case 0x36:
                            updtDetails.PreviousCUserDesktopShortcuts.Add(ReadFiles.ReadString(fs));
                            break;

                        case 0x37:
                            updtDetails.PreviousCUserSMenuShortcuts.Add(ReadFiles.ReadString(fs));
                            break;

                        case 0x32:     //service to stop
                            updtDetails.ServicesToStop.Add(ReadFiles.ReadString(fs));
                            break;

                        case 0x33:     //service to start
                            updtDetails.ServicesToStart.Add(new StartService(ReadFiles.ReadString(fs)));
                            break;

                        case 0x34:     // number of start arguments for the last service
                            updtDetails.ServicesToStart[updtDetails.ServicesToStart.Count - 1].Arguments =
                                new string[ReadFiles.ReadInt(fs)];
                            lastStartServiceArgOn = 0;
                            break;

                        case 0x35:
                            updtDetails.ServicesToStart[updtDetails.ServicesToStart.Count - 1].Arguments[
                                lastStartServiceArgOn] = ReadFiles.ReadString(fs);
                            lastStartServiceArgOn++;
                            break;

                        case 0x40:
                            tempUpdateFile.RelativePath = ReadFiles.ReadDeprecatedString(fs);
                            break;

                        case 0x41:
                            tempUpdateFile.Execute = ReadFiles.ReadBool(fs);
                            break;

                        case 0x42:
                            tempUpdateFile.ExBeforeUpdate = ReadFiles.ReadBool(fs);
                            break;

                        case 0x43:
                            tempUpdateFile.CommandLineArgs = ReadFiles.ReadDeprecatedString(fs);
                            break;

                        case 0x44:
                            tempUpdateFile.IsNETAssembly = ReadFiles.ReadBool(fs);
                            break;

                        case 0x45:
                            tempUpdateFile.WaitForExecution = ReadFiles.ReadBool(fs);
                            break;

                        case 0x8F:
                            tempUpdateFile.RollbackOnNonZeroRet = true;
                            break;

                        case 0x4D:
                            if (tempUpdateFile.RetExceptions == null)
                            {
                                tempUpdateFile.RetExceptions = new List <int>();
                            }

                            tempUpdateFile.RetExceptions.Add(ReadFiles.ReadInt(fs));
                            break;

                        case 0x46:
                            tempUpdateFile.DeleteFile = ReadFiles.ReadBool(fs);
                            break;

                        case 0x47:
                            tempUpdateFile.DeltaPatchRelativePath = ReadFiles.ReadDeprecatedString(fs);
                            break;

                        case 0x48:
                            tempUpdateFile.NewFileAdler32 = ReadFiles.ReadLong(fs);
                            break;

                        case 0x49:
                            tempUpdateFile.CPUVersion = (CPUVersion)ReadFiles.ReadInt(fs);
                            break;

                        case 0x4A:
                            tempUpdateFile.ProcessWindowStyle = (System.Diagnostics.ProcessWindowStyle)ReadFiles.ReadInt(fs);
                            break;

                        case 0x4E:
                            tempUpdateFile.ElevationType = (ElevationType)ReadFiles.ReadInt(fs);
                            break;

                        case 0x4B:
                            tempUpdateFile.FrameworkVersion = (FrameworkVersion)ReadFiles.ReadInt(fs);
                            break;

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

                        case 0x9B:    //end of file
                            updtDetails.UpdateFiles.Add(tempUpdateFile);
                            tempUpdateFile = new UpdateFile();
                            break;

                        case 0x8D:
                            updtDetails.ShortcutInfos.Add(ShortcutInfo.LoadFromStream(fs));
                            break;

                        case 0x60:
                            updtDetails.FoldersToDelete.Add(ReadFiles.ReadDeprecatedString(fs));
                            break;

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

                        bType = (byte)fs.ReadByte();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("The update details file failed to open.\n\nFull details: " + ex.Message);
            }

            return(updtDetails);
        }