private void toolStripButton15_Click(object sender, EventArgs e) { int errorcount = 0; FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string basepath = fbd.SelectedPath + "\\"; int casptype = toolStripComboBox1.SelectedIndex; int count = 0; foreach (DBAccess.EBXInformation ebx in ebxlist) { if (ebx.casPatchType == casptype) { byte[] data = new byte[0]; if (ebx.incas) { data = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ebx.sha1), 0x40); } else { TOCFile toc = new TOCFile(ebx.tocfilepath); byte[] bundledata = toc.ExportBundleDataByPath(ebx.bundlepath); BinaryBundle b = new BinaryBundle(new MemoryStream(bundledata)); foreach (BinaryBundle.EbxEntry ebx2 in b.EbxList) { if (ebx.ebxname == ebx2._name) { data = ebx2._data; } } } EBXStream ex = new EBXStream(new MemoryStream(data)); if (!ex.ErrorLoading) { string subfilename = ebx.ebxname.Replace("/", "\\").Replace("'", "") + ".xml"; string subpath = Path.GetDirectoryName(subfilename) + "\\"; if (!Directory.Exists(basepath + subpath)) { Directory.CreateDirectory(basepath + subpath); } File.WriteAllText(basepath + subfilename, ex.toXML()); if (count++ % 123 == 0) { ebxstatus.Text = "Writing #" + count + " " + basepath + subfilename + " ..."; Application.DoEvents(); } } else { errorcount++; if (count++ % 123 == 0) { this.Text = "Errors exporting : " + errorcount.ToString() + " =(" + ((float)errorcount / (float)count) * 100f + "%) Last:" + ebx.ebxname; Application.DoEvents(); } } } } this.Text = "Content Browser"; ebxstatus.Text = "Ready. Processed Ebx:" + count + " Errors: " + errorcount + " (" + ((float)errorcount / (float)count) * 100f + "%)"; } }
public void RefreshDisplay() { hb1.ByteProvider = new DynamicByteProvider(ebxdata); hb2.ByteProvider = new DynamicByteProvider(ebx.keywordarea); listBox1.Items.Clear(); int count = 0; foreach (EBXStream.StreamingPartitionImportEntry exguid in ebx.imports) { listBox1.Items.Add((count++).ToString("X4") + " : " + exguid.partitionGuid.ToString() + " -> " + exguid.instanceGuid.ToString()); } count = 0; listBox2.Items.Clear(); foreach (EBXStream.KeyWordDicStruct entry in ebx.keyWordDic) { listBox2.Items.Add((count++).ToString("X4") + " : Offset = 0x" + entry.offset.ToString("X8") + " Hash = 0x" + entry.hash.ToString("X8") + " Keyword = '" + entry.keyword + "'"); } count = 0; listBox3.Items.Clear(); foreach (EBXStream.StreamingPartitionFieldDescriptor f in ebx.fieldDescriptors) { listBox3.Items.Add( (count++).ToString("X4") + " : Hash = 0x" + f.fieldNameHash.ToString("X8") + " Type = 0x" + f.flagBits.ToString("X4") + " Reference = 0x" + f.fieldTypeIndex.ToString("X4") + " Offset = 0x" + f.fieldOffset.ToString("X8") + " Secondary Offset = 0x" + f.secondaryOffset.ToString("X8") + " Name ='" + f._name + "'"); } count = 0; listBox4.Items.Clear(); foreach (EBXStream.StreamingPartitionTypeDescriptor f in ebx.typeDescriptors) { listBox4.Items.Add( (count++).ToString("X4") + " : Hash = 0x" + f.typeNameHash.ToString("X8") + " StartIndex = 0x" + f.layoutDescriptorIndex.ToString("X8") + " NumField = 0x" + f.fieldCount.ToString("X2") + " Alignment = 0x" + f.alignment.ToString("X2") + " Type = 0x" + f.typeFlags.ToString("X4") + " Size = 0x" + f.instanceSize.ToString("X4") + " Secondary Size = 0x" + f.secondaryInstanceSize.ToString("X8") + " Name ='" + f._name + "'"); } count = 0; listBox5.Items.Clear(); foreach (EBXStream.StreamingPartitionTypeEntry i in ebx.typeList) { listBox5.Items.Add((count++).ToString("X4") + " : Type Desc Index = 0x" + i.typeDescriptorIndex.ToString("X4") + " Repeats = 0x" + i.repetitions.ToString("X4")); } count = 0; listBox6.Items.Clear(); foreach (EBXStream.StreamingPartitionArrayEntry a in ebx.arrayList) { listBox6.Items.Add((count++).ToString("X4") + " : Offset = 0x" + a.offset.ToString("X8") + " Type Desc Index = 0x" + a.typeDescriptorIndex.ToString("X8") + " Repeats = 0x" + a.elementCount.ToString("X8")); } treeView1.Nodes.Clear(); count = 0; TreeNode t = new TreeNode("Types"); if (ebx.typeEntryList != null) { foreach (EBXStream.TypeEntryStruct typ in ebx.typeEntryList) { t.Nodes.Add(EBXStream.TypeToNode(typ.type)); } } t.ExpandAll(); treeView1.Nodes.Add(t); rtb2.Text = ebx.toXML(); }
private void CheckSelectionEBX() { TreeNode t = treeView4.SelectedNode; if (t == null || t.Nodes == null || t.Nodes.Count != 0) { return; } string path = Helpers.GetPathFromNode(t, "/"); path = path.Substring(1, path.Length - 1); if (path == lastpath) { return; } lastpath = path; foreach (DBAccess.EBXInformation ebx in ebxlist) { if (path == ebx.ebxname && ebx.casPatchType != 2 && !ebx.isbase) { string c = "b"; if (ebx.isDLC) { c = "u"; } if (ebx.isPatch) { c = "p"; } byte[] data = new byte[0]; if (ebx.incas) { data = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ebx.sha1)); } else { TOCFile toc = new TOCFile(ebx.tocfilepath); byte[] bundledata = toc.ExportBundleDataByPath(ebx.bundlepath); BinaryBundle b = new BinaryBundle(new MemoryStream(bundledata)); foreach (BinaryBundle.EbxEntry ebx2 in b.EbxList) { if (path.Contains(ebx2._name)) { data = ebx2._data; } } } if (toolStripButton11.Checked) { hb1.BringToFront(); hb1.ByteProvider = new DynamicByteProvider(data); } else if (toolStripComboBox1.SelectedIndex < 2) { rtb2.BringToFront(); rtb2.Text = ""; rtb2.Visible = false; try { ebxstatus.Text = "Processing..."; Application.DoEvents(); EBXStream ebxf = new EBXStream(new MemoryStream(data), ebxpb1); ebxstatus.Text = "Displaying..."; rtb2.Text = ebxf.toXML(); ebxstatus.Text = "Ready (Type is " + c + ")"; } catch (Exception ex) { rtb2.Text = "Error:\n" + ex.Message; } rtb2.Visible = true; } return; } } }
public void LoadEbx(byte[] data) { ebxdata = data; ebx = new EBXStream(new MemoryStream(ebxdata), pb1); RefreshDisplay(); }