mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-28 04:47:51 -05:00
Fix hex edit
oops add length sanity check
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user