From 6da3257dc3fa0c686f44f89b835aecf24e8c9470 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sat, 7 Oct 2023 02:29:03 +0100 Subject: [PATCH] [Symbian Installation File] Fix parsing of component record. --- Aaru.Archives/Symbian/Info.cs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Aaru.Archives/Symbian/Info.cs b/Aaru.Archives/Symbian/Info.cs index 869c71b3f..754973082 100644 --- a/Aaru.Archives/Symbian/Info.cs +++ b/Aaru.Archives/Symbian/Info.cs @@ -30,11 +30,15 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; using System.Text; using Aaru.CommonTypes.Interfaces; +using Aaru.Console; using Aaru.Helpers; +using Marshal = Aaru.Helpers.Marshal; namespace Aaru.Archives; @@ -99,16 +103,30 @@ public partial class Symbian // Go to component record br.BaseStream.Seek(sh.comp_ptr, SeekOrigin.Begin); + var componentRecord = new ComponentRecord(); + buffer = new byte[sizeof(uint) * languages.Count]; + + // Read the component string lenghts + stream.EnsureRead(buffer, 0, buffer.Length); + ReadOnlySpan span = buffer; + componentRecord.namesLengths = MemoryMarshal.Cast(span)[..languages.Count].ToArray(); + + // Read the component string pointers + stream.EnsureRead(buffer, 0, buffer.Length); + span = buffer; + componentRecord.namesPointers = MemoryMarshal.Cast(span)[..languages.Count].ToArray(); + for(var i = 0; i < sh.languages; i++) { - uint comp_Len = br.ReadUInt32(); - uint comp_Name_Ptr = br.ReadUInt32(); + AaruConsole.DebugWriteLine(MODULE_NAME, + "Found component name for language {0} at {1} with a length of {2} bytes", + languages[i], componentRecord.namesPointers[i], componentRecord.namesLengths[i]); if(i != en_Pos) continue; - br.BaseStream.Seek(comp_Name_Ptr, SeekOrigin.Begin); - byte[] componentName_B = br.ReadBytes((int)comp_Len); + br.BaseStream.Seek(componentRecord.namesPointers[i], SeekOrigin.Begin); + byte[] componentName_B = br.ReadBytes((int)componentRecord.namesLengths[i]); componentName = encoding.GetString(componentName_B); break; }