diff --git a/PointerSearcher/FindPath.cs b/PointerSearcher/FindPath.cs index b0f3065..89efa14 100644 --- a/PointerSearcher/FindPath.cs +++ b/PointerSearcher/FindPath.cs @@ -21,6 +21,11 @@ public ReverseOrderPathOffset(long offsetAddress) } private long offset; + public long getOffset() + { + return offset; + } + public override String ToString(String org) { return org + "+" + offset.ToString("X2"); diff --git a/PointerSearcher/Form1.Designer.cs b/PointerSearcher/Form1.Designer.cs index 9ce1fbf..c979207 100644 --- a/PointerSearcher/Form1.Designer.cs +++ b/PointerSearcher/Form1.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.buttonRead = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); @@ -47,14 +48,17 @@ private void InitializeComponent() this.label3 = new System.Windows.Forms.Label(); this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.buttonCancel = new System.Windows.Forms.Button(); + this.Export_button = new System.Windows.Forms.Button(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // buttonRead // - this.buttonRead.Location = new System.Drawing.Point(14, 214); + this.buttonRead.Location = new System.Drawing.Point(14, 232); this.buttonRead.Name = "buttonRead"; - this.buttonRead.Size = new System.Drawing.Size(158, 23); + this.buttonRead.Size = new System.Drawing.Size(158, 25); this.buttonRead.TabIndex = 0; this.buttonRead.Text = "Read 1st Dump Data"; this.buttonRead.UseVisualStyleBackColor = true; @@ -62,13 +66,14 @@ private void InitializeComponent() // // textBox1 // - this.textBox1.Location = new System.Drawing.Point(12, 243); + this.textBox1.Location = new System.Drawing.Point(12, 263); this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ReadOnly = true; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.textBox1.Size = new System.Drawing.Size(646, 138); + this.textBox1.Size = new System.Drawing.Size(646, 149); this.textBox1.TabIndex = 1; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // // dataGridView1 // @@ -80,12 +85,15 @@ private void InitializeComponent() this.ColumnHeapStart, this.ColumnHeapEnd, this.ColumnTargetAddress}); - this.dataGridView1.Location = new System.Drawing.Point(12, 12); + this.dataGridView1.Location = new System.Drawing.Point(12, 13); this.dataGridView1.Name = "dataGridView1"; + dataGridViewCellStyle1.NullValue = null; + this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView1.RowTemplate.Height = 21; - this.dataGridView1.Size = new System.Drawing.Size(646, 150); + this.dataGridView1.Size = new System.Drawing.Size(646, 163); this.dataGridView1.TabIndex = 2; this.dataGridView1.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView1_CellBeginEdit); + this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick); this.dataGridView1.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEnter); // // ColumnPath @@ -126,9 +134,9 @@ private void InitializeComponent() // // buttonSearch // - this.buttonSearch.Location = new System.Drawing.Point(257, 214); + this.buttonSearch.Location = new System.Drawing.Point(178, 232); this.buttonSearch.Name = "buttonSearch"; - this.buttonSearch.Size = new System.Drawing.Size(158, 23); + this.buttonSearch.Size = new System.Drawing.Size(158, 25); this.buttonSearch.TabIndex = 3; this.buttonSearch.Text = "Reset and Search"; this.buttonSearch.UseVisualStyleBackColor = true; @@ -136,30 +144,31 @@ private void InitializeComponent() // // textBoxDepth // - this.textBoxDepth.Location = new System.Drawing.Point(72, 178); + this.textBoxDepth.Location = new System.Drawing.Point(14, 196); this.textBoxDepth.Name = "textBoxDepth"; - this.textBoxDepth.Size = new System.Drawing.Size(100, 19); + this.textBoxDepth.Size = new System.Drawing.Size(100, 21); this.textBoxDepth.TabIndex = 4; + this.textBoxDepth.TextChanged += new System.EventHandler(this.textBoxDepth_TextChanged); // // textBoxOffsetNum // - this.textBoxOffsetNum.Location = new System.Drawing.Point(315, 178); + this.textBoxOffsetNum.Location = new System.Drawing.Point(141, 196); this.textBoxOffsetNum.Name = "textBoxOffsetNum"; - this.textBoxOffsetNum.Size = new System.Drawing.Size(100, 19); + this.textBoxOffsetNum.Size = new System.Drawing.Size(100, 21); this.textBoxOffsetNum.TabIndex = 5; // // textBoxOffsetAddress // - this.textBoxOffsetAddress.Location = new System.Drawing.Point(558, 178); + this.textBoxOffsetAddress.Location = new System.Drawing.Point(263, 196); this.textBoxOffsetAddress.Name = "textBoxOffsetAddress"; - this.textBoxOffsetAddress.Size = new System.Drawing.Size(100, 19); + this.textBoxOffsetAddress.Size = new System.Drawing.Size(100, 21); this.textBoxOffsetAddress.TabIndex = 6; // // buttonNarrowDown // - this.buttonNarrowDown.Location = new System.Drawing.Point(500, 214); + this.buttonNarrowDown.Location = new System.Drawing.Point(342, 232); this.buttonNarrowDown.Name = "buttonNarrowDown"; - this.buttonNarrowDown.Size = new System.Drawing.Size(158, 23); + this.buttonNarrowDown.Size = new System.Drawing.Size(158, 25); this.buttonNarrowDown.TabIndex = 7; this.buttonNarrowDown.Text = "Narrow Down Result"; this.buttonNarrowDown.UseVisualStyleBackColor = true; @@ -168,52 +177,83 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(10, 181); + this.label1.Location = new System.Drawing.Point(12, 180); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(56, 12); + this.label1.Size = new System.Drawing.Size(56, 13); this.label1.TabIndex = 8; this.label1.Text = "MaxDepth"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(249, 181); + this.label2.Location = new System.Drawing.Point(138, 180); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(60, 12); + this.label2.Size = new System.Drawing.Size(57, 13); this.label2.TabIndex = 9; this.label2.Text = "OffsetNum"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(483, 181); + this.label3.Location = new System.Drawing.Point(260, 180); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(69, 12); + this.label3.Size = new System.Drawing.Size(64, 13); this.label3.TabIndex = 10; this.label3.Text = "OffsetRange"; // // progressBar1 // - this.progressBar1.Location = new System.Drawing.Point(12, 388); + this.progressBar1.Location = new System.Drawing.Point(12, 420); this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(565, 23); + this.progressBar1.Size = new System.Drawing.Size(565, 25); this.progressBar1.TabIndex = 11; // // buttonCancel // - this.buttonCancel.Location = new System.Drawing.Point(583, 388); + this.buttonCancel.Location = new System.Drawing.Point(583, 420); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.Size = new System.Drawing.Size(75, 25); this.buttonCancel.TabIndex = 12; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click_1); // + // Export_button + // + this.Export_button.Location = new System.Drawing.Point(534, 232); + this.Export_button.Name = "Export_button"; + this.Export_button.Size = new System.Drawing.Size(124, 25); + this.Export_button.TabIndex = 13; + this.Export_button.Text = "Export To EdiZon SE"; + this.Export_button.UseVisualStyleBackColor = true; + this.Export_button.Click += new System.EventHandler(this.Export_to_SE_Click); + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(389, 196); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(269, 21); + this.textBox2.TabIndex = 14; + this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(386, 179); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(75, 13); + this.label4.TabIndex = 15; + this.label4.Text = "Book Mark File"; + this.label4.Click += new System.EventHandler(this.label4_Click); + // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(674, 417); + this.ClientSize = new System.Drawing.Size(669, 452); + this.Controls.Add(this.label4); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.Export_button); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.progressBar1); this.Controls.Add(this.label3); @@ -228,7 +268,8 @@ private void InitializeComponent() this.Controls.Add(this.textBox1); this.Controls.Add(this.buttonRead); this.Name = "Form1"; - this.Text = "PointerSearcher 0.04"; + this.Text = "EdiZon SE PointerSearcher 0.3"; + this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -256,6 +297,9 @@ private void InitializeComponent() private System.Windows.Forms.DataGridViewTextBoxColumn ColumnHeapStart; private System.Windows.Forms.DataGridViewTextBoxColumn ColumnHeapEnd; private System.Windows.Forms.DataGridViewTextBoxColumn ColumnTargetAddress; + private System.Windows.Forms.Button Export_button; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Label label4; } } diff --git a/PointerSearcher/Form1.cs b/PointerSearcher/Form1.cs index 0610e1b..a353ade 100644 --- a/PointerSearcher/Form1.cs +++ b/PointerSearcher/Form1.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -33,6 +34,9 @@ public Form1() private List> result; private CancellationTokenSource cancel = null; private double progressTotal; + + public BinaryReader FileStream { get; private set; } + private async void buttonRead_Click(object sender, EventArgs e) { SetProgressBar(0); @@ -46,6 +50,13 @@ private async void buttonRead_Click(object sender, EventArgs e) { throw new Exception("Invalid input" + Environment.NewLine + "Check highlighted cell"); } + reader.readsetup(); + dataGridView1.Rows[0].Cells[1].Value = "0x" + Convert.ToString(reader.mainStartAddress(), 16); + dataGridView1.Rows[0].Cells[2].Value = "0x" + Convert.ToString(reader.mainEndAddress(), 16); + dataGridView1.Rows[0].Cells[2].Value = "0x" + Convert.ToString(reader.mainEndAddress(), 16); + dataGridView1.Rows[0].Cells[3].Value = "0x" + Convert.ToString(reader.heapStartAddress(), 16); + dataGridView1.Rows[0].Cells[4].Value = "0x" + Convert.ToString(reader.heapEndAddress(), 16); + dataGridView1.Rows[0].Cells[5].Value = "0x" + Convert.ToString(reader.TargetAddress(), 16); buttonSearch.Enabled = false; buttonNarrowDown.Enabled = false; buttonCancel.Enabled = true; @@ -88,6 +99,7 @@ private async void buttonSearch_Click(object sender, EventArgs e) buttonRead.Enabled = false; buttonSearch.Enabled = false; buttonNarrowDown.Enabled = false; + textBox2.Text = dataGridView1.Rows[0].Cells[0].Value.ToString(); SetProgressBar(0); try { @@ -151,7 +163,9 @@ private void PrintPath() textBox1.Text = ""; if (result.Count > 100) { - textBox1.Text = "too many results"; + string str; + str = result.Count.ToString(); + textBox1.Text = str + " results" + Environment.NewLine; } else if (result.Count > 0) { @@ -171,17 +185,74 @@ private void PrintPath() } } + private void ExportPath() + { + + if (result.Count > 0) + { + textBox1.Text = "Exporting result to file ... " + result.Count.ToString(); + String filepath = textBox2.Text; + if ((filepath == "") || System.IO.File.Exists(filepath)) + { + textBox1.Text = "Book Mark File exist"; + return; + } + BinaryWriter BM; + try + { + BM = new BinaryWriter(new FileStream(filepath, FileMode.Create, FileAccess.Write)); + BM.BaseStream.Seek(0, SeekOrigin.Begin); + int magic = 0x4E5A4445; + BM.Write(magic); + long fileindex = 0; + long depth = 0; + long[] chain = new long[13]; + + foreach (List path in result) + { + + BM.BaseStream.Seek(134 + fileindex * 8 * 14, SeekOrigin.Begin); // sizeof(pointer_chain_t) Edizon header size = 134 + depth = 0; + for (int i = path.Count - 1; i >= 0; i--) + { + if (path[i] is ReverseOrderPathOffset) + { + chain[depth] = (path[i] as ReverseOrderPathOffset).getOffset(); + } + else + { + depth++; + chain[depth] = 0; + } + } + BM.Write(depth); + for (long z = depth; z >= 0; z--) + BM.Write(chain[z]); + fileindex++; + }; + for (long z = depth + 1; z < 13; z++) + BM.Write(chain[z]); + BM.BaseStream.Seek(5, SeekOrigin.Begin); + BM.Write(result.Count * 8 * 14); + BM.BaseStream.Close(); + } + catch (IOException) { textBox1.Text = "Cannot create file"; } + } + else + { + textBox1.Text = "not found"; + } + } + private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { if (e.ColumnIndex == 0) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = @""; - //[ファイルの種類]に表示される選択肢を指定する - //指定しないとすべてのファイルが表示される - ofd.Filter = "NoexsDumpFile(*.dmp)|*.dmp|All Files(*.*)|*.*"; + ofd.Filter = "EdizonSE DumpFile(*.dmp*)|*.dmp*|All Files(*.*)|*.*"; ofd.FilterIndex = 1; - ofd.Title = "select Noexs dump file"; + ofd.Title = "select EdiZon SE dump file"; if (ofd.ShowDialog() == DialogResult.OK) { dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ofd.FileName; @@ -207,6 +278,13 @@ private async void buttonNarrowDown_Click(object sender, EventArgs e) IDumpDataReader reader = CreateDumpDataReader(row, true); if (reader != null) { + reader.readsetup(); + dataGridView1.Rows[i].Cells[1].Value = "0x" + Convert.ToString(reader.mainStartAddress(), 16); + dataGridView1.Rows[i].Cells[2].Value = "0x" + Convert.ToString(reader.mainEndAddress(), 16); + dataGridView1.Rows[i].Cells[2].Value = "0x" + Convert.ToString(reader.mainEndAddress(), 16); + dataGridView1.Rows[i].Cells[3].Value = "0x" + Convert.ToString(reader.heapStartAddress(), 16); + dataGridView1.Rows[i].Cells[4].Value = "0x" + Convert.ToString(reader.heapEndAddress(), 16); + dataGridView1.Rows[i].Cells[5].Value = "0x" + Convert.ToString(reader.TargetAddress(), 16); long target = Convert.ToInt64(row.Cells[5].Value.ToString(), 16); dumps.Add(reader, target); @@ -285,20 +363,6 @@ private IDumpDataReader CreateDumpDataReader(DataGridViewRow row, bool allowUnkn long mainEnd = -1; long heapStart = -1; long heapEnd = -1; - long target = -1; - - for (int i = 0; i <= 5; i++) - { - if (row.Cells[i] == null) - { - row.Cells[i].Style.BackColor = Color.Red; - canCreate = false; - } - else - { - row.Cells[i].Style.BackColor = Color.White; - } - } if (row.Cells[0].Value != null) { @@ -309,77 +373,6 @@ private IDumpDataReader CreateDumpDataReader(DataGridViewRow row, bool allowUnkn row.Cells[0].Style.BackColor = Color.Red; canCreate = false; } - try - { - mainStart = Convert.ToInt64(row.Cells[1].Value.ToString(), 16); - } - catch - { - row.Cells[1].Style.BackColor = Color.Red; - canCreate = false; - } - try - { - mainEnd = Convert.ToInt64(row.Cells[2].Value.ToString(), 16); - } - catch - { - row.Cells[2].Style.BackColor = Color.Red; - canCreate = false; - } - try - { - heapStart = Convert.ToInt64(row.Cells[3].Value.ToString(), 16); - } - catch - { - row.Cells[3].Style.BackColor = Color.Red; - canCreate = false; - } - try - { - heapEnd = Convert.ToInt64(row.Cells[4].Value.ToString(), 16); - } - catch - { - row.Cells[4].Style.BackColor = Color.Red; - canCreate = false; - } - try - { - target = Convert.ToInt64(row.Cells[5].Value.ToString(), 16); - } - catch - { - row.Cells[5].Style.BackColor = Color.Red; - canCreate = false; - } - if (!canCreate) - { - return null; - } - if (mainEnd <= mainStart) - { - row.Cells[1].Style.BackColor = Color.Red; - row.Cells[2].Style.BackColor = Color.Red; - canCreate = false; - } - if (heapEnd <= heapStart) - { - row.Cells[3].Style.BackColor = Color.Red; - row.Cells[4].Style.BackColor = Color.Red; - canCreate = false; - } - if (allowUnknownTarget && (target == 0)) - { - //if target address is set to 0,it means unknown address. - } - else if ((target < heapStart) || (heapEnd <= target)) - { - //if not unknown,target should be located at heap region - row.Cells[5].Style.BackColor = Color.Red; - canCreate = false; - } if (!canCreate) { return null; @@ -414,5 +407,40 @@ private void buttonCancel_Click_1(object sender, EventArgs e) cancel.Cancel(); } } + + private void textBoxDepth_TextChanged(object sender, EventArgs e) + { + + } + + private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + + } + + private void Form1_Load(object sender, EventArgs e) + { + + } + + private void Export_to_SE_Click(object sender, EventArgs e) + { + ExportPath(); + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + + private void textBox2_TextChanged(object sender, EventArgs e) + { + + } + + private void label4_Click(object sender, EventArgs e) + { + + } } } diff --git a/PointerSearcher/IDumpDataReader.cs b/PointerSearcher/IDumpDataReader.cs index e59a866..c9cd5d7 100644 --- a/PointerSearcher/IDumpDataReader.cs +++ b/PointerSearcher/IDumpDataReader.cs @@ -10,5 +10,11 @@ internal interface IDumpDataReader long TryToParseAbs(List path); Address TryToParseRel(List path); bool IsHeap(long address); + long mainStartAddress(); + long mainEndAddress(); + long heapStartAddress(); + long heapEndAddress(); + long TargetAddress(); + void readsetup(); } } diff --git a/PointerSearcher/NoexsDumpDataReader.cs b/PointerSearcher/NoexsDumpDataReader.cs index 1ac1879..6145e07 100644 --- a/PointerSearcher/NoexsDumpDataReader.cs +++ b/PointerSearcher/NoexsDumpDataReader.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Threading; +using System.Xml.Schema; namespace PointerSearcher { @@ -58,9 +59,13 @@ class NoexsDumpDataReader : IDumpDataReader private long mainEndAddress; private long heapStartAddress; private long heapEndAddress; + private long TargetAddress; private byte[] buffer = new byte[8]; + private byte[] buffN = null; + private long length = 0; + private bool firstread = true; private List indices; - private List infos; + //private List infos; private Dictionary readData; //key:address,value:data public NoexsDumpDataReader(String path, long mainStart, long mainEnd, long heapStart, long heapEnd) { @@ -71,7 +76,7 @@ public NoexsDumpDataReader(String path, long mainStart, long mainEnd, long heapS heapEndAddress = heapEnd; buffer = new byte[8]; indices = null; - infos = new List(); + //infos = new List(); readData = new Dictionary(); } ~NoexsDumpDataReader() @@ -108,12 +113,42 @@ private Int64 ReadLittleEndianInt64() } private Int64 ReadLittleEndianInt64(long address) { - foreach (NoexsDumpIndex x in indices) + if (firstread) { - if ((x.address <= address) && (address + 7 <= x.address + x.size)) + long start = 134 + 8 * 5; // Edizon start of data dump + length = (fileStream.BaseStream.Length - start) / 16;// from Address+ to address + fileStream.BaseStream.Seek(start, SeekOrigin.Begin); + int readSize = (int)(fileStream.BaseStream.Length - start); + buffN = fileStream.ReadBytes(readSize); + firstread = false; + } + int Start = 0; + int end = (int)length - 1; + while ((end - Start) > 5) // check whether optimal + { + int index = Start + (end - Start) / 2; + long source = BitConverter.ToInt64(buffN, (index * 2) << 3); + if (source == address) + { + long target = BitConverter.ToInt64(buffN, (index * 2 + 1) << 3); + return target; + } + else if (source > address) + { + end = (index - 1); + } + else + { + Start = (index + 1); + } + } + for (int index = Start; index <= end; index++) + { + long source = BitConverter.ToInt64(buffN, (index * 2) << 3); + if (source == address) { - fileStream.BaseStream.Seek(x.pos + address - x.address, SeekOrigin.Begin); - return fileStream.ReadInt64(); + long target = BitConverter.ToInt64(buffN, (index * 2 + 1) << 3); + return target; } } return 0; @@ -129,84 +164,47 @@ private void ReadIndicate() indices = new List(); fileStream.BaseStream.Seek(0, SeekOrigin.Begin); - if (ReadBigEndianInt32() != 0x4E444D50) + if (fileStream.ReadInt32() != 0x4E5A4445) //edizon's version { fileStream.Close(); throw new Exception("illegal file format"); } + fileStream.BaseStream.Seek(134, SeekOrigin.Begin); // Edizon header size = 134 + mainStartAddress = fileStream.ReadInt64(); + mainEndAddress = fileStream.ReadInt64(); + heapStartAddress = fileStream.ReadInt64(); + heapEndAddress = fileStream.ReadInt64(); + TargetAddress = fileStream.ReadInt64(); + return; - long tid = ReadBigEndianInt64(); // TID - - int infoCount = ReadBigEndianInt32(); - long infoPtr = ReadBigEndianInt64(); - - int idxCount = ReadBigEndianInt32(); - long idxPtr = ReadBigEndianInt64(); - long dataPtr = fileStream.BaseStream.Position; - fileStream.BaseStream.Seek(idxPtr, SeekOrigin.Begin); - for (int i = 0; i < idxCount; i++) - { - long addr = ReadBigEndianInt64(); - long pos = ReadBigEndianInt64(); - long size = ReadBigEndianInt64(); - indices.Add(new NoexsDumpIndex(addr, pos, size)); - } } PointerInfo IDumpDataReader.Read(CancellationToken token, IProgress prog) { var sw = new System.Diagnostics.Stopwatch(); sw.Start(); PointerInfo pointerInfo = new PointerInfo(); - const int readMaxSize = 4096; ReadIndicate(); - - //foreach (NoexsDumpIndex x in indices) - for (int index = 0; index < indices.Count; index++) + long start = 134 + 8 * 5; // Edizon start of data dump + long length = (fileStream.BaseStream.Length - start) / 16;// from Address+ to address + fileStream.BaseStream.Seek(start, SeekOrigin.Begin); + int readSize = (int)(fileStream.BaseStream.Length - start); + byte[] buff = fileStream.ReadBytes(readSize); + for (int index = 0; index < length; index++) { - NoexsDumpIndex x = indices[index]; if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } - if (!IsMainHeapAddress(x.address)) - { - continue; - } - fileStream.BaseStream.Seek(x.pos, SeekOrigin.Begin); - MemoryType type = GetMemoryType(x.address); - long startAddress = GetStartAddress(type); - long address = x.address - startAddress; - long rem = x.size; - - while (rem > 0) - { - if (token.IsCancellationRequested) - { - token.ThrowIfCancellationRequested(); - } - int readSize = readMaxSize; - if (rem < readSize) - { - readSize = (int)rem; - } - rem -= readSize; - byte[] buff = fileStream.ReadBytes(readSize); - //pickup pointer from heap - int loopcnt = readSize / 8; - for (int i = 0; i < loopcnt; i++) - { - long tmp_data = BitConverter.ToInt64(buff, i << 3); - if (IsHeapAddress(tmp_data)) - { - Address from = new Address(type, address); - Address to = new Address(MemoryType.HEAP, tmp_data - heapStartAddress); - pointerInfo.AddPointer(from, to); - } - address += 8; - } - } - prog.Report((int)(100 * (index + 1) / indices.Count)); + long source = BitConverter.ToInt64(buff, (index * 2) << 3); //fileStream.ReadInt64(); + long target = BitConverter.ToInt64(buff, (index * 2 + 1) << 3); //fileStream.ReadInt64(); + MemoryType sourcetype = GetMemoryType(source); + long startAddress = GetStartAddress(sourcetype); + Address from = new Address(sourcetype, source - startAddress); + Address to = new Address(MemoryType.HEAP, target - heapStartAddress); + pointerInfo.AddPointer(from, to); + if (index % 10000 == 1) + prog.Report((int)(100 * (index + 1) / length)); } pointerInfo.MakeList(); sw.Stop(); @@ -214,6 +212,30 @@ PointerInfo IDumpDataReader.Read(CancellationToken token, IProgress prog) //3.28.24 return pointerInfo; } + void IDumpDataReader.readsetup() + { + ReadIndicate(); + } + long IDumpDataReader.mainStartAddress() + { + return mainStartAddress; + } + long IDumpDataReader.mainEndAddress() + { + return mainEndAddress; + } + long IDumpDataReader.heapStartAddress() + { + return heapStartAddress; + } + long IDumpDataReader.heapEndAddress() + { + return heapEndAddress; + } + long IDumpDataReader.TargetAddress() + { + return TargetAddress; + } long IDumpDataReader.TryToParseAbs(List path) { ReadIndicate();