Skip to content

Commit

Permalink
BinaryLog: fix raw data extraction aka FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Oct 13, 2023
1 parent 0d0809f commit bb7d061
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ExtLibs/Utilities/BinaryLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ private object[] ProcessMessageObjects(byte[] message, string name, string forma
return (mode, 1);

case 'Z':
return (Encoding.ASCII.GetString(message, offset, 64).Trim('\0'), 64);
return (new ReadOnlySpan<byte>(message, offset, 64).ToArray(), 64);

case 'a':
return (new UnionArray(new ReadOnlySpan<byte>(message, offset, 64).ToArray()), 2 * 32);
Expand Down
5 changes: 3 additions & 2 deletions Log/LogBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,7 @@ private void exportFilesToolStripMenuItem_Click(object sender, EventArgs e)
var name = file.GetRaw<string>("FileName");
var offset = file.GetRaw<uint>("Offset");
var length = file.GetRaw<byte>("Length");
var data = file.GetRaw<string>("Data");
var data = file.GetRaw<byte[]>("Data");

var path = Path.Combine(dir, name);

Expand All @@ -3813,10 +3813,11 @@ private void exportFilesToolStripMenuItem_Click(object sender, EventArgs e)
{
f = File.OpenWrite(path);
filehandles.Add(name, f);
f.SetLength(0);
}

f.Seek(offset, SeekOrigin.Begin);
var data2 = data.Select(a => (byte) a).ToArray().MakeSize(length);
var data2 = data.MakeSize(length);
f.Write(data2, 0, length);
}

Expand Down

0 comments on commit bb7d061

Please sign in to comment.