From 9130bb115d99f51a782862e7bae7739987050fd5 Mon Sep 17 00:00:00 2001
From: tomvita <68505331+tomvita@users.noreply.github.com>
Date: Mon, 30 Nov 2020 16:20:24 +0800
Subject: [PATCH] readmemblock
---
PointerSearcher/Form1.Designer.cs | 99 +++++++++++++++++--------------
PointerSearcher/Form1.cs | 97 +++++++++++++++++++++++++++++-
PointerSearcher/Form1.resx | 9 +++
3 files changed, 161 insertions(+), 44 deletions(-)
diff --git a/PointerSearcher/Form1.Designer.cs b/PointerSearcher/Form1.Designer.cs
index 5ab38c2..9e5946d 100644
--- a/PointerSearcher/Form1.Designer.cs
+++ b/PointerSearcher/Form1.Designer.cs
@@ -29,10 +29,10 @@ protected override void Dispose(bool disposing)
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
this.buttonRead = new System.Windows.Forms.Button();
this.txtPointerSearchResults = new System.Windows.Forms.TextBox();
this.dgvDumpTargets = new System.Windows.Forms.DataGridView();
@@ -95,6 +95,9 @@ private void InitializeComponent()
this.button9 = new System.Windows.Forms.Button();
this.overwrite = new System.Windows.Forms.CheckBox();
this.dgvBookmarks = new System.Windows.Forms.DataGridView();
+ this.lblRow = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Address1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Label = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.getbookmarkbutton = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.resumebutton = new System.Windows.Forms.Button();
@@ -208,9 +211,7 @@ private void InitializeComponent()
this.button8 = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.button10 = new System.Windows.Forms.Button();
- this.lblRow = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Address1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Label = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.button11 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgvDumpTargets)).BeginInit();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
@@ -277,8 +278,8 @@ private void InitializeComponent()
this.dgvDumpTargets.Name = "dgvDumpTargets";
this.dgvDumpTargets.RowHeadersVisible = false;
this.dgvDumpTargets.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
- dataGridViewCellStyle10.NullValue = null;
- this.dgvDumpTargets.RowsDefaultCellStyle = dataGridViewCellStyle10;
+ dataGridViewCellStyle6.NullValue = null;
+ this.dgvDumpTargets.RowsDefaultCellStyle = dataGridViewCellStyle6;
this.dgvDumpTargets.RowTemplate.Height = 21;
this.dgvDumpTargets.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dgvDumpTargets.Size = new System.Drawing.Size(1088, 163);
@@ -344,8 +345,8 @@ private void InitializeComponent()
// ColumnFileRow
//
this.ColumnFileRow.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
- dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.ColumnFileRow.DefaultCellStyle = dataGridViewCellStyle9;
+ dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+ this.ColumnFileRow.DefaultCellStyle = dataGridViewCellStyle5;
this.ColumnFileRow.HeaderText = "File";
this.ColumnFileRow.MinimumWidth = 25;
this.ColumnFileRow.Name = "ColumnFileRow";
@@ -884,6 +885,35 @@ private void InitializeComponent()
this.dgvBookmarks.Size = new System.Drawing.Size(336, 99);
this.dgvBookmarks.TabIndex = 22;
//
+ // lblRow
+ //
+ this.lblRow.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
+ this.lblRow.FillWeight = 14.28426F;
+ this.lblRow.HeaderText = "";
+ this.lblRow.MinimumWidth = 10;
+ this.lblRow.Name = "lblRow";
+ this.lblRow.ReadOnly = true;
+ this.lblRow.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+ this.lblRow.Width = 10;
+ //
+ // Address1
+ //
+ this.Address1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Address1.FillWeight = 93.35786F;
+ this.Address1.HeaderText = "Address";
+ this.Address1.Name = "Address1";
+ this.Address1.ReadOnly = true;
+ this.Address1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+ //
+ // Label
+ //
+ this.Label.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
+ this.Label.FillWeight = 93.35786F;
+ this.Label.HeaderText = "Label";
+ this.Label.Name = "Label";
+ this.Label.ReadOnly = true;
+ this.Label.Width = 58;
+ //
// getbookmarkbutton
//
this.getbookmarkbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -1006,17 +1036,17 @@ private void InitializeComponent()
// fromDataGridViewTextBoxColumn
//
this.fromDataGridViewTextBoxColumn.DataPropertyName = "From";
- dataGridViewCellStyle11.Format = "X10";
- dataGridViewCellStyle11.NullValue = null;
- this.fromDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle11;
+ dataGridViewCellStyle7.Format = "X10";
+ dataGridViewCellStyle7.NullValue = null;
+ this.fromDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle7;
this.fromDataGridViewTextBoxColumn.HeaderText = "From";
this.fromDataGridViewTextBoxColumn.Name = "fromDataGridViewTextBoxColumn";
//
// toDataGridViewTextBoxColumn
//
this.toDataGridViewTextBoxColumn.DataPropertyName = "To";
- dataGridViewCellStyle12.Format = "X10";
- this.toDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle12;
+ dataGridViewCellStyle8.Format = "X10";
+ this.toDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle8;
this.toDataGridViewTextBoxColumn.HeaderText = "To";
this.toDataGridViewTextBoxColumn.Name = "toDataGridViewTextBoxColumn";
//
@@ -1830,40 +1860,22 @@ private void InitializeComponent()
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
- // lblRow
- //
- this.lblRow.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
- this.lblRow.FillWeight = 14.28426F;
- this.lblRow.HeaderText = "";
- this.lblRow.MinimumWidth = 10;
- this.lblRow.Name = "lblRow";
- this.lblRow.ReadOnly = true;
- this.lblRow.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
- this.lblRow.Width = 10;
- //
- // Address1
+ // button11
//
- this.Address1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Address1.FillWeight = 93.35786F;
- this.Address1.HeaderText = "Address";
- this.Address1.Name = "Address1";
- this.Address1.ReadOnly = true;
- this.Address1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
- //
- // Label
- //
- this.Label.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
- this.Label.FillWeight = 93.35786F;
- this.Label.HeaderText = "Label";
- this.Label.Name = "Label";
- this.Label.ReadOnly = true;
- this.Label.Width = 58;
+ this.button11.Location = new System.Drawing.Point(646, 497);
+ this.button11.Name = "button11";
+ this.button11.Size = new System.Drawing.Size(210, 23);
+ this.button11.TabIndex = 102;
+ this.button11.Text = "test readmemblock";
+ this.button11.UseVisualStyleBackColor = true;
+ this.button11.Click += new System.EventHandler(this.button11_Click_1);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1114, 660);
+ this.Controls.Add(this.button11);
this.Controls.Add(this.button10);
this.Controls.Add(this.button8);
this.Controls.Add(this.label29);
@@ -2119,6 +2131,7 @@ private void InitializeComponent()
private System.Windows.Forms.DataGridViewTextBoxColumn lblRow;
private System.Windows.Forms.DataGridViewTextBoxColumn Address1;
private System.Windows.Forms.DataGridViewTextBoxColumn Label;
+ private System.Windows.Forms.Button button11;
}
}
diff --git a/PointerSearcher/Form1.cs b/PointerSearcher/Form1.cs
index adb42df..343300e 100644
--- a/PointerSearcher/Form1.cs
+++ b/PointerSearcher/Form1.cs
@@ -1026,7 +1026,92 @@ private int LZ_Uncompress( byte[] inbuf, ref byte[] outbuf, int insize )
} while ( inpos < insize );
return (int)outpos;
}
-
+ private int rle_Uncompress( byte[] inbuf, ref byte[] outbuf, int insize )
+ {
+ int inpos, outpos;
+ byte value, len;
+ if ( insize < 1 )
+ {
+ return 0;
+ }
+ inpos = 0;
+ outpos = 0;
+ do
+ {
+ value = inbuf[inpos];
+ len = inbuf[inpos + 1];
+ for ( byte i = 0; i < len; i++ )
+ outbuf[outpos] = inbuf[inpos + i];
+ inpos += 2;
+ outpos += len;
+ } while ( inpos < insize );
+ return outpos;
+ }
+ private bool noerror()
+ {
+ while ( s.Available < 4 ) { }
+ byte[] b = new byte[4];
+ s.Receive( b );
+ return !showerror( b );
+ }
+ private bool readmemblock(ref byte[] outbuf, long address, int size)
+ {
+ if ( !command_available() )
+ {
+ return false;
+ }
+ byte[] k = new byte[5];
+ int len;
+ int pos = 0;
+ byte[] inbuf;
+ int a = SendMessage( NoexsCommands.ReadMem );
+ a = SendData( BitConverter.GetBytes( address ) );
+ a = SendData( BitConverter.GetBytes( size ) );
+ if ( noerror() )
+ {
+ while (size >0)
+ {
+ if ( noerror() )
+ {
+ while ( s.Available < 5 ) { }
+ s.Receive( k );
+ len = BitConverter.ToInt32( k, 1 );
+ if (k[0] == 0) // no compression
+ {
+ inbuf = new byte[len];
+ while ( s.Available < len ) { }
+ s.Receive( inbuf );
+ for ( int i = 0; i < len; i++ )
+ outbuf[pos + i] = inbuf[i];
+ pos += len;
+ size -= len;
+ }
+ else
+ {
+ k = new byte[4];
+ while ( s.Available < 4 ) { }
+ s.Receive( k );
+ int rlesize = BitConverter.ToInt32( k, 0 );
+ inbuf = new byte[rlesize];
+ while ( s.Available < rlesize ) { }
+ s.Receive( inbuf );
+ int urlesize = 0;
+ for ( int i = 0; urlesize < len; i += 2 )
+ {
+ for ( int m = 0; m < inbuf[1]; m++ )
+ outbuf[pos + urlesize + m] = inbuf[i];
+ urlesize += inbuf[i + 1];
+ }
+ pos += urlesize;
+ size -= urlesize;
+ }
+ }
+
+ }
+
+ }
+ return noerror();
+ }
private int SendMessage( NoexsCommands cmd )
{
return s.Send( new byte[] { (byte)cmd } );
@@ -1993,5 +2078,15 @@ private void button10_Click( object sender, EventArgs e )
{
ExportPath2();
}
+
+
+ private void button11_Click_1( Object sender, EventArgs e )
+ {
+ long targetAddress = Convert.ToInt64( dgvDumpTargets.Rows[fileselect].Cells[5 + targetselect].Value.ToString(), 16 );
+ int size = Convert.ToInt32( dgvDumpTargets.Rows[fileselect].Cells[6 + targetselect].Value.ToString(), 16 );
+ byte[] outbuf = new byte[size];
+ readmemblock( ref outbuf, targetAddress, size );
+ int a = 1;
+ }
}
}
diff --git a/PointerSearcher/Form1.resx b/PointerSearcher/Form1.resx
index 8a29ea6..f616c65 100644
--- a/PointerSearcher/Form1.resx
+++ b/PointerSearcher/Form1.resx
@@ -153,6 +153,15 @@
True
+
+ True
+
+
+ True
+
+
+ True
+
17, 17