Fix hex edit

oops
add length sanity check
This commit is contained in:
Kurt
2020-04-01 20:07:35 -07:00
parent 0baac3751f
commit de5eb9f0f7

View File

@@ -66,12 +66,23 @@ public void SetOffset(uint value)
public void HexEdit(uint offset, int length)
{
var data = ReadBytes(offset, length);
using var ram = new SimpleHexEditor(data);
var read = ReadBytes(offset, length);
using var ram = new SimpleHexEditor(read);
if (ram.ShowDialog() != DialogResult.OK)
return;
WriteBytes(data, offset);
var write = ram.Bytes;
if (read.Length != write.Length)
{
var prompt = WinFormsUtil.Prompt(MessageBoxButtons.OKCancel,
$"Read size (0x{read.Length:X}) != Write Size (0x{write.Length})",
"Write anyway?");
if (prompt != DialogResult.OK)
return;
}
WriteBytes(ram.Bytes, offset);
SetOffset(offset);
System.Media.SystemSounds.Asterisk.Play();
}