Exemplo n.º 1
0
        private void openMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Map opening stuff
            OpenFileDialog map_file = new OpenFileDialog();

            map_file.Filter = "Halo 2 Vista Map (*.map)|*.map";

            if (map_file.ShowDialog() == DialogResult.OK)
            {
                map_stream  = new StreamReader(map_file.FileName);
                SID_list    = new Dictionary <int, string>();//initialise our SIDs
                AllTagslist = new Dictionary <int, string>();

                table_off         = DATA_READ.ReadINT_LE(0x10, map_stream);
                table_size        = DATA_READ.ReadINT_LE(0x14, map_stream);
                file_table_offset = DATA_READ.ReadINT_LE(0x2D0, map_stream);

                table_start = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;

                scnr_off     = table_off + table_size;
                scnr_memaddr = DATA_READ.ReadINT_LE(table_start + 0x8, map_stream);//scnr tag index is 0x0

                map_name = map_file.FileName;

                initialize_treeview();
                map_loaded = true;
                TagToolStripMenu.Visible      = true;
                metaToolStripMenuItem.Visible = true;
            }
        }
Exemplo n.º 2
0
        private void extractMetaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (map_loaded)
            {
                if (treeView1.SelectedNode != null)
                {
                    int    tag_table_ref = Int32.Parse(treeView1.SelectedNode.Name);
                    string type          = DATA_READ.ReadTAG_TYPE(tag_table_ref, map_stream);
                    int    datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);

                    //Meta Extractor
                    MetaExtractor meta_extract;
                    meta_extract = new MetaExtractor(datum_index, type, SID_list, map_stream);
                    meta_extract.Show();
                }
                else
                {
                    MessageBox.Show("Select a TAG", "Hint");
                }
            }
            else
            {
                MessageBox.Show("Select a map First", "Hint");
            }
        }
Exemplo n.º 3
0
 public void CheckedTags(TreeNodeCollection nodes)
 {
     foreach (System.Windows.Forms.TreeNode tagitem in nodes)
     {
         if (tagitem.Checked)
         {
             if (tagitem.Level != 0)
             {
                 int tag_table_ref = Int32.Parse(tagitem.Name);
                 int datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);
                 if (!AddList.ContainsKey(datum_index))
                 {
                     AddList.Add(datum_index, tagitem.Text);
                 }
             }
             else
             {
                 CheckedTags(tagitem.Nodes);
             }
         }
         if (tagitem.Nodes.Count != 0)
         {
             CheckedTags(tagitem.Nodes);
         }
     }
     textBox4.Text = AddList.Count.ToString() + " Tags Selected";
 }
        /// <summary>
        /// Generates a list of StringIndexes contained in the map
        /// </summary>
        /// <returns>List of StringID_info</returns>
        List <StringID_info> Get_SID_list(string map_loc)
        {
            List <StringID_info> ret = new List <StringID_info>();

            StreamReader map_stream = new StreamReader(map_loc);

            int string_table_count        = DATA_READ.ReadINT_LE(0x170, map_stream);
            int string_index_table_offset = DATA_READ.ReadINT_LE(0x178, map_stream);
            int string_table_offset       = DATA_READ.ReadINT_LE(0x17C, map_stream);

            for (int index = 0; index < string_table_count; index++)
            {
                int    table_off = DATA_READ.ReadINT_LE(string_index_table_offset + index * 0x4, map_stream) & 0xFFFF;
                string STRING    = DATA_READ.ReadSTRING(string_table_offset + table_off, map_stream);

                if (STRING.Length > 0)
                {
                    int SID = DATA_READ.Generate_SID(index, 0x0, STRING);//set is 0x0 cuz i couldnt figure out any other value

                    StringID_info SIDI = new StringID_info();
                    SIDI.string_index_table_index = string_index_table_offset + index * 0x4;
                    SIDI.string_table_offset      = table_off;
                    SIDI.StringID = SID;
                    SIDI.STRING   = STRING;

                    ret.Add(SIDI);
                }
            }

            map_stream.Close();

            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// return a list all tagRefs mentioned in the meta and the extended meta
        /// </summary>
        /// <returns></returns>
        public List <tagRef> Get_all_tag_refs()
        {
            List <tagRef> ret = new List <tagRef>();

            //first i add all my the tagRefs in the concerned meta
            foreach (int temp_off in ref_tags)
            {
                string type       = DATA_READ.ReadTAG_TYPE(temp_off, data);
                int    temp_datum = DATA_READ.ReadINT_LE(temp_off + 4, data);

                //i only list them if they are valid
                if (temp_datum != -1)
                {
                    tagRef temp_tagref = new tagRef();
                    temp_tagref.type        = type;
                    temp_tagref.datum_index = temp_datum;

                    ret.Add(temp_tagref);
                }
            }
            //list_extended object is only created when we are reading from a map
            if (list_extended != null)
            {
                //then we add the extended_meta dependencies
                List <int> key_list = list_extended.Keys.ToList <int>();
                foreach (int temp_key in key_list)
                {
                    extended_meta temp_meta = list_extended[temp_key];
                    ret.AddRange(temp_meta.Get_all_tag_refs());
                }
            }
            //listing the WCtagRefs
            //we can only do this when we are reading from a map
            if (map_stream != null)
            {
                //some meta reading prologue
                int table_off   = DATA_READ.ReadINT_LE(0x10, map_stream);
                int table_start = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;

                foreach (int temp_off in ref_WCtags)
                {
                    int temp_datum = DATA_READ.ReadINT_LE(temp_off, data);//we read it from meta data
                    if (temp_datum != -1)
                    {
                        string type = DATA_READ.ReadTAG_TYPE(table_start + (0xFFFF & temp_datum) * 0x10, map_stream);//we read this from map stream

                        tagRef temp_WCtagref = new tagRef();
                        temp_WCtagref.datum_index = temp_datum;
                        temp_WCtagref.type        = type;

                        ret.Add(temp_WCtagref);
                    }
                }
            }

            return(ret);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialises tree view upon opening a map file
        /// </summary>
        void initialize_treeview()
        {
            treeView1.Nodes.Clear();

            int tag_count  = 0;
            int path_start = 0;

            for (int i = 0; ; i++)
            {
                int tag_table_REF = table_start + 0x10 * i;

                if (tag_table_REF > table_size + table_start)
                {
                    break;
                }

                string type        = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream);
                int    datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream);
                string path        = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream);

                if (datum_index != -1)
                {
                    //lets check the mem addrs validity before adding it to the list
                    int mem_addr = DATA_READ.ReadINT_LE(tag_table_REF + (datum_index & 0xffff) * 0x10 + 8, map_stream);

                    if (mem_addr != 0x0)
                    {
                        AllTagList.Add(datum_index, path);//Adding only Map Specific tags with Internal Reference only to list
                    }
                    if (treeView1.Nodes.IndexOfKey(type) == -1)
                    {
                        treeView1.Nodes.Add(type, "- " + type);
                    }
                    int index = treeView1.Nodes.IndexOfKey(type);

                    //HEX Values contains ABCDEF
                    treeView1.Nodes[index].Nodes.Add(tag_table_REF.ToString(), "- " + path);

                    //add this stuff to the SID list
                    SID_list.Add(datum_index, path);

                    //ugh! is basically the last tag
                    if (type.CompareTo("ugh!") == 0)
                    {
                        break;
                    }

                    path_start += path.Length + 1;
                }

                tag_count = i;
            }
            treeView1.Sort();
            textBox2.Text = tag_count.ToString() + " Total Tags";
        }
Exemplo n.º 7
0
        Dictionary <int, extended_meta> list_extended; //<mem_off,extended_meta obj>,a dictionary containing the extended meta by their memory address to prevent redundancy.

        /// <summary>
        /// use to read meta data from a map file
        /// </summary>
        /// <param name="datum_index">the datum index of the tag</param>
        /// <param name="sr">the path of the tag.eg: characters/elite/elite_mp</param>
        /// <param name="sr">the stream object</param>
        public meta(int datum_index, string path, StreamReader sr)
        {
            //initialise some stuff
            this.datum_index = datum_index;
            this.path        = path;
            map_stream       = sr;

            //some meta reading prologue
            int table_off    = DATA_READ.ReadINT_LE(0x10, map_stream);
            int table_size   = DATA_READ.ReadINT_LE(0x14, map_stream);
            int table_start  = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;
            int scnr_off     = table_off + table_size;
            int scnr_memaddr = DATA_READ.ReadINT_LE(table_start + 0x8, map_stream);//scnr tag index is 0x0(mostly)

            //steps concerned with the specified meta
            type    = DATA_READ.ReadTAG_TYPE(table_start + (0xFFFF & datum_index) * 0x10, map_stream);
            mem_off = DATA_READ.ReadINT_LE(table_start + ((0xFFFF & datum_index) * 0x10) + 0x8, map_stream);

            size = DATA_READ.ReadINT_LE(table_start + ((0xFFFF & datum_index) * 0x10) + 0xC, map_stream);

            //read the meta from the map
            data = new byte[size];

            if (!DATA_READ.Check_shared(sr))
            {
                //normal map
                map_stream.BaseStream.Position = scnr_off + (mem_off - scnr_memaddr);
            }
            else
            {
                //shared map
                map_stream.BaseStream.Position = scnr_off + (mem_off - 0x3c000);
                //0x3c000 is a hardcoded value in blam engine
            }

            map_stream.BaseStream.Read(data, 0, size);

            //read and store the plugin structure
            plugin = DATA_READ.Get_Tag_stucture_from_plugin(type);

            //lets initialise some lists and dictionaries
            ref_data      = new List <int>();
            ref_tags      = new List <int>();
            ref_reflexive = new List <int>();
            ref_stringID  = new List <int>();
            ref_extended  = new Dictionary <int, int>();
            list_extended = new Dictionary <int, extended_meta>();
            ref_WCtags    = new List <int>();


            //now lets search for all kinds of stuff
            List_deps(0x0, plugin);
        }
        /// <summary>
        /// Gets the list of tags contained in the map
        /// </summary>
        /// <param name="map_loc"></param>
        /// <returns></returns>
        List <tag_info> Get_Tag_list(string map_loc)
        {
            List <tag_info> ret = new List <tag_info>();


            StreamReader map_stream = new StreamReader(map_loc);

            int table_off         = DATA_READ.ReadINT_LE(0x10, map_stream);
            int table_size        = DATA_READ.ReadINT_LE(0x14, map_stream);
            int file_table_offset = DATA_READ.ReadINT_LE(0x2D0, map_stream);
            int table_start       = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;


            int path_start = 0;

            for (int i = 0; ; i++)
            {
                int tag_table_REF = table_start + 0x10 * i;

                if (tag_table_REF > table_size + table_start)
                {
                    break;
                }

                string type        = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream);
                int    datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream);
                string path        = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream);

                if (datum_index != -1)
                {
                    tag_info temp = new tag_info();

                    temp.datum_index = datum_index;
                    temp.type        = type;
                    temp.file_loc    = path;

                    ret.Add(temp);

                    //ugh! is basically the last tag
                    if (type.CompareTo("ugh!") == 0)
                    {
                        break;
                    }

                    path_start += path.Length + 1;
                }
            }
            map_stream.Close();

            return(ret);
        }
Exemplo n.º 9
0
        /// <summary>
        /// use to rebase current meta data to a newer memory address(affects reflexive,extended and data ref fields only)
        /// </summary>
        /// <param name="new_base">the new memory address to which the meta has to rebased</param>
        public void Rebase_meta(int new_base)
        {
            //first rebase reflexive fields
            foreach (int off in ref_reflexive)
            {
                int old_mem_addr = DATA_READ.ReadINT_LE(off + 4, data);
                int new_mem_addr = new_base + (old_mem_addr - mem_off);

                DATA_READ.WriteINT_LE(new_mem_addr, off + 4, data);
            }
            //then we rebase all the dataref fields
            foreach (int off in ref_data)
            {
                int old_mem_addr = DATA_READ.ReadINT_LE(off + 4, data);
                int new_mem_addr = new_base + (old_mem_addr - mem_off);

                DATA_READ.WriteINT_LE(new_mem_addr, off + 4, data);
            }
            //we venture in extended meta if it is even concerned
            if (list_extended != null)
            {
                //for extended meta stuff we are gonna first rebase the extended meta(s) first and set the offsets accordingly
                //well extende meta are gonna follow meta one by one
                int extended_new_base = new_base + size;

                List <int> key_mems = list_extended.Keys.ToList <int>();
                //Rebase extended meta
                foreach (int temp_key in key_mems)
                {
                    extended_meta temp_meta = list_extended[temp_key];
                    temp_meta.Rebase_meta(extended_new_base);

                    extended_new_base += temp_meta.Get_Total_size();
                }
                //now lets update the offsets with the newer values
                List <int> extend_off = ref_extended.Keys.ToList <int>();
                foreach (int temp_off in extend_off)
                {
                    int           extend_mem_addr = ref_extended[temp_off];
                    extended_meta temp_ext        = list_extended[extend_mem_addr];

                    int new_mem_addr = temp_ext.Get_mem_addr();

                    DATA_READ.WriteINT_LE(new_mem_addr, temp_off + 4, data);
                }
            }

            //update the base to which meta has been compiled
            mem_off = new_base;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialises tree view upon opening a map file
        /// </summary>
        void initialize_treeview()
        {
            treeView1.Nodes.Clear();

            int path_start = 0;

            for (int i = 0; ; i++)
            {
                int tag_table_REF = table_start + 0x10 * i;

                if (tag_table_REF > table_size + table_start)
                {
                    break;
                }

                string type        = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream);
                int    datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream);
                string path        = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream);

                if (datum_index != -1)
                {
                    //lets check the mem addrs validity before adding it to the list
                    int mem_addr = DATA_READ.ReadINT_LE(tag_table_REF + (datum_index & 0xffff) * 0x10 + 8, map_stream);

                    if (mem_addr != 0x0)
                    {
                        datum_list.Add(datum_index);//lets add this to the list
                    }
                    if (treeView1.Nodes.IndexOfKey(type) == -1)
                    {
                        treeView1.Nodes.Add(type, type);
                    }
                    int index = treeView1.Nodes.IndexOfKey(type);
                    //HEX Values contains ABCDEF
                    treeView1.Nodes[index].Nodes.Add(tag_table_REF.ToString(), path);

                    //add this stuff to the SID list
                    SID_list.Add(datum_index, path);

                    //ugh! is basically the last tag
                    if (type.CompareTo("ugh!") == 0)
                    {
                        break;
                    }

                    path_start += path.Length + 1;
                }
            }
        }
Exemplo n.º 11
0
        Dictionary <int, extended_meta> list_extended; //<mem_off,extended_meta obj>,a dictionary containing the extended meta by their memory address to prevent redundancy.

        /// <summary>
        /// extended meta is similar to the meta
        /// </summary>
        /// <param name="mem_address"></param>
        /// <param name="size">the total size of the extended meta containg all occurences</param>
        /// <param name="count"></param>
        /// <param name="plugin"></param>
        /// <param name="sr"></param>
        public extended_meta(int mem_address, int size, int count, plugins_field plugin, StreamReader sr)
        {
            this.mem_off    = mem_address;
            this.size       = size;
            this.plugin     = plugin;
            this.map_stream = sr;
            this.entry_size = size / count;

            //some meta reading prologue
            int table_off    = DATA_READ.ReadINT_LE(0x10, map_stream);
            int table_size   = DATA_READ.ReadINT_LE(0x14, map_stream);
            int table_start  = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;
            int scnr_off     = table_off + table_size;
            int scnr_memaddr = DATA_READ.ReadINT_LE(table_start + 0x8, map_stream);//scnr tag index is 0x0(mostly)

            //read the extended_meta from the map
            data = new byte[this.size];

            if (!DATA_READ.Check_shared(sr))
            {
                //normal map
                map_stream.BaseStream.Position = scnr_off + (mem_off - scnr_memaddr);
            }
            else
            {
                //shared map
                map_stream.BaseStream.Position = scnr_off + (mem_off - 0x3c000);
                //0x3c000 is a hardcoded value in blam engine
            }

            map_stream.BaseStream.Read(data, 0, this.size);

            //lets initialise some lists and dictionaries
            ref_data      = new List <int>();
            ref_tags      = new List <int>();
            ref_stringID  = new List <int>();
            ref_reflexive = new List <int>();
            ref_extended  = new Dictionary <int, int>();
            list_extended = new Dictionary <int, extended_meta>();
            ref_WCtags    = new List <int>();

            //we we have loop through the extended meta stuff
            for (int i = 0; i < count; i++)
            {
                List_deps(i * entry_size, plugin);
            }
        }
Exemplo n.º 12
0
        //Tag extraction stuff
        private void extractTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (map_loaded)
            {
                if (treeView1.SelectedNode != null)
                {
                    //Extraction for a single tag
                    if (treeView1.SelectedNode.Name.CompareTo(treeView1.SelectedNode.Text) != 0)
                    {
                        int tag_table_ref = Int32.Parse(treeView1.SelectedNode.Name);
                        int datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);

                        map_stream.Close();
                        obj.Halo2_ExtractTagCache(datum_index, DATA_READ.Read_File_from_file_location(map_name));
                        map_stream = new StreamReader(map_name);
                    }
                    else
                    {
                        //Extraction for a whole same bunch of tags
                        List <int> DatumsList = new List <int>();
                        foreach (TreeNode tn in treeView1.SelectedNode.Nodes)
                        {
                            int tag_table_ref = Int32.Parse(tn.Name);
                            int datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);
                            DatumsList.Add(datum_index);
                        }

                        map_stream.Close();

                        int index = 1;

                        foreach (int i in DatumsList)
                        {
                            obj.Halo2_ExtractTagCache(i, DATA_READ.Read_File_from_file_location(map_name));

                            progressBar1.Value = (index++) * 100 / DatumsList.Count;//update the progress bar
                        }

                        map_stream = new StreamReader(map_name);
                    }
                }
            }
            progressBar1.Value = 0;//reset the progress bar
        }
Exemplo n.º 13
0
        private void extractTagToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (map_loaded)
            {
                Dictionary <int, string> Extractlist = new Dictionary <int, string>();
                if (treeView1.SelectedNode != null)
                {
                    //Extraction for a single tag
                    if (treeView1.SelectedNode.Name.CompareTo(treeView1.SelectedNode.Text) != 0)
                    {
                        int tag_table_ref = Int32.Parse(treeView1.SelectedNode.Name);
                        int datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);
                        Extractlist.Add(datum_index, treeView1.SelectedNode.Text);
                    }
                    else
                    {
                        //Extraction for a whole same bunch of tags

                        foreach (TreeNode tn in treeView1.SelectedNode.Nodes)
                        {
                            int tag_table_ref = Int32.Parse(tn.Name);
                            int datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);
                            Extractlist.Add(datum_index, tn.Text);
                        }
                    }
                    TagExtractor ob = new TagExtractor(Extractlist, false);
                    ob.Show();
                }
                else
                {
                    MessageBox.Show("Select a Tag First!", "CRASHED!!", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("No Map Loaded ,Reload it", "Error!!", MessageBoxButtons.OK);
            }
        }
Exemplo n.º 14
0
        void DumpTagList()
        {
            if (treeView1.SelectedNode.Nodes.Count != 0)
            {
                string[] x = new string[treeView1.SelectedNode.Nodes.Count];
                int      i = 0;
                foreach (TreeNode tn in treeView1.SelectedNode.Nodes)
                {
                    int tag_table_ref = Int32.Parse(tn.Name);
                    int datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);

                    string Name = System.IO.Path.GetFileNameWithoutExtension(tn.Text);

                    x[i++] = Name + "," + "0x" + datum_index.ToString("X");;
                }

                File.WriteAllLines(Application.StartupPath + @"\TagsList.txt", x);
            }
            else
            {
                MessageBox.Show("Select Tag Nodes First", "Error", MessageBoxButtons.OK);
            }
        }
Exemplo n.º 15
0
        private void DumpShadersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            {
                if (map_loaded)
                {
                    FolderBrowserDialog fbd = new FolderBrowserDialog();
                    fbd.ShowNewFolderButton = true;

                    MessageBox.Show("Select a directory to export the shader dump. Preferably an empty folder.");


                    if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        string tags_directory = fbd.SelectedPath;

                        StreamWriter log = new StreamWriter(tags_directory + '\\' + map_name.Substring(map_name.LastIndexOf('\\') + 1) + ".shader_log");

                        foreach (TreeNode element in treeView1.Nodes["shad"].Nodes)
                        {
                            int table_ref = Int32.Parse(element.Name);
                            int datum     = DATA_READ.ReadINT_LE(table_ref + 4, map_stream);
                            int mem_off   = DATA_READ.ReadINT_LE(table_ref + 8, map_stream);
                            int size      = DATA_READ.ReadINT_LE(table_ref + 0xc, map_stream);

                            meta meta_obj = new meta(datum, SID_list[datum], map_stream);
                            meta_obj.Rebase_meta(0x0);

                            if (meta_obj.Get_Total_size() != 0)
                            {
                                byte[] meta_data = meta_obj.Generate_meta_file();

                                string text_path = tags_directory + '\\' + SID_list[datum] + ".txt";

                                //lets create our directory
                                System.IO.Directory.CreateDirectory(DATA_READ.ReadDirectory_from_file_location(text_path));

                                StreamWriter sw = new StreamWriter(text_path);

                                //supoosing each shad contains only one Post process block element
                                int PPB_off = DATA_READ.ReadINT_LE(0x24, meta_data);

                                int stem_datum   = DATA_READ.ReadINT_LE(PPB_off, meta_data);
                                int bitmap_count = DATA_READ.ReadINT_LE(PPB_off + 0x4, meta_data);
                                int bitmapB_off  = DATA_READ.ReadINT_LE(PPB_off + 0x8, meta_data);

                                //write the stemp path
                                string out_temp;
                                if (stem_datum != 0 && stem_datum != -1)
                                {
                                    if (SID_list.TryGetValue(stem_datum, out out_temp))
                                    {
                                        sw.WriteLine(SID_list[stem_datum]);
                                    }
                                    else
                                    {
                                        sw.WriteLine("---");
                                    }
                                }
                                for (int i = 0; i < bitmap_count; i++)
                                {
                                    int bitm_datum = DATA_READ.ReadINT_LE(bitmapB_off + i * 0xC, meta_data);

                                    if (bitm_datum != 0 && bitm_datum != -1)
                                    {
                                        if (SID_list.TryGetValue(bitm_datum, out out_temp))
                                        {
                                            if (SID_list[bitm_datum] == "")
                                            {
                                                sw.WriteLine(" ");
                                            }
                                            else
                                            {
                                                sw.WriteLine(SID_list[bitm_datum]);
                                            }
                                        }
                                        else
                                        {
                                            sw.WriteLine("---");
                                        }
                                    }
                                    else
                                    {
                                        sw.WriteLine(" ");
                                    }
                                }

                                log.WriteLine(SID_list[datum] + ".txt");

                                sw.Close();
                            }
                            else
                            {
                                log.WriteLine("---");
                            }
                        }
                        log.Close();
                        MessageBox.Show("Extraction Complete");
                    }
                }
                else
                {
                    MessageBox.Show("Load a map first");
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// a function that updates the datum indexes acoording to the list supplied
        /// </summary>
        /// <param name="tag_list"></param>
        /// <returns>return a log about different encounters</returns>
        public string Update_datum_indexes(List <injectRefs> tag_list)
        {
            string log = "\nUPDATE DATUM : " + path;

            //we loop through each offset

            //Updating TagRefs
            foreach (int temp_off in ref_tags)
            {
                int temp_old_datum = DATA_READ.ReadINT_LE(temp_off + 4, data);
                //next we loop through each list
                bool sucess = false;

                foreach (injectRefs temp_ref in tag_list)
                {
                    int old_datum = temp_ref.old_datum;
                    int new_datum = temp_ref.new_datum;

                    if (old_datum == temp_old_datum)
                    {
                        //we found a match
                        if (!sucess)
                        {
                            DATA_READ.WriteINT_LE(new_datum, temp_off + 4, data);
                            log   += "\nSuccesfully refered " + temp_old_datum.ToString("X") + " to " + new_datum.ToString("X");
                            sucess = true;
                        }
                        else
                        {
                            log += "\nMultiple occurences of old datum " + old_datum + " has been found";
                        }
                    }
                }
                if (!sucess)
                {
                    log += "\nCouldnot find reference to " + temp_old_datum.ToString("X");
                }
            }
            //Updating WCtagRefs
            foreach (int temp_off in ref_WCtags)
            {
                int  temp_old_datum = DATA_READ.ReadINT_LE(temp_off, data);
                bool sucess         = false;

                foreach (injectRefs temp_ref in tag_list)
                {
                    int old_datum = temp_ref.old_datum;
                    int new_datum = temp_ref.new_datum;

                    if (old_datum == temp_old_datum)
                    {
                        //we found a match
                        if (!sucess)
                        {
                            DATA_READ.WriteINT_LE(new_datum, temp_off, data);
                            log   += "\nSuccesfully refered " + temp_old_datum.ToString("X") + " to " + new_datum.ToString("X");
                            sucess = true;
                        }
                        else
                        {
                            log += "\nMultiple occurences of old datum " + old_datum + " has been found";
                        }
                    }
                }
                if (!sucess)
                {
                    log += "\nCouldnot find reference to " + temp_old_datum.ToString("X");
                }
            }

            return(log);
        }
Exemplo n.º 17
0
        /// <summary>
        /// a function to fill in all the Lists and Dictionaries
        /// </summary>
        /// <param name="off">the starting offset where the stuff is being read</param>
        /// <param name="fields">the concerned field(s) in that section</param>
        void List_deps(int off, plugins_field fields)
        {
            List <int> temp = fields.Get_tag_ref_list();

            //first we look for tag_refs and add them
            foreach (int i in temp)
            {
                int Toff = off + i;//it contains type
                //we add this off to the list if it doesnt contain the off already
                if (!ref_tags.Contains(Toff))
                {
                    ref_tags.Add(Toff);
                }
            }
            //then we look for data_refs and add them
            temp = fields.Get_data_ref_list();
            foreach (int i in temp)
            {
                int Toff = off + i;
                //we add this off to the list if it doesnt contain the off already
                if (!ref_data.Contains(Toff))
                {
                    ref_data.Add(Toff);
                }
            }
            //then we look for stringId refs and add them
            temp = fields.Get_stringID_ref_list();
            foreach (int i in temp)
            {
                int Toff = off + i;
                //we add this off to the list if it doesnt contain the off already
                if (!ref_stringID.Contains(Toff))
                {
                    ref_stringID.Add(Toff);
                }
            }
            //now we look into reflexive fields and extended meta and add them accordingly
            List <plugins_field> Ptemp = fields.Get_reflexive_list();

            foreach (plugins_field i_Pfield in Ptemp)
            {
                int Toff = off + i_Pfield.Get_offset();//field table off contains count

                int count         = DATA_READ.ReadINT_LE(Toff, data);
                int field_memaddr = DATA_READ.ReadINT_LE(Toff + 4, data);
                int entry_size    = i_Pfield.Get_entry_size(); //entry_size

                int field_off = field_memaddr - mem_off;       //its the offset of the field from the starting of the meta data

                if (count > 0)
                {
                    //now we check whether its inside meta or a case of extended meta
                    if ((field_memaddr >= mem_off) && (field_off < size))
                    {
                        //inside meta
                        //we add this off which contains reflexive table to the list if it doesnt contain the off already
                        if (!ref_reflexive.Contains(Toff))
                        {
                            ref_reflexive.Add(Toff);
                            //after adding it to the list we look into them,recursively
                            for (int j = 0; j < count; j++)
                            {
                                List_deps(field_off + j * entry_size, i_Pfield);
                            }
                        }
                    }
                    else
                    {
                        //extended meta
                        //we add this off to the list if it doesnt contain the off already
                        if (!ref_extended.ContainsKey(Toff))
                        {
                            ref_extended.Add(Toff, field_memaddr);
                            //now we create and add extended_meta to the list if it isnt already there
                            if (!list_extended.ContainsKey(field_memaddr))
                            {
                                extended_meta temp_extend = new extended_meta(field_memaddr, entry_size * count, count, i_Pfield, map_stream);
                                list_extended.Add(field_memaddr, temp_extend);
                            }
                            //we dont need to look into them as extended meta does it for us
                        }
                    }
                }
            }
            //now we go for withClass attribute tagRefs,they are a bit different as they only contain the datum index of the refered tag
            temp = fields.Get_WCtag_ref_list();
            foreach (int i in temp)
            {
                int Toff = off + i;
                //we add this off to the list if it doesnt contain the off already
                if (!ref_WCtags.Contains(Toff))
                {
                    ref_WCtags.Add(Toff);
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// a function to fill in all the Lists and Dictionaries
        /// </summary>
        /// <param name="off">the starting offset where the stuff is being read</param>
        /// <param name="fields">the concerned field(s) in that section</param>
        void List_deps(int off, plugins_field fields)
        {
            List <int> temp = fields.Get_tag_ref_list();

            //first we look for tag_refs and add them
            foreach (int i in temp)
            {
                int Toff = off + i;//it contains type
                //we add this off to the list if it doesnt contain the off already
                if (!ref_tags.Contains(Toff))
                {
                    ref_tags.Add(Toff);
                }
            }
            //then we look for data_refs and add them
            temp = fields.Get_data_ref_list();
            foreach (int i in temp)
            {
                int Toff = off + i;
                //we add this off to the list if it doesnt contain the off already
                if (!ref_data.Contains(Toff))
                {
                    ref_data.Add(Toff);
                }
            }
            //then we look for stringId refs and add them
            temp = fields.Get_stringID_ref_list();
            foreach (int i in temp)
            {
                int Toff = off + i;
                //we add this off to the list if it doesnt contain the off already
                if (!ref_stringID.Contains(Toff))
                {
                    ref_stringID.Add(Toff);
                }
            }
            //now we look into reflexive fields and extended meta and add them accordingly
            List <plugins_field> Ptemp = fields.Get_reflexive_list();

            foreach (plugins_field i_Pfield in Ptemp)
            {
                int Toff = off + i_Pfield.Get_offset();//field table off contains count

                int count         = DATA_READ.ReadINT_LE(Toff, data);
                int field_memaddr = DATA_READ.ReadINT_LE(Toff + 4, data);
                int entry_size    = i_Pfield.Get_entry_size(); //entry_size

                int field_off = field_memaddr - mem_off;       //its the offset of the field from the starting of the meta data

                if (count > 0)
                {
                    //now we check whether its inside meta or a case of extended meta
                    if ((field_memaddr >= mem_off) && (field_off < size))
                    {
                        //inside meta
                        //we add this off which contains reflexive table to the list if it doesnt contain the off already
                        if (!ref_reflexive.Contains(Toff))
                        {
                            ref_reflexive.Add(Toff);
                            //after adding it to the list we look into them,recursively
                            for (int j = 0; j < count; j++)
                            {
                                List_deps(field_off + j * entry_size, i_Pfield);
                            }
                        }
                    }
                    else
                    {
                        //extended meta(IN SUCCESSFULL RUN ,EXTENDED META ONLY APPEARS ONLY WHEN WE READ FROM A MAP)

                        //but first we check whether we are reading meta from a map,or an exracted file,its rather easy
                        if (list_extended != null)
                        {
                            //we add this off to the list if it doesnt contain the off already
                            if (!ref_extended.ContainsKey(Toff))
                            {
                                ref_extended.Add(Toff, field_memaddr);
                                //now we create and add extended_meta to the list if it isnt already there
                                if (!list_extended.ContainsKey(field_memaddr))
                                {
                                    extended_meta temp_extend = new extended_meta(field_memaddr, entry_size * count, count, i_Pfield, map_stream);
                                    list_extended.Add(field_memaddr, temp_extend);
                                }
                                //we dont need to look into them as extended meta does it for us
                            }
                        }
                        else
                        {
                            //the program will only reach here when u try to use an extended meta on meta file.
                            //any meta which i extract from a map file have all issues of extended_meta fixed.
                            throw new Exception("Meta file " + path + "." + type + " is broken.\nEither debug the extraction proceedure or fix the meta file");
                        }
                    }
                }
            }
            //now we go for withClass attribute tagRefs,they are a bit different as they only contain the datum index of the refered tag
            temp = fields.Get_WCtag_ref_list();
            foreach (int i in temp)
            {
                int Toff = off + i;
                //we add this off to the list if it doesnt contain the off already
                if (!ref_WCtags.Contains(Toff))
                {
                    ref_WCtags.Add(Toff);
                }
            }
        }