mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-02-04 05:36:12 +00:00
Update packages
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.IO" Version="1.7.3" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.7.4" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="9.0.9" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.IO" Version="1.7.3" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.7.4" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -97,7 +97,11 @@ namespace SabreTools.Serialization.Test.CrossModel
|
||||
Name = "XXXXXX",
|
||||
Size = "XXXXXX",
|
||||
CRC = "XXXXXX",
|
||||
MD2 = "XXXXXX",
|
||||
MD4 = "XXXXXX",
|
||||
MD5 = "XXXXXX",
|
||||
RIPEMD128 = "XXXXXX",
|
||||
RIPEMD160 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
Merge = "XXXXXX",
|
||||
Status = "XXXXXX",
|
||||
@@ -346,7 +350,11 @@ namespace SabreTools.Serialization.Test.CrossModel
|
||||
Assert.Equal("XXXXXX", rom.Name);
|
||||
Assert.Equal("XXXXXX", rom.Size);
|
||||
Assert.Equal("XXXXXX", rom.CRC);
|
||||
Assert.Equal("XXXXXX", rom.MD2);
|
||||
Assert.Equal("XXXXXX", rom.MD4);
|
||||
Assert.Equal("XXXXXX", rom.MD5);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD128);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD160);
|
||||
Assert.Equal("XXXXXX", rom.SHA1);
|
||||
Assert.Equal("XXXXXX", rom.Merge);
|
||||
Assert.Equal("XXXXXX", rom.Status);
|
||||
|
||||
@@ -150,7 +150,11 @@ namespace SabreTools.Serialization.Test.CrossModel
|
||||
Name = "XXXXXX",
|
||||
Size = "XXXXXX",
|
||||
CRC = "XXXXXX",
|
||||
MD2 = "XXXXXX",
|
||||
MD4 = "XXXXXX",
|
||||
MD5 = "XXXXXX",
|
||||
RIPEMD128 = "XXXXXX",
|
||||
RIPEMD160 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
SHA256 = "XXXXXX",
|
||||
SHA384 = "XXXXXX",
|
||||
@@ -460,7 +464,11 @@ namespace SabreTools.Serialization.Test.CrossModel
|
||||
Assert.Equal("XXXXXX", rom.Name);
|
||||
Assert.Equal("XXXXXX", rom.Size);
|
||||
Assert.Equal("XXXXXX", rom.CRC);
|
||||
Assert.Equal("XXXXXX", rom.MD2);
|
||||
Assert.Equal("XXXXXX", rom.MD4);
|
||||
Assert.Equal("XXXXXX", rom.MD5);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD128);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD160);
|
||||
Assert.Equal("XXXXXX", rom.SHA1);
|
||||
Assert.Equal("XXXXXX", rom.SHA256);
|
||||
Assert.Equal("XXXXXX", rom.SHA384);
|
||||
|
||||
@@ -215,7 +215,11 @@ namespace SabreTools.Serialization.Test.Deserializers
|
||||
Name = "XXXXXX",
|
||||
Size = "XXXXXX",
|
||||
CRC = "XXXXXX",
|
||||
MD2 = "XXXXXX",
|
||||
MD4 = "XXXXXX",
|
||||
MD5 = "XXXXXX",
|
||||
RIPEMD128 = "XXXXXX",
|
||||
RIPEMD160 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
Merge = "XXXXXX",
|
||||
Status = "XXXXXX",
|
||||
@@ -464,7 +468,11 @@ namespace SabreTools.Serialization.Test.Deserializers
|
||||
Assert.Equal("XXXXXX", rom.Name);
|
||||
Assert.Equal("XXXXXX", rom.Size);
|
||||
Assert.Equal("XXXXXX", rom.CRC);
|
||||
Assert.Equal("XXXXXX", rom.MD2);
|
||||
Assert.Equal("XXXXXX", rom.MD4);
|
||||
Assert.Equal("XXXXXX", rom.MD5);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD128);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD160);
|
||||
Assert.Equal("XXXXXX", rom.SHA1);
|
||||
Assert.Equal("XXXXXX", rom.Merge);
|
||||
Assert.Equal("XXXXXX", rom.Status);
|
||||
|
||||
@@ -217,7 +217,11 @@ namespace SabreTools.Serialization.Test.Deserializers
|
||||
Name = "XXXXXX",
|
||||
Size = "XXXXXX",
|
||||
CRC = "XXXXXX",
|
||||
MD2 = "XXXXXX",
|
||||
MD4 = "XXXXXX",
|
||||
MD5 = "XXXXXX",
|
||||
RIPEMD128 = "XXXXXX",
|
||||
RIPEMD160 = "XXXXXX",
|
||||
SHA1 = "XXXXXX",
|
||||
SHA256 = "XXXXXX",
|
||||
SHA384 = "XXXXXX",
|
||||
@@ -512,7 +516,11 @@ namespace SabreTools.Serialization.Test.Deserializers
|
||||
Assert.Equal("XXXXXX", rom.Name);
|
||||
Assert.Equal("XXXXXX", rom.Size);
|
||||
Assert.Equal("XXXXXX", rom.CRC);
|
||||
Assert.Equal("XXXXXX", rom.MD2);
|
||||
Assert.Equal("XXXXXX", rom.MD4);
|
||||
Assert.Equal("XXXXXX", rom.MD5);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD128);
|
||||
Assert.Equal("XXXXXX", rom.RIPEMD160);
|
||||
Assert.Equal("XXXXXX", rom.SHA1);
|
||||
Assert.Equal("XXXXXX", rom.SHA256);
|
||||
Assert.Equal("XXXXXX", rom.SHA384);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.7.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.7.2" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
61
SabreTools.Serialization.Test/Wrappers/LDSCRYPTTests.cs
Normal file
61
SabreTools.Serialization.Test/Wrappers/LDSCRYPTTests.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.Serialization.Test.Wrappers
|
||||
{
|
||||
public class LDSCRYPTTests
|
||||
{
|
||||
[Fact]
|
||||
public void NullArray_Null()
|
||||
{
|
||||
byte[]? data = null;
|
||||
int offset = 0;
|
||||
var actual = LDSCRYPT.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyArray_Null()
|
||||
{
|
||||
byte[]? data = [];
|
||||
int offset = 0;
|
||||
var actual = LDSCRYPT.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidArray_Null()
|
||||
{
|
||||
byte[]? data = [.. Enumerable.Repeat<byte>(0xFF, 1024)];
|
||||
int offset = 0;
|
||||
var actual = LDSCRYPT.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullStream_Null()
|
||||
{
|
||||
Stream? data = null;
|
||||
var actual = LDSCRYPT.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyStream_Null()
|
||||
{
|
||||
Stream? data = new MemoryStream([]);
|
||||
var actual = LDSCRYPT.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidStream_Null()
|
||||
{
|
||||
Stream? data = new MemoryStream([.. Enumerable.Repeat<byte>(0xFF, 1024)]);
|
||||
var actual = LDSCRYPT.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.Serialization.Test.Wrappers
|
||||
{
|
||||
public class RealArcadeInstallerTests
|
||||
{
|
||||
[Fact]
|
||||
public void NullArray_Null()
|
||||
{
|
||||
byte[]? data = null;
|
||||
int offset = 0;
|
||||
var actual = RealArcadeInstaller.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyArray_Null()
|
||||
{
|
||||
byte[]? data = [];
|
||||
int offset = 0;
|
||||
var actual = RealArcadeInstaller.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidArray_Null()
|
||||
{
|
||||
byte[]? data = [.. Enumerable.Repeat<byte>(0xFF, 1024)];
|
||||
int offset = 0;
|
||||
var actual = RealArcadeInstaller.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullStream_Null()
|
||||
{
|
||||
Stream? data = null;
|
||||
var actual = RealArcadeInstaller.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyStream_Null()
|
||||
{
|
||||
Stream? data = new MemoryStream([]);
|
||||
var actual = RealArcadeInstaller.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidStream_Null()
|
||||
{
|
||||
Stream? data = new MemoryStream([.. Enumerable.Repeat<byte>(0xFF, 1024)]);
|
||||
var actual = RealArcadeInstaller.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.Serialization.Test.Wrappers
|
||||
{
|
||||
public class RealArcadeMezzanineTests
|
||||
{
|
||||
[Fact]
|
||||
public void NullArray_Null()
|
||||
{
|
||||
byte[]? data = null;
|
||||
int offset = 0;
|
||||
var actual = RealArcadeMezzanine.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyArray_Null()
|
||||
{
|
||||
byte[]? data = [];
|
||||
int offset = 0;
|
||||
var actual = RealArcadeMezzanine.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidArray_Null()
|
||||
{
|
||||
byte[]? data = [.. Enumerable.Repeat<byte>(0xFF, 1024)];
|
||||
int offset = 0;
|
||||
var actual = RealArcadeMezzanine.Create(data, offset);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NullStream_Null()
|
||||
{
|
||||
Stream? data = null;
|
||||
var actual = RealArcadeMezzanine.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyStream_Null()
|
||||
{
|
||||
Stream? data = new MemoryStream([]);
|
||||
var actual = RealArcadeMezzanine.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidStream_Null()
|
||||
{
|
||||
Stream? data = new MemoryStream([.. Enumerable.Repeat<byte>(0xFF, 1024)]);
|
||||
var actual = RealArcadeMezzanine.Create(data);
|
||||
Assert.Null(actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,7 +275,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Name = item.ReadString(Models.Metadata.Rom.NameKey),
|
||||
Size = item.ReadString(Models.Metadata.Rom.SizeKey),
|
||||
CRC = item.ReadString(Models.Metadata.Rom.CRCKey),
|
||||
MD2 = item.ReadString(Models.Metadata.Rom.MD2Key),
|
||||
MD4 = item.ReadString(Models.Metadata.Rom.MD4Key),
|
||||
MD5 = item.ReadString(Models.Metadata.Rom.MD5Key),
|
||||
RIPEMD128 = item.ReadString(Models.Metadata.Rom.RIPEMD128Key),
|
||||
RIPEMD160 = item.ReadString(Models.Metadata.Rom.RIPEMD160Key),
|
||||
SHA1 = item.ReadString(Models.Metadata.Rom.SHA1Key),
|
||||
SHA256 = item.ReadString(Models.Metadata.Rom.SHA256Key),
|
||||
SHA384 = item.ReadString(Models.Metadata.Rom.SHA384Key),
|
||||
|
||||
@@ -291,7 +291,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Models.Metadata.Rom.NameKey] = item.Name,
|
||||
[Models.Metadata.Rom.SizeKey] = item.Size,
|
||||
[Models.Metadata.Rom.CRCKey] = item.CRC,
|
||||
[Models.Metadata.Rom.MD2Key] = item.MD2,
|
||||
[Models.Metadata.Rom.MD4Key] = item.MD4,
|
||||
[Models.Metadata.Rom.MD5Key] = item.MD5,
|
||||
[Models.Metadata.Rom.RIPEMD128Key] = item.RIPEMD128,
|
||||
[Models.Metadata.Rom.RIPEMD160Key] = item.RIPEMD160,
|
||||
[Models.Metadata.Rom.SHA1Key] = item.SHA1,
|
||||
[Models.Metadata.Rom.SHA256Key] = item.SHA256,
|
||||
[Models.Metadata.Rom.SHA384Key] = item.SHA384,
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var md2s = new List<MD2>();
|
||||
var md4s = new List<MD4>();
|
||||
var md5s = new List<MD5>();
|
||||
var ripemd128s = new List<RIPEMD128>();
|
||||
var ripemd160s = new List<RIPEMD160>();
|
||||
var sha1s = new List<SHA1>();
|
||||
var sha256s = new List<SHA256>();
|
||||
var sha384s = new List<SHA384>();
|
||||
@@ -44,6 +46,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
md4s.AddRange(hashfile.MD4);
|
||||
if (hashfile.MD5 != null && hashfile.MD5.Length > 0)
|
||||
md5s.AddRange(hashfile.MD5);
|
||||
if (hashfile.RIPEMD128 != null && hashfile.RIPEMD128.Length > 0)
|
||||
ripemd128s.AddRange(hashfile.RIPEMD128);
|
||||
if (hashfile.RIPEMD160 != null && hashfile.RIPEMD160.Length > 0)
|
||||
ripemd160s.AddRange(hashfile.RIPEMD160);
|
||||
if (hashfile.SHA1 != null && hashfile.SHA1.Length > 0)
|
||||
sha1s.AddRange(hashfile.SHA1);
|
||||
if (hashfile.SHA256 != null && hashfile.SHA256.Length > 0)
|
||||
@@ -66,6 +72,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
hashfileItem.MD4 = [.. md4s];
|
||||
if (md5s.Count > 0)
|
||||
hashfileItem.MD5 = [.. md5s];
|
||||
if (ripemd128s.Count > 0)
|
||||
hashfileItem.RIPEMD128 = [.. ripemd128s];
|
||||
if (ripemd160s.Count > 0)
|
||||
hashfileItem.RIPEMD160 = [.. ripemd160s];
|
||||
if (sha1s.Count > 0)
|
||||
hashfileItem.SHA1 = [.. sha1s];
|
||||
if (sha256s.Count > 0)
|
||||
@@ -103,6 +113,12 @@ namespace SabreTools.Serialization.CrossModel
|
||||
MD5 = hash == HashType.MD5
|
||||
? Array.ConvertAll(roms, ConvertToMD5)
|
||||
: null,
|
||||
RIPEMD128 = hash == HashType.RIPEMD128
|
||||
? Array.ConvertAll(roms, ConvertToRIPEMD128)
|
||||
: null,
|
||||
RIPEMD160 = hash == HashType.RIPEMD160
|
||||
? Array.ConvertAll(roms, ConvertToRIPEMD160)
|
||||
: null,
|
||||
SHA1 = hash == HashType.SHA1
|
||||
? Array.ConvertAll(roms, ConvertToSHA1)
|
||||
: null,
|
||||
@@ -160,6 +176,32 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return md5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Metadata.Rom"/> to <see cref="Models.Hashfile.RIPEMD128"/>
|
||||
/// </summary>
|
||||
private static RIPEMD128 ConvertToRIPEMD128(Models.Metadata.Rom item)
|
||||
{
|
||||
var ripemd128 = new RIPEMD128
|
||||
{
|
||||
Hash = item.ReadString(Models.Metadata.Rom.RIPEMD128Key),
|
||||
File = item.ReadString(Models.Metadata.Rom.NameKey),
|
||||
};
|
||||
return ripemd128;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Metadata.Rom"/> to <see cref="Models.Hashfile.RIPEMD160"/>
|
||||
/// </summary>
|
||||
private static RIPEMD160 ConvertToRIPEMD160(Models.Metadata.Rom item)
|
||||
{
|
||||
var ripemd160 = new RIPEMD160
|
||||
{
|
||||
Hash = item.ReadString(Models.Metadata.Rom.RIPEMD160Key),
|
||||
File = item.ReadString(Models.Metadata.Rom.NameKey),
|
||||
};
|
||||
return ripemd160;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Metadata.Rom"/> to <see cref="Models.Hashfile.SFV"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -50,6 +50,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
machine[Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD4, ConvertToInternalModel);
|
||||
else if (item.MD5 != null && item.MD5.Length > 0)
|
||||
machine[Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD5, ConvertToInternalModel);
|
||||
else if (item.RIPEMD128 != null && item.RIPEMD128.Length > 0)
|
||||
machine[Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.RIPEMD128, ConvertToInternalModel);
|
||||
else if (item.RIPEMD160 != null && item.RIPEMD160.Length > 0)
|
||||
machine[Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.RIPEMD160, ConvertToInternalModel);
|
||||
else if (item.SHA1 != null && item.SHA1.Length > 0)
|
||||
machine[Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA1, ConvertToInternalModel);
|
||||
else if (item.SHA256 != null && item.SHA256.Length > 0)
|
||||
@@ -103,6 +107,32 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return rom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Hashfile.RIPEMD128"/> to <see cref="Models.Metadata.Rom"/>
|
||||
/// </summary>
|
||||
private static Models.Metadata.Rom ConvertToInternalModel(RIPEMD128 item)
|
||||
{
|
||||
var rom = new Models.Metadata.Rom
|
||||
{
|
||||
[Models.Metadata.Rom.RIPEMD128Key] = item.Hash,
|
||||
[Models.Metadata.Rom.NameKey] = item.File,
|
||||
};
|
||||
return rom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Hashfile.RIPEMD160"/> to <see cref="Models.Metadata.Rom"/>
|
||||
/// </summary>
|
||||
private static Models.Metadata.Rom ConvertToInternalModel(RIPEMD160 item)
|
||||
{
|
||||
var rom = new Models.Metadata.Rom
|
||||
{
|
||||
[Models.Metadata.Rom.RIPEMD160Key] = item.Hash,
|
||||
[Models.Metadata.Rom.NameKey] = item.File,
|
||||
};
|
||||
return rom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert from <see cref="Models.Hashfile.SFV"/> to <see cref="Models.Metadata.Rom"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -302,7 +302,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
Name = item.ReadString(Models.Metadata.Rom.NameKey),
|
||||
Size = item.ReadString(Models.Metadata.Rom.SizeKey),
|
||||
CRC = item.ReadString(Models.Metadata.Rom.CRCKey),
|
||||
MD2 = item.ReadString(Models.Metadata.Rom.MD2Key),
|
||||
MD4 = item.ReadString(Models.Metadata.Rom.MD4Key),
|
||||
MD5 = item.ReadString(Models.Metadata.Rom.MD5Key),
|
||||
RIPEMD128 = item.ReadString(Models.Metadata.Rom.RIPEMD128Key),
|
||||
RIPEMD160 = item.ReadString(Models.Metadata.Rom.RIPEMD160Key),
|
||||
SHA1 = item.ReadString(Models.Metadata.Rom.SHA1Key),
|
||||
SHA256 = item.ReadString(Models.Metadata.Rom.SHA256Key),
|
||||
SHA384 = item.ReadString(Models.Metadata.Rom.SHA384Key),
|
||||
|
||||
@@ -298,7 +298,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Models.Metadata.Rom.NameKey] = item.Name,
|
||||
[Models.Metadata.Rom.SizeKey] = item.Size,
|
||||
[Models.Metadata.Rom.CRCKey] = item.CRC,
|
||||
[Models.Metadata.Rom.MD2Key] = item.MD2,
|
||||
[Models.Metadata.Rom.MD4Key] = item.MD4,
|
||||
[Models.Metadata.Rom.MD5Key] = item.MD5,
|
||||
[Models.Metadata.Rom.RIPEMD128Key] = item.RIPEMD128,
|
||||
[Models.Metadata.Rom.RIPEMD160Key] = item.RIPEMD160,
|
||||
[Models.Metadata.Rom.SHA1Key] = item.SHA1,
|
||||
[Models.Metadata.Rom.SHA256Key] = item.SHA256,
|
||||
[Models.Metadata.Rom.SHA384Key] = item.SHA384,
|
||||
|
||||
@@ -70,25 +70,22 @@ namespace SabreTools.Serialization.Deserializers
|
||||
data.Seek(-4, SeekOrigin.Current);
|
||||
|
||||
// Create a record based on the type
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
// Known record types
|
||||
case RecordType.EndOfMediaKeyBlock: return ParseEndOfMediaKeyBlockRecord(data);
|
||||
case RecordType.ExplicitSubsetDifference: return ParseExplicitSubsetDifferenceRecord(data);
|
||||
case RecordType.MediaKeyData: return ParseMediaKeyDataRecord(data);
|
||||
case RecordType.SubsetDifferenceIndex: return ParseSubsetDifferenceIndexRecord(data);
|
||||
case RecordType.TypeAndVersion: return ParseTypeAndVersionRecord(data);
|
||||
case RecordType.DriveRevocationList: return ParseDriveRevocationListRecord(data);
|
||||
case RecordType.HostRevocationList: return ParseHostRevocationListRecord(data);
|
||||
case RecordType.VerifyMediaKey: return ParseVerifyMediaKeyRecord(data);
|
||||
case RecordType.Copyright: return ParseCopyrightRecord(data);
|
||||
RecordType.EndOfMediaKeyBlock => ParseEndOfMediaKeyBlockRecord(data),
|
||||
RecordType.ExplicitSubsetDifference => ParseExplicitSubsetDifferenceRecord(data),
|
||||
RecordType.MediaKeyData => ParseMediaKeyDataRecord(data),
|
||||
RecordType.SubsetDifferenceIndex => ParseSubsetDifferenceIndexRecord(data),
|
||||
RecordType.TypeAndVersion => ParseTypeAndVersionRecord(data),
|
||||
RecordType.DriveRevocationList => ParseDriveRevocationListRecord(data),
|
||||
RecordType.HostRevocationList => ParseHostRevocationListRecord(data),
|
||||
RecordType.VerifyMediaKey => ParseVerifyMediaKeyRecord(data),
|
||||
RecordType.Copyright => ParseCopyrightRecord(data),
|
||||
|
||||
// Unknown record type
|
||||
default:
|
||||
if (recordLength > 4)
|
||||
_ = data.ReadBytes((int)recordLength - 4);
|
||||
return null;
|
||||
}
|
||||
_ => ParseGenericRecord(data),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -235,6 +232,22 @@ namespace SabreTools.Serialization.Deserializers
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a Stream into a GenericRecord
|
||||
/// </summary>
|
||||
/// <param name="data">Stream to parse</param>
|
||||
/// <returns>Filled GenericRecord on success, null on error</returns>
|
||||
public static GenericRecord ParseGenericRecord(Stream data)
|
||||
{
|
||||
var obj = new GenericRecord();
|
||||
|
||||
obj.RecordType = (RecordType)data.ReadByteValue();
|
||||
obj.RecordLength = data.ReadUInt24LittleEndian();
|
||||
obj.Data = data.ReadBytes(0x10);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse a Stream into a HostRevocationListEntry
|
||||
/// </summary>
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc/>
|
||||
public override MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return default;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public MetadataFile? Deserialize(Stream? data, bool quotes)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -460,9 +460,21 @@ namespace SabreTools.Serialization.Deserializers
|
||||
case "crc":
|
||||
rom.CRC = kvp.Value;
|
||||
break;
|
||||
case "md2":
|
||||
rom.MD2 = kvp.Value;
|
||||
break;
|
||||
case "md4":
|
||||
rom.MD4 = kvp.Value;
|
||||
break;
|
||||
case "md5":
|
||||
rom.MD5 = kvp.Value;
|
||||
break;
|
||||
case "ripemd128":
|
||||
rom.RIPEMD128 = kvp.Value;
|
||||
break;
|
||||
case "ripemd160":
|
||||
rom.RIPEMD160 = kvp.Value;
|
||||
break;
|
||||
case "sha1":
|
||||
rom.SHA1 = kvp.Value;
|
||||
break;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc/>
|
||||
public override MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ namespace SabreTools.Serialization.Deserializers
|
||||
HashType.MD2 => DeserializeMD2(data),
|
||||
HashType.MD4 => DeserializeMD4(data),
|
||||
HashType.MD5 => DeserializeMD5(data),
|
||||
HashType.RIPEMD128 => DeserializeRIPEMD128(data),
|
||||
HashType.RIPEMD160 => DeserializeRIPEMD160(data),
|
||||
HashType.SHA1 => DeserializeSHA1(data),
|
||||
HashType.SHA256 => DeserializeSHA256(data),
|
||||
HashType.SHA384 => DeserializeSHA384(data),
|
||||
@@ -74,7 +76,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeSFV(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -117,7 +119,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeMD2(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -161,7 +163,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeMD4(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -205,7 +207,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeMD5(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -238,10 +240,82 @@ namespace SabreTools.Serialization.Deserializers
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeRIPEMD128(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
// Setup the reader and output
|
||||
var reader = new StreamReader(data);
|
||||
var ripemd128List = new List<RIPEMD128>();
|
||||
|
||||
// Loop through the rows and parse out values
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
// Read and split the line
|
||||
string? line = reader.ReadLine();
|
||||
string[]? lineParts = line?.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lineParts == null || lineParts.Length < 2)
|
||||
continue;
|
||||
|
||||
// Parse the line into a hash
|
||||
var ripemd128 = new RIPEMD128
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
File = string.Join(" ", lineParts, 1, lineParts.Length - 1),
|
||||
};
|
||||
ripemd128List.Add(ripemd128);
|
||||
}
|
||||
|
||||
// Assign the hashes to the hashfile and return
|
||||
if (ripemd128List.Count > 0)
|
||||
return new Models.Hashfile.Hashfile { RIPEMD128 = [.. ripemd128List] };
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeRIPEMD160(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
// Setup the reader and output
|
||||
var reader = new StreamReader(data);
|
||||
var ripemd160List = new List<RIPEMD160>();
|
||||
|
||||
// Loop through the rows and parse out values
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
// Read and split the line
|
||||
string? line = reader.ReadLine();
|
||||
string[]? lineParts = line?.Split([' '], StringSplitOptions.RemoveEmptyEntries);
|
||||
if (lineParts == null || lineParts.Length < 2)
|
||||
continue;
|
||||
|
||||
// Parse the line into a hash
|
||||
var ripemd160 = new RIPEMD160
|
||||
{
|
||||
Hash = lineParts[0],
|
||||
File = string.Join(" ", lineParts, 1, lineParts.Length - 1),
|
||||
};
|
||||
ripemd160List.Add(ripemd160);
|
||||
}
|
||||
|
||||
// Assign the hashes to the hashfile and return
|
||||
if (ripemd160List.Count > 0)
|
||||
return new Models.Hashfile.Hashfile { RIPEMD160 = [.. ripemd160List] };
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeSHA1(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -285,7 +359,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeSHA256(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -329,7 +403,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeSHA384(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -373,7 +447,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeSHA512(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
@@ -417,7 +491,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public Models.Hashfile.Hashfile? DeserializeSpamSum(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return default;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc/>
|
||||
public override MetadataFile? Deserialize(Stream? data)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Models.SecuROM;
|
||||
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
public class SecuROMAddD : BaseBinaryDeserializer<Models.PortableExecutable.SecuROMAddD>
|
||||
public class SecuROMAddD : BaseBinaryDeserializer<AddD>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override Models.PortableExecutable.SecuROMAddD? Deserialize(Stream? data)
|
||||
public override AddD? Deserialize(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
@@ -37,9 +37,9 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// </summary>
|
||||
/// <param name="data">Stream to parse</param>
|
||||
/// <returns>Filled SecuROMAddD on success, null on error</returns>
|
||||
private static Models.PortableExecutable.SecuROMAddD ParseSecuROMAddD(Stream data)
|
||||
private static AddD ParseSecuROMAddD(Stream data)
|
||||
{
|
||||
var obj = new Models.PortableExecutable.SecuROMAddD();
|
||||
var obj = new AddD();
|
||||
|
||||
obj.Signature = data.ReadUInt32LittleEndian();
|
||||
obj.EntryCount = data.ReadUInt32LittleEndian();
|
||||
@@ -49,7 +49,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
obj.Build = buildStr.ToCharArray();
|
||||
obj.Unknown14h = data.ReadBytes(1); // TODO: Figure out how to determine how many bytes are here consistently
|
||||
|
||||
obj.Entries = new SecuROMAddDEntry[obj.EntryCount];
|
||||
obj.Entries = new AddDEntry[obj.EntryCount];
|
||||
for (int i = 0; i < obj.Entries.Length; i++)
|
||||
{
|
||||
var entry = ParseSecuROMAddDEntry(data);
|
||||
@@ -64,9 +64,9 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// </summary>
|
||||
/// <param name="data">Stream to parse</param>
|
||||
/// <returns>Filled SecuROMAddDEntry on success, null on error</returns>
|
||||
private static SecuROMAddDEntry ParseSecuROMAddDEntry(Stream data)
|
||||
private static AddDEntry ParseSecuROMAddDEntry(Stream data)
|
||||
{
|
||||
var obj = new SecuROMAddDEntry();
|
||||
var obj = new AddDEntry();
|
||||
|
||||
obj.PhysicalOffset = data.ReadUInt32LittleEndian();
|
||||
obj.Length = data.ReadUInt32LittleEndian();
|
||||
|
||||
@@ -7,6 +7,7 @@ using static SabreTools.Models.SecuROM.Constants;
|
||||
|
||||
namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
// TODO: Cache data blocks during parse
|
||||
public class SecuROMMatroschkaPackage : BaseBinaryDeserializer<MatroshkaPackage>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@@ -96,7 +97,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
data.Seek(data.Position + 256, SeekOrigin.Begin);
|
||||
var tempValue = data.ReadUInt32LittleEndian();
|
||||
data.Seek(tempPosition, SeekOrigin.Begin);
|
||||
int gapSize = tempValue == 0 ? 512 : 256;
|
||||
int pathSize = tempValue == 0 ? 512 : 256;
|
||||
|
||||
// Set default value for unknown value checking
|
||||
bool? hasUnknown = null;
|
||||
@@ -106,7 +107,8 @@ namespace SabreTools.Serialization.Deserializers
|
||||
{
|
||||
var entry = new MatroshkaEntry();
|
||||
|
||||
entry.Path = data.ReadBytes(gapSize);
|
||||
byte[] pathBytes = data.ReadBytes(pathSize);
|
||||
entry.Path = Encoding.ASCII.GetString(pathBytes);
|
||||
entry.EntryType = (MatroshkaEntryType)data.ReadUInt32LittleEndian();
|
||||
entry.Size = data.ReadUInt32LittleEndian();
|
||||
entry.Offset = data.ReadUInt32LittleEndian();
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace SabreTools.Serialization.Deserializers
|
||||
/// <inheritdoc cref="Deserialize(Stream)"/>
|
||||
public MetadataFile? Deserialize(Stream? data, char delim)
|
||||
{
|
||||
// If tthe data is invalid
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@ using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Models.COFF;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Models.PortableExecutable.ResourceEntries;
|
||||
using SabreTools.Models.PortableExecutable.Resource.Entries;
|
||||
using SabreTools.Models.SecuROM;
|
||||
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
@@ -108,9 +110,9 @@ namespace SabreTools.Serialization
|
||||
/// <param name="data">Data to parse</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled NB10ProgramDatabase on success, null on error</returns>
|
||||
public static NB10ProgramDatabase? ParseNB10ProgramDatabase(this byte[] data, ref int offset)
|
||||
public static Models.PortableExecutable.DebugData.NB10ProgramDatabase? ParseNB10ProgramDatabase(this byte[] data, ref int offset)
|
||||
{
|
||||
var obj = new NB10ProgramDatabase();
|
||||
var obj = new Models.PortableExecutable.DebugData.NB10ProgramDatabase();
|
||||
|
||||
obj.Signature = data.ReadUInt32LittleEndian(ref offset);
|
||||
if (obj.Signature != 0x3031424E)
|
||||
@@ -130,9 +132,9 @@ namespace SabreTools.Serialization
|
||||
/// <param name="data">Data to parse</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled RSDSProgramDatabase on success, null on error</returns>
|
||||
public static RSDSProgramDatabase? ParseRSDSProgramDatabase(this byte[] data, ref int offset)
|
||||
public static Models.PortableExecutable.DebugData.RSDSProgramDatabase? ParseRSDSProgramDatabase(this byte[] data, ref int offset)
|
||||
{
|
||||
var obj = new RSDSProgramDatabase();
|
||||
var obj = new Models.PortableExecutable.DebugData.RSDSProgramDatabase();
|
||||
|
||||
obj.Signature = data.ReadUInt32LittleEndian(ref offset);
|
||||
if (obj.Signature != 0x53445352)
|
||||
@@ -155,10 +157,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="data">Data to parse into overlay data</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled SecuROMAddD on success, null on error</returns>
|
||||
public static SecuROMAddD? ParseSecuROMAddD(this byte[] data, ref int offset)
|
||||
public static AddD? ParseSecuROMAddD(this byte[] data, ref int offset)
|
||||
{
|
||||
// Read in the table
|
||||
var obj = new SecuROMAddD();
|
||||
var obj = new AddD();
|
||||
|
||||
obj.Signature = data.ReadUInt32LittleEndian(ref offset);
|
||||
if (obj.Signature != 0x44646441)
|
||||
@@ -186,7 +188,7 @@ namespace SabreTools.Serialization
|
||||
|
||||
obj.Unknown14h = data.ReadBytes(ref offset, bytesToRead);
|
||||
|
||||
obj.Entries = new SecuROMAddDEntry[obj.EntryCount];
|
||||
obj.Entries = new AddDEntry[obj.EntryCount];
|
||||
for (int i = 0; i < obj.EntryCount; i++)
|
||||
{
|
||||
obj.Entries[i] = ParseSecuROMAddDEntry(data, ref offset);
|
||||
@@ -201,9 +203,9 @@ namespace SabreTools.Serialization
|
||||
/// <param name="data">Data to parse</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>Filled SecuROMAddDEntry on success, null on error</returns>
|
||||
public static SecuROMAddDEntry ParseSecuROMAddDEntry(this byte[] data, ref int offset)
|
||||
public static AddDEntry ParseSecuROMAddDEntry(this byte[] data, ref int offset)
|
||||
{
|
||||
var obj = new SecuROMAddDEntry();
|
||||
var obj = new AddDEntry();
|
||||
|
||||
obj.PhysicalOffset = data.ReadUInt32LittleEndian(ref offset);
|
||||
obj.Length = data.ReadUInt32LittleEndian(ref offset);
|
||||
@@ -229,7 +231,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into an accelerator table resource</param>
|
||||
/// <returns>A filled accelerator table resource on success, null on error</returns>
|
||||
public static AcceleratorTableEntry[]? AsAcceleratorTableResource(this ResourceDataEntry? entry)
|
||||
public static AcceleratorTableEntry[]? AsAcceleratorTableResource(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have data that's invalid for this resource type, we can't do anything
|
||||
if (entry?.Data == null || entry.Data.Length % 8 != 0)
|
||||
@@ -258,7 +260,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a side-by-side assembly manifest</param>
|
||||
/// <returns>A filled side-by-side assembly manifest on success, null on error</returns>
|
||||
public static AssemblyManifest? AsAssemblyManifest(this ResourceDataEntry? entry)
|
||||
public static AssemblyManifest? AsAssemblyManifest(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -280,7 +282,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a dialog box</param>
|
||||
/// <returns>A filled dialog box on success, null on error</returns>
|
||||
public static DialogBoxResource? AsDialogBox(this ResourceDataEntry? entry)
|
||||
public static DialogBoxResource? AsDialogBox(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -757,7 +759,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a font group</param>
|
||||
/// <returns>A filled font group on success, null on error</returns>
|
||||
public static FontGroupHeader? AsFontGroup(this ResourceDataEntry? entry)
|
||||
public static FontGroupHeader? AsFontGroup(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -826,7 +828,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a menu</param>
|
||||
/// <returns>A filled menu on success, null on error</returns>
|
||||
public static MenuResource? AsMenu(this ResourceDataEntry? entry)
|
||||
public static MenuResource? AsMenu(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -922,7 +924,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a message table resource</param>
|
||||
/// <returns>A filled message table resource on success, null on error</returns>
|
||||
public static MessageResourceData? AsMessageResourceData(this ResourceDataEntry? entry)
|
||||
public static MessageResourceData? AsMessageResourceData(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -1010,10 +1012,10 @@ namespace SabreTools.Serialization
|
||||
// Align to the DWORD boundary if we're not at the end
|
||||
data.AlignToBoundary(ref offset, 4);
|
||||
|
||||
var stringFileInfoChildren = new List<StringTable>();
|
||||
var stringFileInfoChildren = new List<Models.PortableExecutable.Resource.Entries.StringTable>();
|
||||
while ((offset - currentOffset) < stringFileInfo.Length)
|
||||
{
|
||||
var stringTable = new StringTable();
|
||||
var stringTable = new Models.PortableExecutable.Resource.Entries.StringTable();
|
||||
|
||||
stringTable.Length = data.ReadUInt16LittleEndian(ref offset);
|
||||
stringTable.ValueLength = data.ReadUInt16LittleEndian(ref offset);
|
||||
@@ -1067,7 +1069,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a string table resource</param>
|
||||
/// <returns>A filled string table resource on success, null on error</returns>
|
||||
public static Dictionary<int, string?>? AsStringTable(this ResourceDataEntry? entry)
|
||||
public static Dictionary<int, string?>? AsStringTable(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -1159,7 +1161,7 @@ namespace SabreTools.Serialization
|
||||
/// </summary>
|
||||
/// <param name="entry">Resource data entry to parse into a version info resource</param>
|
||||
/// <returns>A filled version info resource on success, null on error</returns>
|
||||
public static VersionInfo? AsVersionInfo(this ResourceDataEntry? entry)
|
||||
public static VersionInfo? AsVersionInfo(this Models.PortableExecutable.Resource.DataEntry? entry)
|
||||
{
|
||||
// If we have an invalid entry, just skip
|
||||
if (entry?.Data == null)
|
||||
@@ -1356,10 +1358,10 @@ namespace SabreTools.Serialization
|
||||
/// <param name="data">Data to parse</param>
|
||||
/// <param name="offset">Offset into the byte array</param>
|
||||
/// <returns>A filled ResourceHeader on success, null on error</returns>
|
||||
public static ResourceHeader ParseResourceHeader(this byte[] data, ref int offset)
|
||||
public static Models.PortableExecutable.Resource.ResourceHeader ParseResourceHeader(this byte[] data, ref int offset)
|
||||
{
|
||||
// Read in the table
|
||||
var obj = new ResourceHeader();
|
||||
var obj = new Models.PortableExecutable.Resource.ResourceHeader();
|
||||
|
||||
obj.DataSize = data.ReadUInt32LittleEndian(ref offset);
|
||||
obj.HeaderSize = data.ReadUInt32LittleEndian(ref offset);
|
||||
|
||||
@@ -5,39 +5,39 @@
|
||||
|
||||
namespace SabreTools.Serialization
|
||||
{
|
||||
public delegate TResult Func<out TResult>();
|
||||
internal delegate TResult Func<out TResult>();
|
||||
|
||||
public delegate TResult Func<in T, out TResult>(T arg);
|
||||
internal delegate TResult Func<in T, out TResult>(T arg);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
|
||||
internal delegate TResult Func<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, out TResult>(T1 arg1, T2 arg2, T3 arg3);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, out TResult>(T1 arg1, T2 arg2, T3 arg3);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
|
||||
|
||||
public delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
|
||||
internal delegate TResult Func<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16, out TResult>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Text;
|
||||
using SabreTools.Models.BSP;
|
||||
using SabreTools.Models.TAR;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Printers
|
||||
|
||||
@@ -5,9 +5,10 @@ using System.Xml;
|
||||
using SabreTools.ASN1;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Matching;
|
||||
using SabreTools.Models.COFF;
|
||||
using SabreTools.Models.COFF.SymbolTableEntries;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Models.PortableExecutable.COFFSymbolTableEntries;
|
||||
using SabreTools.Models.PortableExecutable.ResourceEntries;
|
||||
using SabreTools.Models.PortableExecutable.Resource.Entries;
|
||||
using SabreTools.Serialization.Interfaces;
|
||||
|
||||
namespace SabreTools.Serialization.Printers
|
||||
@@ -28,22 +29,36 @@ namespace SabreTools.Serialization.Printers
|
||||
Print(builder, executable.Stub?.Header);
|
||||
|
||||
// Header
|
||||
Print(builder, executable.Signature, executable.COFFFileHeader);
|
||||
Print(builder, executable.Signature, executable.FileHeader);
|
||||
Print(builder, executable.OptionalHeader, executable.SectionTable);
|
||||
|
||||
// Tables
|
||||
// COFF Tables
|
||||
Print(builder, executable.SectionTable);
|
||||
Print(builder, executable.COFFSymbolTable);
|
||||
Print(builder, executable.COFFStringTable);
|
||||
Print(builder, executable.SymbolTable);
|
||||
Print(builder, executable.StringTable);
|
||||
|
||||
// Export Table
|
||||
Print(builder, executable.ExportDirectoryTable, executable.SectionTable);
|
||||
Print(builder, executable.ExportAddressTable, executable.SectionTable);
|
||||
Print(builder, executable.NamePointerTable);
|
||||
Print(builder, executable.OrdinalTable);
|
||||
Print(builder, executable.ExportNameTable);
|
||||
|
||||
// Import Table
|
||||
Print(builder, executable.ImportDirectoryTable, executable.SectionTable);
|
||||
Print(builder, executable.ImportLookupTables, executable.SectionTable);
|
||||
Print(builder, executable.ImportAddressTables, executable.SectionTable);
|
||||
Print(builder, executable.HintNameTable);
|
||||
|
||||
// Resource Table
|
||||
Print(builder, executable.ResourceDirectoryTable, executable.SectionTable);
|
||||
|
||||
Print(builder, executable.AttributeCertificateTable);
|
||||
Print(builder, executable.DelayLoadDirectoryTable, executable.SectionTable);
|
||||
|
||||
// Named Sections
|
||||
Print(builder, executable.BaseRelocationTable, executable.SectionTable);
|
||||
Print(builder, executable.DebugTable);
|
||||
Print(builder, executable.ExportTable, executable.SectionTable);
|
||||
Print(builder, executable.ImportTable, executable.SectionTable);
|
||||
Print(builder, executable.ResourceDirectoryTable, executable.SectionTable);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Models.MSDOS.ExecutableHeader? header)
|
||||
@@ -83,7 +98,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, string? signature, COFFFileHeader? header)
|
||||
private static void Print(StringBuilder builder, string? signature, FileHeader? header)
|
||||
{
|
||||
builder.AppendLine(" File Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -105,7 +120,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, OptionalHeader? header, SectionHeader[]? table)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.OptionalHeader? header, SectionHeader[]? table)
|
||||
{
|
||||
builder.AppendLine(" Optional Header Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -127,10 +142,7 @@ namespace SabreTools.Serialization.Printers
|
||||
if (header.Magic == OptionalHeaderMagicNumber.PE32)
|
||||
builder.AppendLine(header.BaseOfData, " Base of data");
|
||||
|
||||
if (header.Magic == OptionalHeaderMagicNumber.PE32)
|
||||
builder.AppendLine(header.ImageBase_PE32, " Image base");
|
||||
else
|
||||
builder.AppendLine(header.ImageBase_PE32Plus, " Image base");
|
||||
builder.AppendLine(header.ImageBase, " Image base");
|
||||
builder.AppendLine(header.SectionAlignment, " Section alignment");
|
||||
builder.AppendLine(header.FileAlignment, " File alignment");
|
||||
builder.AppendLine(header.MajorOperatingSystemVersion, " Major operating system version");
|
||||
@@ -145,20 +157,10 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine(header.CheckSum, " Checksum");
|
||||
builder.AppendLine($" Subsystem: {header.Subsystem} (0x{header.Subsystem:X})");
|
||||
builder.AppendLine($" DLL characteristics: {header.DllCharacteristics} (0x{header.DllCharacteristics:X})");
|
||||
if (header.Magic == OptionalHeaderMagicNumber.PE32)
|
||||
{
|
||||
builder.AppendLine(header.SizeOfStackReserve_PE32, " Size of stack reserve");
|
||||
builder.AppendLine(header.SizeOfStackCommit_PE32, " Size of stack commit");
|
||||
builder.AppendLine(header.SizeOfHeapReserve_PE32, " Size of heap reserve");
|
||||
builder.AppendLine(header.SizeOfHeapCommit_PE32, " Size of heap commit");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine(header.SizeOfStackReserve_PE32Plus, " Size of stack reserve");
|
||||
builder.AppendLine(header.SizeOfStackCommit_PE32Plus, " Size of stack commit");
|
||||
builder.AppendLine(header.SizeOfHeapReserve_PE32Plus, " Size of heap reserve");
|
||||
builder.AppendLine(header.SizeOfHeapCommit_PE32Plus, " Size of heap commit");
|
||||
}
|
||||
builder.AppendLine(header.SizeOfStackReserve, " Size of stack reserve");
|
||||
builder.AppendLine(header.SizeOfStackCommit, " Size of stack commit");
|
||||
builder.AppendLine(header.SizeOfHeapReserve, " Size of heap reserve");
|
||||
builder.AppendLine(header.SizeOfHeapCommit, " Size of heap commit");
|
||||
builder.AppendLine(header.LoaderFlags, " Loader flags");
|
||||
builder.AppendLine(header.NumberOfRvaAndSizes, " Number of data-directory entries");
|
||||
|
||||
@@ -355,7 +357,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine(entry.Offset, " Offset");
|
||||
}
|
||||
builder.AppendLine(entry.Value, " Value");
|
||||
builder.AppendLine(entry.SectionNumber, " Section number");
|
||||
builder.AppendLine($" Section number: {entry.SectionNumber} (0x{entry.SectionNumber:X})");
|
||||
builder.AppendLine($" Symbol type: {entry.SymbolType} (0x{entry.SymbolType:X})");
|
||||
builder.AppendLine($" Storage class: {entry.StorageClass} (0x{entry.StorageClass:X})");
|
||||
builder.AppendLine(entry.NumberOfAuxSymbols, " Number of aux symbols");
|
||||
@@ -416,7 +418,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine(entry.Reserved2, " Reserved");
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, COFFStringTable? stringTable)
|
||||
private static void Print(StringBuilder builder, Models.COFF.StringTable? stringTable)
|
||||
{
|
||||
builder.AppendLine(" String Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -438,7 +440,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, AttributeCertificateTableEntry[]? entries)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.AttributeCertificate.Entry[]? entries)
|
||||
{
|
||||
builder.AppendLine(" Attribute Certificate Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -502,7 +504,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DelayLoadDirectoryTable? table, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.DelayLoad.DirectoryTable? table, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Delay-Load Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -514,8 +516,8 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
|
||||
builder.AppendLine(table.Attributes, " Attributes");
|
||||
builder.AppendLine(table.Name, " Name RVA");
|
||||
builder.AppendLine(table.Name.ConvertVirtualAddress(sections), " Name physical address");
|
||||
builder.AppendLine(table.NameRVA, " Name RVA");
|
||||
builder.AppendLine(table.NameRVA.ConvertVirtualAddress(sections), " Name physical address");
|
||||
builder.AppendLine(table.ModuleHandle, " Module handle");
|
||||
builder.AppendLine(table.DelayImportAddressTable, " Delay import address table RVA");
|
||||
builder.AppendLine(table.DelayImportAddressTable.ConvertVirtualAddress(sections), " Delay import address table physical address");
|
||||
@@ -529,7 +531,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, BaseRelocationBlock[]? entries, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.BaseRelocation.Block[]? entries, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Base Relocation Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -572,7 +574,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, DebugTable? table)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.DebugData.Table? table)
|
||||
{
|
||||
builder.AppendLine(" Debug Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -602,180 +604,176 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ExportTable? table, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.DirectoryTable? table, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Export Table Information:");
|
||||
builder.AppendLine(value: " Export Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null)
|
||||
{
|
||||
builder.AppendLine(" No export table");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine(" Export Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.ExportDirectoryTable == null)
|
||||
{
|
||||
builder.AppendLine(" No export directory table");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine(table.ExportDirectoryTable.ExportFlags, " Export flags");
|
||||
builder.AppendLine(table.ExportDirectoryTable.TimeDateStamp, " Time/Date stamp");
|
||||
builder.AppendLine(table.ExportDirectoryTable.MajorVersion, " Major version");
|
||||
builder.AppendLine(table.ExportDirectoryTable.MinorVersion, " Minor version");
|
||||
builder.AppendLine(table.ExportDirectoryTable.NameRVA, " Name RVA");
|
||||
builder.AppendLine(table.ExportDirectoryTable.NameRVA.ConvertVirtualAddress(sections), " Name physical address");
|
||||
builder.AppendLine(table.ExportDirectoryTable.Name, " Name");
|
||||
builder.AppendLine(table.ExportDirectoryTable.OrdinalBase, " Ordinal base");
|
||||
builder.AppendLine(table.ExportDirectoryTable.AddressTableEntries, " Address table entries");
|
||||
builder.AppendLine(table.ExportDirectoryTable.NumberOfNamePointers, " Number of name pointers");
|
||||
builder.AppendLine(table.ExportDirectoryTable.ExportAddressTableRVA, " Export address table RVA");
|
||||
builder.AppendLine(table.ExportDirectoryTable.ExportAddressTableRVA.ConvertVirtualAddress(sections), " Export address table physical address");
|
||||
builder.AppendLine(table.ExportDirectoryTable.NamePointerRVA, " Name pointer table RVA");
|
||||
builder.AppendLine(table.ExportDirectoryTable.NamePointerRVA.ConvertVirtualAddress(sections), " Name pointer table physical address");
|
||||
builder.AppendLine(table.ExportDirectoryTable.OrdinalTableRVA, " Ordinal table RVA");
|
||||
builder.AppendLine(table.ExportDirectoryTable.OrdinalTableRVA.ConvertVirtualAddress(sections), " Ordinal table physical address");
|
||||
builder.AppendLine(table.ExportFlags, " Export flags");
|
||||
builder.AppendLine(table.TimeDateStamp, " Time/Date stamp");
|
||||
builder.AppendLine(table.MajorVersion, " Major version");
|
||||
builder.AppendLine(table.MinorVersion, " Minor version");
|
||||
builder.AppendLine(table.NameRVA, " Name RVA");
|
||||
builder.AppendLine(table.NameRVA.ConvertVirtualAddress(sections), " Name physical address");
|
||||
builder.AppendLine(table.Name, " Name");
|
||||
builder.AppendLine(table.OrdinalBase, " Ordinal base");
|
||||
builder.AppendLine(table.AddressTableEntries, " Address table entries");
|
||||
builder.AppendLine(table.NumberOfNamePointers, " Number of name pointers");
|
||||
builder.AppendLine(table.ExportAddressTableRVA, " Export address table RVA");
|
||||
builder.AppendLine(table.ExportAddressTableRVA.ConvertVirtualAddress(sections), " Export address table physical address");
|
||||
builder.AppendLine(table.NamePointerRVA, " Name pointer table RVA");
|
||||
builder.AppendLine(table.NamePointerRVA.ConvertVirtualAddress(sections), " Name pointer table physical address");
|
||||
builder.AppendLine(table.OrdinalTableRVA, " Ordinal table RVA");
|
||||
builder.AppendLine(table.OrdinalTableRVA.ConvertVirtualAddress(sections), " Ordinal table physical address");
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
builder.AppendLine(" Export Address Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.ExportAddressTable == null || table.ExportAddressTable.Length == 0)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.AddressTableEntry[]? table, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Export Address Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null || table.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No export address table items");
|
||||
builder.AppendLine(" No export address table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.ExportAddressTable.Length; i++)
|
||||
for (int i = 0; i < table.Length; i++)
|
||||
{
|
||||
var entry = table.ExportAddressTable[i];
|
||||
var entry = table[i];
|
||||
|
||||
builder.AppendLine($" Export Address Table Entry {i}");
|
||||
builder.AppendLine(entry.ExportRVA, " Export / Forwarder RVA");
|
||||
builder.AppendLine(entry.ExportRVA.ConvertVirtualAddress(sections), " Export / Forwarder physical address");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
builder.AppendLine(" Name Pointer Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.NamePointerTable?.Pointers == null || table.NamePointerTable.Pointers.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No name pointer table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.NamePointerTable.Pointers.Length; i++)
|
||||
{
|
||||
var entry = table.NamePointerTable.Pointers[i];
|
||||
|
||||
builder.AppendLine($" Name Pointer Table Entry {i}");
|
||||
builder.AppendLine(entry, " Pointer");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
builder.AppendLine(" Ordinal Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.OrdinalTable?.Indexes == null || table.OrdinalTable.Indexes.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No ordinal table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.OrdinalTable.Indexes.Length; i++)
|
||||
{
|
||||
var entry = table.OrdinalTable.Indexes[i];
|
||||
|
||||
builder.AppendLine($" Ordinal Table Entry {i}");
|
||||
builder.AppendLine(entry, " Index");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
|
||||
builder.AppendLine(" Export Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.ExportNameTable?.Strings == null || table.ExportNameTable.Strings.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No export name table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.ExportNameTable.Strings.Length; i++)
|
||||
{
|
||||
var entry = table.ExportNameTable.Strings[i];
|
||||
|
||||
builder.AppendLine($" Export Name Table Entry {i}");
|
||||
builder.AppendLine(entry, " String");
|
||||
builder.AppendLine($" Export Address Table Entry {i}");
|
||||
builder.AppendLine(entry.ExportRVA, " Export / Forwarder RVA");
|
||||
builder.AppendLine(entry.ExportRVA.ConvertVirtualAddress(sections), " Export / Forwarder physical address");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ImportTable? table, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.NamePointerTable? table)
|
||||
{
|
||||
builder.AppendLine(" Import Table Information:");
|
||||
builder.AppendLine(" Export Name Pointer Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null)
|
||||
if (table?.Pointers == null || table.Pointers.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No import table");
|
||||
builder.AppendLine();
|
||||
return;
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
builder.AppendLine(" Import Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.ImportDirectoryTable == null || table.ImportDirectoryTable.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No import directory table items");
|
||||
builder.AppendLine(" No export name pointer table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.ImportDirectoryTable.Length; i++)
|
||||
for (int i = 0; i < table.Pointers.Length; i++)
|
||||
{
|
||||
var entry = table.ImportDirectoryTable[i];
|
||||
var entry = table.Pointers[i];
|
||||
|
||||
builder.AppendLine($" Import Directory Table Entry {i}");
|
||||
builder.AppendLine(entry.ImportLookupTableRVA, " Import lookup table RVA");
|
||||
builder.AppendLine(entry.ImportLookupTableRVA.ConvertVirtualAddress(sections), " Import lookup table physical address");
|
||||
builder.AppendLine(entry.TimeDateStamp, " Time/Date stamp");
|
||||
builder.AppendLine(entry.ForwarderChain, " Forwarder chain");
|
||||
builder.AppendLine(entry.NameRVA, " Name RVA");
|
||||
builder.AppendLine(entry.NameRVA.ConvertVirtualAddress(sections), " Name physical address");
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
builder.AppendLine(entry.ImportAddressTableRVA, " Import address table RVA");
|
||||
builder.AppendLine(entry.ImportAddressTableRVA.ConvertVirtualAddress(sections), " Import address table physical address");
|
||||
builder.AppendLine($" Export Name Pointer Table Entry {i}");
|
||||
builder.AppendLine(entry, " Pointer");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
builder.AppendLine(" Import Lookup Tables Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.ImportLookupTables == null || table.ImportLookupTables.Count == 0)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.OrdinalTable? table)
|
||||
{
|
||||
builder.AppendLine(" Export Ordinal Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table?.Indexes == null || table.Indexes.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No import lookup tables");
|
||||
builder.AppendLine(" No export ordinal table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kvp in table.ImportLookupTables)
|
||||
for (int i = 0; i < table.Indexes.Length; i++)
|
||||
{
|
||||
var entry = table.Indexes[i];
|
||||
|
||||
builder.AppendLine($" Export Ordinal Table Entry {i}");
|
||||
builder.AppendLine(entry, " Index");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Export.NameTable? table)
|
||||
{
|
||||
builder.AppendLine(" Export Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table?.Strings == null || table.Strings.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No export name table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.Strings.Length; i++)
|
||||
{
|
||||
var entry = table.Strings[i];
|
||||
|
||||
builder.AppendLine($" Export Name Table Entry {i}");
|
||||
builder.AppendLine(entry, " String");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Import.DirectoryTableEntry[]? table, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Import Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null || table.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No import directory table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.Length; i++)
|
||||
{
|
||||
var entry = table[i];
|
||||
|
||||
builder.AppendLine($" Import Directory Table Entry {i}");
|
||||
builder.AppendLine(entry.ImportLookupTableRVA, " Import lookup table RVA");
|
||||
builder.AppendLine(entry.ImportLookupTableRVA.ConvertVirtualAddress(sections), " Import lookup table physical address");
|
||||
builder.AppendLine(entry.TimeDateStamp, " Time/Date stamp");
|
||||
builder.AppendLine(entry.ForwarderChain, " Forwarder chain");
|
||||
builder.AppendLine(entry.NameRVA, " Name RVA");
|
||||
builder.AppendLine(entry.NameRVA.ConvertVirtualAddress(sections), " Name physical address");
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
builder.AppendLine(entry.ImportAddressTableRVA, " Import address table RVA");
|
||||
builder.AppendLine(entry.ImportAddressTableRVA.ConvertVirtualAddress(sections), " Import address table physical address");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, Dictionary<int, Models.PortableExecutable.Import.LookupTableEntry[]?>? tables, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Import Lookup Tables Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (tables == null || tables.Count == 0)
|
||||
{
|
||||
builder.AppendLine(" No import lookup tables");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kvp in tables)
|
||||
{
|
||||
int index = kvp.Key;
|
||||
var importLookupTable = kvp.Value;
|
||||
|
||||
builder.AppendLine();
|
||||
builder.AppendLine($" Import Lookup Table {index} Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Import Lookup Table {index} Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (importLookupTable == null || importLookupTable.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No import lookup table items");
|
||||
builder.AppendLine(" No import lookup table items");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -783,42 +781,45 @@ namespace SabreTools.Serialization.Printers
|
||||
{
|
||||
var entry = importLookupTable[i];
|
||||
|
||||
builder.AppendLine($" Import Lookup Table {index} Entry {i}");
|
||||
builder.AppendLine(entry.OrdinalNameFlag, " Ordinal/Name flag");
|
||||
builder.AppendLine($" Import Lookup Table {index} Entry {i}");
|
||||
builder.AppendLine(entry.OrdinalNameFlag, " Ordinal/Name flag");
|
||||
if (entry.OrdinalNameFlag)
|
||||
{
|
||||
builder.AppendLine(entry.OrdinalNumber, " Ordinal number");
|
||||
builder.AppendLine(entry.OrdinalNumber, " Ordinal number");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine(entry.HintNameTableRVA, " Hint/Name table RVA");
|
||||
builder.AppendLine(entry.HintNameTableRVA.ConvertVirtualAddress(sections), " Hint/Name table physical address");
|
||||
builder.AppendLine(entry.HintNameTableRVA, " Hint/Name table RVA");
|
||||
builder.AppendLine(entry.HintNameTableRVA.ConvertVirtualAddress(sections), " Hint/Name table physical address");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
builder.AppendLine(" Import Address Tables Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.ImportAddressTables == null || table.ImportAddressTables.Count == 0)
|
||||
private static void Print(StringBuilder builder, Dictionary<int, Models.PortableExecutable.Import.AddressTableEntry[]?>? tables, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Import Address Tables Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (tables == null || tables.Count == 0)
|
||||
{
|
||||
builder.AppendLine(" No import address tables");
|
||||
builder.AppendLine(" No import address tables");
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var kvp in table.ImportAddressTables)
|
||||
foreach (var kvp in tables)
|
||||
{
|
||||
int index = kvp.Key;
|
||||
var importAddressTable = kvp.Value;
|
||||
|
||||
builder.AppendLine();
|
||||
builder.AppendLine($" Import Address Table {index} Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
builder.AppendLine($" Import Address Table {index} Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (importAddressTable == null || importAddressTable.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No import address table items");
|
||||
builder.AppendLine(" No import address table items");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -826,45 +827,48 @@ namespace SabreTools.Serialization.Printers
|
||||
{
|
||||
var entry = importAddressTable[i];
|
||||
|
||||
builder.AppendLine($" Import Address Table {index} Entry {i}");
|
||||
builder.AppendLine(entry.OrdinalNameFlag, " Ordinal/Name flag");
|
||||
builder.AppendLine($" Import Address Table {index} Entry {i}");
|
||||
builder.AppendLine(entry.OrdinalNameFlag, " Ordinal/Name flag");
|
||||
if (entry.OrdinalNameFlag)
|
||||
{
|
||||
builder.AppendLine(entry.OrdinalNumber, " Ordinal number");
|
||||
builder.AppendLine(entry.OrdinalNumber, " Ordinal number");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine(entry.HintNameTableRVA, " Hint/Name table RVA");
|
||||
builder.AppendLine(entry.HintNameTableRVA.ConvertVirtualAddress(sections), " Hint/Name table physical address");
|
||||
builder.AppendLine(entry.HintNameTableRVA, " Hint/Name table RVA");
|
||||
builder.AppendLine(entry.HintNameTableRVA.ConvertVirtualAddress(sections), " Hint/Name table physical address");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
builder.AppendLine(" Hint/Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table.HintNameTable == null || table.HintNameTable.Length == 0)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Import.HintNameTableEntry[]? table)
|
||||
{
|
||||
builder.AppendLine(" Import Hint/Name Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
if (table == null || table.Length == 0)
|
||||
{
|
||||
builder.AppendLine(" No hint/name table items");
|
||||
builder.AppendLine(" No import hint/name table items");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < table.HintNameTable.Length; i++)
|
||||
for (int i = 0; i < table.Length; i++)
|
||||
{
|
||||
var entry = table.HintNameTable[i];
|
||||
var entry = table[i];
|
||||
|
||||
builder.AppendLine($" Hint/Name Table Entry {i}");
|
||||
builder.AppendLine(entry.Hint, " Hint");
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
builder.AppendLine($" Hint/Name Table Entry {i}");
|
||||
builder.AppendLine(entry.Hint, " Hint");
|
||||
builder.AppendLine(entry.Name, " Name");
|
||||
}
|
||||
}
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ResourceDirectoryTable? table, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DirectoryTable? table, SectionHeader[]? sections)
|
||||
{
|
||||
builder.AppendLine(" Resource Directory Table Information:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -879,7 +883,7 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ResourceDirectoryTable table, int level, List<object> types, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DirectoryTable table, int level, List<object> types, SectionHeader[]? sections)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -919,7 +923,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ResourceDirectoryEntry entry, int level, List<object> types, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DirectoryEntry entry, int level, List<object> types, SectionHeader[]? sections)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -940,7 +944,7 @@ namespace SabreTools.Serialization.Printers
|
||||
Print(builder, entry.Subdirectory, level: level + 1, types, sections);
|
||||
}
|
||||
|
||||
private static void Print(StringBuilder builder, ResourceDataEntry entry, int level, List<object> types, SectionHeader[]? sections)
|
||||
private static void Print(StringBuilder builder, Models.PortableExecutable.Resource.DataEntry entry, int level, List<object> types, SectionHeader[]? sections)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1036,25 +1040,25 @@ namespace SabreTools.Serialization.Printers
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_CURSOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_CURSOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-dependent cursor resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_BITMAP(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_BITMAP(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Bitmap resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ICON(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_ICON(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-dependent icon resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_MENU(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_MENU(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1132,7 +1136,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_DIALOG(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_DIALOG(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1267,7 +1271,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_STRING(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_STRING(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1287,19 +1291,19 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_FONTDIR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_FONTDIR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Font directory resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_FONT(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_FONT(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Font resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ACCELERATOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_ACCELERATOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1322,7 +1326,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_RCDATA(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_RCDATA(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Application-defined resource found, not parsed yet");
|
||||
@@ -1381,7 +1385,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_MESSAGETABLE(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_MESSAGETABLE(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1448,19 +1452,19 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_GROUP_CURSOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_GROUP_CURSOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-independent cursor resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_GROUP_ICON(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_GROUP_ICON(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Hardware-independent icon resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_VERSION(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_VERSION(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1581,37 +1585,37 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_DLGINCLUDE(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_DLGINCLUDE(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}External header resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_PLUGPLAY(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_PLUGPLAY(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Plug and Play resource found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_VXD(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_VXD(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}VXD found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ANICURSOR(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_ANICURSOR(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Animated cursor found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_ANIICON(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_ANIICON(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}Animated icon found, not parsed yet");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_HTML(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_HTML(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}HTML resource found, not parsed yet");
|
||||
@@ -1624,7 +1628,7 @@ namespace SabreTools.Serialization.Printers
|
||||
// builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)");
|
||||
}
|
||||
|
||||
private static void PrintResourceRT_MANIFEST(ResourceDataEntry entry, int level, StringBuilder builder)
|
||||
private static void PrintResourceRT_MANIFEST(Models.PortableExecutable.Resource.DataEntry entry, int level, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
@@ -1801,7 +1805,7 @@ namespace SabreTools.Serialization.Printers
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintResourceUNKNOWN(ResourceDataEntry entry, int level, object resourceType, StringBuilder builder)
|
||||
private static void PrintResourceUNKNOWN(Models.PortableExecutable.Resource.DataEntry entry, int level, object resourceType, StringBuilder builder)
|
||||
{
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
|
||||
|
||||
@@ -85,11 +85,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.ASN1" Version="1.6.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="SabreTools.ASN1" Version="1.6.4" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.7.3" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.7.1" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.7.4" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.7.2" />
|
||||
<PackageReference Include="SabreTools.Matching" Version="1.6.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.40.0" Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -272,7 +272,11 @@ namespace SabreTools.Serialization.Serializers
|
||||
writer.WriteRequiredAttributeString("name", rom.Name, throwOnError: true);
|
||||
writer.WriteRequiredAttributeString("size", rom.Size, throwOnError: true);
|
||||
writer.WriteOptionalAttributeString("crc", rom.CRC);
|
||||
writer.WriteOptionalAttributeString("md2", rom.MD2);
|
||||
writer.WriteOptionalAttributeString("md4", rom.MD4);
|
||||
writer.WriteOptionalAttributeString("md5", rom.MD5);
|
||||
writer.WriteOptionalAttributeString("ripemd128", rom.RIPEMD128);
|
||||
writer.WriteOptionalAttributeString("ripemd160", rom.RIPEMD160);
|
||||
writer.WriteOptionalAttributeString("sha1", rom.SHA1);
|
||||
writer.WriteOptionalAttributeString("sha256", rom.SHA256);
|
||||
writer.WriteOptionalAttributeString("sha384", rom.SHA384);
|
||||
|
||||
@@ -112,6 +112,12 @@ namespace SabreTools.Serialization.Serializers
|
||||
case HashType.MD5:
|
||||
WriteMD5(obj.MD5, writer);
|
||||
break;
|
||||
case HashType.RIPEMD128:
|
||||
WriteRIPEMD128(obj.RIPEMD128, writer);
|
||||
break;
|
||||
case HashType.RIPEMD160:
|
||||
WriteRIPEMD160(obj.RIPEMD160, writer);
|
||||
break;
|
||||
case HashType.SHA1:
|
||||
WriteSHA1(obj.SHA1, writer);
|
||||
break;
|
||||
@@ -224,6 +230,50 @@ namespace SabreTools.Serialization.Serializers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write RIPEMD128 information to the current writer
|
||||
/// </summary>
|
||||
/// <param name="ripemd128s">Array of RIPEMD128 objects representing the files</param>
|
||||
/// <param name="writer">SeparatedValueWriter representing the output</param>
|
||||
private static void WriteRIPEMD128(RIPEMD128[]? ripemd128s, SeparatedValueWriter writer)
|
||||
{
|
||||
// If the item information is missing, we can't do anything
|
||||
if (ripemd128s == null || ripemd128s.Length == 0)
|
||||
return;
|
||||
|
||||
// Loop through and write out the items
|
||||
foreach (var ripemd128 in ripemd128s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ripemd128.Hash) || string.IsNullOrEmpty(ripemd128.File))
|
||||
continue;
|
||||
|
||||
writer.WriteValues([ripemd128.Hash!, ripemd128.File!]);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write RIPEMD160 information to the current writer
|
||||
/// </summary>
|
||||
/// <param name="ripemd160s">Array of RIPEMD160 objects representing the files</param>
|
||||
/// <param name="writer">SeparatedValueWriter representing the output</param>
|
||||
private static void WriteRIPEMD160(RIPEMD160[]? ripemd160s, SeparatedValueWriter writer)
|
||||
{
|
||||
// If the item information is missing, we can't do anything
|
||||
if (ripemd160s == null || ripemd160s.Length == 0)
|
||||
return;
|
||||
|
||||
// Loop through and write out the items
|
||||
foreach (var ripemd160 in ripemd160s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ripemd160.Hash) || string.IsNullOrEmpty(ripemd160.File))
|
||||
continue;
|
||||
|
||||
writer.WriteValues([ripemd160.Hash!, ripemd160.File!]);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write SHA1 information to the current writer
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.BZip2;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
@@ -7,7 +8,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public partial class BZip2 : WrapperBase
|
||||
public partial class BZip2 : WrapperBase<Archive>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
@@ -19,22 +20,22 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public BZip2(byte[] data) : base(data) { }
|
||||
public BZip2(Archive model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public BZip2(byte[] data, int offset) : base(data, offset) { }
|
||||
public BZip2(Archive model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public BZip2(byte[] data, int offset, int length) : base(data, offset, length) { }
|
||||
public BZip2(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public BZip2(Stream data) : base(data) { }
|
||||
public BZip2(Archive model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public BZip2(Stream data, long offset) : base(data, offset) { }
|
||||
public BZip2(Archive model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public BZip2(Stream data, long offset, long length) : base(data, offset, length) { }
|
||||
public BZip2(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -72,7 +73,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new BZip2(data);
|
||||
return new BZip2(new Archive(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
91
SabreTools.Serialization/Wrappers/LDSCRYPT.cs
Normal file
91
SabreTools.Serialization/Wrappers/LDSCRYPT.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.LDSCRYPT;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a shell wrapper; one that does not contain
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public class LDSCRYPT : WrapperBase<EncryptedFile>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string DescriptionString => "Link Data Security encrypted file";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LDSCRYPT(EncryptedFile model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LDSCRYPT(EncryptedFile model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LDSCRYPT(EncryptedFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LDSCRYPT(EncryptedFile model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LDSCRYPT(EncryptedFile model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public LDSCRYPT(EncryptedFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a LDSCRYPT file from a byte array and offset
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array representing the archive</param>
|
||||
/// <param name="offset">Offset within the array to parse</param>
|
||||
/// <returns>A LDSCRYPT wrapper on success, null on failure</returns>
|
||||
public static LDSCRYPT? Create(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || data.Length == 0)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and use that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return Create(dataStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a LDSCRYPT file from a Stream
|
||||
/// </summary>
|
||||
/// <param name="data">Stream representing the archive</param>
|
||||
/// <returns>A LDSCRYPT wrapper on success, null on failure</returns>
|
||||
public static LDSCRYPT? Create(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new LDSCRYPT(new EncryptedFile(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JSON Export
|
||||
|
||||
#if NETCOREAPP
|
||||
/// <inheritdoc/>
|
||||
public override string ExportJSON() => throw new System.NotImplementedException();
|
||||
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return false;
|
||||
|
||||
// Get the decompressor
|
||||
var decompressor = Decompressor.CreateKWAJ(contents, CompressionType);
|
||||
var decompressor = Decompressor.CreateKWAJ(contents, (ushort)CompressionType);
|
||||
if (decompressor == null)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -4,8 +4,9 @@ using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Matching;
|
||||
using SabreTools.Models.COFF;
|
||||
using SabreTools.Models.PortableExecutable;
|
||||
using SabreTools.Models.PortableExecutable.ResourceEntries;
|
||||
using SabreTools.Models.PortableExecutable.Resource.Entries;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
@@ -20,8 +21,8 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#region Extension Properties
|
||||
|
||||
/// <inheritdoc cref="Executable.COFFFileHeader"/>
|
||||
public COFFFileHeader? COFFFileHeader => Model.COFFFileHeader;
|
||||
/// <inheritdoc cref="Executable.FileHeader"/>
|
||||
public FileHeader? COFFFileHeader => Model.FileHeader;
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of debug data
|
||||
@@ -47,8 +48,8 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="DebugTable.DebugDirectoryTable"/>
|
||||
public DebugDirectoryEntry[]? DebugDirectoryTable
|
||||
/// <inheritdoc cref="Models.PortableExecutable.DebugData.Table.Table"/>
|
||||
public Models.PortableExecutable.DebugData.Entry[]? DebugDirectoryTable
|
||||
=> Model.DebugTable?.DebugDirectoryTable;
|
||||
|
||||
/// <summary>
|
||||
@@ -101,8 +102,20 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Executable.ExportTable"/>
|
||||
public ExportTable? ExportTable => Model.ExportTable;
|
||||
/// <inheritdoc cref="Executable.ExportAddressTable"/>
|
||||
public Models.PortableExecutable.Export.AddressTableEntry[]? ExportTable => Model.ExportAddressTable;
|
||||
|
||||
/// <inheritdoc cref="Executable.ExportDirectoryTable"/>
|
||||
public Models.PortableExecutable.Export.DirectoryTable? ExportDirectoryTable => Model.ExportDirectoryTable;
|
||||
|
||||
/// <inheritdoc cref="Executable.NamePointerTable"/>
|
||||
public Models.PortableExecutable.Export.NamePointerTable? ExportNamePointerTable => Model.NamePointerTable;
|
||||
|
||||
/// <inheritdoc cref="Executable.ExportNameTable"/>
|
||||
public Models.PortableExecutable.Export.NameTable? ExportNameTable => Model.ExportNameTable;
|
||||
|
||||
/// <inheritdoc cref="Executable.OrdinalTable"/>
|
||||
public Models.PortableExecutable.Export.OrdinalTable? ExportOrdinalTable => Model.OrdinalTable;
|
||||
|
||||
/// <summary>
|
||||
/// Header padding data, if it exists
|
||||
@@ -182,8 +195,17 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Executable.ImportTable"/>
|
||||
public ImportTable? ImportTable => Model.ImportTable;
|
||||
/// <inheritdoc cref="Executable.ImportAddressTables"/>
|
||||
public Dictionary<int, Models.PortableExecutable.Import.AddressTableEntry[]?>? ImportAddressTables => Model.ImportAddressTables;
|
||||
|
||||
/// <inheritdoc cref="Executable.ImportDirectoryTable"/>
|
||||
public Models.PortableExecutable.Import.DirectoryTableEntry[]? ImportDirectoryTable => Model.ImportDirectoryTable;
|
||||
|
||||
/// <inheritdoc cref="Executable.HintNameTable"/>
|
||||
public Models.PortableExecutable.Import.HintNameTableEntry[]? ImportHintNameTable => Model.HintNameTable;
|
||||
|
||||
/// <inheritdoc cref="Executable.ImportLookupTables"/>
|
||||
public Dictionary<int, Models.PortableExecutable.Import.LookupTableEntry[]?>? ImportLookupTables => Model.ImportLookupTables;
|
||||
|
||||
/// <summary>
|
||||
/// SecuROM Matroschka package wrapper, if it exists
|
||||
@@ -264,7 +286,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Executable.OptionalHeader"/>
|
||||
public OptionalHeader? OptionalHeader => Model.OptionalHeader;
|
||||
public Models.PortableExecutable.OptionalHeader? OptionalHeader => Model.OptionalHeader;
|
||||
|
||||
/// <summary>
|
||||
/// Address of the overlay, if it exists
|
||||
@@ -420,7 +442,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Executable.ResourceDirectoryTable"/>
|
||||
public ResourceDirectoryTable? ResourceDirectoryTable => Model.ResourceDirectoryTable;
|
||||
public Models.PortableExecutable.Resource.DirectoryTable? ResourceDirectoryTable => Model.ResourceDirectoryTable;
|
||||
|
||||
/// <summary>
|
||||
/// Sanitized section names
|
||||
@@ -1174,14 +1196,14 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (data == null)
|
||||
continue;
|
||||
|
||||
if (data is NB10ProgramDatabase n)
|
||||
if (data is Models.PortableExecutable.DebugData.NB10ProgramDatabase n)
|
||||
{
|
||||
if (n.PdbFileName == null || !n.PdbFileName.Contains(path))
|
||||
continue;
|
||||
|
||||
debugFound.Add(n);
|
||||
}
|
||||
else if (data is RSDSProgramDatabase r)
|
||||
else if (data is Models.PortableExecutable.DebugData.RSDSProgramDatabase r)
|
||||
{
|
||||
if (r.PathAndFileName == null || !r.PathAndFileName.Contains(path))
|
||||
continue;
|
||||
@@ -1635,7 +1657,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Parse the resource directory table information
|
||||
/// </summary>
|
||||
private void ParseResourceDirectoryTable(ResourceDirectoryTable table, List<object> types)
|
||||
private void ParseResourceDirectoryTable(Models.PortableExecutable.Resource.DirectoryTable table, List<object> types)
|
||||
{
|
||||
if (table?.Entries == null)
|
||||
return;
|
||||
@@ -1657,7 +1679,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Parse the name resource directory entry information
|
||||
/// </summary>
|
||||
private void ParseResourceDirectoryEntry(ResourceDirectoryEntry entry, List<object> types)
|
||||
private void ParseResourceDirectoryEntry(Models.PortableExecutable.Resource.DirectoryEntry entry, List<object> types)
|
||||
{
|
||||
if (entry.DataEntry != null)
|
||||
ParseResourceDataEntry(entry.DataEntry, types);
|
||||
@@ -1673,7 +1695,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// of those resources in the entire exectuable. This means that only the last found version or manifest will
|
||||
/// ever be cached.
|
||||
/// </remarks>
|
||||
private void ParseResourceDataEntry(ResourceDataEntry entry, List<object> types)
|
||||
private void ParseResourceDataEntry(Models.PortableExecutable.Resource.DataEntry entry, List<object> types)
|
||||
{
|
||||
// Create the key and value objects
|
||||
string key = types == null
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.RAR;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
@@ -7,7 +8,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public partial class RAR : WrapperBase
|
||||
public partial class RAR : WrapperBase<Archive>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
@@ -19,22 +20,22 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RAR(byte[] data) : base(data) { }
|
||||
public RAR(Archive model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RAR(byte[] data, int offset) : base(data, offset) { }
|
||||
public RAR(Archive model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RAR(byte[] data, int offset, int length) : base(data, offset, length) { }
|
||||
public RAR(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RAR(Stream data) : base(data) { }
|
||||
public RAR(Archive model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RAR(Stream data, long offset) : base(data, offset) { }
|
||||
public RAR(Archive model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RAR(Stream data, long offset, long length) : base(data, offset, length) { }
|
||||
public RAR(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -72,7 +73,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new RAR(data);
|
||||
return new RAR(new Archive(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
90
SabreTools.Serialization/Wrappers/RealArcadeInstaller.cs
Normal file
90
SabreTools.Serialization/Wrappers/RealArcadeInstaller.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.RealArcade;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a shell wrapper; one that does not contain
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public class RealArcadeInstaller : WrapperBase<RgsFile>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string DescriptionString => "RealArcade Installer RGS File";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeInstaller(RgsFile model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeInstaller(RgsFile model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeInstaller(RgsFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeInstaller(RgsFile model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeInstaller(RgsFile model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeInstaller(RgsFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a RealArcade installer RGS file from a byte array and offset
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array representing the archive</param>
|
||||
/// <param name="offset">Offset within the array to parse</param>
|
||||
/// <returns>A RealArcade installer RGS file wrapper on success, null on failure</returns>
|
||||
public static RealArcadeInstaller? Create(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || data.Length == 0)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and use that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return Create(dataStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a RealArcade installer RGS file from a Stream
|
||||
/// </summary>
|
||||
/// <param name="data">Stream representing the archive</param>
|
||||
/// <returns>A RealArcade installer RGS file wrapper on success, null on failure</returns>
|
||||
public static RealArcadeInstaller? Create(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new RealArcadeInstaller(new RgsFile(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JSON Export
|
||||
|
||||
#if NETCOREAPP
|
||||
/// <inheritdoc/>
|
||||
public override string ExportJSON() => throw new System.NotImplementedException();
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
90
SabreTools.Serialization/Wrappers/RealArcadeMezzanine.cs
Normal file
90
SabreTools.Serialization/Wrappers/RealArcadeMezzanine.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.RealArcade;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a shell wrapper; one that does not contain
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public class RealArcadeMezzanine : WrapperBase<Mezzanine>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string DescriptionString => "RealArcade Mezzanine";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeMezzanine(Mezzanine model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeMezzanine(Mezzanine model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeMezzanine(Mezzanine model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeMezzanine(Mezzanine model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeMezzanine(Mezzanine model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public RealArcadeMezzanine(Mezzanine model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a RealArcade mezzanine from a byte array and offset
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array representing the archive</param>
|
||||
/// <param name="offset">Offset within the array to parse</param>
|
||||
/// <returns>A RealArcade mezzanine wrapper on success, null on failure</returns>
|
||||
public static RealArcadeMezzanine? Create(byte[]? data, int offset)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || data.Length == 0)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
if (offset < 0 || offset >= data.Length)
|
||||
return null;
|
||||
|
||||
// Create a memory stream and use that
|
||||
var dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return Create(dataStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a RealArcade mezzanine from a Stream
|
||||
/// </summary>
|
||||
/// <param name="data">Stream representing the archive</param>
|
||||
/// <returns>A RealArcade mezzanine wrapper on success, null on failure</returns>
|
||||
public static RealArcadeMezzanine? Create(Stream? data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new RealArcadeMezzanine(new Mezzanine(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JSON Export
|
||||
|
||||
#if NETCOREAPP
|
||||
/// <inheritdoc/>
|
||||
public override string ExportJSON() => throw new System.NotImplementedException();
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.StarForce;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
@@ -8,7 +9,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
/// TODO: Hook up the models to a proper deserializer
|
||||
public class SFFS : WrapperBase
|
||||
public class SFFS : WrapperBase<FileSystem>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
@@ -20,22 +21,22 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(byte[] data) : base(data) { }
|
||||
public SFFS(FileSystem model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(byte[] data, int offset) : base(data, offset) { }
|
||||
public SFFS(FileSystem model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(byte[] data, int offset, int length) : base(data, offset, length) { }
|
||||
public SFFS(FileSystem model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(Stream data) : base(data) { }
|
||||
public SFFS(FileSystem model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(Stream data, long offset) : base(data, offset) { }
|
||||
public SFFS(FileSystem model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SFFS(Stream data, long offset, long length) : base(data, offset, length) { }
|
||||
public SFFS(FileSystem model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -73,7 +74,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new SFFS(data);
|
||||
return new SFFS(new FileSystem(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return false;
|
||||
|
||||
// Ensure directory separators are consistent
|
||||
string filename = Encoding.ASCII.GetString(entry.Path).TrimEnd('\0');
|
||||
string filename = entry.Path.TrimEnd('\0');
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
filename = filename.Replace('/', '\\');
|
||||
else if (Path.DirectorySeparatorChar == '/')
|
||||
@@ -122,7 +122,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Do not return on a hash mismatch
|
||||
if (actualMd5 != expectedMd5)
|
||||
{
|
||||
string filename = Encoding.ASCII.GetString(entry.Path).TrimEnd('\0');
|
||||
string filename = entry.Path.TrimEnd('\0');
|
||||
if (includeDebug) Console.Error.WriteLine($"MD5 checksum failure for file {filename})");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using SabreTools.Serialization.Interfaces;
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
using SharpCompress.Archives;
|
||||
using SharpCompress.Archives.SevenZip;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.SevenZip;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
@@ -7,7 +8,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public partial class SevenZip : WrapperBase
|
||||
public partial class SevenZip : WrapperBase<Archive>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
@@ -19,22 +20,22 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SevenZip(byte[] data) : base(data) { }
|
||||
public SevenZip(Archive model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SevenZip(byte[] data, int offset) : base(data, offset) { }
|
||||
public SevenZip(Archive model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SevenZip(byte[] data, int offset, int length) : base(data, offset, length) { }
|
||||
public SevenZip(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SevenZip(Stream data) : base(data) { }
|
||||
public SevenZip(Archive model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SevenZip(Stream data, long offset) : base(data, offset) { }
|
||||
public SevenZip(Archive model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public SevenZip(Stream data, long offset, long length) : base(data, offset, length) { }
|
||||
public SevenZip(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -72,7 +73,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new SevenZip(data);
|
||||
return new SevenZip(new Archive(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
WrapperType.IniFile => null,// TODO: Implement wrapper
|
||||
WrapperType.InstallShieldArchiveV3 => InstallShieldArchiveV3.Create(data),
|
||||
WrapperType.InstallShieldCAB => InstallShieldCabinet.Create(data),
|
||||
WrapperType.LDSCRYPT => null,// TODO: Implement wrapper
|
||||
WrapperType.LDSCRYPT => LDSCRYPT.Create(data),
|
||||
WrapperType.LZKWAJ => LZKWAJ.Create(data),
|
||||
WrapperType.LZQBasic => LZQBasic.Create(data),
|
||||
WrapperType.LZSZDD => LZSZDD.Create(data),
|
||||
@@ -47,8 +47,8 @@ namespace SabreTools.Serialization.Wrappers
|
||||
WrapperType.PlayJPlaylist => PlayJPlaylist.Create(data),
|
||||
WrapperType.Quantum => Quantum.Create(data),
|
||||
WrapperType.RAR => RAR.Create(data),
|
||||
WrapperType.RealArcadeInstaller => null,// TODO: Implement wrapper
|
||||
WrapperType.RealArcadeMezzanine => null,// TODO: Implement wrapper
|
||||
WrapperType.RealArcadeInstaller => RealArcadeInstaller.Create(data),
|
||||
WrapperType.RealArcadeMezzanine => RealArcadeMezzanine.Create(data),
|
||||
WrapperType.SecuROMDFA => SecuROMDFA.Create(data),
|
||||
WrapperType.SevenZip => SevenZip.Create(data),
|
||||
WrapperType.SFFS => SFFS.Create(data),
|
||||
@@ -158,10 +158,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region BDPlusSVM
|
||||
|
||||
if (magic.StartsWith([0x42, 0x44, 0x53, 0x56, 0x4D, 0x5F, 0x43, 0x43]))
|
||||
if (magic.StartsWith(Models.BDPlus.Constants.SignatureBytes))
|
||||
return WrapperType.BDPlusSVM;
|
||||
|
||||
if (extension.Equals("svm", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -191,10 +190,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region BZip2
|
||||
|
||||
if (magic.StartsWith([0x42, 0x52, 0x68]))
|
||||
if (magic.StartsWith(Models.BZip2.Constants.SignatureBytes))
|
||||
return WrapperType.BZip2;
|
||||
|
||||
if (extension.Equals("bz2", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -229,10 +227,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region CHD
|
||||
|
||||
if (magic.StartsWith([0x4D, 0x43, 0x6F, 0x6D, 0x70, 0x72, 0x48, 0x44]))
|
||||
if (magic.StartsWith(Models.CHD.Constants.SignatureBytes))
|
||||
return WrapperType.CHD;
|
||||
|
||||
#endregion
|
||||
@@ -315,10 +312,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region InstallShieldArchiveV3
|
||||
|
||||
if (magic.StartsWith([0x13, 0x5D, 0x65, 0x8C]))
|
||||
if (magic.StartsWith(Models.InstallShieldArchiveV3.Constants.HeaderSignatureBytes))
|
||||
return WrapperType.InstallShieldArchiveV3;
|
||||
|
||||
if (extension.Equals("z", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -335,10 +331,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region LDSCRYPT
|
||||
|
||||
if (magic.StartsWith([0x4C, 0x44, 0x53, 0x43, 0x52, 0x59, 0x50, 0x54]))
|
||||
if (magic.StartsWith(Models.LDSCRYPT.Constants.SignatureBytes))
|
||||
return WrapperType.LDSCRYPT;
|
||||
|
||||
#endregion
|
||||
@@ -592,15 +587,14 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region RAR
|
||||
|
||||
// RAR archive version 1.50 onwards
|
||||
if (magic.StartsWith([0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00]))
|
||||
if (magic.StartsWith(Models.RAR.Constants.OldSignatureBytes))
|
||||
return WrapperType.RAR;
|
||||
|
||||
// RAR archive version 5.0 onwards
|
||||
if (magic.StartsWith([0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00]))
|
||||
if (magic.StartsWith(Models.RAR.Constants.NewSignatureBytes))
|
||||
return WrapperType.RAR;
|
||||
|
||||
if (extension.Equals("rar", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -608,17 +602,16 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region RealArcade
|
||||
|
||||
// RASGI2.0
|
||||
// Found in the ".rgs files in IA item "Nova_RealArcadeCD_USA".
|
||||
if (magic.StartsWith([0x52, 0x41, 0x53, 0x47, 0x49, 0x32, 0x2E, 0x30]))
|
||||
if (magic.StartsWith(Models.RealArcades.Constants.RgsSignatureBytes))
|
||||
return WrapperType.RealArcadeInstaller;
|
||||
|
||||
// XZip2.0
|
||||
// Found in the ".mez" files in IA item "Nova_RealArcadeCD_USA".
|
||||
if (magic.StartsWith([0x58, 0x5A, 0x69, 0x70, 0x32, 0x2E, 0x30]))
|
||||
if (magic.StartsWith(Models.RealArcades.Constants.MezzanineSignatureBytes))
|
||||
return WrapperType.RealArcadeMezzanine;
|
||||
|
||||
#endregion
|
||||
@@ -630,10 +623,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region SevenZip
|
||||
|
||||
if (magic.StartsWith([0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]))
|
||||
if (magic.StartsWith(Models.SevenZip.Constants.SignatureBytes))
|
||||
return WrapperType.SevenZip;
|
||||
|
||||
if (extension.Equals("7z", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -644,7 +636,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region SFFS
|
||||
|
||||
// Found in Redump entry 81756, confirmed to be "StarForce Filesystem" by PiD.
|
||||
if (magic.StartsWith(Models.SFFS.Constants.SignatureBytes))
|
||||
if (magic.StartsWith(Models.StarForce.Constants.SignatureBytes))
|
||||
return WrapperType.SFFS;
|
||||
|
||||
#endregion
|
||||
@@ -796,10 +788,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Use constants from Models here
|
||||
#region XZ
|
||||
|
||||
if (magic.StartsWith([0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00]))
|
||||
if (magic.StartsWith(Models.XZ.Constants.SignatureBytes))
|
||||
return WrapperType.XZ;
|
||||
|
||||
if (extension.Equals("xz", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
@@ -85,7 +85,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// Link Data Security encrypted file
|
||||
/// </summary>
|
||||
/// <remarks>Currently has no IWrapper implementation</remarks>
|
||||
LDSCRYPT,
|
||||
|
||||
/// <summary>
|
||||
@@ -141,7 +140,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// PIC data object
|
||||
/// </summary>
|
||||
/// <remarks>Currently has no detection method</remarks>
|
||||
PIC,
|
||||
|
||||
/// <summary>
|
||||
@@ -157,7 +155,6 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// PlayJ playlist file
|
||||
/// </summary>
|
||||
/// <remarks>Currently has no detection method/remarks>
|
||||
PlayJPlaylist,
|
||||
|
||||
/// <summary>
|
||||
@@ -173,13 +170,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// <summary>
|
||||
/// RealArcade Installer
|
||||
/// </summary>
|
||||
/// <remarks>Currently has no IWrapper implementation</remarks>
|
||||
RealArcadeInstaller,
|
||||
|
||||
/// <summary>
|
||||
/// RealArcade Mezzanine
|
||||
/// </summary>
|
||||
/// <remarks>Currently has no IWrapper implementation</remarks>
|
||||
RealArcadeMezzanine,
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using SabreTools.Models.XZ;
|
||||
|
||||
namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
@@ -7,7 +8,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// any actual parsing. It is used as a placeholder for
|
||||
/// types that typically do not have models.
|
||||
/// </summary>
|
||||
public partial class XZ : WrapperBase
|
||||
public partial class XZ : WrapperBase<Archive>
|
||||
{
|
||||
#region Descriptive Properties
|
||||
|
||||
@@ -19,22 +20,22 @@ namespace SabreTools.Serialization.Wrappers
|
||||
#region Constructors
|
||||
|
||||
/// <inheritdoc/>
|
||||
public XZ(byte[] data) : base(data) { }
|
||||
public XZ(Archive model, byte[] data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public XZ(byte[] data, int offset) : base(data, offset) { }
|
||||
public XZ(Archive model, byte[] data, int offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public XZ(byte[] data, int offset, int length) : base(data, offset, length) { }
|
||||
public XZ(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public XZ(Stream data) : base(data) { }
|
||||
public XZ(Archive model, Stream data) : base(model, data) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public XZ(Stream data, long offset) : base(data, offset) { }
|
||||
public XZ(Archive model, Stream data, long offset) : base(model, data, offset) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public XZ(Stream data, long offset, long length) : base(data, offset, length) { }
|
||||
public XZ(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -72,7 +73,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (data == null || !data.CanRead)
|
||||
return null;
|
||||
|
||||
return new XZ(data);
|
||||
return new XZ(new Archive(), data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user