Пример #1
0
 public FormSelectBINEntry(BINFile binfile, string current)
     :
     base(current)
 {
     myBIN = binfile;
     FindEntries();
 }
Пример #2
0
        private static IEnumerable <string> ProcessBINFile(BINFile bin)
        {
            List <string> strings = new List <string>();

            foreach (BINFileEntry entry in bin.Entries)
            {
                strings.AddRange(ProcessBINEntry(entry));
            }
            return(strings);
        }
Пример #3
0
        public static List <WadResult> GenerateWADStrings(WADFile wad, List <WadResult> wadResults)
        {
            List <string> strings = new List <string>();

            foreach (WADEntry entry in wad.Entries.Where(x => x.Type != EntryType.FileRedirection))
            {
                byte[]         entryContent = entry.GetContent(true);
                LeagueFileType fileType     = Utilities.GetLeagueFileExtensionType(entryContent);

                if (fileType == LeagueFileType.BIN)
                {
                    BINFile bin = null;
                    try
                    {
                        bin = new BINFile(new MemoryStream(entryContent));
                        strings.AddRange(ProcessBINLinkedFiles(bin.LinkedFiles));
                        strings.AddRange(ProcessBINFile(bin));
                    }
                    catch (Exception excp)
                    {
                        throw new Exception(TAG + "解析wad文件失败,创建BIN文件失败...|" + excp.Message);
                    }
                }
            }
            Dictionary <ulong, string> stringDictionary = new Dictionary <ulong, string>();

            strings = strings.Distinct().ToList();
            using (XXHash64 xxHash = XXHash64.Create())
            {
                foreach (string fetchedString in strings)
                {
                    if (!string.IsNullOrEmpty(fetchedString))
                    {
                        // 计算路径的哈希值
                        byte[] b       = Encoding.ASCII.GetBytes(fetchedString.ToLower());
                        byte[] hashVal = xxHash.ComputeHash(b);
                        ulong  hash    = BitConverter.ToUInt64(hashVal, 0);
                        string hex     = BitConverter.ToString(hashVal, 0);

                        if (!stringDictionary.ContainsKey(hash))
                        {
                            stringDictionary.Add(hash, fetchedString);
                            WadResult wadResult = new WadResult();
                            wadResult.hash = hash;
                            wadResult.hex  = hex;
                            wadResult.name = fetchedString;
                            //wadResult.type = Utilities.GetLeagueFileExtensionType(b);
                            wadResults.Add(wadResult);
                        }
                    }
                }
            }
            GC.Collect();
            return(wadResults);
        }
Пример #4
0
        public static Dictionary <ulong, string> Generate(Wad wad)
        {
            Dictionary <ulong, string> hashtable = new Dictionary <ulong, string>();
            List <string> strings = new List <string>();

            foreach (WadEntry entry in wad.Entries.Values.Where(x => x.Type != WadEntryType.FileRedirection))
            {
                using Stream entryStream = entry.GetDataHandle().GetDecompressedStream();
                LeagueFileType fileType = LeagueUtilities.GetExtensionType(entryStream);

                if (fileType == LeagueFileType.BIN)
                {
                    BINFile bin = null;
                    try
                    {
                        bin = new BINFile(entryStream);
                    }
                    catch (Exception)
                    {
                    }

                    if (bin != null)
                    {
                        strings.AddRange(ProcessBINDependencies(bin.Dependencies));
                        strings.AddRange(ProcessBINFile(bin));
                    }
                }
                else if (IsLegacyDirList(entry.XXHash))
                {
                    strings.AddRange(ProcessLegacyDirList(entry));
                }
            }

            using (XXHash64 xxHash = XXHash64.Create())
            {
                foreach (string fetchedString in strings.Distinct())
                {
                    if (!string.IsNullOrEmpty(fetchedString))
                    {
                        ulong hash = BitConverter.ToUInt64(xxHash.ComputeHash(Encoding.ASCII.GetBytes(fetchedString.ToLower())), 0);

                        if (!hashtable.ContainsKey(hash))
                        {
                            hashtable.Add(hash, fetchedString);
                        }
                    }
                }
            }

            return(hashtable);
        }
Пример #5
0
        public FormNewGameBINEntry(BINFile bin)
        {
            InitializeComponent();

            myBIN = bin;

            DefinitionType[] defTypes =
                FileDatabase.Instance.Definitions.GetDefinitions();

            foreach (DefinitionType defType in defTypes)
            {
                comboBoxDefs.Items.Add(defType.Name);
            }
        }
Пример #6
0
        public static TreeViewItem GenerateTreeView(BINFile bin, string binName)
        {
            TreeViewItem mainNode = new TreeViewItem()
            {
                Header = IOPath.GetFileName(binName)
            };

            foreach (BINEntry entry in bin.Entries)
            {
                mainNode.Items.Add(GenerateEntryNode(entry));
            }

            return(mainNode);
        }
Пример #7
0
        public void Build(BINFile bin, Progress progress)
        {
            myBIN = bin;

            progress.Begin(bin.EntryCount);

            for (int i = 0; i < bin.EntryCount; ++i)
            {
                AddEntry(bin.get_Entries(i));

                progress.Update();
            }

            progress.End();
        }
Пример #8
0
        public static void GenerateWADStrings(WADFile wad, Dictionary <ulong, string> stringDictionary)
        {
            List <string> strings = new List <string>();

            foreach (WADEntry entry in wad.Entries.Where(x => x.Type != EntryType.FileRedirection))
            {
                byte[]         entryContent = entry.GetContent(true);
                LeagueFileType fileType     = Utilities.GetLeagueFileExtensionType(entryContent);

                if (fileType == LeagueFileType.BIN)
                {
                    BINFile bin = null;
                    try
                    {
                        bin = new BINFile(new MemoryStream(entryContent));
                    }
                    catch (Exception excp)
                    {
                        Console.WriteLine(excp.Message);
                    }

                    if (bin != null)
                    {
                        strings.AddRange(ProcessBINLinkedFiles(bin.LinkedFiles));
                        strings = strings.Distinct().ToList();

                        strings.AddRange(ProcessBINFile(bin));
                    }
                }
            }

            using (XXHash64 xxHash = XXHash64.Create())
            {
                for (int i = 0; i < strings.Count; i++)
                {
                    string fetchedString = strings[i];
                    if (!string.IsNullOrEmpty(fetchedString))
                    {
                        ulong hash = BitConverter.ToUInt64(xxHash.ComputeHash(Encoding.ASCII.GetBytes(fetchedString.ToLower())), 0);

                        if (!stringDictionary.ContainsKey(hash))
                        {
                            stringDictionary.Add(hash, fetchedString);
                        }
                    }
                }
            }
        }
Пример #9
0
        protected override bool OnLoad(Progress progress)
        {
            try
            {
                NamesBINController c = GetNamesController();

                myBIN = new BINFile(c.Names);

                myBIN.Load(FileName, progress);
            }
            catch (Exception ex)
            {
                FormMain.Instance.ErrorMessage(ex.Message);
                return(false);
            }

            return(true);
        }
Пример #10
0
        private void FindModified(BINFile bin, Progress progress)
        {
            progress.Begin(bin.EntryCount);

            for (int i = 0; i < bin.EntryCount; ++i)
            {
                BINEntry entry = bin.get_Entries(i);

                if (entry.Modified)
                {
                    myObjects.Add(
                        FileDatabase.Instance.GetContentObject(entry));
                }

                progress.Update();
            }

            progress.End();
        }
Пример #11
0
        public static Dictionary <uint, object> Serialize(BINFile bin)
        {
            Dictionary <uint, object> serializedEntries = new Dictionary <uint, object>();

            if (_classMap == null)
            {
                RegisterClasses();
            }

            foreach (BINEntry entry in bin.Entries)
            {
                if (!_classMap.ContainsKey(entry.Class))
                {
                    continue;
                }
                else
                {
                    Type entryType = _classMap[entry.Class];
                    serializedEntries[entry.Property] = Serialize(entry.Values, entryType);
                }
            }

            return(serializedEntries);
        }
Пример #12
0
        public static TreeViewItem GenerateTreeView(BINFile bin, string binName)
        {
            TreeViewItem mainNode = new TreeViewItem()
            {
                Header = System.IO.Path.GetFileName(binName)
            };

            foreach (BINEntry entry in bin.Entries)
            {
                TreeViewItem entryNode = new TreeViewItem()
                {
                    Header = entry.GetPath() + " : " + BINGlobal.GetClass(entry.Class)
                };

                foreach (BINValue value in entry.Values)
                {
                    entryNode.Items.Add(GenerateValueNode(value));
                }

                mainNode.Items.Add(entryNode);
            }

            return(mainNode);
        }
Пример #13
0
        static void BINTest()
        {
            //BINFile bin = new BINFile("929042894B990D88.bin");
            BINFile bin = new BINFile("AAFA250508F27EEF.bin");
            Dictionary <uint, string> classNames = new Dictionary <uint, string>();
            Dictionary <uint, string> fieldNames = new Dictionary <uint, string>();

            List <string> classNamesRaw = File.ReadAllLines("hashes.bintypes.txt").ToList();

            foreach (string classNameRaw in classNamesRaw)
            {
                string className = classNameRaw.Split(' ')[1];
                classNames.Add(Cryptography.FNV32Hash(className), className);
            }

            List <string> fieldNamesRaw = File.ReadAllLines("hashes.binfields.txt").ToList();

            foreach (string fieldNameRaw in fieldNamesRaw)
            {
                string fieldName = fieldNameRaw.Split(' ')[1];
                fieldNames.Add(Cryptography.FNV32Hash(fieldName), fieldName);
            }

            BINGlobal.SetHashmap(new Dictionary <uint, string>(), classNames, fieldNames);

            List <string> paths = new List <string>();

            foreach (BINEntry entry in bin.Entries)
            {
                paths.AddRange(ProcessBINEntry(entry));
            }

            List <BINValue> values = new List <BINValue>();
            int             j2     = 0;

            foreach (string path in paths)
            {
                string entryPath = path.Substring(0, path.IndexOf('/'));
                string valuePath = path.Substring(path.IndexOf('/') + 1);

                if (j2 == 141)
                {
                }

                values.Add(bin[entryPath, valuePath]);

                j2++;
            }

            List <string> paths2 = new List <string>();
            int           j      = 0;

            foreach (BINValue value in values)
            {
                if (j == 247)
                {
                }

                paths2.Add(value.GetPath(false));

                j++;
            }

            for (int i = 0; i < paths.Count; i++)
            {
                if (paths[i] != paths2[i])
                {
                    //450496931/2257500010/164488258[0].2646858022/2010092456.3857869021/1759261366.3031705514
                    //450496931/2257500010/164488258[0].2646858022/2010092456.3857869021
                }
            }

            IEnumerable <string> ProcessBINEntry(BINEntry entry)
            {
                List <string> strings = new List <string>();

                foreach (BINValue value in entry.Values)
                {
                    strings.AddRange(ProcessBINValue(value));
                }

                return(strings);
            }

            IEnumerable <string> ProcessBINValue(BINValue value)
            {
                List <string> strings = new List <string>();

                if (value.Type == BINValueType.Optional)
                {
                    strings.AddRange(ProcessBINAdditionalData(value.Value as BINOptional));
                }
                else if (value.Type == BINValueType.Container)
                {
                    strings.AddRange(ProcessBINContainer(value.Value as BINContainer));
                }
                else if (value.Type == BINValueType.Embedded || value.Type == BINValueType.Structure)
                {
                    strings.AddRange(ProcessBINStructure(value.Value as BINStructure));
                }
                else if (value.Type == BINValueType.Map)
                {
                    strings.AddRange(ProcessBINMap(value.Value as BINMap));
                }
                else
                {
                    strings.Add(value.GetPath(false));
                }

                return(strings);
            }

            IEnumerable <string> ProcessBINAdditionalData(BINOptional additionalData)
            {
                List <string> strings = new List <string>();

                strings.AddRange(ProcessBINValue(additionalData.Value));

                return(strings);
            }

            IEnumerable <string> ProcessBINContainer(BINContainer container)
            {
                List <string> strings = new List <string>();

                foreach (BINValue value in container.Values)
                {
                    strings.AddRange(ProcessBINValue(value));
                }

                return(strings);
            }

            IEnumerable <string> ProcessBINStructure(BINStructure structure)
            {
                List <string> strings = new List <string>();

                foreach (BINValue value in structure.Values)
                {
                    strings.AddRange(ProcessBINValue(value));
                }

                return(strings);
            }

            IEnumerable <string> ProcessBINMap(BINMap map)
            {
                List <string> strings = new List <string>();

                foreach (KeyValuePair <BINValue, BINValue> valuePair in map.Values)
                {
                    strings.AddRange(ProcessBINValue(valuePair.Key));
                }

                return(strings);
            }
        }
Пример #14
0
        static void BINTest()
        {
            BINFile bin = new BINFile("D2E417608491E1C8.bin");

            bin.Write("test.bin");
        }
Пример #15
0
        static void BINTest()
        {
            BINFile bin = new BINFile("4E348110B14461B3.bin");

            bin.Write("test.bin");
        }
Пример #16
0
 public BINDumber(BINFile bin, string folder)
 {
     myBIN    = bin;
     myFolder = folder;
 }
Пример #17
0
        public static Dictionary <uint, object> LoadMapBIN(string fileLocation)
        {
            BINFile bin = new BINFile(fileLocation);

            return(BINSerializer.Serialize(bin));
        }
Пример #18
0
        public FormObjectBuilder()
        {
            InitializeComponent();

            myGameBin = ContentManager.Instance.Objects;
        }