Skip to content

Commit

Permalink
Add label and offset upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed Oct 4, 2022
1 parent 13c04fc commit 1730297
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 2 deletions.
18 changes: 16 additions & 2 deletions PointerSearcher/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 122 additions & 0 deletions PointerSearcher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<IReverseOrderPath> 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"; }
}
}
}

0 comments on commit 1730297

Please sign in to comment.