Exemple #1
0
        PazScheme QueryEncryption(string arc_name, uint signature)
        {
            PazScheme scheme = null;

            if (!KnownSchemes.TryGetValue(signature, out scheme) && KnownTitles.Count > 1)
            {
                var title = FormatCatalog.Instance.LookupGame(arc_name);
                scheme = GetScheme(title);
                if (null == scheme)
                {
                    if (!arc_name.HasExtension(".paz"))
                    {
                        return(null);
                    }
                    var options = Query <PazOptions> (arcStrings.ArcEncryptedNotice);
                    scheme = options.Scheme;
                }
            }
            arc_name = Path.GetFileNameWithoutExtension(arc_name).ToLowerInvariant();
            if (null == scheme || !scheme.ArcKeys.ContainsKey(arc_name))
            {
                throw new UnknownEncryptionScheme();
            }
            return(scheme);
        }
Exemple #2
0
        YpfScheme QueryEncryptionScheme(string arc_name, uint version)
        {
            var title = FormatCatalog.Instance.LookupGame(arc_name);

            if (string.IsNullOrEmpty(title))
            {
                title = FormatCatalog.Instance.LookupGame(arc_name, @"..\*.exe");
            }
            YpfScheme scheme;

            if (!string.IsNullOrEmpty(title) && KnownSchemes.TryGetValue(title, out scheme))
            {
                return(scheme);
            }
            var options = Query <YpfOptions> (arcStrings.YPFNotice);

            if (!KnownSchemes.TryGetValue(options.Scheme, out scheme) || null == scheme)
            {
                scheme = new YpfScheme {
                    SwapTable       = GuessSwapTable(version),
                    GuessKey        = true,
                    ExtraHeaderSize = version >= 0x1D9 ? 4u : version == 0xDE ? 8u : 0u,
                }
            }
            ;
            return(scheme);
        }
Exemple #3
0
        public EncryptionScheme GetScheme(string title)
        {
            EncryptionScheme scheme;

            if (string.IsNullOrEmpty(title) || !KnownSchemes.TryGetValue(title, out scheme))
            {
                scheme = DefaultScheme;
            }
            return(scheme);
        }
Exemple #4
0
        public static ICrypt GetScheme(string scheme)
        {
            ICrypt algorithm;

            if (string.IsNullOrEmpty(scheme) || !KnownSchemes.TryGetValue(scheme, out algorithm))
            {
                algorithm = NoCryptAlgorithm;
            }
            return(algorithm);
        }
Exemple #5
0
        public static AImageScheme GetScheme(string title)
        {
            AImageScheme scheme = null;

            if (string.IsNullOrEmpty(title) || !KnownSchemes.TryGetValue(title, out scheme))
            {
                return(null);
            }
            return(scheme);
        }
Exemple #6
0
        public static IScriptEncryption GetEncryption(string scheme)
        {
            IScriptEncryption enc;

            if (string.IsNullOrEmpty(scheme) || !KnownSchemes.TryGetValue(scheme, out enc))
            {
                return(null);
            }
            return(enc);
        }
Exemple #7
0
        public static string GetPassPhrase(string title)
        {
            string pass;

            if (string.IsNullOrEmpty(title) || !KnownSchemes.TryGetValue(title, out pass))
            {
                return("");
            }
            return(pass);
        }
Exemple #8
0
        protected IDictionary <string, byte[]> QueryScheme(ArcView file)
        {
            var title = FormatCatalog.Instance.LookupGame(file.Name, @"..\*.sb");

            if (string.IsNullOrEmpty(title) || !KnownSchemes.ContainsKey(title))
            {
                return(null);
            }
            return(KnownSchemes[title]);
        }
Exemple #9
0
        internal AImageScheme QueryScheme(string arc_name)
        {
            var title = FormatCatalog.Instance.LookupGame(arc_name);

            if (!string.IsNullOrEmpty(title) && KnownSchemes.ContainsKey(title))
            {
                return(KnownSchemes[title]);
            }
            var options = Query <BellOptions> (arcStrings.ArcEncryptedNotice);

            return(options.Scheme);
        }
Exemple #10
0
        uint?QueryEncryptionInfo(string arc_name)
        {
            var title = FormatCatalog.Instance.LookupGame(arc_name);

            if (!string.IsNullOrEmpty(title) && KnownSchemes.ContainsKey(title))
            {
                return(KnownSchemes[title].Key);
            }
            var options = Query <IntOptions> (arcStrings.INTNotice);

            return(options.EncryptionInfo.GetKey());
        }
Exemple #11
0
        IScriptEncryption QueryEncryption(string arc_name)
        {
            var title = FormatCatalog.Instance.LookupGame(arc_name);

            if (!string.IsNullOrEmpty(title) && KnownSchemes.ContainsKey(title))
            {
                return(KnownSchemes[title]);
            }
            var options = Query <MedOptions> (arcStrings.ArcEncryptedNotice);

            return(options.Encryption);
        }
Exemple #12
0
        public override ResourceOptions GetDefaultOptions()
        {
            IEntryEncryption enc = null;

            if (!string.IsNullOrEmpty(Settings.Default.EAGLSEncryption))
            {
                KnownSchemes.TryGetValue(Settings.Default.EAGLSEncryption, out enc);
            }
            return(new EaglsOptions {
                Encryption = enc
            });
        }
Exemple #13
0
        public override ResourceOptions GetDefaultOptions()
        {
            string    title  = Properties.Settings.Default.TacticsArcTitle;
            ArcScheme scheme = null;

            if (!KnownSchemes.TryGetValue(title, out scheme) && !string.IsNullOrEmpty(Properties.Settings.Default.TacticsArcPassword))
            {
                scheme = new ArcScheme(Properties.Settings.Default.TacticsArcPassword);
            }
            return(new TacticsOptions {
                Scheme = scheme
            });
        }
Exemple #14
0
        internal ArcFile GetArchive(ArcView file, List <Entry> dir)
        {
            if (0 == dir.Count)
            {
                return(null);
            }
            string         arc_id = file.View.ReadString(0, 5);
            ScrambleScheme scheme;

            if (!KnownSchemes.TryGetValue(arc_id, out scheme))
            {
                scheme = DefaultScheme;
            }
            return(new MkArchive(file, this, dir, scheme));
        }
Exemple #15
0
        ICrypt GuessCryptAlgorithm(ArcView file)
        {
            var title = FormatCatalog.Instance.LookupGame(file.Name);

            if (string.IsNullOrEmpty(title))
            {
                return(null);
            }
            ICrypt algorithm;

            if (!KnownSchemes.TryGetValue(title, out algorithm) && NoCryptTitles.Contains(title))
            {
                algorithm = NoCryptAlgorithm;
            }
            return(algorithm);
        }
Exemple #16
0
        internal Scheme QueryScheme(string arc_name)
        {
            var title = FormatCatalog.Instance.LookupGame(arc_name);

            if (!string.IsNullOrEmpty(title) && KnownSchemes.ContainsKey(title))
            {
                return(KnownSchemes[title]);
            }
            var    options = Query <ArcDatOptions> (arcStrings.ArcEncryptedNotice);
            Scheme scheme;

            if (string.IsNullOrEmpty(options.Scheme) || !KnownSchemes.TryGetValue(options.Scheme, out scheme))
            {
                return(null);
            }
            return(scheme);
        }
Exemple #17
0
 byte[] GuessSwapTable(uint version)
 {
     if (0x1F4 == version)
     {
         YpfScheme scheme;
         if (KnownSchemes.TryGetValue("Unionism Quartet", out scheme))
         {
             return(scheme.SwapTable);
         }
     }
     if (version < 0x100)
     {
         return(SwapTable04);
     }
     else if (version >= 0x12c && version < 0x196)
     {
         return(SwapTable10);
     }
     else
     {
         return(SwapTable00);
     }
 }
Exemple #18
0
        public override ArcFile TryOpen(ArcView file)
        {
            if (!file.View.AsciiEqual(4, "0\0"))
            {
                return(null);
            }
            int count = file.View.ReadInt32(0x12);

            if (!IsSaneCount(count))
            {
                return(null);
            }

            string arc_id       = file.View.ReadString(0, 5);
            uint   base_offset  = file.View.ReadUInt16(8);
            uint   index_offset = file.View.ReadUInt32(0xE);

            if (index_offset >= file.MaxOffset)
            {
                return(null);
            }
            uint index_size = file.View.ReadUInt32(0xA);

            if (index_size > file.View.Reserve(index_offset, index_size))
            {
                return(null);
            }

            uint current_offset = index_offset;
            var  dir            = new List <Entry> (count);

            for (int i = 0; i < 512; ++i)
            {
                uint entry_offset = index_offset + file.View.ReadUInt32(current_offset);
                int  n            = file.View.ReadUInt16(current_offset + 4);
                if (n > 0)
                {
                    for (int j = 0; j < n; ++j)
                    {
                        uint offset      = file.View.ReadUInt32(entry_offset) + base_offset;
                        uint size        = file.View.ReadUInt32(entry_offset + 4);
                        uint name_length = file.View.ReadByte(entry_offset + 8);
                        if (0 == name_length)
                        {
                            return(null);
                        }
                        var name = file.View.ReadString(entry_offset + 9, name_length);
                        entry_offset += 9 + name_length;

                        var entry = FormatCatalog.Instance.Create <Entry> (name);
                        entry.Offset = offset;
                        entry.Size   = size;
                        if (!entry.CheckPlacement(index_offset))
                        {
                            return(null);
                        }
                        dir.Add(entry);
                    }
                }
                else if (-1 == file.View.ReadInt32(entry_offset))
                {
                    break;
                }
                current_offset += 6;
            }
            if (0 == dir.Count)
            {
                return(null);
            }
            ScrambleScheme scheme;

            if (!KnownSchemes.TryGetValue(arc_id, out scheme))
            {
                scheme = DefaultScheme;
            }
            return(new MkArchive(file, this, dir, scheme));
        }