From 17302976f0e1c24cc8ea70ea844596c739fbe5c0 Mon Sep 17 00:00:00 2001 From: tomvita <68505331+tomvita@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:17:41 +0800 Subject: [PATCH] Add label and offset upload --- PointerSearcher/Form1.Designer.cs | 18 ++++- PointerSearcher/Form1.cs | 122 ++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 2 deletions(-) diff --git a/PointerSearcher/Form1.Designer.cs b/PointerSearcher/Form1.Designer.cs index 14077e5..88f7057 100644 --- a/PointerSearcher/Form1.Designer.cs +++ b/PointerSearcher/Form1.Designer.cs @@ -99,6 +99,7 @@ private void InitializeComponent() this.radioButton10 = new System.Windows.Forms.RadioButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.button15 = new System.Windows.Forms.Button(); this.button9 = new System.Windows.Forms.Button(); this.overwrite = new System.Windows.Forms.CheckBox(); this.dgvBookmarks = new System.Windows.Forms.DataGridView(); @@ -911,6 +912,7 @@ private void InitializeComponent() // this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox3.Controls.Add(this.button15); this.groupBox3.Controls.Add(this.button9); this.groupBox3.Controls.Add(this.overwrite); this.groupBox3.Controls.Add(this.dgvBookmarks); @@ -933,6 +935,17 @@ private void InitializeComponent() this.groupBox3.TabStop = false; this.groupBox3.Text = "Wireless feature"; // + // button15 + // + this.button15.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button15.Location = new System.Drawing.Point(186, 247); + this.button15.Name = "button15"; + this.button15.Size = new System.Drawing.Size(156, 23); + this.button15.TabIndex = 101; + this.button15.Text = "Upload Bookmark with label"; + this.button15.UseVisualStyleBackColor = true; + this.button15.Click += new System.EventHandler(this.button15_Click); + // // button9 // this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -1021,7 +1034,7 @@ private void InitializeComponent() // button6 // this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.button6.Location = new System.Drawing.Point(257, 247); + this.button6.Location = new System.Drawing.Point(6, 247); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(85, 23); this.button6.TabIndex = 91; @@ -2074,7 +2087,7 @@ private void InitializeComponent() this.Controls.Add(this.pictureBox2); this.Controls.Add(this.groupBox4); this.Name = "Form1"; - this.Text = "PointerSearcher SE 0.5.14b"; + this.Text = "PointerSearcher SE 0.5.15"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.dgvDumpTargets)).EndInit(); this.tabControl1.ResumeLayout(false); @@ -2300,6 +2313,7 @@ private void InitializeComponent() private System.Windows.Forms.TextBox WatchPointAddress_textBox11; private System.Windows.Forms.Button SetWatchPoint_button; private System.Windows.Forms.Button button14; + private System.Windows.Forms.Button button15; } } diff --git a/PointerSearcher/Form1.cs b/PointerSearcher/Form1.cs index 62f2cd9..594611a 100644 --- a/PointerSearcher/Form1.cs +++ b/PointerSearcher/Form1.cs @@ -683,6 +683,7 @@ private void dataGridView1_CellEnter( object sender, DataGridViewCellEventArgs e private void dataGridView1_CellEndEdit( object sender, DataGridViewCellEventArgs e ) { + return; if (( e.ColumnIndex >= 5 && e.ColumnIndex <= 7 || e.ColumnIndex == 10 ) && dgvDumpTargets.Rows[e.RowIndex].Cells[0].Value !=null) { // string filename = dgvDumpTargets.Rows[e.RowIndex].Cells[0].Value.ToString(); @@ -2443,5 +2444,126 @@ private void button14_Click( Object sender, EventArgs e ) resumebutton.Enabled = false; } } + private void prepareASM() + { + txtPointerSearchResults.Text = "Exporting result to file ... " + result.Count.ToString(); + String filepath = textBox2.Text; + BinaryWriter BM; + try + { + BM = new BinaryWriter( new FileStream( filepath, FileMode.Create, FileAccess.Write ) ); + BM.BaseStream.Seek( 0, SeekOrigin.Begin ); + int magic = 0x4E5A4545; // 0x4E5A4445 + BM.Write( magic ); + + int bookmark_count = 0; + for ( int i = 0; i < dgvDumpTargets.Rows.Count; i++ ) + { + DataGridViewRow row = dgvDumpTargets.Rows[i]; + ClearRowBackColor( row ); + if ( row.Cells[8].Value.ToString() == "0" ) + { + continue; + } + BM.BaseStream.Seek( 135 + bookmark_count * ( 4 + 100 ), SeekOrigin.Begin ); // u32 offset; char * label[100] Edizon header size = 135 + BM.Write( Convert.ToInt32( dgvDumpTargets.Rows[i].Cells[7].Value.ToString(), 16 ) ); + BM.Write( dgvDumpTargets.Rows[i].Cells[10].Value.ToString() ); //= "address"; + + bookmark_count++; + // dgvDumpTargets.Rows[i].Cells[2].Value = "0x" + Convert.ToString( reader.mainEndAddress(), 16 ); + // dataGridView1.Rows[i].Cells[5].Value = "0x" + Convert.ToString(reader.TargetAddress(), 16); + //long target = Convert.ToInt64( row.Cells[5 + targetselect].Value.ToString(), 16 ); + + } + //long fileindex = 0; + //long depth = 0; + //long[] chain = new long[13]; + + //foreach ( List path in result ) + //{ + // BM.BaseStream.Seek( 135 + fileindex * 8 * 14, SeekOrigin.Begin ); // sizeof(pointer_chain_t) Edizon header size = 135 + // 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( bookmark_count * ( 4 + 100 ) ); + BM.BaseStream.Close(); + } + catch ( IOException ) { txtPointerSearchResults.Text = "Cannot create file"; } + } + private void button15_Click( Object sender, EventArgs e ) + { + button15.BackColor = System.Drawing.Color.White; + + // prepare file + textBox2.Text = "AsmOffsetLabel.bmk"; + prepareASM(); + + if ( textBox2.Text == "" ) { MessageBox.Show( "bookmark filename missing" ); return; }; + String filepath = textBox2.Text; + BinaryReader BM; + try + { + BM = new BinaryReader( new FileStream( filepath, FileMode.Open, FileAccess.Read ) ); + BM.BaseStream.Seek( 0, SeekOrigin.Begin ); + int readSize = (int)( BM.BaseStream.Length ); + byte[] buff; + buff = BM.ReadBytes( readSize ); + + if ( !command_available() ) + { + return; + } + + int a = SendMessage( NoexsCommands.PutBookmark ); + while ( s.Available < 4 ) + { + ; + } + + byte[] b = new byte[s.Available]; + s.Receive( b ); + if ( !showerror( b ) ) + { + byte[] fsize = BitConverter.GetBytes( readSize ); + SendData( fsize ); + SendData( buff ); + while ( s.Available < 4 ) + { + ; + } + + b = new byte[s.Available]; + s.Receive( b ); + if ( !showerror( b ) ) + { button15.BackColor = System.Drawing.Color.LightGreen; } + } + else { MessageBox.Show( "Remote file not accessible" ); } + BM.BaseStream.Close(); + } + catch ( IOException ) { txtPointerSearchResults.Text = "Cannot Read file"; } + } } }