public void MapPluginWithPDBList(List <mValue> mValueList, List <PluginDataBlock> PDBList, int chunkSize, int unknownStructCount)
 {
     for (int i = 0; i < chunkSize; i += 4)
     {
         List <PluginDataBlock> pDBList = new List <PluginDataBlock>();
         foreach (PluginDataBlock block in PDBList)
         {
             foreach (Reflexive_DataBlock block2 in block.Reflexive_Data_Blocks)
             {
                 if (block2.Offset_In_Parent == i)
                 {
                     pDBList.Add(block2);
                 }
             }
         }
         if (pDBList.Count != 0)
         {
             mTagBlock item = new mTagBlock {
                 Name = "Unknown " + unknownStructCount
             };
             unknownStructCount++;
             item.Offset  = i;
             item.Size    = FindMostLikelySizeForChunk(pDBList);
             item.Visible = false;
             mValueList.Add(item);
             MapPluginWithPDBList(item.Values, pDBList, item.Size, unknownStructCount);
             i += 8;
             continue;
         }
         bool flag  = false;
         bool flag2 = false;
         foreach (PluginDataBlock block in PDBList)
         {
             foreach (Tag_Ident ident in block.Tag_Idents)
             {
                 if (ident.Offset_In_Parent == i)
                 {
                     mTagReference reference = new mTagReference {
                         Name    = "Unknown",
                         Offset  = i,
                         Visible = false
                     };
                     mValueList.Add(reference);
                     i   += 12;
                     flag = true;
                     break;
                 }
             }
             if (flag)
             {
                 break;
             }
             foreach (Tag_Void @void in block.Tag_Voids)
             {
                 if (@void.Offset_In_Parent == i)
                 {
                     mTagData data = new mTagData {
                         Name    = "Unknown",
                         Offset  = i,
                         Visible = false
                     };
                     mValueList.Add(data);
                     i    += 0x10;
                     flag2 = true;
                     break;
                 }
             }
             if (flag2)
             {
                 break;
             }
         }
         if (!flag && !flag2)
         {
             if ((chunkSize - i) >= 4)
             {
                 mUndefined undefined = new mUndefined {
                     Name    = "Unknown",
                     Offset  = i,
                     Visible = false
                 };
                 mValueList.Add(undefined);
             }
             else if ((chunkSize - i) >= 2)
             {
                 mInt16 num2 = new mInt16 {
                     Name    = "Unknown",
                     Offset  = i,
                     Visible = false
                 };
                 mValueList.Add(num2);
                 i -= 2;
             }
             else if ((chunkSize - i) == 1)
             {
                 mByte num3 = new mByte {
                     Name    = "Unknown",
                     Offset  = i,
                     Visible = false
                 };
                 mValueList.Add(num3);
             }
         }
     }
 }
Esempio n. 2
0
        private mValue ReadNode(XmlNode xmlNode)
        {
            //Indiciate what type of value this is.
            switch (xmlNode.Name.ToLower())
            {
            case "reflexive":
            case "structure":
            case "reflex":
            case "struct":
            {
                //Initialize our instance of a reflexive.
                mReflexive reflexive = new mReflexive();
                //Retrieve the structure's name.
                reflexive.Name = xmlNode.Attributes["name"].Value;
                //Retrieve its offset within its parent.
                reflexive.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Retrieve its chunk size.
                reflexive.Size = int.Parse(xmlNode.Attributes["size"].Value);
                //Retrieve its visibility flag.
                reflexive.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);

                //Initialize the value list for the reflexive
                reflexive.Values = new List <mValue>();

                //Recursively add any nodes that belong to it.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //Get our returned value.
                    mValue returnedVal = ReadNode(xmlNode.ChildNodes[i]);

                    //If its not some unknown node that couldnt be read...
                    if (returnedVal.Attributes != mValue.ObjectAttributes.None)
                    {
                        //Then add it to this reflexive value list.
                        reflexive.Values.Add(returnedVal);
                    }
                }
                //Return our reflexive
                return(reflexive);
            }

            case "tagref":
            case "tag":
            {
                //Initialize our instance of TagRef
                mTagRef tagRef = new mTagRef();
                //Assign the name
                tagRef.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                tagRef.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                tagRef.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(tagRef);
            }

            case "ident":
            case "id":
            case "tagid":
            {
                //Initialize our instance of ident
                mIdent ident = new mIdent();
                //Assign the name
                ident.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                ident.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                ident.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(ident);
            }

            case "sid":
            case "stringid":
            case "stringidentifier":
            {
                //Initialize our instance of string
                mStringID stringID = new mStringID();
                //Assign the name
                stringID.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                stringID.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                stringID.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(stringID);
            }

            case "bitmask8":
            case "bit8":
            {
                //Initialize our instance of bitmask8
                mBitmask8 bitmask8 = new mBitmask8();
                //Assign the name
                bitmask8.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                bitmask8.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                bitmask8.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the bitOption list.
                bitmask8.Options = new List <mBitOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mBitOption bitOption = new mBitOption();
                        //Get the name of the bit
                        bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        bitmask8.Options.Add(bitOption);
                    }
                }
                //return the value
                return(bitmask8);
            }

            case "bitmask16":
            case "bit16":
            {
                //Initialize our instance of bitmask16
                mBitmask16 bitmask16 = new mBitmask16();
                //Assign the name
                bitmask16.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                bitmask16.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                bitmask16.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the bitOption list.
                bitmask16.Options = new List <mBitOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mBitOption bitOption = new mBitOption();
                        //Get the name of the bit
                        bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        bitmask16.Options.Add(bitOption);
                    }
                }
                //return the value
                return(bitmask16);
            }

            case "bitmask32":
            case "bit32":
            {
                //Initialize our instance of bitmask32
                mBitmask32 bitmask32 = new mBitmask32();
                //Assign the name
                bitmask32.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                bitmask32.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                bitmask32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the bitOption list.
                bitmask32.Options = new List <mBitOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mBitOption bitOption = new mBitOption();
                        //Get the name of the bit
                        bitOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        bitOption.BitIndex = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        bitmask32.Options.Add(bitOption);
                    }
                }
                //return the value
                return(bitmask32);
            }

            case "enum8":
            {
                //Initialize our instance of enum8
                mEnum8 enum8 = new mEnum8();
                //Assign the name
                enum8.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                enum8.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                enum8.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the enumOption list.
                enum8.Options = new List <mEnumOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mEnumOption enumOption = new mEnumOption();
                        //Get the name of the bit
                        enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        enum8.Options.Add(enumOption);
                    }
                }
                //return the value
                return(enum8);
            }

            case "enum16":
            {
                //Initialize our instance of enum16
                mEnum16 enum16 = new mEnum16();
                //Assign the name
                enum16.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                enum16.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                enum16.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the enumOption list.
                enum16.Options = new List <mEnumOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mEnumOption enumOption = new mEnumOption();
                        //Get the name of the bit
                        enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        enum16.Options.Add(enumOption);
                    }
                }
                //return the value
                return(enum16);
            }

            case "enum32":
            {
                //Initialize our instance of enum32
                mEnum32 enum32 = new mEnum32();
                //Assign the name
                enum32.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                enum32.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                enum32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //Initialize the enumOption list.
                enum32.Options = new List <mEnumOption>();
                //Loop through the children nodes for options.
                for (int i = 0; i < xmlNode.ChildNodes.Count; i++)
                {
                    //if its an option...
                    if (xmlNode.ChildNodes[i].Name.ToLower() == "option")
                    {
                        //then initialize a new instance of option
                        mEnumOption enumOption = new mEnumOption();
                        //Get the name of the bit
                        enumOption.Name = xmlNode.ChildNodes[i].Attributes["name"].Value;
                        //Get the bit value
                        enumOption.Value = int.Parse(xmlNode.ChildNodes[i].Attributes["value"].Value);
                        //Add it to the bitList
                        enum32.Options.Add(enumOption);
                    }
                }
                //return the value
                return(enum32);
            }

            case "int8":
            case "byte":
            {
                //Initialize our instance of byte
                mByte byteVal = new mByte();
                //Assign the name
                byteVal.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                byteVal.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                byteVal.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(byteVal);
            }

            case "int16":
            case "short":
            {
                //Initialize our instance of int16
                mInt16 int16Val = new mInt16();
                //Assign the name
                int16Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                int16Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                int16Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(int16Val);
            }

            case "uint16":
            case "ushort":
            {
                //Initialize our instance of uint16
                mUInt16 uint16Val = new mUInt16();
                //Assign the name
                uint16Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                uint16Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                uint16Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(uint16Val);
            }

            case "int32":
            case "long":
            case "int":
            {
                //Initialize our instance of int32
                mInt32 int32Val = new mInt32();
                //Assign the name
                int32Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                int32Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                int32Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(int32Val);
            }

            case "uint32":
            case "ulong":
            case "uint":
            {
                //Initialize our instance of uint32
                mUInt32 uint32Val = new mUInt32();
                //Assign the name
                uint32Val.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                uint32Val.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                uint32Val.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(uint32Val);
            }

            case "single":
            case "float":
            {
                //Initialize our instance of float
                mFloat floatVal = new mFloat();
                //Assign the name
                floatVal.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                floatVal.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                floatVal.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(floatVal);
            }

            case "string32":
            case "32string":
            {
                //Initialize our instance of string32
                mString32 string32 = new mString32();
                //Assign the name
                string32.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                string32.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                string32.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(string32);
            }

            case "string256":
            case "256string":
            {
                //Initialize our instance of string32
                mString256 string256 = new mString256();
                //Assign the name
                string256.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                string256.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                string256.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(string256);
            }

            case "unic64":
            case "unicode64":
            case "64unic":
            case "64unicode":
            {
                //Initialize our instance of unicode64
                mUnicode64 unicode64 = new mUnicode64();
                //Assign the name
                unicode64.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                unicode64.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                unicode64.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(unicode64);
            }

            case "unic256":
            case "unicode256":
            case "256unic":
            case "256unicode":
            {
                //Initialize our instance of unicode64
                mUnicode256 unicode256 = new mUnicode256();
                //Assign the name
                unicode256.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                unicode256.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                unicode256.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(unicode256);
            }

            case "undefined":
            case "unknown":
            {
                //Initialize our instance of undefined
                mUndefined undefined = new mUndefined();
                //Assign the name
                undefined.Name = xmlNode.Attributes["name"].Value;
                //Assign the offset
                undefined.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                undefined.Visible = bool.Parse(xmlNode.Attributes["visible"].Value);
                //return the value
                return(undefined);
            }

            case "unused":
            case "blank":
            {
                //Initialize our instance of undefined
                mUnused unused = new mUnused();
                //Assign the offset
                unused.Offset = int.Parse(xmlNode.Attributes["offset"].Value);
                //Assign the visibility flag
                unused.Size = int.Parse(xmlNode.Attributes["size"].Value);
                //return the value
                return(unused);
            }
            }
            //If all else fails, make a 'none' value.
            mValue blankVal = new mValue();

            blankVal.Attributes = mValue.ObjectAttributes.None;
            return(blankVal);
        }
Esempio n. 3
0
        public void MapPluginWithPDBList(List <mValue> mValueList, List <PluginDataBlock> PDBList, int chunkSize, int unknownStructCount)
        {
            //Loop until we hit our chunkSize
            for (int i = 0; i < chunkSize; i += 4)
            {
                //Create our reflexive list
                List <PluginDataBlock> PDBList2 = new List <PluginDataBlock>();

                //Loop through each PDBList
                foreach (PluginDataBlock PDB in PDBList)
                {
                    //Loop for each reflexive
                    foreach (Reflexive_DataBlock RDB in PDB.Reflexive_Data_Blocks)
                    {
                        if (RDB.Offset_In_Parent == i)
                        {
                            //Add it to our PDB list
                            PDBList2.Add(RDB);
                        }
                    }
                }

                //If we got reflexives
                if (PDBList2.Count != 0)
                {
                    //Initialize our reflexive
                    mReflexive mReflex = new mReflexive();
                    mReflex.Name = "Unknown " + unknownStructCount;
                    unknownStructCount++;
                    mReflex.Offset  = i;
                    mReflex.Size    = FindMostLikelySizeForChunk(PDBList2);
                    mReflex.Visible = false;
                    //Add it to our list
                    mValueList.Add(mReflex);
                    //Map more.
                    MapPluginWithPDBList(mReflex.Values, PDBList2, mReflex.Size, unknownStructCount);
                    //Add 8 to our i.
                    i += 8;
                }
                else
                {
                    //Our bool that indicates if we found an ident.
                    bool foundIdent = false;
                    //Loop through each PDBList
                    foreach (PluginDataBlock PDB in PDBList)
                    {
                        //Loop for each ident
                        foreach (Tag_Ident ident in PDB.Tag_Idents)
                        {
                            if (ident.Offset_In_Parent == i)
                            {
                                //Initialize our ident parts
                                mTagRef tRef = new mTagRef();
                                tRef.Name    = "Unknown";
                                tRef.Offset  = i;
                                tRef.Visible = false;
                                mIdent tIdent = new mIdent();
                                tIdent.Name    = "Unknown";
                                tIdent.Offset  = i + 12;
                                tIdent.Visible = false;

                                //Add it to our list
                                mValueList.Add(tRef);
                                mValueList.Add(tIdent);

                                //Add 12 more to i
                                i += 12;

                                //We found our ident.
                                foundIdent = true;

                                //Leave.
                                break;
                            }
                        }

                        //If we found our ident
                        if (foundIdent)
                        {
                            //Leave
                            break;
                        }
                    }
                    if (!foundIdent)
                    {
                        //If we got 4 bytes left.
                        if (chunkSize - i >= 4)
                        {
                            //Let's make our unidentified
                            mUndefined mU = new mUndefined();
                            mU.Name    = "Unknown";
                            mU.Offset  = i;
                            mU.Visible = false;
                            //Add it to our list
                            mValueList.Add(mU);
                        }
                        else
                        {
                            //If we got 2 bytes left
                            if (chunkSize - i >= 2)
                            {
                                //Make our short
                                mInt16 m16 = new mInt16();
                                m16.Name    = "Unknown";
                                m16.Offset  = i;
                                m16.Visible = false;
                                //Add it to our list
                                mValueList.Add(m16);
                                //Take 2 away from i, since it'll add 4, it makes it progress 2
                                i -= 2;
                            }
                            else
                            {
                                if (chunkSize - i == 1)
                                {
                                    //Make our byte
                                    mByte mB = new mByte();
                                    mB.Name    = "Unknown";
                                    mB.Offset  = i;
                                    mB.Visible = false;
                                    //Add it to our list
                                    mValueList.Add(mB);
                                    //We're done, we dont need to take away 3 to make i increment 1.
                                }
                            }
                        }
                    }
                }
            }
        }