public FormSelectBINEntry(BINFile binfile, string current) : base(current) { myBIN = binfile; FindEntries(); }
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); }
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); }
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); }
public FormNewGameBINEntry(BINFile bin) { InitializeComponent(); myBIN = bin; DefinitionType[] defTypes = FileDatabase.Instance.Definitions.GetDefinitions(); foreach (DefinitionType defType in defTypes) { comboBoxDefs.Items.Add(defType.Name); } }
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); }
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(); }
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); } } } } }
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); }
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(); }
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); }
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); }
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); } }
static void BINTest() { BINFile bin = new BINFile("D2E417608491E1C8.bin"); bin.Write("test.bin"); }
static void BINTest() { BINFile bin = new BINFile("4E348110B14461B3.bin"); bin.Write("test.bin"); }
public BINDumber(BINFile bin, string folder) { myBIN = bin; myFolder = folder; }
public static Dictionary <uint, object> LoadMapBIN(string fileLocation) { BINFile bin = new BINFile(fileLocation); return(BINSerializer.Serialize(bin)); }
public FormObjectBuilder() { InitializeComponent(); myGameBin = ContentManager.Instance.Objects; }