示例#1
0
        private void PreviewRaw()
        {
            int n = GetSelected();

            if (n == -1 || !(CurrentView == 2 || CurrentView == 3))
            {
                return;
            }
            PCCObject.ExportEntry ent = pcc.Exports[n];
            hexBox1.ByteProvider = new DynamicByteProvider(ent.Data);
            Status.Text          = ent.ClassName + " Offset: " + ent.DataOffset + " - " + (ent.DataOffset + ent.DataSize);
        }
示例#2
0
        private void exportBINToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = GetSelected();

            if (n == -1 || !(CurrentView == 2 || CurrentView == 3))
            {
                return;
            }
            PCCObject.ExportEntry ent = pcc.Exports[n];
            SaveFileDialog        d   = new SaveFileDialog();

            d.Filter   = "*.bin|*.bin";
            d.FileName = ent.ObjectName + ".bin";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                FileStream fs = new FileStream(d.FileName, FileMode.Create, FileAccess.Write);
                fs.Write(ent.Data, 0, ent.DataSize);
                fs.Close();
                MessageBox.Show("Done.");
            }
        }
示例#3
0
        private void saveHexChangesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pcc == null)
            {
                return;
            }
            int n = GetSelected();

            if (n == -1 || !(CurrentView == 2 || CurrentView == 3))
            {
                return;
            }
            MemoryStream m = new MemoryStream();

            for (int i = 0; i < hexBox1.ByteProvider.Length; i++)
            {
                m.WriteByte(hexBox1.ByteProvider.ReadByte(i));
            }
            PCCObject.ExportEntry ent = pcc.Exports[n];
            ent.Data       = m.ToArray();
            ent.hasChanged = true;
            pcc.Exports[n] = ent;
        }
示例#4
0
        private void pg1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            n = CurrentObjects[n];
            string   name   = e.ChangedItem.Label;
            GridItem parent = e.ChangedItem.Parent;

            //if (parent != null) name = parent.Label;
            if (parent.Label == "data")
            {
                GridItem parent2 = parent.Parent;
                if (parent2 != null)
                {
                    name = parent2.Label;
                }
            }
            if (name == "nameindex")
            {
                name = parent.Label;
            }
            byte[] buff = pcc.Exports[n].Data;
            List <PropertyReader.Property> p = PropertyReader.getPropList(pcc, buff);
            int m = -1;

            for (int i = 0; i < p.Count; i++)
            {
                if (pcc.Names[p[i].Name] == name)
                {
                    m = i;
                }
            }
            if (m == -1)
            {
                return;
            }
            PCCObject.ExportEntry ent = pcc.Exports[n];
            byte[] buff2;
            switch (p[m].TypeVal)
            {
            case PropertyReader.Type.BoolProperty:
                byte res = 0;
                if ((bool)e.ChangedItem.Value == true)
                {
                    res = 1;
                }
                ent.Data[p[m].offsetval] = res;
                break;

            case PropertyReader.Type.FloatProperty:
                buff2 = BitConverter.GetBytes((float)e.ChangedItem.Value);
                for (int i = 0; i < 4; i++)
                {
                    ent.Data[p[m].offsetval + i] = buff2[i];
                }
                break;

            case PropertyReader.Type.IntProperty:
            case PropertyReader.Type.StringRefProperty:
                int newv = Convert.ToInt32(e.ChangedItem.Value);
                int oldv = Convert.ToInt32(e.OldValue);
                buff2 = BitConverter.GetBytes(newv);
                for (int i = 0; i < 4; i++)
                {
                    ent.Data[p[m].offsetval + i] = buff2[i];
                }
                break;

            case PropertyReader.Type.StructProperty:
                if (e.ChangedItem.Value.GetType() == typeof(int))
                {
                    int val = Convert.ToInt32(e.ChangedItem.Value);
                    if (e.ChangedItem.Label == "nameindex")
                    {
                        int val1 = Convert.ToInt32(e.ChangedItem.Value);
                        buff2 = BitConverter.GetBytes(val1);
                        for (int i = 0; i < 4; i++)
                        {
                            ent.Data[p[m].offsetval + i] = buff2[i];
                        }
                        int t = listBox1.SelectedIndex;
                        listBox1.SelectedIndex = -1;
                        listBox1.SelectedIndex = t;
                    }
                    else
                    {
                        string sidx = e.ChangedItem.Label.Replace("[", "");
                        sidx = sidx.Replace("]", "");
                        int index = Convert.ToInt32(sidx);
                        buff2 = BitConverter.GetBytes(val);
                        for (int i = 0; i < 4; i++)
                        {
                            ent.Data[p[m].offsetval + i + index * 4 + 8] = buff2[i];
                        }
                        int t = listBox1.SelectedIndex;
                        listBox1.SelectedIndex = -1;
                        listBox1.SelectedIndex = t;
                    }
                }
                break;

            case PropertyReader.Type.ByteProperty:
            case PropertyReader.Type.NameProperty:
                if (e.ChangedItem.Value.GetType() == typeof(int))
                {
                    int val = Convert.ToInt32(e.ChangedItem.Value);
                    buff2 = BitConverter.GetBytes(val);
                    for (int i = 0; i < 4; i++)
                    {
                        ent.Data[p[m].offsetval + i] = buff2[i];
                    }
                    int t = listBox1.SelectedIndex;
                    listBox1.SelectedIndex = -1;
                    listBox1.SelectedIndex = t;
                }
                break;

            case PropertyReader.Type.ObjectProperty:
                if (e.ChangedItem.Value.GetType() == typeof(int))
                {
                    int val = Convert.ToInt32(e.ChangedItem.Value);
                    buff2 = BitConverter.GetBytes(val);
                    for (int i = 0; i < 4; i++)
                    {
                        ent.Data[p[m].offsetval + i] = buff2[i];
                    }
                    int t = listBox1.SelectedIndex;
                    listBox1.SelectedIndex = -1;
                    listBox1.SelectedIndex = t;
                }
                break;

            default:
                return;
            }
            pcc.Exports[n] = ent;
            pg1.ExpandAllGridItems();
        }
示例#5
0
        public void RefreshView()
        {
            listBox1.Visible = false;
            listBox1.Items.Clear();
            if (pcc == null)
            {
                listBox1.Visible = true;
                return;
            }
            //cloneObjectToolStripMenuItem.Enabled = false;
            listBox1.BeginUpdate();
            treeView1.BeginUpdate();
            if (CurrentView == 0)
            {
                for (int i = 0; i < pcc.Names.Count; i++)
                {
                    listBox1.Items.Add(i.ToString() + " : " + pcc.Names[i]);
                }
            }
            if (CurrentView == 1)
            {
                for (int i = 0; i < pcc.Imports.Count; i++)
                {
                    listBox1.Items.Add(i.ToString() + " : " + pcc.Imports[i].Name);
                }
            }
            string s;

            if (CurrentView == 2)
            {
                for (int i = 0; i < pcc.Exports.Count; i++)
                {
                    //cloneObjectToolStripMenuItem.Enabled = true;
                    s = "";
                    if (pcc.Exports[i].PackageFullName != "Class" && pcc.Exports[i].PackageFullName != "Package")
                    {
                        s += pcc.Exports[i].PackageFullName + ".";
                    }
                    s += pcc.Exports[i].ObjectName;
                    listBox1.Items.Add(i.ToString() + " : " + s);
                }
            }
            if (CurrentView == 3)
            {
                for (int i = 0; i < pcc.Exports.Count; i++)
                {
                    //cloneObjectToolStripMenuItem.Enabled = true;
                    s = "";
                    if (pcc.Exports[i].PackageFullName != "Class" && pcc.Exports[i].PackageFullName != "Package")
                    {
                        s += pcc.Exports[i].PackageFullName + ".";
                    }
                    s += pcc.Exports[i].ObjectName;
                    listBox1.Items.Add(i.ToString() + " : " + s);
                }
                listBox1.Visible  = false;
                treeView1.Visible = true;
                treeView1.Nodes.Clear();
                TreeNode t = new TreeNode(pcc.pccFileName);
                for (int i = 0; i < pcc.Exports.Count; i++)
                {
                    //cloneObjectToolStripMenuItem.Enabled = true;
                    PCCObject.ExportEntry e        = pcc.Exports[i];
                    List <int>            LinkList = new List <int>();
                    LinkList.Add(i + 1);
                    int Link = e.LinkID;
                    while (Link != 0)
                    {
                        LinkList.Add(Link);
                        if (Link > 0)
                        {
                            Link = pcc.Exports[Link - 1].LinkID;
                        }
                        else
                        {
                            Link = pcc.Imports[-Link - 1].link;
                        }
                    }
                    t = AddPathToTree(t, LinkList);
                }
                for (int i = 0; i < pcc.Imports.Count; i++)
                {
                    //cloneObjectToolStripMenuItem.Enabled = true;
                    PCCObject.ImportEntry e        = pcc.Imports[i];
                    List <int>            LinkList = new List <int>();
                    LinkList.Add(-(i + 1));
                    int Link = e.link;
                    while (Link != 0)
                    {
                        LinkList.Add(Link);
                        if (Link > 0)
                        {
                            Link = pcc.Exports[Link - 1].LinkID;
                        }
                        else
                        {
                            Link = pcc.Imports[-Link - 1].link;
                        }
                    }
                    t = AddPathToTree(t, LinkList);
                }
                treeView1.Nodes.Add(t);
            }
            else
            {
                treeView1.Visible = false;
                listBox1.Visible  = true;
            }
            listBox1.EndUpdate();
            treeView1.EndUpdate();

            toolStripComboBox1.Items.Clear();
            foreach (int index in classes)
            {
                toolStripComboBox1.Items.Add(pcc.GetClass(index));
            }
        }