public MainWindow() { InitializeComponent(); Dictionary <uint, string> classNames = hashlist("hashes.bintypes.txt"); Dictionary <uint, string> fieldNames = hashlist("hashes.binfields.txt"); Dictionary <uint, string> entryNames = hashlist("hashes.binentries.txt"); BINGlobal.SetHashmap(entryNames, classNames, fieldNames); }
private static TreeViewItem GenerateValueNode(BINValue value, bool createFieldProperty = true) { TreeViewItem entryNode = new TreeViewItem(); if (IsPrimitiveValue(value.Type.Value)) { entryNode.Header = ProcessPrimitiveValue(value, createFieldProperty); } else if (value.Type == BINValueType.Container) { entryNode.Header = BINGlobal.GetField(value.Property); foreach (TreeViewItem node in ProcessContainer(value)) { entryNode.Items.Add(node); } } else if (value.Type == BINValueType.Structure || value.Type == BINValueType.Embedded) { entryNode.Header = ""; if (createFieldProperty) { entryNode.Header += BINGlobal.GetField(value.Property) + " : "; } entryNode.Header += BINGlobal.GetClass((value.Value as BINStructure).Property); foreach (TreeViewItem node in ProcessStructure(value)) { entryNode.Items.Add(node); } } else if (value.Type == BINValueType.Map) { entryNode.Header = BINGlobal.GetField(value.Property); foreach (TreeViewItem node in ProcessMap(value)) { entryNode.Items.Add(node); } } else if (value.Type == BINValueType.Optional) { entryNode.Header = BINGlobal.GetField(value.Property); } else if (value.Type == BINValueType.Container2) { entryNode.Header = BINGlobal.GetField(value.Property); } return(entryNode); }
private static TreeViewItem GenerateEntryNode(BINEntry entry) { TreeViewItem entryNode = new TreeViewItem() { Header = entry.GetPath() + " : " + BINGlobal.GetClass(entry.Class) }; foreach (BINValue value in entry.Values) { entryNode.Items.Add(GenerateValueNode(value)); } return(entryNode); }
public string GetPath(bool excludeEntry = true) { string path = ""; if (this.Parent.Parent is BINContainer) { BINContainer container = this.Parent.Parent as BINContainer; path = string.Format("{0}/{1}[{2}]", this.Parent.Parent.GetPath(excludeEntry), BINGlobal.GetClass(this.Property), container.Values.IndexOf(this.Parent as BINValue)); } else { path = string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), BINGlobal.GetClass(this.Property)); } return(path); }
private void InitializeBINGlobal() { 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); }
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); }
public string GetPath(bool excludeEntry = true) { string path = ""; if (this.Property == 0 && this.Parent is BINContainer) { path += string.Format("{0}/[{1}]", this.Parent.GetPath(excludeEntry), (this.Parent as BINContainer).Values.IndexOf(this)); } else if (this.Property == 0 && this.Parent is BINMap) { BINMap map = this.Parent as BINMap; if (map.Values.ContainsValue(this)) { path += map.Values.First(x => x.Value == this).Key.GetPath(excludeEntry); } else { if (map.KeyType == BINValueType.Byte) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), (byte)this.Value); } else if (map.KeyType == BINValueType.UInt16) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), (ushort)this.Value); } else if (map.KeyType == BINValueType.UInt32) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), (uint)this.Value); } else if (map.KeyType == BINValueType.UInt64) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), (ulong)this.Value); } else if (map.KeyType == BINValueType.String) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), (string)this.Value); } else if (map.KeyType == BINValueType.Hash) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), (uint)this.Value); } else { throw new Exception(); } } } else if (this.Property == 0 && this.Parent is BINOptional) { path += this.Parent.GetPath(excludeEntry); } else if (this.Parent is BINStructure) { path += string.Format("{0}.{1}", this.Parent.GetPath(excludeEntry), BINGlobal.GetField(this.Property)); } else if (this.Parent is BINEntry) { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), BINGlobal.GetField(this.Property)); } else { path += string.Format("{0}/{1}", this.Parent.GetPath(excludeEntry), BINGlobal.GetClass(this.Property)); } return(excludeEntry ? path.Remove(0, path.IndexOf('/') + 1) : path); }
public string GetPath(bool excludeEntry = true) { return(BINGlobal.GetEntry(this.Property)); }
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); } }
private static List <TreeViewItem> ProcessMap(BINValue value) { BINMap map = value.Value as BINMap; List <TreeViewItem> nodes = new List <TreeViewItem>(); foreach (KeyValuePair <BINValue, BINValue> pair in map.Values) { TreeViewItem node = new TreeViewItem() { Header = ProcessKeyValue(pair.Key) }; if (map.ValueType != BINValueType.Structure && map.ValueType != BINValueType.Embedded) { node.Header += " => " + (ProcessPrimitiveValue(pair.Value, false).Children[0] as TextBlock).Text; } else { BINStructure structure = pair.Value.Value as BINStructure; node.Header += " : " + BINGlobal.GetClass(structure.Property); foreach (TreeViewItem structureNode in ProcessStructure(pair.Value)) { node.Items.Add(structureNode); } } nodes.Add(node); } return(nodes); string ProcessKeyValue(BINValue keyValue) { if (map.KeyType == BINValueType.Byte) { return(((byte)keyValue.Value).ToString()); } else if (map.KeyType == BINValueType.UInt16) { return(((ushort)keyValue.Value).ToString()); } else if (map.KeyType == BINValueType.UInt32) { return(((uint)keyValue.Value).ToString()); } else if (map.KeyType == BINValueType.UInt64) { return(((ulong)keyValue.Value).ToString()); } else if (map.KeyType == BINValueType.String) { return((string)keyValue.Value); } else if (map.KeyType == BINValueType.StringHash) { return(((uint)keyValue.Value).ToString()); } else { return(""); } } }
private static StackPanel ProcessPrimitiveValue(BINValue value, bool createFieldProperty = true) { StackPanel stackPanel = new StackPanel() { Orientation = Orientation.Horizontal }; if (createFieldProperty) { stackPanel.Children.Add(new TextBlock() { Text = BINGlobal.GetField(value.Property), Margin = new Thickness(0, 0, 15, 0) }); } if (value.Type == BINValueType.Boolean) { stackPanel.Children.Add(new TextBlock() { Text = ((bool)value.Value).ToString() }); } else if (value.Type == BINValueType.SByte) { stackPanel.Children.Add(new TextBlock() { Text = ((sbyte)value.Value).ToString() }); } else if (value.Type == BINValueType.Byte) { stackPanel.Children.Add(new TextBlock() { Text = ((byte)value.Value).ToString() }); } else if (value.Type == BINValueType.Int16) { stackPanel.Children.Add(new TextBlock() { Text = ((short)value.Value).ToString() }); } else if (value.Type == BINValueType.UInt16) { stackPanel.Children.Add(new TextBlock() { Text = ((ushort)value.Value).ToString() }); } else if (value.Type == BINValueType.Int32) { stackPanel.Children.Add(new TextBlock() { Text = ((int)value.Value).ToString() }); } else if (value.Type == BINValueType.UInt32) { stackPanel.Children.Add(new TextBlock() { Text = ((uint)value.Value).ToString() }); } else if (value.Type == BINValueType.Int64) { stackPanel.Children.Add(new TextBlock() { Text = ((long)value.Value).ToString() }); } else if (value.Type == BINValueType.UInt64) { stackPanel.Children.Add(new TextBlock() { Text = ((ulong)value.Value).ToString() }); } else if (value.Type == BINValueType.Float) { stackPanel.Children.Add(new TextBlock() { Text = ((float)value.Value).ToString() }); } else if (value.Type == BINValueType.FloatVector2) { Vector2 vector = value.Value as Vector2; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1} ]", vector.X, vector.Y) }); } else if (value.Type == BINValueType.FloatVector3) { Vector3 vector = value.Value as Vector3; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2} ]", vector.X, vector.Y, vector.Z) }); } else if (value.Type == BINValueType.FloatVector4) { Vector4 vector = value.Value as Vector4; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2}, {3} ]", vector.X, vector.Y, vector.Z, vector.W) }); } else if (value.Type == BINValueType.Matrix44) { R3DMatrix44 matrix = value.Value as R3DMatrix44; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2}, {3} ]\n", matrix.M11, matrix.M12, matrix.M13, matrix.M14) + string.Format("[ {0}, {1}, {2}, {3} ]\n", matrix.M21, matrix.M22, matrix.M23, matrix.M24) + string.Format("[ {0}, {1}, {2}, {3} ]\n", matrix.M31, matrix.M32, matrix.M33, matrix.M34) + string.Format("[ {0}, {1}, {2}, {3} ]", matrix.M41, matrix.M42, matrix.M43, matrix.M44) }); } else if (value.Type == BINValueType.Color) { ColorRGBAVector4Byte color = value.Value as ColorRGBAVector4Byte; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2}, {3} ]", color.R, color.G, color.B, color.A) }); } else if (value.Type == BINValueType.String) { stackPanel.Children.Add(new TextBlock() { Text = (string)value.Value }); } else if (value.Type == BINValueType.StringHash) { stackPanel.Children.Add(new TextBlock() { Text = ((uint)value.Value).ToString() }); } else if (value.Type == BINValueType.LinkOffset) { stackPanel.Children.Add(new TextBlock() { Text = BINGlobal.GetEntry((uint)value.Value) }); } else if (value.Type == BINValueType.FlagsBoolean) { stackPanel.Children.Add(new TextBlock() { Text = ((bool)value.Value).ToString() }); } return(stackPanel); }