private void PreviewRaw() { int n = GetSelected(); if (n == -1 || !(CurrentView == 2 || CurrentView == 3)) { return; } PCCObject.ExportEntry ent = pcc.Exports[n]; hb1.ByteProvider = new DynamicByteProvider(ent.Data); //Status.Text = ent.ClassName + " Offset: " + ent.DataOffset + " - " + (ent.DataOffset + ent.DataSize); }
private void saveHexChangesToolStripMenuItem_Click(object sender, EventArgs e) { int n = GetSelected(); if (n < 0) { return; } PCCObject.ExportEntry exp = pcc.Exports[n]; MemoryStream m = new MemoryStream(); for (int i = 0; i < hb1.ByteProvider.Length; i++) { m.WriteByte(hb1.ByteProvider.ReadByte(i)); } exp.Data = m.ToArray(); exp.DataSize = (int)m.Length; pcc.Exports[n] = exp; }
private void dumpRawExportToolStripMenuItem_Click(object sender, EventArgs e) { int n = GetSelected(); if (n < 0) { return; } PCCObject.ExportEntry exp = pcc.Exports[n]; SaveFileDialog d = new SaveFileDialog(); //d.Filter = "*.u;*.upk;*sfm|*.u;*.upk;*sfm"; d.Filter = "Binary File|*.bin"; if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (FileStream fs = new FileStream(d.FileName, FileMode.Create, FileAccess.Write)) { fs.WriteBytes(exp.Data); } MessageBox.Show("Done."); } }
public void RefreshView() { listBox1.BeginUpdate(); listBox1.Items.Clear(); if (pcc == null) { return; } int count = 0; if (CurrentView == 0) { foreach (string name in pcc.Names) { listBox1.Items.Add((count++).ToString("d6") + " : " + name); } } if (CurrentView == 1) { foreach (PCCObject.ImportEntry imp in pcc.Imports) { listBox1.Items.Add((count++).ToString("d6") + " : " + pcc.FollowLink(imp.link) + imp.ObjectName); } } string s; if (CurrentView == 2) { for (int i = 0; i < pcc.Exports.Count; i++) { 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) { treeView1.BeginUpdate(); for (int i = 0; i < pcc.Exports.Count; i++) { 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++) { 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++) { 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); treeView1.EndUpdate(); } else { treeView1.Visible = false; listBox1.Visible = true; } listBox1.EndUpdate(); toolStripComboBox1.Items.Clear(); foreach (int index in classes) { toolStripComboBox1.Items.Add(pcc.GetClass(index)); } }
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(); }