예제 #1
0
 private void addPropertyToolStripMenuItem_Click(object sender, EventArgs e)
 {
     int n = listBox1.SelectedIndex;
     if (n == -1)
         return;
     string propname = Microsoft.VisualBasic.Interaction.InputBox("Please enter the name of the new Property", "ME3 Explorer", "", 0, 0);
     if (propname == "")
         return;
     string counts = Microsoft.VisualBasic.Interaction.InputBox("Please enter the count of Elemets it will contain", "ME3 Explorer", "0", 0, 0);
     if (counts == "")
         return;
     int count = Convert.ToInt32(counts);
     List<UPropertyReader.PropertyMeta> tMeta = new List<UPropertyReader.PropertyMeta>();
     if (count < 0 || count > 100)
         return;
     for (int i = 0; i < count; i++)
     {
         UPropertyReader.PropertyMeta t = new UPropertyReader.PropertyMeta();
         string sizes = Microsoft.VisualBasic.Interaction.InputBox("What size has element #" + i.ToString() + "? (1,2 or 4 bytes)", "ME3 Explorer", "4", 0, 0);
         if (sizes == "")
             return;
         int size = Convert.ToInt32(sizes);
         if (size != 1 && size != 2 && size != 4)
             return;
         t.size = size;
         string types = Microsoft.VisualBasic.Interaction.InputBox("What type has element #" + i.ToString() + "? \n(0=Value, 1=Float, 2=Name, 3=Ignore)", "ME3 Explorer", "", 0, 0);
         if (types == "")
             return;
         int type = Convert.ToInt32(types);
         if (type < 0 || type > 3)
             return;
         t.type = type;
         if (type == 1 && size == 1)
             return;
         tMeta.Add(t);
     }
     UPropertyReader.Property p = new UPropertyReader.Property();
     p.name = propname;
     p.Meta = tMeta;
     UPR.AddProp(UPR.Definitions[n].name, p);
     MessageBox.Show("Done.");
     RefreshView(n);
 }
예제 #2
0
        private void Guess(int off, bool auto = false)
        {
            if (off + 4 >= memsize)
            {
                return;
            }
            uint n = BitConverter.ToUInt32(memory, off);

            if (n >= Names.Length)
            {
                return;
            }
            string s = Names[n];

            for (int i = 0; i < Definitions.Count; i++)
            {
                if (tempClass == Definitions[i].name)
                {
                    for (int j = 0; j < Definitions[i].props.Count; j++)
                    {
                        if (Definitions[i].props[j].name + "\0" == s)
                        {
                            int      pos = off;
                            Property p   = Definitions[i].props[j];
                            for (int k = 0; k < Definitions[i].props[j].Meta.Count; k++)
                            {
                                UPropertyReader.PropertyMeta m = Definitions[i].props[j].Meta[k];

                                if (m.type == 0)
                                {
                                    switch (m.size)
                                    {
                                    case 1:
                                        p.value += memory[pos] + " ";
                                        break;

                                    case 2:
                                        p.value += BitConverter.ToUInt16(memory, pos) + " ";
                                        break;

                                    case 4:
                                        p.value += BitConverter.ToUInt32(memory, pos) + " ";
                                        break;
                                    }
                                }
                                if (m.type == 1)
                                {
                                    switch (m.size)
                                    {
                                    case 2:
                                        p.value += getFloat16(pos) + " ";
                                        break;

                                    case 4:
                                        p.value += BitConverter.ToSingle(memory, pos) + " ";
                                        break;

                                    default:
                                        p.value += "";
                                        break;
                                    }
                                }

                                if (m.type == 2)
                                {
                                    uint z = BitConverter.ToUInt32(memory, pos);
                                    if (z >= 0 && z < Names.Count() && k != 0)
                                    {
                                        p.value += clr0(Names[z]) + " ";
                                    }
                                }
                                pos += m.size;
                            }
                            p.raw    = new byte[pos - off];
                            p.offset = off;
                            for (int k = 0; k < pos - off; k++)
                            {
                                p.raw[k] = memory[off + k];
                            }
                            tempProps.Add(p);
                            if (auto)
                            {
                                Guess(pos, auto);
                                return;
                            }
                        }
                        if (s == "ArrayProperty\0")
                        {
                            int pos   = off;
                            int len   = BitConverter.ToInt32(memory, pos + 8);
                            int count = BitConverter.ToInt32(memory, pos + 16);
                            int size;
                            if (count == 0)
                            {
                                size = len;
                            }
                            else
                            {
                                size = (len - 4) / count;
                            }
                            Property p = new Property();
                            p.offset = pos;
                            pos     += 20;
                            p.name   = s;
                            for (int k = 0; k < count; k++)
                            {
                                switch (size)
                                {
                                case 1:
                                    p.value += memory[pos] + " ";
                                    pos     += 4;
                                    break;

                                case 2:
                                    p.value += BitConverter.ToUInt16(memory, pos) + " ";
                                    pos     += 4;
                                    break;

                                case 4:
                                    p.value += BitConverter.ToUInt32(memory, pos) + " ";
                                    pos     += 4;
                                    break;

                                default:
                                    p.value = "";
                                    pos    += size;
                                    break;
                                }
                            }
                            p.raw = new byte[pos - off];
                            for (int k = 0; k < pos - off; k++)
                            {
                                p.raw[k] = memory[off + k];
                            }
                            tempProps.Add(p);
                            if (auto)
                            {
                                Guess(pos, auto);
                                return;
                            }
                        }
                        if (s == "StrProperty\0")
                        {
                            int      pos = off;
                            int      len = BitConverter.ToInt32(memory, pos + 16) * -1;
                            Property p   = new Property();
                            p.offset = pos;
                            pos     += 20;
                            p.name   = s;
                            p.value  = "";
                            for (int k = 0; k < len; k++)
                            {
                                p.value += (char)memory[pos];
                                pos     += 2;
                            }
                            p.raw = new byte[pos - off];
                            for (int k = 0; k < pos - off; k++)
                            {
                                p.raw[k] = memory[off + k];
                            }
                            tempProps.Add(p);
                            if (auto)
                            {
                                Guess(pos, auto);
                                return;
                            }
                        }
                        if (s == "m_aObjComment\0")
                        {
                            int      pos = off;
                            int      len = BitConverter.ToInt32(memory, pos + 28) * -1;
                            Property p   = new Property();
                            p.offset = pos;
                            pos     += 32;
                            p.name   = s;
                            p.value  = "";
                            for (int k = 0; k < len; k++)
                            {
                                p.value += (char)memory[pos];
                                pos     += 2;
                            }
                            p.raw = new byte[pos - off];
                            for (int k = 0; k < pos - off; k++)
                            {
                                p.raw[k] = memory[off + k];
                            }
                            tempProps.Add(p);
                            if (auto)
                            {
                                Guess(pos, auto);
                                return;
                            }
                        }
                    }
                }
            }
        }