public static UpdateHelperData FromByteArray(byte[] data)
        {
            UpdateHelperData uhData = new UpdateHelperData();

            using (MemoryStream ms = new MemoryStream(data))
            {
                byte bType = (byte)ms.ReadByte();

                //read until the end byte is detected
                while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF))
                {
                    switch (bType)
                    {
                    case 0x01:
                        uhData.Action = (UpdateAction)ReadFiles.ReadInt(ms);
                        break;

                    case 0x02:     // update step we're on
                        uhData.UpdateStep = (UpdateStep)ReadFiles.ReadInt(ms);
                        break;

                    case 0x80:
                        uhData.ExtraDataIsRTF.Add(true);
                        break;

                    case 0x03:     // extra data

                        uhData.ExtraData.Add(ReadFiles.ReadString(ms));

                        // keep the 'ExtraDataIsRTF' same length as ExtraData
                        if (uhData.ExtraDataIsRTF.Count != uhData.ExtraData.Count)
                        {
                            uhData.ExtraDataIsRTF.Add(false);
                        }

                        break;

                    case 0x04:
                        uhData.ProcessID = ReadFiles.ReadInt(ms);
                        break;

                    case 0x05:
                        uhData.Progress = ReadFiles.ReadInt(ms);
                        break;

                    case 0x06:
                        uhData.ResponseType = (Response)ReadFiles.ReadInt(ms);
                        break;

                    // 0x07, 0x08, and 0x09 used to be links data - obsolete

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

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

            return(uhData);
        }
Example #2
0
        //Open Pre-RC2  client files
        public void OpenObsoleteClientFile(string fileName)
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            }
            catch (Exception ex)
            {
                if (fs != null)
                {
                    fs.Close();
                }

                throw new ArgumentException("The client data file (client.wyc) failed to open.\n\nFull details:\n\n" + ex.Message);
            }


            // Read back the file identification data, if any
            if (!ReadFiles.IsHeaderValid(fs, "IUCDFV2"))
            {
                //free up the file so it can be deleted
                fs.Close();

                throw new ArgumentException("The client file does not have the correct identifier - this is usually caused by file corruption. \n\nA possible solution is to replace the following file by reinstalling:\n\n" + fileName);
            }

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

            while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
            {
                switch (bType)
                {
                case 0x01:     // Read Company Name
                    CompanyName = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x02:     // Product Name
                    ProductName = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x03:     // Read Installed Version
                    InstalledVersion = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x04:     // Add server file site
                    AddUniqueString(ReadFiles.ReadDeprecatedString(fs), ServerFileSites);
                    break;

                case 0x09:     // Add client server file site
                    AddUniqueString(ReadFiles.ReadDeprecatedString(fs), ClientServerSites);
                    break;

                case 0x11:     // Header image alignment
                    try
                    {
                        HeaderImageAlign = (ImageAlign)Enum.Parse(typeof(ImageAlign), ReadFiles.ReadDeprecatedString(fs));
                    }
                    catch { }
                    break;

                case 0x12:     // Header text indent
                    HeaderTextIndent = ReadFiles.ReadInt(fs);
                    break;

                case 0x13:     // Header text color
                    HeaderTextColorName = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x06:     // top Image
                    TopImage = ReadFiles.ReadImage(fs);
                    break;

                case 0x07:     // side Image
                    SideImage = ReadFiles.ReadImage(fs);
                    break;

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

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

            fs.Close();
        }
Example #3
0
        void LoadClientData(Stream ms, string updatePathVar, string customUrlArgs)
        {
            ms.Position = 0;

            // Read back the file identification data, if any
            if (!ReadFiles.IsHeaderValid(ms, "IUCDFV2"))
            {
                //free up the file so it can be deleted
                ms.Close();

                throw new Exception("The client file does not have the correct identifier - this is usually caused by file corruption.");
            }

#if !CLIENT_READER
            LanguageCulture lastLanguage = null;
#endif
            string serverSite;
            byte   bType = (byte)ms.ReadByte();
            while (!ReadFiles.ReachedEndByte(ms, bType, 0xFF))
            {
                switch (bType)
                {
                case 0x01:    //Read Company Name
                    CompanyName = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 0x02:    //Product Name
                    ProductName = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 0x0A:     // GUID
                    m_GUID = ReadFiles.ReadString(ms);
                    break;

                case 0x03:    //Read Installed Version
                    InstalledVersion = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 0x04:    //Add server file site

                    serverSite = ReadFiles.ReadDeprecatedString(ms);

                    if (updatePathVar != null)
                    {
                        serverSite = serverSite.Replace("%updatepath%", updatePathVar);
                    }

                    if (customUrlArgs != null)
                    {
                        serverSite = serverSite.Replace("%urlargs%", customUrlArgs);
                    }

                    AddUniqueString(serverSite, ServerFileSites);


                    break;

                case 0x09:    //Add client server file site

                    serverSite = ReadFiles.ReadDeprecatedString(ms);

                    if (updatePathVar != null)
                    {
                        serverSite = serverSite.Replace("%updatepath%", updatePathVar);
                    }

                    if (customUrlArgs != null)
                    {
                        serverSite = serverSite.Replace("%urlargs%", customUrlArgs);
                    }

                    AddUniqueString(serverSite, ClientServerSites);
                    break;

                case 0x11:    //Header image alignment
                    try
                    {
                        HeaderImageAlign = (ImageAlign)Enum.Parse(typeof(ImageAlign), ReadFiles.ReadDeprecatedString(ms));
                    }
                    catch { }
                    break;

                case 0x12:    //Header text indent
                    HeaderTextIndent = ReadFiles.ReadInt(ms);
                    break;

                case 0x13:    //Header text color
                    HeaderTextColorName = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 0x14:     //header image filename
                    TopImageFilename = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 0x15:     //side image filename
                    SideImageFilename = ReadFiles.ReadDeprecatedString(ms);
                    break;

#if CLIENT_READER
                case 0x18:     // language culture
                    Languages.Add(ReadFiles.ReadDeprecatedString(ms));
                    break;
#else
                case 0x18:     // language culture

                    lastLanguage = new LanguageCulture(ReadFiles.ReadDeprecatedString(ms));

                    Languages.Add(lastLanguage.Culture, lastLanguage);
                    break;

                case 0x16:     //language filename

                    if (lastLanguage != null)
                    {
                        lastLanguage.Filename = ReadFiles.ReadDeprecatedString(ms);
                    }
                    else
                    {
                        Languages.Add(string.Empty, new LanguageCulture(null)
                        {
                            Filename = ReadFiles.ReadDeprecatedString(ms)
                        });
                    }

                    break;
#endif
                case 0x17:     //hide the header divider
                    HideHeaderDivider = ReadFiles.ReadBool(ms);
                    break;

                case 0x19:
                    CloseOnSuccess = ReadFiles.ReadBool(ms);
                    break;

                case 0x1A:
                    CustomWyUpdateTitle = ReadFiles.ReadString(ms);
                    break;

                case 0x1B:
                    PublicSignKey = ReadFiles.ReadString(ms);
                    break;

                case 0x1C:
                    UpdatePassword = ReadFiles.ReadString(ms);
                    break;

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

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

            ms.Close();
        }
Example #4
0
        public static ServerFile Load(string fileName, string updatePathVar, string customUrlArgs)
        {
            ServerFile serv = new ServerFile();

            byte[] fileIDBytes = new byte[7];

            Stream fs = null;

            try
            {
                fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);

                // Read the first 7 bytes of identification data
                fs.Read(fileIDBytes, 0, 7);
            }
            catch (Exception)
            {
                if (fs != null)
                {
                    fs.Close();
                }

                throw;
            }

            // check for compression (see if PKZip header is there)
            if (fileIDBytes[0] == 0x50 && fileIDBytes[1] == 0x4B && fileIDBytes[2] == 0x03 && fileIDBytes[3] == 0x04)
            {
                // decompress the "actual" server file to memory
                fs.Close();

                using (ZipFile zip = ZipFile.Read(fileName))
                {
                    fs = new MemoryStream();

                    zip["0"].Extract(fs);
                }


                fs.Position = 0;

                // Read the first 7 bytes of identification data
                fs.Read(fileIDBytes, 0, 7);
            }


            // see if the file is in the correct server format

            string fileID = Encoding.UTF8.GetString(fileIDBytes);

            if (fileID != "IUSDFV2")
            {
                //free up the file so it can be deleted
                fs.Close();
                throw new Exception("The downloaded server file does not have the correct identifier. This is usually caused by file corruption.");
            }



            serv.VersionChoices.Add(new VersionChoice());

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

            while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF))
            {
                switch (bType)
                {
                case 0x01:    //Read New Version
                    serv.NewVersion = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x07:     //Min Client version
                    serv.MinClientVersion = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x0B:     //The version to update from
                    if (serv.VersionChoices.Count > 1 || serv.VersionChoices[0].Version != null)
                    {
                        serv.VersionChoices.Add(new VersionChoice());
                    }

                    serv.VersionChoices[serv.VersionChoices.Count - 1].Version = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x03:    //Add update file site

                    string updateSite = ReadFiles.ReadDeprecatedString(fs);

                    if (updatePathVar != null)
                    {
                        updateSite = updateSite.Replace("%updatepath%", updatePathVar);
                    }

                    updateSite = updateSite.Replace("%urlargs%", customUrlArgs ?? string.Empty);

                    ClientFile.AddUniqueString(updateSite, serv.VersionChoices[serv.VersionChoices.Count - 1].FileSites);

                    break;

                case 0x80:     //the changes text is in RTF format
                    serv.VersionChoices[serv.VersionChoices.Count - 1].RTFChanges = true;
                    break;

                case 0x04:    //Read Changes
                    serv.VersionChoices[serv.VersionChoices.Count - 1].Changes = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x09:    //update's filesize
                    serv.VersionChoices[serv.VersionChoices.Count - 1].FileSize = ReadFiles.ReadLong(fs);
                    break;

                case 0x08:    //update's Adler32 checksum
                    serv.VersionChoices[serv.VersionChoices.Count - 1].Adler32 = ReadFiles.ReadLong(fs);
                    break;

                case 0x14:     // signed SHA1 hash
                    serv.VersionChoices[serv.VersionChoices.Count - 1].SignedSHA1Hash = ReadFiles.ReadByteArray(fs);
                    break;

                case 0x0A:     //Installing to which directories?
                    serv.VersionChoices[serv.VersionChoices.Count - 1].InstallingTo = (InstallingTo)ReadFiles.ReadInt(fs);
                    break;

                case 0x8E:     //the RegChanges (built with wyBuid 2.6.11.4 and below)
                    if (RegChange.ReadFromStream(fs).RegBasekey != RegBasekeys.HKEY_CURRENT_USER)
                    {
                        serv.VersionChoices[serv.VersionChoices.Count - 1].InstallingTo |= InstallingTo.NonCurrentUserReg;
                    }
                    break;

                case 0x20:
                    serv.NoUpdateToLatestLinkText = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x21:
                    serv.NoUpdateToLatestLinkURL = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x0F:
                    //skip over the integer (4 bytes) length
                    //this is just used to trick pre-1.0 Final versions
                    //of wyUpdate to correctly read the server file correctly
                    fs.Position += 4;
                    break;

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

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

            fs.Close();

            return(serv);
        }
Example #5
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);
            }
        }
Example #6
0
        public static RegChange ReadFromStream(Stream fs)
        {
            RegChange regChange = new RegChange();
            bool      flag      = false;
            byte      b         = (byte)fs.ReadByte();

            while (!ReadFiles.ReachedEndByte(fs, b, 158))
            {
                switch (b)
                {
                case 1:
                    regChange.RegOperation = (RegOperations)ReadFiles.ReadInt(fs);
                    break;

                case 2:
                    regChange.RegBasekey = (RegBasekeys)ReadFiles.ReadInt(fs);
                    break;

                case 3:
                    regChange.RegValueKind = (RegistryValueKind)ReadFiles.ReadInt(fs);
                    break;

                case 4:
                    regChange.SubKey = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 5:
                    regChange.ValueName = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 6:
                    if (regChange.RegValueKind != RegistryValueKind.ExpandString && regChange.RegValueKind != RegistryValueKind.String)
                    {
                        regChange.RegValueKind = RegistryValueKind.String;
                    }
                    regChange.ValueData = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 128:
                    flag = true;
                    break;

                case 129:
                    regChange.Is32BitKey = true;
                    break;

                case 7:
                    switch (regChange.RegValueKind)
                    {
                    case RegistryValueKind.Binary:
                        if (flag)
                        {
                            regChange.ValueData = ReadFiles.ReadDeprecatedString(fs);
                        }
                        else
                        {
                            regChange.ValueData = ReadFiles.ReadByteArray(fs);
                        }
                        break;

                    case RegistryValueKind.DWord:
                        regChange.ValueData = ReadFiles.ReadInt(fs);
                        break;

                    case RegistryValueKind.QWord:
                        regChange.ValueData = ReadFiles.ReadLong(fs);
                        break;

                    case RegistryValueKind.String:
                    case RegistryValueKind.ExpandString:
                    case RegistryValueKind.MultiString:
                        regChange.ValueData = ReadFiles.ReadDeprecatedString(fs);
                        break;
                    }
                    break;

                default:
                    ReadFiles.SkipField(fs, b);
                    break;
                }
                b = (byte)fs.ReadByte();
            }
            return(regChange);
        }
Example #7
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);
        }
Example #8
0
        public void OpenObsoleteClientFile(string fileName)
        {
            FileStream fileStream = null;

            try
            {
                fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            }
            catch (Exception ex)
            {
                fileStream?.Close();
                throw new ArgumentException("The client data file (client.wyc) failed to open.\n\nFull details:\n\n" + ex.Message);
            }
            if (!ReadFiles.IsHeaderValid(fileStream, "IUCDFV2"))
            {
                fileStream.Close();
                throw new ArgumentException("The client file does not have the correct identifier - this is usually caused by file corruption. \n\nA possible solution is to replace the following file by reinstalling:\n\n" + fileName);
            }
            byte b = (byte)fileStream.ReadByte();

            while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue))
            {
                switch (b)
                {
                case 1:
                    CompanyName = ReadFiles.ReadDeprecatedString(fileStream);
                    break;

                case 2:
                    ProductName = ReadFiles.ReadDeprecatedString(fileStream);
                    break;

                case 3:
                    InstalledVersion = ReadFiles.ReadDeprecatedString(fileStream);
                    break;

                case 4:
                    AddUniqueString(ReadFiles.ReadDeprecatedString(fileStream), ServerFileSites);
                    break;

                case 9:
                    AddUniqueString(ReadFiles.ReadDeprecatedString(fileStream), ClientServerSites);
                    break;

                case 17:
                    try
                    {
                        HeaderImageAlign = (ImageAlign)Enum.Parse(typeof(ImageAlign), ReadFiles.ReadDeprecatedString(fileStream));
                    }
                    catch
                    {
                    }
                    break;

                case 18:
                    HeaderTextIndent = ReadFiles.ReadInt(fileStream);
                    break;

                case 19:
                    HeaderTextColorName = ReadFiles.ReadDeprecatedString(fileStream);
                    break;

                case 6:
                    TopImage = ReadFiles.ReadImage(fileStream);
                    break;

                case 7:
                    SideImage = ReadFiles.ReadImage(fileStream);
                    break;

                default:
                    ReadFiles.SkipField(fileStream, b);
                    break;
                }
                b = (byte)fileStream.ReadByte();
            }
            fileStream.Close();
        }
Example #9
0
        private void LoadClientData(Stream ms, string updatePathVar, string customUrlArgs)
        {
            ms.Position = 0L;
            if (!ReadFiles.IsHeaderValid(ms, "IUCDFV2"))
            {
                ms.Close();
                throw new Exception("The client file does not have the correct identifier - this is usually caused by file corruption.");
            }
            LanguageCulture languageCulture = null;
            byte            b = (byte)ms.ReadByte();

            while (!ReadFiles.ReachedEndByte(ms, b, byte.MaxValue))
            {
                switch (b)
                {
                case 1:
                    CompanyName = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 2:
                    ProductName = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 10:
                    m_GUID = ReadFiles.ReadString(ms);
                    break;

                case 3:
                    InstalledVersion = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 4:
                {
                    string text = ReadFiles.ReadDeprecatedString(ms);
                    if (updatePathVar != null)
                    {
                        text = text.Replace("%updatepath%", updatePathVar);
                    }
                    if (customUrlArgs != null)
                    {
                        text = text.Replace("%urlargs%", customUrlArgs);
                    }
                    AddUniqueString(text, ServerFileSites);
                    break;
                }

                case 9:
                {
                    string text = ReadFiles.ReadDeprecatedString(ms);
                    if (updatePathVar != null)
                    {
                        text = text.Replace("%updatepath%", updatePathVar);
                    }
                    if (customUrlArgs != null)
                    {
                        text = text.Replace("%urlargs%", customUrlArgs);
                    }
                    AddUniqueString(text, ClientServerSites);
                    break;
                }

                case 17:
                    try
                    {
                        HeaderImageAlign = (ImageAlign)Enum.Parse(typeof(ImageAlign), ReadFiles.ReadDeprecatedString(ms));
                    }
                    catch
                    {
                    }
                    break;

                case 18:
                    HeaderTextIndent = ReadFiles.ReadInt(ms);
                    break;

                case 19:
                    HeaderTextColorName = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 20:
                    TopImageFilename = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 21:
                    SideImageFilename = ReadFiles.ReadDeprecatedString(ms);
                    break;

                case 24:
                    languageCulture = new LanguageCulture(ReadFiles.ReadDeprecatedString(ms));
                    Languages.Add(languageCulture.Culture, languageCulture);
                    break;

                case 22:
                    if (languageCulture != null)
                    {
                        languageCulture.Filename = ReadFiles.ReadDeprecatedString(ms);
                    }
                    else
                    {
                        Languages.Add(string.Empty, new LanguageCulture(null)
                        {
                            Filename = ReadFiles.ReadDeprecatedString(ms)
                        });
                    }
                    break;

                case 23:
                    HideHeaderDivider = ReadFiles.ReadBool(ms);
                    break;

                case 25:
                    CloseOnSuccess = ReadFiles.ReadBool(ms);
                    break;

                case 26:
                    CustomWyUpdateTitle = ReadFiles.ReadString(ms);
                    break;

                case 27:
                    PublicSignKey = ReadFiles.ReadString(ms);
                    break;

                case 28:
                    UpdatePassword = ReadFiles.ReadString(ms);
                    break;

                default:
                    ReadFiles.SkipField(ms, b);
                    break;
                }
                b = (byte)ms.ReadByte();
            }
            ms.Close();
        }
Example #10
0
        public static RegChange ReadFromStream(Stream fs)
        {
            RegChange tempReg = new RegChange();

            bool isBinaryString = false;

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

            //read until the end byte is detected
            while (!ReadFiles.ReachedEndByte(fs, bType, 0x9E))
            {
                switch (bType)
                {
                case 0x01:    //RegOperation
                    tempReg.RegOperation = (RegOperations)ReadFiles.ReadInt(fs);
                    break;

                case 0x02:    //load basekey
                    tempReg.RegBasekey = (RegBasekeys)ReadFiles.ReadInt(fs);
                    break;

                case 0x03:    //load valuekind
                    tempReg.RegValueKind = (RegistryValueKind)ReadFiles.ReadInt(fs);
                    break;

                case 0x04:    //subkey
                    tempReg.SubKey = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x05:    //value name
                    tempReg.ValueName = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x06:     //Depreciated: Use 0x07. All 0x06 will be converted to a string "ValueKind"
                    if (tempReg.RegValueKind != RegistryValueKind.ExpandString &&
                        tempReg.RegValueKind != RegistryValueKind.String)
                    {
                        //Read in the entry,if it's
                        tempReg.RegValueKind = RegistryValueKind.String;
                    }

                    tempReg.ValueData = ReadFiles.ReadDeprecatedString(fs);
                    break;

                case 0x80:
                    isBinaryString = true;
                    break;

                case 0x81:
                    tempReg.Is32BitKey = true;
                    break;

                case 0x07:     //Value data
                    switch (tempReg.RegValueKind)
                    {
                    case RegistryValueKind.Binary:

                        if (isBinaryString)
                        {
                            tempReg.ValueData = ReadFiles.ReadDeprecatedString(fs);
                        }
                        else
                        {
                            tempReg.ValueData = ReadFiles.ReadByteArray(fs);
                        }

                        break;

                    case RegistryValueKind.DWord:
                        tempReg.ValueData = ReadFiles.ReadInt(fs);
                        break;

                    case RegistryValueKind.QWord:
                        tempReg.ValueData = ReadFiles.ReadLong(fs);
                        break;

                    case RegistryValueKind.ExpandString:
                    case RegistryValueKind.MultiString:
                    case RegistryValueKind.String:
                        tempReg.ValueData = ReadFiles.ReadDeprecatedString(fs);
                        break;
                    }
                    break;

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

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

            return(tempReg);
        }