Пример #1
0
        private bool loadFile(string fileName, bool fromConsole = false)
        {
            bool result = false;

            if (this.av == null)
            {
                this.av = new UnknownDE();
            }
            UnknownB0 b = new UnknownB0();

            this.writeToConsole("Loading: " + fileName);
            b.a(fileName);
            if (this.bOne(b))
            {
                UnknownBA ba   = b.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
                string    text = ba.sa1[0];

                MenuItem menuItem = new MenuItem(text, new EventHandler(this.bFour));

                // Setting the Name property allows us to use the convenient Key-based methods on the MenuItems collection.
                menuItem.Name = text;

                this.miUnload.MenuItems.Add(menuItem);
                result = true;
            }
            if (fromConsole)
            {
                this.tvRefresh();
            }
            return(result);
        }
Пример #2
0
 private void listLoadedFiles()
 {
     foreach (UnknownB0 b in this.au)
     {
         UnknownBA ba = b.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
         this.writeToConsole(ba.sa1[0]);
     }
 }
Пример #3
0
        // TODO: opt
        private bool bOne(UnknownB0 A_0)
        {
            UnknownBA ba  = A_0.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
            uint      num = ba.uia1[0];

            foreach (UnknownB0 b in this.au)
            {
                UnknownBA ba2 = b.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
                if (ba2.uia1[0] == num)
                {
                    MessageBox.Show("This VLT data file has already been loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }
            }
            this.aTwo(A_0);
            this.au.Add(A_0);
            return(true);
        }
Пример #4
0
        private UnknownC0 a(BinaryReader A_0)
        {
            if (A_0.BaseStream.Position == A_0.BaseStream.Length)
            {
                return(null);
            }

            UnknownE e = new UnknownE();

            e.read(A_0);
            if (!e.isBlank())
            {
                VLTOtherValue ce = e.ce1;
                UnknownC0     c;

                switch (ce)
                {
                case VLTOtherValue.VLTMAGIC:
                    c = new UnknownBA();
                    break;

                case VLTOtherValue.TABLE_START:
                    c = new UnknownDH();
                    break;

                case VLTOtherValue.TABLE_END:
                    c = new UnknownA8();
                    break;

                case VLTOtherValue.d:
                case VLTOtherValue.e:
                default:
                    c = new UnknownA4();
                    break;
                }

                c.e1 = e;
                c.read(A_0);
                e.seekToNextBlock(A_0.BaseStream);
                return(c);
            }

            return(null);
        }
Пример #5
0
        private void tvFields_AfterSelect(object A_0, TreeViewEventArgs A_1)
        {
            object tag = A_1.Node.Tag;

            if (tag is VLTBaseType && !(tag is VLTArrayType))
            {
                VLTBaseType bb = tag as VLTBaseType;
                //bb.l(); // MW: TODO: What is l() supposed to be?
                DataSet   dataSet   = new DataSet("DataItem");
                DataTable dataTable = dataSet.Tables.Add("Values");
                dataTable.Columns.Add("Name", typeof(string));
                dataTable.Columns.Add("Value", typeof(string));
                Type        type   = bb.GetType();
                FieldInfo[] fields = type.GetFields();
                foreach (FieldInfo fieldInfo in fields)
                {
                    object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(DataValueAttribute), false);
                    if (customAttributes != null && customAttributes.Length == 1 && customAttributes[0] is DataValueAttribute)
                    {
                        DataValueAttribute dataValueAttribute = customAttributes[0] as DataValueAttribute;
                        DataRow            dataRow            = dataTable.NewRow();
                        dataRow[0] = dataValueAttribute.Name;
                        object value = fieldInfo.GetValue(bb);
                        if (value == null)
                        {
                            dataRow[1] = "(null)";
                        }
                        else
                        {
                            if (dataValueAttribute.Hex)
                            {
                                dataRow[1] = string.Format("0x{0:x}", value);
                            }
                            else
                            {
                                dataRow[1] = value.ToString();
                            }
                        }
                        dataTable.Rows.Add(dataRow);
                    }
                }
                this.dataGrid.DataSource = dataSet;
                this.dataGrid.DataMember = "Values";

                // This gets rid of the extra row in the table that appears when viewing a sub-node (e.x. junkman --> default)
                CurrencyManager currencyManager = (CurrencyManager)this.BindingContext[dataSet, "Values"];
                ((DataView)currencyManager.List).AllowNew    = false;
                ((DataView)currencyManager.List).AllowEdit   = false;
                ((DataView)currencyManager.List).AllowDelete = false;

                this.lblFieldType.Text = "Type: " + HashTracker.getValueForHash(bb.typeHash);
                if (BuildConfig.DEBUG)
                {
                    this.writeToConsole("bb.GetType(): " + type.ToString());                       // Here, we're getting the proper type! Great!
                    this.writeToConsole("bb.j(): " + string.Format("0x{0:x}", bb.typeHash));       // Here, we're derping! OMG!
                }
                UnknownBA ba   = bb.dr1.b01.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
                string    text = ba.sa1[0];
                this.lblFieldOffset.Text = string.Format("Offset: {0}:0x{1:x}  ({2})", bb.isVltOffset ? "vlt" : "bin", bb.ui1, text);
                this.dataGrid.Update();
            }
            else
            {
                this.lblFieldType.Text   = "";
                this.lblFieldOffset.Text = "";
                this.dataGrid.DataSource = null;
                this.dataGrid.Update();
            }
        }
Пример #6
0
        private void tvFields_AfterSelect(object sender, TreeViewEventArgs e)
        {
            object tag = e.Node.Tag;

            if (tag is VLTBaseType && !(tag is VLTArrayType))
            {
                VLTBaseType bb = tag as VLTBaseType;
                //bb.l(); // MW: TODO: What is l() supposed to be?
                DataSet   dataSet   = new DataSet("DataItem");
                DataTable dataTable = dataSet.Tables.Add("Values");
                dataTable.Columns.Add("Name", typeof(string));
                dataTable.Columns.Add("Value", typeof(string));
                Type        type   = bb.GetType();
                FieldInfo[] fields = type.GetFields();
                foreach (FieldInfo fieldInfo in fields)
                {
                    object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(DataValueAttribute), false);
                    if (customAttributes != null && customAttributes.Length == 1 && customAttributes[0] is DataValueAttribute)
                    {
                        DataValueAttribute dataValueAttribute = customAttributes[0] as DataValueAttribute;
                        DataRow            dataRow            = dataTable.NewRow();
                        dataRow[0] = dataValueAttribute.Name;
                        object value = fieldInfo.GetValue(bb);
                        if (value == null)
                        {
                            dataRow[1] = "(null)";
                        }
                        else
                        {
                            if (dataValueAttribute.Hex)
                            {
                                dataRow[1] = string.Format("0x{0:x}", value);
                            }
                            else
                            {
                                dataRow[1] = value.ToString();
                            }
                        }
                        dataTable.Rows.Add(dataRow);
                    }
                }
                this.dataGrid.DataSource = dataSet;
                this.dataGrid.DataMember = "Values";

                this.lblFieldType.Text = "Type: " + HashTracker.getValueForHash(bb.typeHash);

                /*
                 * if( BuildConfig.DEBUG )
                 * {
                 *      this.writeToConsole( "bb.GetType(): " + type.ToString() ); // Here, we're getting the proper type! Great!
                 *      this.writeToConsole( "bb.j(): " + string.Format( "0x{0:x}", bb.ui2 ) ); // Here, we're derping! OMG!
                 * }*/
                UnknownBA ba   = bb.dr1.b01.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
                string    text = ba.sa1[0];
                this.lblFieldOffset.Text = string.Format("Offset: {0}:0x{1:x}  ({2})", bb.isVltOffset ? "vlt" : "bin", bb.ui1, text);
                this.dataGrid.Update();
            }
            else
            {
                this.lblFieldType.Text   = "";
                this.lblFieldOffset.Text = "";
                this.dataGrid.DataSource = null;
                this.dataGrid.Update();
            }
        }
Пример #7
0
        public void a(Stream A_0, Stream A_1)
        {
            byte[] array = new byte[A_0.Length];
            A_0.Read(array, 0, array.Length);               // array.Length --> .vlt FileSize
            this.ms2       = new MemoryStream(array);
            this.genc0list = new List <UnknownC0>();
            BinaryReader a_ = new BinaryReader(this.ms2);
            UnknownC0    c;

            while ((c = this.a(a_)) != null)
            {
                this.genc0list.Add(c);
            }

            this.Trim();

            UnknownDH dh = this.a(VLTOtherValue.TABLE_START) as UnknownDH;

            for (int i = 0; i < dh.asa1.Length; ++i)
            {
                dh.asa1[i].b(a_);                   // TODO read vs b? b, DEFINITELY b
            }
            if (A_1 == null)
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(this.directory);
                UnknownBA     ba            = this.a(VLTOtherValue.VLTMAGIC) as UnknownBA;
                string        text          = ba.sa1[1];
                FileInfo[]    files         = directoryInfo.GetFiles(text);
                if (files.Length == 0)
                {
                    throw new Exception("Required file " + text + " was not found.");
                }
                A_1   = new FileStream(files[0].FullName, FileMode.Open, FileAccess.ReadWrite);
                array = new byte[A_1.Length];
                A_1.Read(array, 0, array.Length);
                A_1.Close();
            }
            else
            {
                array = new byte[A_1.Length];
                A_1.Read(array, 0, array.Length);
            }
            this.ms1 = new MemoryStream(array);
            a_       = new BinaryReader(this.ms1);
            this.ms1.Seek(0L, SeekOrigin.Begin);
            c = this.a(a_);
            c.e1.seekToDataStart(this.ms1);
            if (c.e1.ce1 == VLTOtherValue.BINMAGIC)
            {
                long num = this.ms1.Position + c.e1.dataSize();
                while (this.ms1.Position < num)
                {
                    string text2 = UnknownAP.a(a_);
                    if (text2 != "")
                    {
                        HashTracker.addHashFromVLTDB(text2);
                    }
                }
            }
            UnknownA8 a = this.a(VLTOtherValue.TABLE_END) as UnknownA8;

            a.a(this.ms1);
        }