From d74b82dc5545b0d905fae0506820f4b3d271288c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 2 Sep 2025 14:30:20 -0400 Subject: [PATCH] Hacky hack hack --- .../Wrappers/WiseSectionHeader.cs | 56 ++++--------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs b/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs index ffc31fc0..d9004243 100644 --- a/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs +++ b/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs @@ -23,50 +23,13 @@ namespace SabreTools.Serialization.Wrappers /// Returns the offset relative to the start of the header /// where the compressed data lives /// - public long CompressedDataOffset - { - get - { - long offset = 0; - - offset += 4; // UnknownDataSize - offset += 4; // SecondExecutableFileEntryLength - offset += 4; // UnknownValue2 - offset += 4; // UnknownValue3 - offset += 4; // UnknownValue4 - offset += 4; // FirstExecutableFileEntryLength - offset += 4; // MsiFileEntryLength - offset += 4; // UnknownValue7 - offset += 4; // UnknownValue8 - offset += 4; // ThirdExecutableFileEntryLength - offset += 4; // UnknownValue10 - offset += 4; // UnknownValue11 - offset += 4; // UnknownValue12 - offset += 4; // UnknownValue13 - offset += 4; // UnknownValue14 - offset += 4; // UnknownValue15 - offset += 4; // UnknownValue16 - offset += 4; // UnknownValue17 - offset += 4; // UnknownValue18 - offset += Version?.Length ?? 0; - offset += Model.TmpString == null ? 0 : Model.TmpString.Length + 1; - offset += Model.GuidString == null ? 0 : Model.GuidString.Length + 1; - offset += Model.NonWiseVersion == null ? 0 : Model.NonWiseVersion.Length + 1; - offset += Model.PreFontValue == null ? 0 : Model.PreFontValue.Length; - offset += 4; // FontSize - offset += Model.PreStringValues == null ? 0 : Model.PreStringValues.Length; - if (Model.Strings != null) - { - foreach (var str in Model.Strings) - { - offset += str.Length; - } - } - - return offset; - } - } - + /// TODO: Find a way for this to be automatically found based on the model + /// Likely would be able to replace most of the unknown values with + /// an array of values followed by padding bytes. This should be sufficient + /// to ensure that all possible values before the temp string are found + /// and read properly + public long CompressedDataOffset { get; private set; } + /// public uint UnknownDataSize => Model.UnknownDataSize; @@ -192,8 +155,11 @@ namespace SabreTools.Serialization.Wrappers if (model == null) return null; + // HACK: Cache the end-of-header offset + long endOffset = data.Position; + data.Seek(currentOffset, SeekOrigin.Begin); - return new WiseSectionHeader(model, data); + return new WiseSectionHeader(model, data) { CompressedDataOffset = endOffset}; } catch {