Пример #1
0
        public static void init()
        {
            HashTracker.hashesFromTextFile  = new Dictionary <uint, string>();
            HashTracker.guessesFromTextFile = new Dictionary <uint, string>();
            string hashFile = Path.Combine((new FileInfo(Application.ExecutablePath)).Directory.FullName, "hashes.txt");

            if (File.Exists(hashFile))
            {
                HashTracker.loadHashes(hashFile);
            }
        }
Пример #2
0
 private string a(UnknownDR A_0)
 {
     try
     {
         VLTClass dq   = A_0.dq1;
         string   text = HashTracker.getValueForHash(A_0.c1.hash);
         if (A_0.c1.ui3 == 0u)
         {
             return(text);
         }
         return(this.a(dq.dqb1.a(A_0.c1.ui3)) + "/" + text);
     }
     catch
     {
         return("");
     }
 }
Пример #3
0
        public void am(RootRecord A_0, UnknownB0 A_1)
        {
            UnknownA8 a   = A_1.a(VLTOtherValue.TABLE_END) as UnknownA8;
            int       num = a.genht1[A_0.position].i2;

            A_1.ms1.Seek(num, SeekOrigin.Begin);
            BinaryReader a_ = new BinaryReader(A_1.ms1);

            this.genht1 = new Dictionary <uint, aclzz>(A_0.i3);
            for (int i = 0; i < A_0.i3; ++i)
            {
                UnknownDE.aclzz a2 = new UnknownDE.aclzz();
                a2.s1  = UnknownAP.a(a_);
                a2.i1  = A_0.ia1[i];
                a2.ui1 = JenkinsHash.getHash32(a2.s1);
                this.genht1.Add(a2.ui1, a2);
                HashTracker.addHashFromVLTDB(a2.s1);
            }
            this.genht2 = new Dictionary <uint, VLTClass>();
        }
Пример #4
0
        public void a(ClassRecord A_0, UnknownB0 A_1)
        {
            this.b01         = A_1;
            this.classRecord = A_0;
            this.classHash   = A_0.hash;
            UnknownA8 a81 = (A_1.a(VLTOtherValue.TABLE_END) as UnknownA8);
            int       num = a81.genht1[A_0.position].i2;

            A_1.ms1.Seek(num, SeekOrigin.Begin);
            BinaryReader br = new BinaryReader(A_1.ms1);

            this.fields = new VLTClass.aclz1[this.classRecord.i2];
            for (int i = 0; i < this.classRecord.i2; ++i)
            {
                VLTClass.aclz1 a = new VLTClass.aclz1();
                a.read(br);
                HashTracker.getValueForHash(a.hash);
                this.fields[i] = a;
            }
            this.dqb1 = new VLTClass.bie(this);
        }
Пример #5
0
        /*
         * private void i( object A_0, EventArgs A_1 )
         * {
         *      if( this.tv.SelectedNode != null )
         *      {
         *              TreeNode selectedNode = this.tv.SelectedNode;
         *              if( selectedNode.Tag is UnknownDE )
         *              {
         *                      // Right-clicked "Database", selected "Copy Node Path"
         *                      Clipboard.SetDataObject( "" );
         *              }
         *              else if( selectedNode.Tag is VLTClass )
         *              {
         *                      VLTClass dq = selectedNode.Tag as VLTClass;
         *                      Clipboard.SetDataObject( HashTracker.getValueForHash( dq.hash ) );
         *              }
         *              else
         *              {
         *                      UnknownDR dr = selectedNode.Tag as UnknownDR;
         *                      VLTClass dq2 = dr.dq1;
         *                      Clipboard.SetDataObject( HashTracker.getValueForHash( dq2.hash ) + "/" + this.a( dr ) );
         *              }
         *      }
         * }
         */

        private void h(object A_0, EventArgs A_1)
        {
            if (this.tvFields.SelectedNode != null)
            {
                TreeNode    selectedNode = this.tvFields.SelectedNode;
                VLTBaseType bb           = selectedNode.Tag as VLTBaseType;
                if (selectedNode.Parent != null)
                {
                    VLTBaseType bb2 = selectedNode.Parent.Tag as VLTArrayType;
                    Clipboard.SetDataObject(string.Concat(new object[]
                    {
                        HashTracker.getValueForHash(bb2.ui3),
                        "[",
                        bb.arrayIndex,
                        "]"
                    }));
                    return;
                }
                Clipboard.SetDataObject(HashTracker.getValueForHash(bb.ui3));
            }
        }
Пример #6
0
 private void j(object A_0, EventArgs A_1)
 {
     if (this.tv.SelectedNode != null)
     {
         TreeNode selectedNode = this.tv.SelectedNode;
         if (selectedNode.Tag is UnknownDE)
         {
             Clipboard.SetDataObject("Database");
         }
         else if (selectedNode.Tag is VLTClass)
         {
             VLTClass dq = selectedNode.Tag as VLTClass;
             Clipboard.SetDataObject(HashTracker.getValueForHash(dq.classHash));
         }
         else
         {
             UnknownDR dr = selectedNode.Tag as UnknownDR;
             Clipboard.SetDataObject(HashTracker.getValueForHash(dr.c1.hash));
         }
     }
 }
Пример #7
0
 static HashTracker()
 {
     HashTracker.hashesFromVLTFile = new Dictionary <uint, string>();
     HashTracker.hashesInUse       = new Dictionary <uint, string>();
     HashTracker.init();
 }
Пример #8
0
        /*
         * private void e( object A_0, EventArgs A_1 )
         * {
         *      if( this.tvFields.SelectedNode != null )
         *      {
         *              TreeNode treeNode = this.tvFields.SelectedNode;
         *              if( treeNode.Parent != null )
         *              {
         *                      treeNode = treeNode.Parent;
         *              }
         *              VLTBaseType bb = treeNode.Tag as VLTBaseType;
         *              this.a( bb.dr1, bb.ui3 );
         *      }
         * }
         */

        // TODO: opt
        private void tv_AfterSelect(object A_0, TreeViewEventArgs A_1)
        {
            object tag = A_1.Node.Tag;

            if (tag is VLTClass)
            {
                this.classGrid.Visible = true;
                this.pnlData.Visible   = false;
                VLTClass  dq        = tag as VLTClass;
                DataSet   dataSet   = new DataSet("VLT");
                DataTable dataTable = dataSet.Tables.Add("Fields");
                dataTable.Columns.Add("Name", typeof(string));
                dataTable.Columns.Add("Type", typeof(string));
                dataTable.Columns.Add("Length", typeof(ushort));
                dataTable.Columns.Add("Count", typeof(short));

                foreach (VLTClass.aclz1 a in dq)
                {
                    DataRow dataRow = dataTable.NewRow();
                    dataRow[0] = HashTracker.getValueForHash(a.hash);
                    dataRow[1] = HashTracker.getValueForHash(a.ui2);
                    dataRow[2] = a.len;
                    dataRow[3] = a.count;
                    dataTable.Rows.Add(dataRow);
                }

                this.classGrid.DataSource = dataSet;
                this.classGrid.DataMember = "Fields";

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

                UnknownA8 a2 = dq.b01.a(VLTOtherValue.TABLE_END) as UnknownA8;
                this.classGrid.Update();
            }
            else if (tag is UnknownDR)
            {
                this.lblFieldType.Text   = "";
                this.lblFieldOffset.Text = "";
                this.dataGrid.DataSource = null;
                this.dataGrid.Update();
                this.classGrid.Visible = false;
                this.pnlData.Visible   = true;
                string   text     = "";
                string   text2    = "";
                TreeNode treeNode = null;
                if (this.tvFields.SelectedNode != null)
                {
                    if (this.tvFields.SelectedNode.Parent != null && this.tvFields.SelectedNode.Parent.Tag == null)
                    {
                        text  = this.tvFields.SelectedNode.Parent.Text;
                        text2 = this.tvFields.SelectedNode.Text;
                    }
                    else
                    {
                        text = this.tvFields.SelectedNode.Text;
                    }
                }
                UnknownDR dr  = tag as UnknownDR;
                VLTClass  dq2 = dr.dq1;
                this.tvFields.BeginUpdate();
                this.tvFields.Nodes.Clear();
                int num = 0;

                foreach (VLTClass.aclz1 a3 in dq2)
                {
                    VLTBaseType bb = dr.bba1[num++];
                    if (!a3.c() || dr.booa1[num - 1])
                    {
                        if (a3.isArray())
                        {
                            VLTArrayType m     = bb as VLTArrayType;
                            string       text3 = string.Concat(new object[]
                            {
                                HashTracker.getValueForHash(a3.hash),
                                " [",
                                m.getMaxEntryCount(),
                                "/",
                                m.getCurrentEntryCount(),
                                "]"
                            });
                            TreeNode treeNode2 = this.tvFields.Nodes.Add(text3);
                            treeNode2.Tag = bb;
                            for (int i = 0; i < m.getMaxEntryCount(); ++i)
                            {
                                TreeNode treeNode3 = treeNode2.Nodes.Add("[" + i + "]");
                                treeNode3.Tag = m.genlist[i];
                                if (treeNode2.Text == text && treeNode3.Text == text2)
                                {
                                    treeNode = treeNode3;
                                }
                            }
                            if (treeNode2.Text == text && treeNode == null)
                            {
                                treeNode = treeNode2;
                            }
                        }
                        else
                        {
                            TreeNode treeNode4 = this.tvFields.Nodes.Add(HashTracker.getValueForHash(a3.hash));
                            treeNode4.Tag = bb;
                            if (treeNode4.Text == text)
                            {
                                treeNode = treeNode4;
                            }
                        }
                    }
                }

                if (this.tvFields.Nodes.Count > 0)
                {
                    if (treeNode == null)
                    {
                        this.tvFields.SelectedNode = this.tvFields.Nodes[0];
                    }
                    else
                    {
                        this.tvFields.SelectedNode = treeNode;
                    }
                }
                this.tvFields.EndUpdate();
                UnknownA8 a4 = dr.b01.a(VLTOtherValue.TABLE_END) as UnknownA8;
            }
            else
            {
                this.classGrid.Visible = false;
                this.pnlData.Visible   = false;
            }
        }
Пример #9
0
        private void classdump()
        {
            using (StreamWriter streamWriter = new StreamWriter((new FileInfo(Application.ExecutablePath)).Directory.FullName + "\\temp.cs", false, Encoding.ASCII))
            {
                streamWriter.WriteLine("using System;");
                streamWriter.WriteLine("using mwperf;");
                streamWriter.WriteLine("namespace mwperf.VLTTables {");

                foreach (VLTClass dq in this.av)
                {
                    string text = this.bThree(HashTracker.getValueForHash(dq.classHash));
                    if (this.c(text))
                    {
                        streamWriter.WriteLine("\tnamespace " + text + " {");
                        streamWriter.WriteLine("\t\tpublic abstract class " + this.bThree(text + "_base") + " {");

                        foreach (VLTClass.aclz1 a in dq)
                        {
                            string text2 = this.bThree(HashTracker.getValueForHash(a.hash));
                            if (this.c(text2))
                            {
                                streamWriter.WriteLine(string.Concat(new string[]
                                {
                                    "\t\t\tpublic static VLTOffsetData",
                                    a.isArray() ? "[]" : "",
                                    " ",
                                    text2,
                                    ";"
                                }));
                            }
                        }

                        streamWriter.WriteLine("\t\t}");

                        foreach (UnknownDR dr in dq.dqb1)
                        {
                            int    num   = 0;
                            string text3 = this.bThree(HashTracker.getValueForHash(dr.c1.hash));
                            if (this.c(text3))
                            {
                                streamWriter.WriteLine(string.Concat(new string[]
                                {
                                    "\t\tpublic class ",
                                    text3,
                                    " : ",
                                    text,
                                    "_base {"
                                }));
                                streamWriter.WriteLine("\t\t\tstatic " + text3 + "() {");

                                foreach (VLTClass.aclz1 a2 in dq)
                                {
                                    VLTBaseType bb = dr.bba1[num++];
                                    if (!a2.c() || dr.booa1[num - 1])
                                    {
                                        string text4 = this.bThree(HashTracker.getValueForHash(a2.hash));
                                        if (this.c(text4))
                                        {
                                            streamWriter.Write("\t\t\t\t" + text4 + " = ");
                                            if (a2.isArray())
                                            {
                                                VLTArrayType m = bb as VLTArrayType;
                                                streamWriter.WriteLine("new VLTOffsetData[] {");
                                                for (int i = 0; i < m.getMaxEntryCount(); ++i)
                                                {
                                                    bb = m.genlist[i];
                                                    streamWriter.WriteLine(string.Concat(new string[]
                                                    {
                                                        "\t\t\t\t\tnew VLTOffsetData(VLTOffsetType.",
                                                        bb.isVltOffset ? "Vlt" : "Bin",
                                                        ", ",
                                                        string.Format("0x{0:x}", bb.ui1),
                                                        ")",
                                                        (i != (int)(m.getMaxEntryCount() - 1)) ? "," : ""
                                                    }));
                                                }
                                                streamWriter.WriteLine("\t\t\t\t};");
                                            }
                                            else
                                            {
                                                streamWriter.WriteLine(string.Concat(new string[]
                                                {
                                                    "new VLTOffsetData(VLTOffsetType.",
                                                    bb.isVltOffset ? "Vlt" : "Bin",
                                                    ", ",
                                                    string.Format("0x{0:x}", bb.ui1),
                                                    ");"
                                                }));
                                            }
                                        }
                                    }
                                }

                                streamWriter.WriteLine("\t\t\t}");
                                streamWriter.WriteLine("\t\t}");
                            }
                        }

                        streamWriter.WriteLine("\t}");
                    }
                }

                streamWriter.WriteLine("}");
            }
        }
Пример #10
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();
            }
        }
Пример #11
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();
            }
        }
Пример #12
0
        private void tv_AfterSelect(object sender, TreeViewEventArgs e)
        {
            object tag = e.Node.Tag;

            if (tag is VLTClass)
            {
                this.classGrid.Visible = true;
                this.pnlData.Visible   = false;
                VLTClass dq = tag as VLTClass;

                if (!this.classGridDataSet.Tables.Contains(dq.classHash.ToString()))
                {
                    DataTable dataTable = this.classGridDataSet.Tables.Add(dq.classHash.ToString());
                    dataTable.Columns.Add("Name", typeof(string));
                    dataTable.Columns.Add("Type", typeof(string));
                    dataTable.Columns.Add("Length", typeof(ushort));
                    dataTable.Columns.Add("Count", typeof(short));

                    foreach (VLTClass.aclz1 a in dq)
                    {
                        /*
                         * object[] rowData =
                         * {
                         *      HashTracker.getValueForHash( a.hash ),
                         *      HashTracker.getValueForHash( a.ui2 ),
                         *      a.len,
                         *      a.count
                         * };
                         * dataTable.Rows.Add( rowData );*/
                        dataTable.Rows.Add(new object[] {
                            HashTracker.getValueForHash(a.hash),
                            HashTracker.getValueForHash(a.ui2),
                            a.len,
                            a.count
                        });

                        /*
                         * DataRow dataRow = dataTable.NewRow();
                         * dataRow[0] = HashTracker.getValueForHash( a.hash );
                         * dataRow[1] = HashTracker.getValueForHash( a.ui2 );
                         * dataRow[2] = a.len;
                         * dataRow[3] = a.count;
                         * dataTable.Rows.Add( dataRow );*/
                    }
                }

                this.classGrid.DataMember = dq.classHash.ToString();
                //this.classGrid.Columns["Name"].Width = 80;
                //this.classGrid.Columns["Type"].Width = 150;
                //this.classGrid.Columns["Length"].Width = 60;
                //this.classGrid.Columns["Count"].Width = 60;

                this.classGrid.Update();
            }
            else if (tag is UnknownDR)              // TODO
            {
                this.lblFieldType.Text   = "";
                this.lblFieldOffset.Text = "";
                this.dataGrid.DataSource = null;
                this.dataGrid.Update();
                this.classGrid.Visible = false;
                this.pnlData.Visible   = true;
                string   text     = "";
                string   text2    = "";
                TreeNode treeNode = null;
                if (this.tvFields.SelectedNode != null)
                {
                    if (this.tvFields.SelectedNode.Parent != null && this.tvFields.SelectedNode.Parent.Tag == null)
                    {
                        text  = this.tvFields.SelectedNode.Parent.Text;
                        text2 = this.tvFields.SelectedNode.Text;
                    }
                    else
                    {
                        text = this.tvFields.SelectedNode.Text;
                    }
                }
                UnknownDR dr  = tag as UnknownDR;
                VLTClass  dq2 = dr.dq1;
                this.tvFields.BeginUpdate();
                this.tvFields.Nodes.Clear();
                int num = 0;

                foreach (VLTClass.aclz1 a3 in dq2)
                {
                    VLTBaseType bb = dr.bba1[num++];
                    if (!a3.c() || dr.booa1[num - 1])
                    {
                        if (a3.isArray())
                        {
                            VLTArrayType m     = bb as VLTArrayType;
                            string       text3 = string.Concat(new object[]
                            {
                                HashTracker.getValueForHash(a3.hash),
                                " [",
                                m.getMaxEntryCount(),
                                "/",
                                m.getCurrentEntryCount(),
                                "]"
                            });
                            TreeNode treeNode2 = this.tvFields.Nodes.Add(text3);
                            treeNode2.Tag = bb;
                            for (int i = 0; i < m.getMaxEntryCount(); ++i)
                            {
                                TreeNode treeNode3 = treeNode2.Nodes.Add("[" + i + "]");
                                treeNode3.Tag = m.genlist[i];
                                if (treeNode2.Text == text && treeNode3.Text == text2)
                                {
                                    treeNode = treeNode3;
                                }
                            }
                            if (treeNode2.Text == text && treeNode == null)
                            {
                                treeNode = treeNode2;
                            }
                        }
                        else
                        {
                            TreeNode treeNode4 = this.tvFields.Nodes.Add(HashTracker.getValueForHash(a3.hash));
                            treeNode4.Tag = bb;
                            if (treeNode4.Text == text)
                            {
                                treeNode = treeNode4;
                            }
                        }
                    }
                }

                if (this.tvFields.Nodes.Count > 0)
                {
                    if (treeNode == null)
                    {
                        this.tvFields.SelectedNode = this.tvFields.Nodes[0];
                    }
                    else
                    {
                        this.tvFields.SelectedNode = treeNode;
                    }
                }
                this.tvFields.EndUpdate();
            }
            else
            {
                this.classGrid.Visible = false;
                this.pnlData.Visible   = false;
            }
        }
Пример #13
0
        private void consoleCommandHandler(string cmd)
        {
            // TODO: impl
            string[] array  = cmd.Split(new char[] { ' ' }, 2);
            string   text   = array[0];
            bool     noArgs = true;
            string   text2  = null;

            if (array.Length > 1)
            {
                noArgs = false;
                text2  = array[1];
                text2.Split(new char[] { ' ' });
            }

            try
            {
                switch (text)
                {
                case "quit":
                case "exit":
                    this.exit();
                    break;

                case "open":
                case "load":
                    if (noArgs)
                    {
                        this.openFile();
                        break;
                    }
                    FileInfo fileInfo = new FileInfo(text2);
                    if (!fileInfo.Exists)
                    {
                        this.writeToConsole("Non existant file: " + fileInfo.FullName);
                        break;
                    }
                    if (!this.loadFile(fileInfo.FullName, true))
                    {
                        this.writeToConsole("Failed to load file: " + fileInfo.FullName);
                    }
                    break;

                case "unload":
                    if (noArgs)
                    {
                        this.writeToConsole("Error in command.");
                        break;
                    }
                    string[] filesToUnload = { text2 };
                    this.unloadFiles(new List <string>(filesToUnload));
                    break;

                case "unloadall":
                    if (!noArgs)
                    {
                        this.writeToConsole("Error in command.");
                        break;
                    }
                    this.unloadFiles();
                    break;

                case "reparse":
                    this.writeToConsole("Reparsing all VLTs...");
                    this.d();
                    this.tvRefresh();
                    break;

                case "cls":
                case "clear":
                    this.txtConsole.Text = "";
                    break;

                case "hex":
                    if (noArgs)
                    {
                        this.writeToConsole("Error in command.");
                        break;
                    }
                    this.writeToConsole(string.Format("hex({0})=0x{1:x}", ulong.Parse(text2), ulong.Parse(text2)));
                    break;

                case "hash":
                case "hash32":
                    if (noArgs)
                    {
                        this.writeToConsole("Error in command.");
                        break;
                    }
                    this.writeToConsole(string.Format("hash({0})=0x{1:x}", text2, JenkinsHash.getHash32(text2)));
                    break;

                case "hash64":
                    if (noArgs)
                    {
                        this.writeToConsole("Error in command.");
                        break;
                    }
                    this.writeToConsole(string.Format("hash64({0})=0x{1:x}", text2, JenkinsHash.getHash64(text2)));
                    break;

                case "hs":
                case "hsearch":
                    if (noArgs)
                    {
                        this.writeToConsole("Error in command.");
                    }
                    else if (this.au.Count <= 0)                              // No loaded files
                    {
                        this.writeToConsole("No files loaded to search!");
                        break;
                    }
                    else
                    {
                        this.search(text2);
                    }
                    if (text == "hs")
                    {
                        this.txtConsoleInput.Text           = "hs ";
                        this.txtConsoleInput.SelectionStart = this.txtConsoleInput.Text.Length;
                    }
                    break;

                case "savehash":
                    if (noArgs)
                    {
                        this.writeToConsole("Error in command.");
                        break;
                    }
                    FileInfo fileInfo2 = new FileInfo(text2);
                    HashTracker.dumpUsedHashes(fileInfo2.FullName);
                    this.writeToConsole("Saved used hashes list to: " + fileInfo2.FullName);
                    break;

                case "loadhash":
                    if (File.Exists(text2))
                    {
                        HashTracker.loadHashes(text2);
                        break;
                    }
                    this.writeToConsole("File does not exist.");
                    break;

                case "reloadhashes":
                    HashTracker.init();
                    this.writeToConsole("Hashes reloaded.");
                    break;

                case "help":
                    this.writeToConsole("Common commands:");
                    this.writeToConsole("\thash, hash64 <string>: returns the hash(64) of the given string.");
                    this.writeToConsole("\ths, hsearch <string/0xHASH>: searches for VLT entries of the given string or hash.");
                    this.writeToConsole("\thex <int>: returns the hexadecimal representation of the given decimal.");
                    this.writeToConsole("\tcls, clear: clear the console.");
                    break;

                case "debug":
                    frmMain maintest = new frmMain();
                    maintest.Show();
                    this.WindowState = FormWindowState.Minimized;
                    break;

                case "":
                    break;

                default:
                    this.writeToConsole("Unknown command.");
                    break;
                }
            }
            catch (Exception ex2)
            {
                this.writeToConsole("Exception: " + ex2.ToString());
                this.writeToConsole("Error while executing: " + cmd);
            }
        }
Пример #14
0
        /**
         * Searches open files for the specified entry name/hash; stores results in the given List
         */
        private void search(string A_0, ref List <string> A_1)
        {
            uint num;

            if (A_0.StartsWith("0x"))
            {
                num = uint.Parse(A_0.Substring(2), NumberStyles.AllowHexSpecifier | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite);
            }
            else
            {
                num = JenkinsHash.getHash32(A_0);
            }

            foreach (VLTClass dq in this.av)
            {
                if (dq.classHash == num)
                {
                    string text = A_0 + ": Found match for class: " + HashTracker.getValueForHash(dq.classHash);
                    if (!A_1.Contains(text))
                    {
                        A_1.Add(text);
                    }
                }

                foreach (VLTClass.aclz1 a in dq)
                {
                    if (a.hash == num)
                    {
                        string text = string.Concat(new string[]
                        {
                            A_0,
                            ": Found match for field: ",
                            HashTracker.getValueForHash(dq.classHash),
                            "/",
                            HashTracker.getValueForHash(a.hash)
                        });
                        if (!A_1.Contains(text))
                        {
                            A_1.Add(text);
                        }
                    }
                }

                foreach (UnknownDR dr in dq.dqb1)
                {
                    if (dr.c1.hash == num)
                    {
                        string text = string.Concat(new string[]
                        {
                            A_0,
                            ": Found match for row: ",
                            HashTracker.getValueForHash(dq.classHash),
                            "/",
                            this.a(dr)
                        });
                        if (!A_1.Contains(text))
                        {
                            A_1.Add(text);
                        }
                    }
                }
            }
        }
Пример #15
0
        private void tvRefresh()
        {
            bool flag = true;

            this.classGrid.Visible = false;

            // Clear out the class DataSet, just in case something in the cache changes somehow upon loading a file.
            this.classGridDataSet     = new DataSet("VLT");
            this.classGrid.DataSource = this.classGridDataSet;

            this.pnlData.Visible = false;
            this.tv.Nodes.Clear();
            if (this.au.Count == 0)
            {
                return;
            }
            this.tv.BeginUpdate();
            Dictionary <string, TreeNode> dict = new Dictionary <string, TreeNode>();

            foreach (VLTClass dq in this.av)
            {
                string   text      = HashTracker.getValueForHash(dq.classHash);
                TreeNode treeNode2 = this.tv.Nodes.Add(text);
                treeNode2.Tag = dq;

                foreach (UnknownDR dr in dq.dqb1)
                {
                    TreeNode treeNode3 = null;
                    string   text2;
                    if (dr.c1.ui3 == 0u)
                    {
                        treeNode3 = treeNode2;
                    }
                    else
                    {
                        // This failure seems to be caused by our underlying problem with the VLTClass RowEntry failure.
                        text2 = string.Format("{0:x},{1:x}", dq.classHash, dr.c1.ui3);
                        if (dict.ContainsKey(text2))
                        {
                            treeNode3 = dict[text2];
                        }
                    }

                    if (treeNode3 == null)
                    {
                        if (flag)
                        {
                            DialogResult dialogResult = MessageBox.Show("Could not find parent data row. Did you forget to load a dependency?\nThe hierarchy will be flattened.", "Warning", MessageBoxButtons.OK);                               // TODO: , 48);
                            if (dialogResult == DialogResult.OK)
                            {
                                flag = false;
                            }
                        }
                        treeNode3 = treeNode2;
                    }
                    text = string.Concat(new object[]
                    {
                        HashTracker.getValueForHash(dr.c1.hash),
                        " [",
                        dq.classRecord.i6,
                        "+",
                        dr.c1.i1,
                        "]"
                    });
                    treeNode3     = treeNode3.Nodes.Add(text);
                    treeNode3.Tag = dr;
                    text2         = string.Format("{0:x},{1:x}", dq.classHash, dr.c1.hash);
                    dict[text2]   = treeNode3;
                }
            }

            this.tv.Sort();
            this.tv.EndUpdate();
        }
Пример #16
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);
        }