[Symbian Installation File] Parse Symbian OS >= 6.0 options.

This commit is contained in:
2023-10-08 04:42:45 +01:00
parent aa39281033
commit 42b2a8100b
5 changed files with 146 additions and 76 deletions

View File

@@ -171,6 +171,9 @@ public sealed partial class Symbian
unused = br.ReadUInt32()
};
if((int)attributeExpression.attribute > 0x2000)
sb.Append($"option({attributeExpression.attribute - 0x2000}, ENABLED)");
else
sb.Append($"{attributeExpression.attribute}");
attribute = attributeExpression.attribute;
@@ -184,6 +187,10 @@ public sealed partial class Symbian
unused = br.ReadUInt32()
};
if(attribute is null)
sb.Append($"0x{numberExpression.number:X8}");
else if((uint)attribute.Value < 0x2000)
{
switch(attribute)
{
case Attribute.Manufacturer:
@@ -261,6 +268,9 @@ public sealed partial class Symbian
sb.Append($"0x{numberExpression.number:X8}");
break;
}
}
else
sb.Append($"option({attribute.Value - 0x2000}, {(numberExpression.number > 0 ? "ENABLED" : "DISABLED")})");
attribute = null;

View File

@@ -301,6 +301,7 @@ public sealed partial class Symbian
uint currentFile = 0;
offset = sh.files_ptr;
var conditionLevel = 0;
_options = new List<OptionRecord>();
do
{
@@ -333,6 +334,20 @@ public sealed partial class Symbian
description.AppendLine();
}
if(_options.Count > 0)
{
for(var i = 0; i < _options.Count; i++)
{
OptionRecord option = _options[i];
description.AppendFormat("Option {0}:", i + 1).AppendLine();
foreach(KeyValuePair<string, string> kvp in option.names)
description.AppendFormat("\tName for language {0}: {1}", kvp.Key, kvp.Value).AppendLine();
}
description.AppendLine();
}
if(_conditions.Count > 0)
{
description.AppendLine("Conditions:");

View File

@@ -320,6 +320,9 @@ public sealed partial class Symbian
bool wait, close;
switch(decodedFileRecords[0].type)
{
case FileType.File:
_conditions.Add(tabulation + $"InstallFileTo(\"{decodedFileRecords[0].destinationName}\")");
break;
case FileType.FileText:
switch((FileDetails)((uint)decodedFileRecords[0].details & 0xFF))
{
@@ -444,7 +447,46 @@ public sealed partial class Symbian
break;
case FileRecordType.Options:
throw new NotImplementedException();
OptionsLineRecord optionsLineRecord = new()
{
recordType = (FileRecordType)br.ReadUInt32(),
numberOfOptions = br.ReadUInt32()
};
optionsLineRecord.options = new OptionRecord[(int)optionsLineRecord.numberOfOptions];
for(var i = 0; i < optionsLineRecord.numberOfOptions; i++)
{
optionsLineRecord.options[i] = new OptionRecord();
buffer = br.ReadBytes(sizeof(uint) * languages.Count);
span = buffer;
optionsLineRecord.options[i].lengths =
MemoryMarshal.Cast<byte, uint>(span)[..languages.Count].ToArray();
buffer = br.ReadBytes(sizeof(uint) * languages.Count);
span = buffer;
optionsLineRecord.options[i].pointers =
MemoryMarshal.Cast<byte, uint>(span)[..languages.Count].ToArray();
optionsLineRecord.options[i].names = new Dictionary<string, string>();
offset = (uint)br.BaseStream.Position;
for(var j = 0; j < languages.Count; j++)
{
br.BaseStream.Seek(optionsLineRecord.options[i].pointers[j], SeekOrigin.Begin);
buffer = br.ReadBytes((int)optionsLineRecord.options[i].lengths[j]);
optionsLineRecord.options[i].names.Add(languages[j], _encoding.GetString(buffer));
}
br.BaseStream.Seek(offset, SeekOrigin.Begin);
_options.Add(optionsLineRecord.options[i]);
}
offset = (uint)br.BaseStream.Position;
break;
case FileRecordType.If:
conditionLevel--;

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
@@ -316,7 +317,8 @@ public sealed partial class Symbian
/// <summary>
/// Pointer to the option names, array sorted as language records
/// </summary>
public uint[] strings;
public uint[] pointers;
public Dictionary<string, string> names;
}
#endregion

View File

@@ -47,6 +47,7 @@ public sealed partial class Symbian : IArchive
Encoding _encoding;
ArchiveSupportedFeature _features;
List<DecodedFileRecord> _files;
List<OptionRecord> _options;
bool _release6;
Stream _stream;