Skip to content

Commit

Permalink
readmemblock
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed Nov 30, 2020
1 parent 5b87029 commit 9130bb1
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 44 deletions.
99 changes: 56 additions & 43 deletions PointerSearcher/Form1.Designer.cs

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

97 changes: 96 additions & 1 deletion PointerSearcher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } );
Expand Down Expand Up @@ -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;
}
}
}
9 changes: 9 additions & 0 deletions PointerSearcher/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@
<metadata name="Label.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblRow.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Address1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Label.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataSet1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
Expand Down

0 comments on commit 9130bb1

Please sign in to comment.