Skip to content

Commit

Permalink
add label, file select and save more data with file
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed Sep 7, 2021
1 parent a41482a commit d4599e8
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 42 deletions.
98 changes: 68 additions & 30 deletions PointerSearcher/Form1.Designer.cs

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

96 changes: 84 additions & 12 deletions PointerSearcher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,26 @@ private void Form1_Load( object sender, EventArgs e )
{
pictureBox1.BringToFront();
dgvDumpTargets.Rows.Add( 10 );
dgvDumpTargets[8, 0].Value = 1;
dgvDumpTargets[8, 1].Value = 2;
dgvDumpTargets[8, 2].Value = 3;
dgvDumpTargets[8, 3].Value = 4;
dgvDumpTargets[8, 4].Value = 5;
dgvDumpTargets[8, 5].Value = 6;
dgvDumpTargets[8, 6].Value = 7;
dgvDumpTargets[8, 7].Value = 8;
dgvDumpTargets[8, 8].Value = 9;
dgvDumpTargets[8, 9].Value = 10;
dgvDumpTargets[8, 0].Value = 0;
dgvDumpTargets[8, 1].Value = 0;
dgvDumpTargets[8, 2].Value = 0;
dgvDumpTargets[8, 3].Value = 0;
dgvDumpTargets[8, 4].Value = 0;
dgvDumpTargets[8, 5].Value = 0;
dgvDumpTargets[8, 6].Value = 0;
dgvDumpTargets[8, 7].Value = 0;
dgvDumpTargets[8, 8].Value = 0;
dgvDumpTargets[8, 9].Value = 0;
dgvDumpTargets[9, 0].Value = 1;
dgvDumpTargets[9, 1].Value = 2;
dgvDumpTargets[9, 2].Value = 3;
dgvDumpTargets[9, 3].Value = 4;
dgvDumpTargets[9, 4].Value = 5;
dgvDumpTargets[9, 5].Value = 6;
dgvDumpTargets[9, 6].Value = 7;
dgvDumpTargets[9, 7].Value = 8;
dgvDumpTargets[9, 8].Value = 9;
dgvDumpTargets[9, 9].Value = 10;

s = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
s.Close();
Expand Down Expand Up @@ -444,8 +454,13 @@ private void dataGridView1_CellBeginEdit( object sender, DataGridViewCellCancelE
dgvDumpTargets.Rows[e.RowIndex].Cells[3].Value = "0x" + Convert.ToString( reader.heapStartAddress(), 16 );
dgvDumpTargets.Rows[e.RowIndex].Cells[4].Value = "0x" + Convert.ToString( reader.heapEndAddress(), 16 );
dgvDumpTargets.Rows[e.RowIndex].Cells[5].Value = "0x" + Convert.ToString( reader.TargetAddress(), 16 );
if (reader.extra_data()) {
dgvDumpTargets.Rows[e.RowIndex].Cells[6].Value = "0x" + Convert.ToString( reader.TargetAddress2(), 16 );
dgvDumpTargets.Rows[e.RowIndex].Cells[7].Value = "0x" + Convert.ToString( reader.TargetAddress3(), 16 );
dgvDumpTargets.Rows[e.RowIndex].Cells[10].Value = reader.label();
}
// BM1

reader.delete();
}
}
}
Expand Down Expand Up @@ -532,6 +547,10 @@ private async void buttonNarrowDown_Click( object sender, EventArgs e )

private bool IsBlankRow( DataGridViewRow row )
{
if ( row.Cells[8].Value.ToString() == "0" )
{
return true;
}
for ( int i = 0; i <= 5; i++ )
{
if ( row.Cells[i].Value == null )
Expand Down Expand Up @@ -662,6 +681,40 @@ private void dataGridView1_CellEnter( object sender, DataGridViewCellEventArgs e
// dataGridView1.BeginEdit(true);
}

private void dataGridView1_CellEndEdit( object sender, DataGridViewCellEventArgs e )
{
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();
BinaryWriter fileStream = new BinaryWriter( new FileStream( dgvDumpTargets.Rows[e.RowIndex].Cells[0].Value.ToString(), FileMode.Open, FileAccess.Write ) );
// }
if ( fileStream != null )
{
fileStream.BaseStream.Seek( 0, SeekOrigin.Begin );
int magic = 0x4E5A4446;
byte[] buffer = BitConverter.GetBytes( magic );
fileStream.BaseStream.Write( buffer, 0, 4 );
buffer = BitConverter.GetBytes( ( dgvDumpTargets.Rows[e.RowIndex].Cells[6].Value != null ) ? Convert.ToInt64( dgvDumpTargets.Rows[e.RowIndex].Cells[6].Value.ToString(), 16 ) : 0 );
fileStream.BaseStream.Write( buffer, 0, 8 );
buffer = BitConverter.GetBytes( ( dgvDumpTargets.Rows[e.RowIndex].Cells[7].Value != null ) ? Convert.ToInt64( dgvDumpTargets.Rows[e.RowIndex].Cells[7].Value.ToString(), 16 ) : 0 );
fileStream.BaseStream.Write( buffer, 0, 8 );
fileStream.BaseStream.Write( System.Text.Encoding.UTF8.GetBytes( dgvDumpTargets.Rows[e.RowIndex].Cells[10].Value.ToString() ), 0, dgvDumpTargets.Rows[e.RowIndex].Cells[10].Value.ToString().Length);
for (int i = 0; i < 100- dgvDumpTargets.Rows[e.RowIndex].Cells[10].Value.ToString().Length; i++ )
fileStream.BaseStream.WriteByte( 0 );
fileStream.BaseStream.Seek( 135 + 32, SeekOrigin.Begin );
buffer = BitConverter.GetBytes( ( dgvDumpTargets.Rows[e.RowIndex].Cells[5].Value != null ) ? Convert.ToInt64( dgvDumpTargets.Rows[e.RowIndex].Cells[5].Value.ToString(), 16 ) : 0 );
fileStream.BaseStream.Write( buffer, 0, 8 );
fileStream.Close();
}
}
// WIP update extra data
// IDumpDataReader reader = CreateDumpDataReader( dgvDumpTargets.Rows[e.RowIndex], false );
// if ( reader == null )
// {
// throw new Exception( "Invalid input" + Environment.NewLine + "Check highlighted cell" );
// }
// dataGridView1.BeginEdit(true);
}
private void SetProgressBar( int percent )
{
progressBar1.Value = percent;
Expand Down Expand Up @@ -1246,9 +1299,15 @@ private void button3_Click( object sender, EventArgs e )
BinaryWriter fileStream2 = new BinaryWriter( new FileStream( "DirectTransfer.tmp" + Convert.ToString( fileselect ), FileMode.Create, FileAccess.Write ) );
fileStream2.BaseStream.Seek( 0, SeekOrigin.Begin );
fileStream.BaseStream.Seek( 0, SeekOrigin.Begin );
int magic = 0x4E5A4445;
int magic = 0x4E5A4446;
byte[] buffer = BitConverter.GetBytes( magic );
fileStream.BaseStream.Write( buffer, 0, 4 );
buffer = BitConverter.GetBytes( ( dgvDumpTargets.Rows[fileselect].Cells[6].Value != null ) ? Convert.ToInt64( dgvDumpTargets.Rows[fileselect].Cells[6].Value.ToString(), 16 ) : 0 );
fileStream.BaseStream.Write( buffer, 0, 8 );
buffer = BitConverter.GetBytes( ( dgvDumpTargets.Rows[fileselect].Cells[7].Value != null ) ? Convert.ToInt64( dgvDumpTargets.Rows[fileselect].Cells[7].Value.ToString(), 16 ) : 0 );
fileStream.BaseStream.Write( buffer, 0, 8 );
if ( dgvDumpTargets.Rows[fileselect].Cells[10].Value !=null )
fileStream.BaseStream.Write( System.Text.Encoding.UTF8.GetBytes( dgvDumpTargets.Rows[fileselect].Cells[10].Value.ToString()), 0, dgvDumpTargets.Rows[fileselect].Cells[10].Value.ToString().Length );
fileStream.BaseStream.Seek( 135, SeekOrigin.Begin );
buffer = BitConverter.GetBytes( address1 );
fileStream.BaseStream.Write( buffer, 0, 8 );
Expand Down Expand Up @@ -2243,5 +2302,18 @@ private async void button13_Click( Object sender, EventArgs e )
buttonCancel.Enabled = false;
}
}

private void button13_Click_1( Object sender, EventArgs e )
{
char[] array = textBox1.Text.Replace(" ","").Replace( "\\x", "" ).ToCharArray();
int len = array.Length / 2;
char[] reverse = new char[len * 2];
for ( int i = 0; i < len; i++ )
{
reverse[i*2] = array[( len - 1 - i ) * 2];
reverse[i*2 + 1] = array[( len - 1 - i ) * 2 + 1];
};
textBox1.Text = new string( reverse );
}
}
}
Loading

0 comments on commit d4599e8

Please sign in to comment.