Fix issue with seeking by introducing more constructors

This commit is contained in:
Matt Nadareski
2025-09-16 21:54:26 -04:00
parent f5d0f065c1
commit 10848e6c51
49 changed files with 1025 additions and 643 deletions

View File

@@ -24,18 +24,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public AACSMediaKeyBlock(MediaKeyBlock? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public AACSMediaKeyBlock(MediaKeyBlock model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public AACSMediaKeyBlock(MediaKeyBlock? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public AACSMediaKeyBlock(MediaKeyBlock model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public AACSMediaKeyBlock(MediaKeyBlock model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public AACSMediaKeyBlock(MediaKeyBlock model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public AACSMediaKeyBlock(MediaKeyBlock model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public AACSMediaKeyBlock(MediaKeyBlock model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an AACS media key block from a byte array and offset
@@ -78,8 +86,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new AACSMediaKeyBlock(model, data);
return new AACSMediaKeyBlock(model, data, currentOffset);
}
catch
{

View File

@@ -24,18 +24,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public BDPlusSVM(SVM? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public BDPlusSVM(SVM model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public BDPlusSVM(SVM? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public BDPlusSVM(SVM model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public BDPlusSVM(SVM model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public BDPlusSVM(SVM model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public BDPlusSVM(SVM model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public BDPlusSVM(SVM model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a BD+ SVM from a byte array and offset
@@ -78,8 +86,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new BDPlusSVM(model, data);
return new BDPlusSVM(model, data, currentOffset);
}
catch
{

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public BFPK(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public BFPK(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public BFPK(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public BFPK(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public BFPK(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public BFPK(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public BFPK(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public BFPK(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a BFPK archive from a byte array and offset
@@ -76,8 +84,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new BFPK(model, data);
return new BFPK(model, data, currentOffset);
}
catch
{

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public BSP(BspFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public BSP(BspFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public BSP(BspFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public BSP(BspFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public BSP(BspFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public BSP(BspFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public BSP(BspFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public BSP(BspFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a BSP from a byte array and offset
@@ -76,8 +84,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new BSP(model, data);
return new BSP(model, data, currentOffset);
}
catch
{

View File

@@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public BZip2(byte[]? data, int offset)
: base(data, offset)
{
// All logic is handled by the base class
}
public BZip2(byte[] data) : base(data) { }
/// <inheritdoc/>
public BZip2(Stream? data)
: base(data)
{
// All logic is handled by the base class
}
public BZip2(byte[] data, int offset) : base(data, offset) { }
/// <inheritdoc/>
public BZip2(byte[] data, int offset, int length) : base(data, offset, length) { }
/// <inheritdoc/>
public BZip2(Stream data) : base(data) { }
/// <inheritdoc/>
public BZip2(Stream data, long offset) : base(data, offset) { }
/// <inheritdoc/>
public BZip2(Stream data, long offset, long length) : base(data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a BZip2 archive from a byte array and offset

View File

@@ -69,18 +69,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public CFB(Binary? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public CFB(Binary model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public CFB(Binary? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public CFB(Binary model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public CFB(Binary model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public CFB(Binary model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public CFB(Binary model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public CFB(Binary model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a Compound File Binary from a byte array and offset
@@ -123,8 +131,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new CFB(model, data);
return new CFB(model, data, currentOffset);
}
catch
{

View File

@@ -60,18 +60,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public CHD(Header? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public CHD(Header model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public CHD(Header? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public CHD(Header model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public CHD(Header model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public CHD(Header model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public CHD(Header model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public CHD(Header model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a CHD header from a byte array and offset
@@ -114,8 +122,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new CHD(model, data);
return new CHD(model, data, currentOffset);
}
catch
{

View File

@@ -15,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public CIA(Models.N3DS.CIA? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public CIA(Models.N3DS.CIA model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public CIA(Models.N3DS.CIA? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public CIA(Models.N3DS.CIA model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public CIA(Models.N3DS.CIA model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public CIA(Models.N3DS.CIA model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public CIA(Models.N3DS.CIA model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public CIA(Models.N3DS.CIA model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a CIA archive from a byte array and offset
@@ -69,8 +77,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new CIA(model, data);
return new CIA(model, data, currentOffset);
}
catch
{

View File

@@ -164,18 +164,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public GCF(Models.GCF.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public GCF(Models.GCF.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public GCF(Models.GCF.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public GCF(Models.GCF.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public GCF(Models.GCF.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public GCF(Models.GCF.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public GCF(Models.GCF.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public GCF(Models.GCF.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an GCF from a byte array and offset
@@ -218,8 +226,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new GCF(model, data);
return new GCF(model, data, currentOffset);
}
catch
{

View File

@@ -71,18 +71,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public GZip(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public GZip(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public GZip(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public GZip(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public GZip(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public GZip(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public GZip(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public GZip(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a GZip archive from a byte array and offset
@@ -125,8 +133,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new GZip(model, data);
return new GZip(model, data, currentOffset);
}
catch
{

View File

@@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public IRD(Models.IRD.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public IRD(Models.IRD.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public IRD(Models.IRD.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public IRD(Models.IRD.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public IRD(Models.IRD.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public IRD(Models.IRD.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public IRD(Models.IRD.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public IRD(Models.IRD.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an IRD from a byte array and offset
@@ -68,8 +76,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new IRD(model, data);
return new IRD(model, data, currentOffset);
}
catch
{

View File

@@ -108,18 +108,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public InstallShieldArchiveV3(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public InstallShieldArchiveV3(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public InstallShieldArchiveV3(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public InstallShieldArchiveV3(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public InstallShieldArchiveV3(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public InstallShieldArchiveV3(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public InstallShieldArchiveV3(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public InstallShieldArchiveV3(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an InstallShield Archive V3 from a byte array and offset
@@ -162,8 +170,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new InstallShieldArchiveV3(model, data);
return new InstallShieldArchiveV3(model, data, currentOffset);
}
catch
{

View File

@@ -68,18 +68,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public InstallShieldCabinet(Cabinet? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public InstallShieldCabinet(Cabinet model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public InstallShieldCabinet(Cabinet? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public InstallShieldCabinet(Cabinet model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public InstallShieldCabinet(Cabinet model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public InstallShieldCabinet(Cabinet model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public InstallShieldCabinet(Cabinet model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public InstallShieldCabinet(Cabinet model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an InstallShield Cabinet from a byte array and offset
@@ -122,8 +130,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new InstallShieldCabinet(model, data);
return new InstallShieldCabinet(model, data, currentOffset);
}
catch
{

View File

@@ -31,18 +31,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public LZKWAJ(KWAJFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public LZKWAJ(KWAJFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public LZKWAJ(KWAJFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public LZKWAJ(KWAJFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LZKWAJ(KWAJFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public LZKWAJ(KWAJFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public LZKWAJ(KWAJFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LZKWAJ(KWAJFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an LZ (KWAJ variant) from a byte array and offset
@@ -85,8 +93,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new LZKWAJ(model, data);
return new LZKWAJ(model, data, currentOffset);
}
catch
{

View File

@@ -15,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public LZQBasic(QBasicFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public LZQBasic(QBasicFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public LZQBasic(QBasicFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public LZQBasic(QBasicFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LZQBasic(QBasicFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public LZQBasic(QBasicFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public LZQBasic(QBasicFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LZQBasic(QBasicFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an LZ (QBasic variant) from a byte array and offset
@@ -69,8 +77,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new LZQBasic(model, data);
return new LZQBasic(model, data, currentOffset);
}
catch
{

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public LZSZDD(SZDDFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public LZSZDD(SZDDFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public LZSZDD(SZDDFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public LZSZDD(SZDDFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LZSZDD(SZDDFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public LZSZDD(SZDDFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public LZSZDD(SZDDFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LZSZDD(SZDDFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an LZ (SZDD variant) from a byte array and offset
@@ -76,8 +84,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new LZSZDD(model, data);
return new LZSZDD(model, data, currentOffset);
}
catch
{

View File

@@ -33,18 +33,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public LinearExecutable(Executable? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public LinearExecutable(Executable model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public LinearExecutable(Executable? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public LinearExecutable(Executable model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LinearExecutable(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public LinearExecutable(Executable model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public LinearExecutable(Executable model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public LinearExecutable(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an LE/LX executable from a byte array and offset
@@ -87,8 +95,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new LinearExecutable(model, data);
return new LinearExecutable(model, data, currentOffset);
}
catch
{

View File

@@ -1,8 +1,9 @@
using System.IO;
using SabreTools.Models.MSDOS;
namespace SabreTools.Serialization.Wrappers
{
public class MSDOS : WrapperBase<Models.MSDOS.Executable>
public class MSDOS : WrapperBase<Executable>
{
#region Descriptive Properties
@@ -14,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public MSDOS(Models.MSDOS.Executable? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public MSDOS(Executable model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public MSDOS(Models.MSDOS.Executable? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public MSDOS(Executable model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public MSDOS(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public MSDOS(Executable model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public MSDOS(Executable model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public MSDOS(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an MS-DOS executable from a byte array and offset
@@ -68,8 +77,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new MSDOS(model, data);
return new MSDOS(model, data, currentOffset);
}
catch
{

View File

@@ -42,18 +42,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public MicrosoftCabinet(Cabinet? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public MicrosoftCabinet(Cabinet model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public MicrosoftCabinet(Cabinet? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public MicrosoftCabinet(Cabinet model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public MicrosoftCabinet(Cabinet model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public MicrosoftCabinet(Cabinet model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public MicrosoftCabinet(Cabinet model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public MicrosoftCabinet(Cabinet model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a Microsoft Cabinet from a byte array and offset
@@ -96,8 +104,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new MicrosoftCabinet(model, data);
return new MicrosoftCabinet(model, data, currentOffset);
}
catch
{

View File

@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.Wrappers
/// <inheritdoc/>
/// <remarks>This should only be used for until MPQ parsing is fixed</remarks>
public MoPaQ(byte[]? data, int offset)
public MoPaQ(byte[] data, int offset)
: base(new Archive(), data, offset)
{
// All logic is handled by the base class
@@ -24,25 +24,33 @@ namespace SabreTools.Serialization.Wrappers
/// <inheritdoc/>
/// <remarks>This should only be used for until MPQ parsing is fixed</remarks>
public MoPaQ(Stream? data)
public MoPaQ(Stream data)
: base(new Archive(), data)
{
// All logic is handled by the base class
}
/// <inheritdoc/>
public MoPaQ(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public MoPaQ(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public MoPaQ(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public MoPaQ(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public MoPaQ(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public MoPaQ(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public MoPaQ(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public MoPaQ(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a MoPaQ archive from a byte array and offset
@@ -85,8 +93,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new MoPaQ(model, data);
return new MoPaQ(model, data, currentOffset);
}
catch
{

View File

@@ -209,18 +209,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public N3DS(Cart? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public N3DS(Cart model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public N3DS(Cart? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public N3DS(Cart model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public N3DS(Cart model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public N3DS(Cart model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public N3DS(Cart model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public N3DS(Cart model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a 3DS cart image from a byte array and offset
@@ -263,8 +271,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new N3DS(model, data);
return new N3DS(model, data, currentOffset);
}
catch
{

View File

@@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public NCF(Models.NCF.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public NCF(Models.NCF.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public NCF(Models.NCF.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public NCF(Models.NCF.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public NCF(Models.NCF.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public NCF(Models.NCF.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public NCF(Models.NCF.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public NCF(Models.NCF.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an NCF from a byte array and offset
@@ -68,8 +76,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new NCF(model, data);
return new NCF(model, data, currentOffset);
}
catch
{

View File

@@ -287,18 +287,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public NewExecutable(Executable? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public NewExecutable(Executable model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public NewExecutable(Executable? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public NewExecutable(Executable model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public NewExecutable(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public NewExecutable(Executable model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public NewExecutable(Executable model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public NewExecutable(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an NE executable from a byte array and offset
@@ -341,8 +349,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new NewExecutable(model, data);
return new NewExecutable(model, data, currentOffset);
}
catch
{

View File

@@ -28,18 +28,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public Nitro(Cart? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public Nitro(Cart model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public Nitro(Cart? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public Nitro(Cart model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public Nitro(Cart model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public Nitro(Cart model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public Nitro(Cart model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public Nitro(Cart model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a NDS cart image from a byte array and offset
@@ -82,8 +90,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new Nitro(model, data);
return new Nitro(model, data, currentOffset);
}
catch
{

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public PAK(Models.PAK.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PAK(Models.PAK.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public PAK(Models.PAK.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PAK(Models.PAK.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PAK(Models.PAK.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PAK(Models.PAK.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PAK(Models.PAK.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PAK(Models.PAK.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PAK from a byte array and offset
@@ -76,8 +84,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PAK(model, data);
return new PAK(model, data, currentOffset);
}
catch
{

View File

@@ -27,18 +27,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public PFF(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PFF(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public PFF(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PFF(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PFF(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PFF(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PFF(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PFF(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PFF archive from a byte array and offset
@@ -81,8 +89,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PFF(model, data);
return new PFF(model, data, currentOffset);
}
catch
{

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public PIC(DiscInformation? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PIC(DiscInformation model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public PIC(DiscInformation? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PIC(DiscInformation model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PIC(DiscInformation model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PIC(DiscInformation model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PIC(DiscInformation model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PIC(DiscInformation model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PIC disc information object from a byte array and offset
@@ -77,8 +85,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PIC(model, data);
return new PIC(model, data, currentOffset);
}
catch
{

View File

@@ -34,34 +34,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
/// <remarks>This should only be used for WinZipSFX</remarks>
public PKZIP(byte[]? data, int offset)
: base(new Archive(), data, offset)
{
// All logic is handled by the base class
}
public PKZIP(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
/// <remarks>This should only be used for WinZipSFX</remarks>
public PKZIP(Stream? data)
: base(new Archive(), data)
{
// All logic is handled by the base class
}
public PKZIP(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PKZIP(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PKZIP(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PKZIP(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PKZIP(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PKZIP(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PKZIP(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PKZIP archive (or derived format) from a byte array and offset
@@ -104,8 +96,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PKZIP(model, data);
return new PKZIP(model, data, currentOffset);
}
catch
{

View File

@@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public PlayJAudioFile(Models.PlayJ.AudioFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PlayJAudioFile(Models.PlayJ.AudioFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public PlayJAudioFile(Models.PlayJ.AudioFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PlayJAudioFile(Models.PlayJ.AudioFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PlayJAudioFile(Models.PlayJ.AudioFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PlayJ audio file from a byte array and offset
@@ -68,8 +76,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PlayJAudioFile(model, data);
return new PlayJAudioFile(model, data, currentOffset);
}
catch
{

View File

@@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public PlayJPlaylist(Models.PlayJ.Playlist? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PlayJPlaylist(Models.PlayJ.Playlist model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public PlayJPlaylist(Models.PlayJ.Playlist? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PlayJPlaylist(Models.PlayJ.Playlist model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PlayJPlaylist(Models.PlayJ.Playlist model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PlayJPlaylist(Models.PlayJ.Playlist model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PlayJPlaylist(Models.PlayJ.Playlist model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PlayJPlaylist(Models.PlayJ.Playlist model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PlayJ playlist from a byte array and offset
@@ -68,8 +76,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PlayJPlaylist(model, data);
return new PlayJPlaylist(model, data, currentOffset);
}
catch
{

View File

@@ -4,11 +4,12 @@ using System.IO;
using System.Text;
using SabreTools.IO.Extensions;
using SabreTools.Matching;
using SabreTools.Models.PortableExecutable;
using SabreTools.Models.PortableExecutable.ResourceEntries;
namespace SabreTools.Serialization.Wrappers
{
public partial class PortableExecutable : WrapperBase<Models.PortableExecutable.Executable>
public partial class PortableExecutable : WrapperBase<Executable>
{
#region Descriptive Properties
@@ -19,8 +20,8 @@ namespace SabreTools.Serialization.Wrappers
#region Extension Properties
/// <inheritdoc cref="Models.PortableExecutable.Executable.COFFFileHeader"/>
public Models.PortableExecutable.COFFFileHeader? COFFFileHeader => Model.COFFFileHeader;
/// <inheritdoc cref="Executable.COFFFileHeader"/>
public COFFFileHeader? COFFFileHeader => Model.COFFFileHeader;
/// <summary>
/// Dictionary of debug data
@@ -46,8 +47,8 @@ namespace SabreTools.Serialization.Wrappers
}
}
/// <inheritdoc cref="Models.PortableExecutable.DebugTable.DebugDirectoryTable"/>
public Models.PortableExecutable.DebugDirectoryEntry[]? DebugDirectoryTable
/// <inheritdoc cref="DebugTable.DebugDirectoryTable"/>
public DebugDirectoryEntry[]? DebugDirectoryTable
=> Model.DebugTable?.DebugDirectoryTable;
/// <summary>
@@ -100,8 +101,8 @@ namespace SabreTools.Serialization.Wrappers
}
}
/// <inheritdoc cref="Models.PortableExecutable.Executable.ExportTable"/>
public Models.PortableExecutable.ExportTable? ExportTable => Model.ExportTable;
/// <inheritdoc cref="Executable.ExportTable"/>
public ExportTable? ExportTable => Model.ExportTable;
/// <summary>
/// Header padding data, if it exists
@@ -181,11 +182,11 @@ namespace SabreTools.Serialization.Wrappers
}
}
/// <inheritdoc cref="Models.PortableExecutable.Executable.ImportTable"/>
public Models.PortableExecutable.ImportTable? ImportTable => Model.ImportTable;
/// <inheritdoc cref="Executable.ImportTable"/>
public ImportTable? ImportTable => Model.ImportTable;
/// <inheritdoc cref="Models.PortableExecutable.Executable.OptionalHeader"/>
public Models.PortableExecutable.OptionalHeader? OptionalHeader => Model.OptionalHeader;
/// <inheritdoc cref="Executable.OptionalHeader"/>
public OptionalHeader? OptionalHeader => Model.OptionalHeader;
/// <summary>
/// Address of the overlay, if it exists
@@ -340,8 +341,8 @@ namespace SabreTools.Serialization.Wrappers
}
}
/// <inheritdoc cref="Models.PortableExecutable.Executable.ResourceDirectoryTable"/>
public Models.PortableExecutable.ResourceDirectoryTable? ResourceDirectoryTable => Model.ResourceDirectoryTable;
/// <inheritdoc cref="Executable.ResourceDirectoryTable"/>
public ResourceDirectoryTable? ResourceDirectoryTable => Model.ResourceDirectoryTable;
/// <summary>
/// Sanitized section names
@@ -385,8 +386,8 @@ namespace SabreTools.Serialization.Wrappers
}
}
/// <inheritdoc cref="Models.PortableExecutable.Executable.SectionTable"/>
public Models.PortableExecutable.SectionHeader[]? SectionTable => Model.SectionTable;
/// <inheritdoc cref="Executable.SectionTable"/>
public SectionHeader[]? SectionTable => Model.SectionTable;
/// <summary>
/// Data after the section table, if it exists
@@ -429,7 +430,7 @@ namespace SabreTools.Serialization.Wrappers
}
}
/// <inheritdoc cref="Models.PortableExecutable.Executable.Stub"/>
/// <inheritdoc cref="Executable.Stub"/>
public Models.MSDOS.Executable? Stub => Model.Stub;
/// <summary>
@@ -837,18 +838,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public PortableExecutable(Models.PortableExecutable.Executable? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public PortableExecutable(Executable model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public PortableExecutable(Models.PortableExecutable.Executable? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public PortableExecutable(Executable model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PortableExecutable(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public PortableExecutable(Executable model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public PortableExecutable(Executable model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public PortableExecutable(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a PE executable from a byte array and offset
@@ -891,8 +900,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new PortableExecutable(model, data);
return new PortableExecutable(model, data, currentOffset);
}
catch
{
@@ -984,14 +992,14 @@ namespace SabreTools.Serialization.Wrappers
if (data == null)
continue;
if (data is Models.PortableExecutable.NB10ProgramDatabase n)
if (data is NB10ProgramDatabase n)
{
if (n.PdbFileName == null || !n.PdbFileName.Contains(path))
continue;
debugFound.Add(n);
}
else if (data is Models.PortableExecutable.RSDSProgramDatabase r)
else if (data is RSDSProgramDatabase r)
{
if (r.PathAndFileName == null || !r.PathAndFileName.Contains(path))
continue;
@@ -1094,7 +1102,7 @@ namespace SabreTools.Serialization.Wrappers
}
// If we have CodeView debug data, try to parse it
if (entry.DebugType == Models.PortableExecutable.DebugType.IMAGE_DEBUG_TYPE_CODEVIEW)
if (entry.DebugType == DebugType.IMAGE_DEBUG_TYPE_CODEVIEW)
{
// Read the signature
int offset = 0;
@@ -1442,7 +1450,7 @@ namespace SabreTools.Serialization.Wrappers
/// Find the location of a Wise section, if it exists
/// </summary>
/// <returns>Wise section on success, null otherwise</returns>
public Models.PortableExecutable.SectionHeader? FindWiseSection()
public SectionHeader? FindWiseSection()
{
// If the section table is invalid
if (SectionTable == null)
@@ -1469,7 +1477,7 @@ namespace SabreTools.Serialization.Wrappers
/// <summary>
/// Parse the resource directory table information
/// </summary>
private void ParseResourceDirectoryTable(Models.PortableExecutable.ResourceDirectoryTable table, List<object> types)
private void ParseResourceDirectoryTable(ResourceDirectoryTable table, List<object> types)
{
if (table?.Entries == null)
return;
@@ -1491,7 +1499,7 @@ namespace SabreTools.Serialization.Wrappers
/// <summary>
/// Parse the name resource directory entry information
/// </summary>
private void ParseResourceDirectoryEntry(Models.PortableExecutable.ResourceDirectoryEntry entry, List<object> types)
private void ParseResourceDirectoryEntry(ResourceDirectoryEntry entry, List<object> types)
{
if (entry.DataEntry != null)
ParseResourceDataEntry(entry.DataEntry, types);
@@ -1507,7 +1515,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(Models.PortableExecutable.ResourceDataEntry entry, List<object> types)
private void ParseResourceDataEntry(ResourceDataEntry entry, List<object> types)
{
// Create the key and value objects
string key = types == null
@@ -1521,70 +1529,70 @@ namespace SabreTools.Serialization.Wrappers
{
try
{
switch ((Models.PortableExecutable.ResourceType)resourceType)
switch ((ResourceType)resourceType)
{
case Models.PortableExecutable.ResourceType.RT_CURSOR:
case ResourceType.RT_CURSOR:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_BITMAP:
case ResourceType.RT_BITMAP:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_ICON:
case ResourceType.RT_ICON:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_MENU:
case ResourceType.RT_MENU:
value = entry.AsMenu();
break;
case Models.PortableExecutable.ResourceType.RT_DIALOG:
case ResourceType.RT_DIALOG:
value = entry.AsDialogBox();
break;
case Models.PortableExecutable.ResourceType.RT_STRING:
case ResourceType.RT_STRING:
value = entry.AsStringTable();
break;
case Models.PortableExecutable.ResourceType.RT_FONTDIR:
case ResourceType.RT_FONTDIR:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_FONT:
case ResourceType.RT_FONT:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_ACCELERATOR:
case ResourceType.RT_ACCELERATOR:
value = entry.AsAcceleratorTableResource();
break;
case Models.PortableExecutable.ResourceType.RT_RCDATA:
case ResourceType.RT_RCDATA:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_MESSAGETABLE:
case ResourceType.RT_MESSAGETABLE:
value = entry.AsMessageResourceData();
break;
case Models.PortableExecutable.ResourceType.RT_GROUP_CURSOR:
case ResourceType.RT_GROUP_CURSOR:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_GROUP_ICON:
case ResourceType.RT_GROUP_ICON:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_VERSION:
case ResourceType.RT_VERSION:
_versionInfo = entry.AsVersionInfo();
value = _versionInfo;
break;
case Models.PortableExecutable.ResourceType.RT_DLGINCLUDE:
case ResourceType.RT_DLGINCLUDE:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_PLUGPLAY:
case ResourceType.RT_PLUGPLAY:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_VXD:
case ResourceType.RT_VXD:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_ANICURSOR:
case ResourceType.RT_ANICURSOR:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_ANIICON:
case ResourceType.RT_ANIICON:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_HTML:
case ResourceType.RT_HTML:
value = entry.Data;
break;
case Models.PortableExecutable.ResourceType.RT_MANIFEST:
case ResourceType.RT_MANIFEST:
_assemblyManifest = entry.AsAssemblyManifest();
value = _assemblyManifest;
break;
@@ -1667,7 +1675,7 @@ namespace SabreTools.Serialization.Wrappers
/// <param name="name">Name of the section to check for</param>
/// <param name="exact">True to enable exact matching of names, false for starts-with</param>
/// <returns>Section data on success, null on error</returns>
public Models.PortableExecutable.SectionHeader? GetFirstSection(string? name, bool exact = false)
public SectionHeader? GetFirstSection(string? name, bool exact = false)
{
// If we have no sections
if (SectionNames.Length == 0 || SectionTable == null || SectionTable.Length == 0)
@@ -1692,7 +1700,7 @@ namespace SabreTools.Serialization.Wrappers
/// <param name="name">Name of the section to check for</param>
/// <param name="exact">True to enable exact matching of names, false for starts-with</param>
/// <returns>Section data on success, null on error</returns>
public Models.PortableExecutable.SectionHeader? GetLastSection(string? name, bool exact = false)
public SectionHeader? GetLastSection(string? name, bool exact = false)
{
// If we have no sections
if (SectionNames.Length == 0 || SectionTable == null || SectionTable.Length == 0)
@@ -1716,7 +1724,7 @@ namespace SabreTools.Serialization.Wrappers
/// </summary>
/// <param name="index">Index of the section to check for</param>
/// <returns>Section data on success, null on error</returns>
public Models.PortableExecutable.SectionHeader? GetSection(int index)
public SectionHeader? GetSection(int index)
{
// If we have no sections
if (SectionTable == null || SectionTable.Length == 0)
@@ -1906,7 +1914,7 @@ namespace SabreTools.Serialization.Wrappers
/// </summary>
/// <param name="index">Index of the table to check for</param>
/// <returns>Table on success, null on error</returns>
public Models.PortableExecutable.DataDirectory? GetTable(int index)
public DataDirectory? GetTable(int index)
{
// If the table doesn't exist
if (OptionalHeader == null || index < 0 || index > 16)

View File

@@ -31,18 +31,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public Quantum(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public Quantum(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public Quantum(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public Quantum(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public Quantum(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public Quantum(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public Quantum(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public Quantum(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a Quantum archive from a byte array and offset
@@ -85,8 +93,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new Quantum(model, data);
return new Quantum(model, data, currentOffset);
}
catch
{

View File

@@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public RAR(byte[]? data, int offset)
: base(data, offset)
{
// All logic is handled by the base class
}
public RAR(byte[] data) : base(data) { }
/// <inheritdoc/>
public RAR(Stream? data)
: base(data)
{
// All logic is handled by the base class
}
public RAR(byte[] data, int offset) : base(data, offset) { }
/// <inheritdoc/>
public RAR(byte[] data, int offset, int length) : base(data, offset, length) { }
/// <inheritdoc/>
public RAR(Stream data) : base(data) { }
/// <inheritdoc/>
public RAR(Stream data, long offset) : base(data, offset) { }
/// <inheritdoc/>
public RAR(Stream data, long offset, long length) : base(data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a RAR archive (or derived format) from a byte array and offset

View File

@@ -59,18 +59,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public SGA(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public SGA(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public SGA(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public SGA(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public SGA(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public SGA(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public SGA(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public SGA(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create an SGA from a byte array and offset
@@ -113,8 +121,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new SGA(model, data);
return new SGA(model, data, currentOffset);
}
catch
{

View File

@@ -15,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public SecuROMDFA(DFAFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public SecuROMDFA(DFAFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public SecuROMDFA(DFAFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public SecuROMDFA(DFAFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public SecuROMDFA(DFAFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public SecuROMDFA(DFAFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public SecuROMDFA(DFAFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public SecuROMDFA(DFAFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a SecuROM DFA file from a byte array and offset
@@ -69,8 +77,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new SecuROMDFA(model, data);
return new SecuROMDFA(model, data, currentOffset);
}
catch
{

View File

@@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public SevenZip(byte[]? data, int offset)
: base(data, offset)
{
// All logic is handled by the base class
}
public SevenZip(byte[] data) : base(data) { }
/// <inheritdoc/>
public SevenZip(Stream? data)
: base(data)
{
// All logic is handled by the base class
}
public SevenZip(byte[] data, int offset) : base(data, offset) { }
/// <inheritdoc/>
public SevenZip(byte[] data, int offset, int length) : base(data, offset, length) { }
/// <inheritdoc/>
public SevenZip(Stream data) : base(data) { }
/// <inheritdoc/>
public SevenZip(Stream data, long offset) : base(data, offset) { }
/// <inheritdoc/>
public SevenZip(Stream data, long offset, long length) : base(data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a SevenZip archive (or derived format) from a byte array and offset

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public TapeArchive(Archive? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public TapeArchive(Archive model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public TapeArchive(Archive? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public TapeArchive(Archive model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public TapeArchive(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public TapeArchive(Archive model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public TapeArchive(Archive model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public TapeArchive(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a tape archive (or derived format) from a byte array and offset
@@ -76,8 +84,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new TapeArchive(model, data);
return new TapeArchive(model, data, currentOffset);
}
catch
{

View File

@@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public VBSP(VbspFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public VBSP(VbspFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public VBSP(VbspFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public VBSP(VbspFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public VBSP(VbspFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public VBSP(VbspFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public VBSP(VbspFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public VBSP(VbspFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a VBSP from a byte array and offset
@@ -76,8 +84,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new VBSP(model, data);
return new VBSP(model, data, currentOffset);
}
catch
{

View File

@@ -87,18 +87,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public VPK(Models.VPK.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public VPK(Models.VPK.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public VPK(Models.VPK.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public VPK(Models.VPK.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public VPK(Models.VPK.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public VPK(Models.VPK.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public VPK(Models.VPK.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public VPK(Models.VPK.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a VPK from a byte array and offset
@@ -141,8 +149,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new VPK(model, data);
return new VPK(model, data, currentOffset);
}
catch
{

View File

@@ -21,18 +21,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public WAD3(Models.WAD3.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public WAD3(Models.WAD3.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public WAD3(Models.WAD3.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public WAD3(Models.WAD3.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WAD3(Models.WAD3.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public WAD3(Models.WAD3.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public WAD3(Models.WAD3.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WAD3(Models.WAD3.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a WAD3 from a byte array and offset
@@ -75,8 +83,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new WAD3(model, data);
return new WAD3(model, data, currentOffset);
}
catch
{

View File

@@ -152,18 +152,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public WiseOverlayHeader(OverlayHeader? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public WiseOverlayHeader(OverlayHeader model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public WiseOverlayHeader(OverlayHeader? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public WiseOverlayHeader(OverlayHeader model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WiseOverlayHeader(OverlayHeader model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public WiseOverlayHeader(OverlayHeader model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public WiseOverlayHeader(OverlayHeader model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WiseOverlayHeader(OverlayHeader model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a Wise installer overlay header from a byte array and offset
@@ -206,8 +214,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new WiseOverlayHeader(model, data);
return new WiseOverlayHeader(model, data, currentOffset);
}
catch
{

View File

@@ -62,18 +62,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public WiseScript(ScriptFile? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public WiseScript(ScriptFile model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public WiseScript(ScriptFile? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public WiseScript(ScriptFile model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WiseScript(ScriptFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public WiseScript(ScriptFile model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public WiseScript(ScriptFile model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WiseScript(ScriptFile model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a Wise installer script file from a byte array and offset
@@ -116,8 +124,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new WiseScript(model, data);
return new WiseScript(model, data, currentOffset);
}
catch
{

View File

@@ -96,18 +96,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public WiseSectionHeader(SectionHeader? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public WiseSectionHeader(SectionHeader model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public WiseSectionHeader(SectionHeader? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public WiseSectionHeader(SectionHeader model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WiseSectionHeader(SectionHeader model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public WiseSectionHeader(SectionHeader model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public WiseSectionHeader(SectionHeader model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public WiseSectionHeader(SectionHeader model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a Wise Self-Extracting installer .WISE section from a byte array and offset
@@ -153,8 +161,7 @@ namespace SabreTools.Serialization.Wrappers
// HACK: Cache the end-of-header offset
long endOffset = data.Position - currentOffset;
data.Seek(currentOffset, SeekOrigin.Begin);
return new WiseSectionHeader(model, data) { CompressedDataOffset = endOffset };
return new WiseSectionHeader(model, data, currentOffset) { CompressedDataOffset = endOffset };
}
catch
{

View File

@@ -65,32 +65,71 @@ namespace SabreTools.Serialization.Wrappers
#endregion
#region Constructors
#region Byte Array Constructors
/// <summary>
/// Construct a new instance of the wrapper from a byte array
/// </summary>
protected WrapperBase(byte[]? data, int offset)
protected WrapperBase(byte[] data)
: this(data, 0, data.Length)
{
}
/// <summary>
/// Construct a new instance of the wrapper from a byte array
/// </summary>
protected WrapperBase(byte[] data, int offset)
: this(data, offset, data.Length - offset)
{
}
/// <summary>
/// Construct a new instance of the wrapper from a byte array
/// </summary>
protected WrapperBase(byte[] data, int offset, int length)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
if (offset < 0 || offset >= data.Length)
throw new ArgumentOutOfRangeException(nameof(offset));
if (length < 0 || offset + length >= data.Length)
throw new ArgumentOutOfRangeException(nameof(length));
_dataSource = new ViewStream(data, offset, data.Length - offset);
_dataSource = new ViewStream(data, offset, length);
}
#endregion
#region Stream Constructors
/// <summary>
/// Construct a new instance of the wrapper from a Stream
/// </summary>
/// <remarks>Uses the current stream position as the offset</remarks>
protected WrapperBase(Stream data)
: this(data, data.Position, data.Length - data.Position)
{
}
/// <summary>
/// Construct a new instance of the wrapper from a Stream
/// </summary>
protected WrapperBase(Stream? data)
protected WrapperBase(Stream data, long offset)
: this(data, offset, data.Length - offset)
{
}
/// <summary>
/// Construct a new instance of the wrapper from a Stream
/// </summary>
protected WrapperBase(Stream data, long offset, long length)
{
if (data == null)
throw new ArgumentNullException(nameof(data));
if (!data.CanSeek || !data.CanRead)
throw new ArgumentOutOfRangeException(nameof(data));
if (offset < 0 || offset >= data.Length)
throw new ArgumentOutOfRangeException(nameof(offset));
if (length < 0 || offset + length >= data.Length)
throw new ArgumentOutOfRangeException(nameof(length));
_dataSource = new ViewStream(data, data.Position, data.Length - data.Position);
_dataSource = new ViewStream(data, offset, length);
}
#endregion

View File

@@ -1,4 +1,3 @@
using System;
using System.IO;
using SabreTools.Serialization.Interfaces;
@@ -18,37 +17,60 @@ namespace SabreTools.Serialization.Wrappers
#endregion
#region Constructors
#region Byte Array Constructors
/// <summary>
/// Construct a new instance of the wrapper from a byte array
/// </summary>
protected WrapperBase(T? model, byte[]? data, int offset)
: base(data, offset)
protected WrapperBase(T model, byte[] data)
: this(model, data, 0, data.Length)
{
if (model == null)
throw new ArgumentNullException(nameof(model));
if (data == null)
throw new ArgumentNullException(nameof(data));
if (offset < 0 || offset >= data.Length)
throw new ArgumentOutOfRangeException(nameof(offset));
}
/// <summary>
/// Construct a new instance of the wrapper from a byte array
/// </summary>
protected WrapperBase(T model, byte[] data, int offset)
: this(model, data, offset, data.Length - offset)
{
}
/// <summary>
/// Construct a new instance of the wrapper from a byte array
/// </summary>
protected WrapperBase(T model, byte[] data, int offset, int length)
: base(data, offset, length)
{
Model = model;
}
#endregion
#region Stream Constructors
/// <summary>
/// Construct a new instance of the wrapper from a Stream
/// </summary>
/// <remarks>Uses the current stream position as the offset</remarks>
protected WrapperBase(T model, Stream data)
: this(model, data, data.Position, data.Length - data.Position)
{
}
/// <summary>
/// Construct a new instance of the wrapper from a Stream
/// </summary>
protected WrapperBase(T? model, Stream? data)
: base(data)
protected WrapperBase(T model, Stream data, long offset)
: this(model, data, offset, data.Length - offset)
{
if (model == null)
throw new ArgumentNullException(nameof(model));
if (data == null)
throw new ArgumentNullException(nameof(data));
if (!data.CanSeek || !data.CanRead)
throw new ArgumentOutOfRangeException(nameof(data));
}
/// <summary>
/// Construct a new instance of the wrapper from a Stream
/// </summary>
protected WrapperBase(T model, Stream data, long offset, long length)
: base(data, offset, length)
{
Model = model;
}

View File

@@ -63,18 +63,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public XMID(Models.Xbox.XMID? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public XMID(Models.Xbox.XMID model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public XMID(Models.Xbox.XMID? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public XMID(Models.Xbox.XMID model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public XMID(Models.Xbox.XMID model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public XMID(Models.Xbox.XMID model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public XMID(Models.Xbox.XMID model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public XMID(Models.Xbox.XMID model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a XMID from a string

View File

@@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public XZ(byte[]? data, int offset)
: base(data, offset)
{
// All logic is handled by the base class
}
public XZ(byte[] data) : base(data) { }
/// <inheritdoc/>
public XZ(Stream? data)
: base(data)
{
// All logic is handled by the base class
}
public XZ(byte[] data, int offset) : base(data, offset) { }
/// <inheritdoc/>
public XZ(byte[] data, int offset, int length) : base(data, offset, length) { }
/// <inheritdoc/>
public XZ(Stream data) : base(data) { }
/// <inheritdoc/>
public XZ(Stream data, long offset) : base(data, offset) { }
/// <inheritdoc/>
public XZ(Stream data, long offset, long length) : base(data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a XZ archive from a byte array and offset

View File

@@ -24,18 +24,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public XZP(Models.XZP.File? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public XZP(Models.XZP.File model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public XZP(Models.XZP.File? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public XZP(Models.XZP.File model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public XZP(Models.XZP.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public XZP(Models.XZP.File model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public XZP(Models.XZP.File model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public XZP(Models.XZP.File model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a XZP from a byte array and offset
@@ -78,8 +86,7 @@ namespace SabreTools.Serialization.Wrappers
if (model == null)
return null;
data.Seek(currentOffset, SeekOrigin.Begin);
return new XZP(model, data);
return new XZP(model, data, currentOffset);
}
catch
{

View File

@@ -78,18 +78,26 @@ namespace SabreTools.Serialization.Wrappers
#region Constructors
/// <inheritdoc/>
public XeMID(Models.Xbox.XeMID? model, byte[]? data, int offset)
: base(model, data, offset)
{
// All logic is handled by the base class
}
public XeMID(Models.Xbox.XeMID model, byte[] data) : base(model, data) { }
/// <inheritdoc/>
public XeMID(Models.Xbox.XeMID? model, Stream? data)
: base(model, data)
{
// All logic is handled by the base class
}
public XeMID(Models.Xbox.XeMID model, byte[] data, int offset) : base(model, data, offset) { }
/// <inheritdoc/>
public XeMID(Models.Xbox.XeMID model, byte[] data, int offset, int length) : base(model, data, offset, length) { }
/// <inheritdoc/>
public XeMID(Models.Xbox.XeMID model, Stream data) : base(model, data) { }
/// <inheritdoc/>
public XeMID(Models.Xbox.XeMID model, Stream data, long offset) : base(model, data, offset) { }
/// <inheritdoc/>
public XeMID(Models.Xbox.XeMID model, Stream data, long offset, long length) : base(model, data, offset, length) { }
#endregion
#region Static Constructors
/// <summary>
/// Create a XeMID from a string