Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #173 from acrilly-msft/gpt_handling_and_dll_update
Browse files Browse the repository at this point in the history
Updated 7z.dll to 22.1 and added additional GPT handling
  • Loading branch information
squid-box committed Mar 22, 2023
2 parents 03a197c + 673466a commit 7ce04c5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
Binary file modified SevenZip/7z.dll
Binary file not shown.
Binary file modified SevenZip/7z64.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions SevenZip/FileChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public static InArchiveFormat CheckSignature(Stream stream, out int offset, out
return InArchiveFormat.Iso;
}

if (SpecialDetect(stream, 0x9001, InArchiveFormat.Iso))
if (SpecialDetect(stream, 0x200, InArchiveFormat.Gpt))
{
return InArchiveFormat.Iso;
return InArchiveFormat.Gpt;
}

if (SpecialDetect(stream, 0x400, InArchiveFormat.Hfs))
Expand Down
69 changes: 38 additions & 31 deletions SevenZip/Formats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public enum InArchiveFormat
/// <remarks><a href="http://en.wikipedia.org/wiki/NSIS">Wikipedia information</a></remarks>
Nsis,
/// <summary>
/// GUID Partition Table.
/// </summary>
/// <remarks><a href="https://en.wikipedia.org/wiki/GUID_Partition_Table">Wikipedia information</a></remarks>
Gpt,
/// <summary>
/// RarLab Rar archive format, version 5.
/// </summary>
/// <remarks><a href="http://en.wikipedia.org/wiki/Rar">Wikipedia information</a></remarks>
Expand Down Expand Up @@ -387,6 +392,7 @@ internal static int GetMaxValue(Type type)
{InArchiveFormat.Lzh, new Guid("23170f69-40c1-278a-1000-000110060000")},
{InArchiveFormat.Lzma, new Guid("23170f69-40c1-278a-1000-0001100a0000")},
{InArchiveFormat.Nsis, new Guid("23170f69-40c1-278a-1000-000110090000")},
{InArchiveFormat.Gpt, new Guid("23170f69-40c1-278a-1000-000110cb0000")},
{InArchiveFormat.Rar, new Guid("23170f69-40c1-278a-1000-000110CC0000")},
{InArchiveFormat.Rar4, new Guid("23170f69-40c1-278a-1000-000110030000")},
{InArchiveFormat.Rpm, new Guid("23170f69-40c1-278a-1000-000110eb0000")},
Expand Down Expand Up @@ -422,7 +428,7 @@ internal static int GetMaxValue(Type type)
{InArchiveFormat.MachO, new Guid("23170f69-40c1-278a-1000-000110DF0000")}
};

#endregion
#endregion

/// <summary>
/// List of writable archive format interface guids for 7-zip COM interop.
Expand All @@ -437,10 +443,10 @@ internal static int GetMaxValue(Type type)
{OutArchiveFormat.BZip2, new Guid("23170f69-40c1-278a-1000-000110020000")},
{OutArchiveFormat.GZip, new Guid("23170f69-40c1-278a-1000-000110ef0000")},
{OutArchiveFormat.Tar, new Guid("23170f69-40c1-278a-1000-000110ee0000")},
{OutArchiveFormat.XZ, new Guid("23170f69-40c1-278a-1000-0001100C0000")},
{OutArchiveFormat.XZ, new Guid("23170f69-40c1-278a-1000-0001100C0000")},
};

#endregion
#endregion

internal static readonly Dictionary<CompressionMethod, string> MethodNames =
new Dictionary<CompressionMethod, string>
Expand All @@ -456,7 +462,7 @@ internal static int GetMaxValue(Type type)
{CompressionMethod.BZip2, "BZip2"}
};

#endregion
#endregion

internal static readonly Dictionary<OutArchiveFormat, InArchiveFormat> InForOutFormats =
new Dictionary<OutArchiveFormat, InArchiveFormat>
Expand All @@ -471,7 +477,7 @@ internal static int GetMaxValue(Type type)
{OutArchiveFormat.Zip, InArchiveFormat.Zip}
};

#endregion
#endregion

/// <summary>
/// List of archive formats corresponding to specific extensions
Expand Down Expand Up @@ -506,7 +512,9 @@ internal static int GetMaxValue(Type type)
{"swf", InArchiveFormat.Swf},
{"exe", InArchiveFormat.PE},
{"dll", InArchiveFormat.PE},
{"vhd", InArchiveFormat.Vhd}
{"vhd", InArchiveFormat.Vhd},
{"gpt", InArchiveFormat.Gpt },
{"ntfs", InArchiveFormat.Ntfs }
};

#endregion
Expand All @@ -525,33 +533,34 @@ internal static int GetMaxValue(Type type)
//257 byte offset
{"52-61-72-21-1A-07-00", InArchiveFormat.Rar4},
{"52-61-72-21-1A-07-01-00", InArchiveFormat.Rar},
{"50-4B-03-04", InArchiveFormat.Zip},
{"5D-00-00-40-00", InArchiveFormat.Lzma},
{"2D-6C-68", InArchiveFormat.Lzh},
{"50-4B-03-04", InArchiveFormat.Zip},
{"5D-00-00-40-00", InArchiveFormat.Lzma},
{"2D-6C-68", InArchiveFormat.Lzh},
//^ 2 byte offset
{"1F-9D-90", InArchiveFormat.Lzw},
{"60-EA", InArchiveFormat.Arj},
{"42-5A-68", InArchiveFormat.BZip2},
{"4D-53-43-46", InArchiveFormat.Cab},
{"49-54-53-46", InArchiveFormat.Chm},
{"21-3C-61-72-63-68-3E-0A-64-65-62-69-61-6E-2D-62-69-6E-61-72-79", InArchiveFormat.Deb},
{"43-44-30-30-31", InArchiveFormat.Iso},
{"1F-9D-90", InArchiveFormat.Lzw},
{"60-EA", InArchiveFormat.Arj},
{"42-5A-68", InArchiveFormat.BZip2},
{"4D-53-43-46", InArchiveFormat.Cab},
{"49-54-53-46", InArchiveFormat.Chm},
{"21-3C-61-72-63-68-3E-0A-64-65-62-69-61-6E-2D-62-69-6E-61-72-79", InArchiveFormat.Deb},
{"43-44-30-30-31", InArchiveFormat.Iso},
//^ 0x8001, 0x8801 or 0x9001 byte offset
{"ED-AB-EE-DB", InArchiveFormat.Rpm},
{"4D-53-57-49-4D-00-00-00", InArchiveFormat.Wim},
{"udf", InArchiveFormat.Udf},
{"mub", InArchiveFormat.Mub},
{"78-61-72-21", InArchiveFormat.Xar},
{"ED-AB-EE-DB", InArchiveFormat.Rpm},
{"4D-53-57-49-4D-00-00-00", InArchiveFormat.Wim},
{"udf", InArchiveFormat.Udf},
{"mub", InArchiveFormat.Mub},
{"78-61-72-21", InArchiveFormat.Xar},
//0x400 byte offset
{"48-2B", InArchiveFormat.Hfs},
{"FD-37-7A-58-5A", InArchiveFormat.XZ},
{"46-4C-56", InArchiveFormat.Flv},
{"46-57-53", InArchiveFormat.Swf},
{"4D-5A", InArchiveFormat.PE},
{"7F-45-4C-46", InArchiveFormat.Elf},
{"48-2B", InArchiveFormat.Hfs},
{"FD-37-7A-58-5A", InArchiveFormat.XZ},
{"46-4C-56", InArchiveFormat.Flv},
{"46-57-53", InArchiveFormat.Swf},
{"4D-5A", InArchiveFormat.PE},
{"7F-45-4C-46", InArchiveFormat.Elf},
{"78", InArchiveFormat.Dmg},
{"63-6F-6E-65-63-74-69-78", InArchiveFormat.Vhd}};
#endregion
{"63-6F-6E-65-63-74-69-78", InArchiveFormat.Vhd},
{"45-46-49-20-50-41-52-54-00-00-01-00", InArchiveFormat.Gpt}};
#endregion

internal static Dictionary<InArchiveFormat, string> InSignatureFormatsReversed;

Expand Down Expand Up @@ -583,8 +592,6 @@ public static InArchiveFormat FormatByFileName(string fileName, bool reportError
if (!InExtensionFormats.ContainsKey(extension) && reportErrors)
{
throw new ArgumentException("Extension \"" + extension + "\" is not a supported archive file name extension.");


}

return InExtensionFormats[extension];
Expand Down

0 comments on commit 7ce04c5

Please sign in to comment.