From 713b1c83e122134934c56f05a4091af87cf7d74a Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 8 Dec 2022 10:38:46 -0800 Subject: [PATCH] Fix yet more string data reading --- BurnOutSharp.Builder/Extensions.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/BurnOutSharp.Builder/Extensions.cs b/BurnOutSharp.Builder/Extensions.cs index c6a918a6..e96d5d6c 100644 --- a/BurnOutSharp.Builder/Extensions.cs +++ b/BurnOutSharp.Builder/Extensions.cs @@ -1280,7 +1280,7 @@ namespace BurnOutSharp.Builder versionInfo.Padding1 = entry.Data.ReadUInt16(ref offset); // Read fixed file info - if (versionInfo.ValueLength != 0) + if (versionInfo.ValueLength > 0) { var fixedFileInfo = new Models.PortableExecutable.FixedFileInfo(); fixedFileInfo.Signature = entry.Data.ReadUInt32(ref offset); @@ -1357,8 +1357,11 @@ namespace BurnOutSharp.Builder while ((offset % 4) != 0) stringData.Padding = entry.Data.ReadUInt16(ref offset); - if (stringData.ValueLength != 0) - stringData.Value = entry.Data.ReadString(ref offset, Encoding.Unicode); + if (stringData.ValueLength > 0) + { + byte[] valueBytes = entry.Data.ReadBytes(ref offset, stringData.ValueLength * sizeof(ushort)); + stringData.Value = Encoding.Unicode.GetString(valueBytes); + } while ((offset % 4) != 0) _ = entry.Data.ReadUInt16(ref offset); @@ -1472,8 +1475,11 @@ namespace BurnOutSharp.Builder while ((offset % 4) != 0) stringData.Padding = entry.Data.ReadUInt16(ref offset); - if (stringData.ValueLength != 0) - stringData.Value = entry.Data.ReadString(ref offset, Encoding.Unicode); + if (stringData.ValueLength > 0) + { + byte[] valueBytes = entry.Data.ReadBytes(ref offset, stringData.ValueLength * sizeof(ushort)); + stringData.Value = Encoding.Unicode.GetString(valueBytes); + } while ((offset % 4) != 0) _ = entry.Data.ReadUInt16(ref offset);