mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
More fixes to IS-CAB
This commit is contained in:
@@ -131,7 +131,7 @@ namespace BurnOutSharp.Builders
|
||||
#region Directory Descriptors
|
||||
|
||||
// Create and fill the directory descriptors
|
||||
cabinet.DirectoryDescriptors = new FileDescriptor[descriptor.DirectoryCount];
|
||||
cabinet.DirectoryNames = new string[descriptor.DirectoryCount];
|
||||
for (int i = 0; i < descriptor.DirectoryCount; i++)
|
||||
{
|
||||
// Get the directory descriptor offset
|
||||
@@ -147,8 +147,8 @@ namespace BurnOutSharp.Builders
|
||||
data.Seek(offset, SeekOrigin.Begin);
|
||||
|
||||
// Create and add the file descriptor
|
||||
FileDescriptor directoryDescriptor = ParseDirectoryDescriptor(data, GetMajorVersion(commonHeader));
|
||||
cabinet.DirectoryDescriptors[i] = directoryDescriptor;
|
||||
string directoryName = ParseDirectoryName(data, GetMajorVersion(commonHeader));
|
||||
cabinet.DirectoryNames[i] = directoryName;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -673,10 +673,22 @@ namespace BurnOutSharp.Builders
|
||||
component.FileGroupNames = new string[component.FileGroupCount];
|
||||
for (int j = 0; j < component.FileGroupCount; j++)
|
||||
{
|
||||
// Get the name offset
|
||||
uint nameOffset = data.ReadUInt32();
|
||||
|
||||
// Cache the current offset
|
||||
long preNameOffset = data.Position;
|
||||
|
||||
// Seek to the name offset
|
||||
data.Seek(nameOffset + descriptorOffset, SeekOrigin.Begin);
|
||||
|
||||
if (majorVersion >= 17)
|
||||
component.FileGroupNames[j] = data.ReadString(Encoding.Unicode);
|
||||
else
|
||||
component.FileGroupNames[j] = data.ReadString(Encoding.ASCII);
|
||||
|
||||
// Seek back to the original position
|
||||
data.Seek(preNameOffset, SeekOrigin.Begin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -687,22 +699,18 @@ namespace BurnOutSharp.Builders
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a Stream into a directory descriptor
|
||||
/// Parse a Stream into a directory name
|
||||
/// </summary>
|
||||
/// <param name="data">Stream to parse</param>
|
||||
/// <param name="majorVersion">Major version of the cabinet</param>
|
||||
/// <returns>Filled directory descriptor on success, null on error</returns>
|
||||
private static FileDescriptor ParseDirectoryDescriptor(Stream data, int majorVersion)
|
||||
/// <returns>Filled directory name on success, null on error</returns>
|
||||
private static string ParseDirectoryName(Stream data, int majorVersion)
|
||||
{
|
||||
FileDescriptor fileDescriptor = new FileDescriptor();
|
||||
|
||||
// Read the string
|
||||
if (majorVersion >= 17)
|
||||
fileDescriptor.Name = data.ReadString(Encoding.Unicode);
|
||||
return data.ReadString(Encoding.Unicode);
|
||||
else
|
||||
fileDescriptor.Name = data.ReadString(Encoding.ASCII);
|
||||
|
||||
return fileDescriptor;
|
||||
return data.ReadString(Encoding.ASCII);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace BurnOutSharp.Models.InstallShieldCabinet
|
||||
public uint[] FileDescriptorOffsets { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Directory file descriptors
|
||||
/// Directory names
|
||||
/// </summary>
|
||||
public FileDescriptor[] DirectoryDescriptors { get; set; }
|
||||
public string[] DirectoryNames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Standard file descriptors
|
||||
|
||||
@@ -8,6 +8,12 @@ namespace BurnOutSharp.Models.InstallShieldCabinet
|
||||
|
||||
public const uint SignatureUInt32 = 0x28635349;
|
||||
|
||||
public const int COMMON_HEADER_SIZE = 20;
|
||||
|
||||
public const int VOLUME_HEADER_SIZE_V5 = 40;
|
||||
|
||||
public const int VOLUME_HEADER_SIZE_V6 = 64;
|
||||
|
||||
// TODO: Determine how the value "71" was chosen here
|
||||
public const int MAX_FILE_GROUP_COUNT = 71;
|
||||
|
||||
|
||||
@@ -162,8 +162,8 @@ namespace BurnOutSharp.Wrappers
|
||||
|
||||
#region Directory Descriptors
|
||||
|
||||
/// <inheritdoc cref="Models.InstallShieldCabinet.Cabinet.DirectoryDescriptors"/>
|
||||
public Models.InstallShieldCabinet.FileDescriptor[] DirectoryDescriptors => _cabinet.DirectoryDescriptors;
|
||||
/// <inheritdoc cref="Models.InstallShieldCabinet.Cabinet.DirectoryNames"/>
|
||||
public string[] DirectoryNames => _cabinet.DirectoryNames;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace BurnOutSharp.Wrappers
|
||||
|
||||
// File Descriptors
|
||||
PrintFileDescriptorOffsets(builder);
|
||||
PrintDirectoryDescriptors(builder);
|
||||
PrintDirectoryNames(builder);
|
||||
PrintFileDescriptors(builder);
|
||||
|
||||
// File Groups
|
||||
@@ -472,35 +472,22 @@ namespace BurnOutSharp.Wrappers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Print directory descriptors information
|
||||
/// Print directory names information
|
||||
/// </summary>
|
||||
/// <param name="builder">StringBuilder to append information to</param>
|
||||
private void PrintDirectoryDescriptors(StringBuilder builder)
|
||||
private void PrintDirectoryNames(StringBuilder builder)
|
||||
{
|
||||
builder.AppendLine(" Directory Descriptors:");
|
||||
builder.AppendLine(" Directory Names:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (DirectoryDescriptors == null || DirectoryDescriptors.Length == 0)
|
||||
if (DirectoryNames == null || DirectoryNames.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No directory descriptors");
|
||||
builder.AppendLine(" No directory names");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < DirectoryDescriptors.Length; i++)
|
||||
for (int i = 0; i < DirectoryNames.Length; i++)
|
||||
{
|
||||
var directoryDescriptor = DirectoryDescriptors[i];
|
||||
builder.AppendLine($" Directory Descriptor {i}:");
|
||||
builder.AppendLine($" Name offset: {directoryDescriptor.NameOffset} (0x{directoryDescriptor.NameOffset:X})");
|
||||
builder.AppendLine($" Name: {directoryDescriptor.Name ?? "[NULL]"}");
|
||||
builder.AppendLine($" Directory index: {directoryDescriptor.DirectoryIndex} (0x{directoryDescriptor.DirectoryIndex:X})");
|
||||
builder.AppendLine($" Flags: {directoryDescriptor.Flags} (0x{directoryDescriptor.Flags:X})");
|
||||
builder.AppendLine($" Expanded size: {directoryDescriptor.ExpandedSize} (0x{directoryDescriptor.ExpandedSize:X})");
|
||||
builder.AppendLine($" Compressed size: {directoryDescriptor.CompressedSize} (0x{directoryDescriptor.CompressedSize:X})");
|
||||
builder.AppendLine($" Data offset: {directoryDescriptor.DataOffset} (0x{directoryDescriptor.DataOffset:X})");
|
||||
builder.AppendLine($" MD5: {BitConverter.ToString(directoryDescriptor.MD5 ?? new byte[0]).Replace('-', ' ')}");
|
||||
builder.AppendLine($" Volume: {directoryDescriptor.Volume} (0x{directoryDescriptor.Volume:X})");
|
||||
builder.AppendLine($" Link previous: {directoryDescriptor.LinkPrevious} (0x{directoryDescriptor.LinkPrevious:X})");
|
||||
builder.AppendLine($" Link next: {directoryDescriptor.LinkNext} (0x{directoryDescriptor.LinkNext:X})");
|
||||
builder.AppendLine($" Link flags: {directoryDescriptor.LinkFlags} (0x{directoryDescriptor.LinkFlags:X})");
|
||||
builder.AppendLine($" Directory Name {i}: {DirectoryNames[i] ?? "[NULL]"}");
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
@@ -587,6 +574,7 @@ namespace BurnOutSharp.Wrappers
|
||||
if (FileGroups == null || FileGroups.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No file groups");
|
||||
builder.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -625,9 +613,9 @@ namespace BurnOutSharp.Wrappers
|
||||
builder.AppendLine($" Reserved 6: {BitConverter.ToString(fileGroup.Reserved6).Replace('-', ' ')}");
|
||||
builder.AppendLine($" Reserved 7: {BitConverter.ToString(fileGroup.Reserved7).Replace('-', ' ')}");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -676,6 +664,7 @@ namespace BurnOutSharp.Wrappers
|
||||
if (Components == null || Components.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No components");
|
||||
builder.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -739,9 +728,9 @@ namespace BurnOutSharp.Wrappers
|
||||
builder.AppendLine($" Reserved offset 7: {component.ReservedOffset7} (0x{component.ReservedOffset7:X})");
|
||||
builder.AppendLine($" Reserved offset 8: {component.ReservedOffset8} (0x{component.ReservedOffset8:X})");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
|
||||
Reference in New Issue
Block a user