Esempio n. 1
0
        private static void WriteNode(XmlWriter writer,
                                      IEnumerable <BinaryObject> parentChain,
                                      BinaryObject node)
        {
            var chain = parentChain.Concat(new[] { node });

            writer.WriteStartElement("object");

            // get object name from object hash via string list
            var objectHashInput = (int)node.NameHash;

            if (StringHasher.CanResolveHash(objectHashInput))
            {
                var objectHashOutput = StringHasher.ResolveHash(objectHashInput);

                writer.WriteAttributeString("name", objectHashOutput);
            }
            else
            {
                writer.WriteAttributeString("hash", node.NameHash.ToString("X8"));
            }

            WriteNodeField(writer, node);

            foreach (var childNode in node.Children)
            {
                WriteNode(writer, chain, childNode);
            }

            writer.WriteEndElement();
        }
Esempio n. 2
0
        private static void WriteRootNode(XmlWriter writer,
                                          IEnumerable <BinaryObject> parentChain,
                                          BinaryObjectFile bof)
        {
            BinaryObject node = bof.Root;

            var chain = parentChain.Concat(new[] { node });

            writer.WriteStartElement("object");

            // get object name from object hash via string list
            var objectHashInput = (int)node.NameHash;

            if (StringHasher.CanResolveHash(objectHashInput))
            {
                var objectHashOutput = StringHasher.ResolveHash(objectHashInput);

                writer.WriteAttributeString("name", objectHashOutput);
            }
            else
            {
                writer.WriteAttributeString("hash", node.NameHash.ToString("X8"));
            }

            // add version attribute to root object
            string bofVersion = bof.Version.ToString();

            if (bofVersion != null)
            {
                writer.WriteAttributeString("version", bofVersion);
            }

            // add header attribute to root object
            string bofHeader = bof.Header;

            if (bofHeader.Length > 0)
            {
                writer.WriteAttributeString("header", bofHeader);
            }

            WriteNodeField(writer, node);

            foreach (var childNode in node.Children)
            {
                WriteNode(writer, chain, childNode);
            }

            writer.WriteEndElement();
        }
Esempio n. 3
0
        private static FieldInfo ResolveField(uint key, byte[] value)
        {
            FieldInfo field = new FieldInfo();

            // key
            string keyTypeString = "hash";
            string keyNameString = $"{key:X8}";

            if (StringHasher.CanResolveHash((int)key))
            {
                keyTypeString = "name";
                keyNameString = StringHasher.ResolveHash((int)key);
            }

            // value
            string valueTypeString  = FieldHandling.GetTypeName(FieldType.BinHex);
            string valueValueString = BitConverter.ToString(value).Replace("-", "");

            string r_valueTypeString  = valueTypeString;
            string r_valueValueString = valueValueString;

            if (TypeGuesser.FieldHandler(value, out r_valueTypeString, out r_valueValueString) == true)
            {
                valueTypeString  = r_valueTypeString;
                valueValueString = r_valueValueString;
            }

            // fill structure
            field.key.type = keyTypeString;
            field.key.name = keyNameString;

            field.value.type  = valueTypeString;
            field.value.value = valueValueString;

            return(field);
        }