public List <MetaHeader_DataBlock> GetMetaHeaderDataBlocksMapped(bool FindVoids, bool FindIdents, bool FindChildren)
        {
            int num;

            Plugin_Scanning_Regions = new List <PluginScanningRegion>();
            Plugin_Data_Blocks      = new List <PluginDataBlock>();
            MetaHeader_Data_Blocks  = new List <MetaHeader_DataBlock>();
            Tag_Idents = new List <Tag_Ident>();
            Tag_Voids  = new List <Tag_Void>();
            PluginScanningRegion region = new PluginScanningRegion {
                Offset = Map.Map_Header.RawTableOffset + Map.Map_Header.RawTableSize
            };

            region.Size = Map.Index_Header.tagInfoHeaderOffset - region.Offset;
            Plugin_Scanning_Regions.Add(region);
            PluginScanningRegion region2 = new PluginScanningRegion {
                Offset = (Map.Map_Header.indexOffset + 0x2c) + ExtraFunctions.CalculatePadding(Map.Map_Header.indexOffset + 0x2c, 0x1000)
            };

            region2.Size = new LocaleHandler(Map).LocaleTables[0].LocaleTableIndexOffset - region2.Offset;
            Plugin_Scanning_Regions.Add(region2);
            foreach (HaloMap.TagItem item in Map.Index_Items)
            {
                MetaHeader_DataBlock block = new MetaHeader_DataBlock(item);
                Plugin_Data_Blocks.Add(block);
                MetaHeader_Data_Blocks.Add(block);
                Application.DoEvents();
            }
            Map.OpenIO();
            for (num = 0; num < Plugin_Scanning_Regions.Count; num++)
            {
                PluginScanningRegion region3 = Plugin_Scanning_Regions[num];
                Map.IO.In.BaseStream.Position = region3.Offset;
                while (Map.IO.In.BaseStream.Position < (region3.Offset + region3.Size))
                {
                    double num2    = ((Map.IO.In.BaseStream.Position - region3.Offset) / ((double)region3.Size)) * 100.0;
                    int    count   = Map.IO.In.ReadInt32();
                    int    pointer = Map.IO.In.ReadInt32() - Map.Map_Header.mapMagic;
                    int    num5    = Map.IO.In.ReadInt32();
                    if (((num5 == 0) && ((count > 0) && (count < 0x927c0))) && PointerIsInRegions(count, pointer))
                    {
                        Reflexive_DataBlock block2 = new Reflexive_DataBlock {
                            Count   = count,
                            Offset  = (int)(Map.IO.In.BaseStream.Position - 12L),
                            Pointer = pointer
                        };
                        Plugin_Data_Blocks.Add(block2);
                    }
                    else if ((PointerIsInRegions(pointer + Map.Map_Header.mapMagic, num5 - Map.Map_Header.mapMagic) && ((pointer + Map.Map_Header.mapMagic) > 0)) && ((pointer + Map.Map_Header.mapMagic) < 0x927c0))
                    {
                        Stream baseStream = Map.IO.In.BaseStream;
                        baseStream.Position -= 8L;
                    }
                    else if (FindIdents)
                    {
                        Stream stream2 = Map.IO.In.BaseStream;
                        stream2.Position -= 12L;
                        string str     = Map.IO.In.ReadAsciiString(4);
                        Stream stream3 = Map.IO.In.BaseStream;
                        stream3.Position += 8L;
                        int num6            = Map.IO.In.ReadInt32();
                        int tagIndexByIdent = Map.GetTagIndexByIdent(num6);
                        if ((tagIndexByIdent != -1) && (Map.Index_Items[tagIndexByIdent].Class == str))
                        {
                            Tag_Ident ident = new Tag_Ident {
                                Offset = ((int)Map.IO.In.BaseStream.Position) - 0x10
                            };
                            Tag_Idents.Add(ident);
                        }
                        else
                        {
                            Stream stream4 = Map.IO.In.BaseStream;
                            stream4.Position -= 12L;
                            if (FindVoids)
                            {
                                Stream stream5 = Map.IO.In.BaseStream;
                                stream5.Position -= 4L;
                                uint num8  = Map.IO.In.ReadUInt32();
                                int  num9  = Map.IO.In.ReadInt32();
                                int  num10 = Map.IO.In.ReadInt32();
                                pointer = Map.IO.In.ReadInt32() - Map.Map_Header.mapMagic;
                                int num11 = Map.IO.In.ReadInt32();
                                if (((PointerIsInRegions((int)num8, pointer) && (num8 > 0)) && ((num9 == 0) && (num10 == 0))) && (num11 == 0))
                                {
                                    Tag_Void @void = new Tag_Void {
                                        Offset = ((int)Map.IO.In.BaseStream.Position) - 20
                                    };
                                    Tag_Voids.Add(@void);
                                }
                                else
                                {
                                    Stream stream6 = Map.IO.In.BaseStream;
                                    stream6.Position -= 0x10L;
                                }
                            }
                            else
                            {
                                Stream stream7 = Map.IO.In.BaseStream;
                                stream7.Position -= 4L;
                            }
                        }
                    }
                }
            }
            Map.CloseIO();
            for (num = 0; num < Plugin_Data_Blocks.Count; num++)
            {
                CalculateStructureSize(Plugin_Data_Blocks[num]);
            }
            if (FindChildren)
            {
                for (num = 0; num < Plugin_Data_Blocks.Count; num++)
                {
                    MapChildren(Plugin_Data_Blocks[num]);
                }
            }
            return(MetaHeader_Data_Blocks);
        }
示例#2
0
        public List <MetaHeader_DataBlock> GetMetaHeaderDataBlocksMapped(bool FindIdents, bool FindChildren)
        {
            //Let's initialize our lists.
            Plugin_Scanning_Regions = new List <PluginScanningRegion>();
            Plugin_Data_Blocks      = new List <PluginDataBlock>();
            MetaHeader_Data_Blocks  = new List <MetaHeader_DataBlock>();
            Tag_Idents = new List <Tag_Ident>();

            //Let's make our first region
            PluginScanningRegion pluginScanRegion = new PluginScanningRegion();

            pluginScanRegion.Offset = Map.MapHeader.RawTableOffset + Map.MapHeader.RawTableSize;
            pluginScanRegion.Size   = Map.IndexHeader.tagInfoHeaderOffset - pluginScanRegion.Offset;
            //Add it to our list
            Plugin_Scanning_Regions.Add(pluginScanRegion);

            //Let's make our second region
            PluginScanningRegion pluginScanRegion2 = new PluginScanningRegion();

            pluginScanRegion2.Offset = Map.MapHeader.indexOffset + 40 + ExtraFunctions.CalculatePadding(Map.MapHeader.indexOffset + 40, 0x1000);
            pluginScanRegion2.Size   = new LocaleHandler(Map).LocaleTables[0].LocaleTableIndexOffset - pluginScanRegion2.Offset;
            //Add it to our list
            Plugin_Scanning_Regions.Add(pluginScanRegion2);

            //Loop through each of our tags
            foreach (HaloMap.TagItem tagItem in Map.IndexItems)
            {
                //Initialize our metaheader_datablock
                MetaHeader_DataBlock mhdb = new MetaHeader_DataBlock(tagItem);

                //Add it to our list
                Plugin_Data_Blocks.Add(mhdb);
                MetaHeader_Data_Blocks.Add(mhdb);

                //Unfreeze
                Application.DoEvents();
            }

            //Open our IO
            Map.OpenIO();



            //Loop through each scan region
            for (int i = 0; i < Plugin_Scanning_Regions.Count; i++)
            {
                //Set our plugin scanning region
                PluginScanningRegion scanRegion = Plugin_Scanning_Regions[i];

                //Make our IO go to the scan regions position
                Map.IO.In.BaseStream.Position = scanRegion.Offset;

                while (Map.IO.In.BaseStream.Position < (scanRegion.Offset + scanRegion.Size))
                {
                    double percent = (((double)Map.IO.In.BaseStream.Position - scanRegion.Offset) / (double)scanRegion.Size) * 100;
                    //Possible count
                    int count   = Map.IO.In.ReadInt32();
                    int pointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic;
                    int zeros   = Map.IO.In.ReadInt32();

                    //If our zero data = 0
                    if (zeros == 0)
                    {
                        //If our count is valid.
                        if (count > 0 && count < 600000)
                        {
                            //If our pointer is valid.
                            if (PointerIsInRegions(count, pointer))
                            {
                                //Let's initialize our reflexive data block
                                Reflexive_DataBlock rdb = new Reflexive_DataBlock();
                                rdb.Count   = count;
                                rdb.Offset  = (int)(Map.IO.In.BaseStream.Position - 12);
                                rdb.Pointer = pointer;

                                //Add it to our list
                                Plugin_Data_Blocks.Add(rdb);

                                //Go to our FoundAReflexive location
                                goto FoundAReflexive;
                            }
                        }
                    }
                    //Determine how much to jump back
                    if (PointerIsInRegions(pointer + Map.MapHeader.mapMagic, zeros - Map.MapHeader.mapMagic) && pointer + Map.MapHeader.mapMagic > 0 && pointer + Map.MapHeader.mapMagic < 600000)
                    {
                        //There's a potential reflexive 8 bytes back!
                        Map.IO.In.BaseStream.Position -= 8;
                    }
                    else
                    {
                        //If we are to find idents.
                        if (FindIdents)
                        {
                            //Didn't find anything. Go back and scan for idents
                            Map.IO.In.BaseStream.Position -= 12;

                            //Read our 4 values
                            string tagClass = Map.IO.In.ReadAsciiString(4);

                            //Skip 4 bytes
                            Map.IO.In.BaseStream.Position += 8;

                            //Read our id
                            int ident = Map.IO.In.ReadInt32();

                            //Get our index
                            int index = Map.GetTagIndexByIdent(ident);

                            //If our index isn't -1
                            if (index != -1)
                            {
                                //If our tag's class == tagclass
                                if (Map.IndexItems[index].Class == tagClass)
                                {
                                    //Initialize our new ident
                                    Tag_Ident id = new Tag_Ident();
                                    //Set our offset.
                                    id.Offset = ((int)Map.IO.In.BaseStream.Position - 16);
                                    //Add it to our list
                                    Tag_Idents.Add(id);
                                    //Go to our found ident spot
                                    goto FoundIdent;
                                }
                            }
                            //We didn't find an ident. Go back
                            Map.IO.In.BaseStream.Position -= 12;

                            //Where we go if we found an ident
                            FoundIdent :;
                        }
                        else
                        {
                            //If we aren't to find idents.
                            //Go 4 bytes back.
                            Map.IO.In.BaseStream.Position -= 4;
                        }
                    }
                    //Where we'll jump to if we found a reflex, so we dont go back 8 bytes for no reason, wasting time.
                    FoundAReflexive :;
                }
            }

            //Close our IO
            Map.CloseIO();

            //Let's calculate our sizes.. Loop through each data block
            for (int i = 0; i < Plugin_Data_Blocks.Count; i++)
            {
                CalculateStructureSize(Plugin_Data_Blocks[i]);
            }

            //If we are to map children.
            if (FindChildren)
            {
                //Let's map our children. Loop through each plugin data block
                for (int i = 0; i < Plugin_Data_Blocks.Count; i++)
                {
                    MapChildren(Plugin_Data_Blocks[i]);
                }
            }

            //Return our meta blocks
            return(MetaHeader_Data_Blocks);
        }