diff --git a/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs b/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs index ea19b795..0a50a875 100644 --- a/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs +++ b/SabreTools.Serialization/Wrappers/AACSMediaKeyBlock.cs @@ -24,18 +24,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public AACSMediaKeyBlock(MediaKeyBlock model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public AACSMediaKeyBlock(MediaKeyBlock model, Stream data) : base(model, data) { } + + /// + public AACSMediaKeyBlock(MediaKeyBlock model, Stream data, long offset) : base(model, data, offset) { } + + /// + public AACSMediaKeyBlock(MediaKeyBlock model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/BDPlusSVM.cs b/SabreTools.Serialization/Wrappers/BDPlusSVM.cs index 3f963f00..8e48aabe 100644 --- a/SabreTools.Serialization/Wrappers/BDPlusSVM.cs +++ b/SabreTools.Serialization/Wrappers/BDPlusSVM.cs @@ -24,18 +24,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public BDPlusSVM(SVM model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public BDPlusSVM(SVM model, Stream data) : base(model, data) { } + + /// + public BDPlusSVM(SVM model, Stream data, long offset) : base(model, data, offset) { } + + /// + public BDPlusSVM(SVM model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/BFPK.cs b/SabreTools.Serialization/Wrappers/BFPK.cs index b3a2b771..1693de61 100644 --- a/SabreTools.Serialization/Wrappers/BFPK.cs +++ b/SabreTools.Serialization/Wrappers/BFPK.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public BFPK(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public BFPK(Archive model, Stream data) : base(model, data) { } + + /// + public BFPK(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public BFPK(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/BSP.cs b/SabreTools.Serialization/Wrappers/BSP.cs index fc9d9c34..07abc2ad 100644 --- a/SabreTools.Serialization/Wrappers/BSP.cs +++ b/SabreTools.Serialization/Wrappers/BSP.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public BSP(BspFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public BSP(BspFile model, Stream data) : base(model, data) { } + + /// + public BSP(BspFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public BSP(BspFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/BZip2.cs b/SabreTools.Serialization/Wrappers/BZip2.cs index e98b8a40..c5a514ff 100644 --- a/SabreTools.Serialization/Wrappers/BZip2.cs +++ b/SabreTools.Serialization/Wrappers/BZip2.cs @@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - public BZip2(byte[]? data, int offset) - : base(data, offset) - { - // All logic is handled by the base class - } + public BZip2(byte[] data) : base(data) { } /// - public BZip2(Stream? data) - : base(data) - { - // All logic is handled by the base class - } + public BZip2(byte[] data, int offset) : base(data, offset) { } + + /// + public BZip2(byte[] data, int offset, int length) : base(data, offset, length) { } + + /// + public BZip2(Stream data) : base(data) { } + + /// + public BZip2(Stream data, long offset) : base(data, offset) { } + + /// + public BZip2(Stream data, long offset, long length) : base(data, offset, length) { } + + #endregion + + #region Static Constructors /// /// Create a BZip2 archive from a byte array and offset diff --git a/SabreTools.Serialization/Wrappers/CFB.cs b/SabreTools.Serialization/Wrappers/CFB.cs index 94cda190..f20badca 100644 --- a/SabreTools.Serialization/Wrappers/CFB.cs +++ b/SabreTools.Serialization/Wrappers/CFB.cs @@ -69,18 +69,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public CFB(Binary model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public CFB(Binary model, Stream data) : base(model, data) { } + + /// + public CFB(Binary model, Stream data, long offset) : base(model, data, offset) { } + + /// + public CFB(Binary model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/CHD.cs b/SabreTools.Serialization/Wrappers/CHD.cs index cce48d87..197bca83 100644 --- a/SabreTools.Serialization/Wrappers/CHD.cs +++ b/SabreTools.Serialization/Wrappers/CHD.cs @@ -60,18 +60,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public CHD(Header model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public CHD(Header model, Stream data) : base(model, data) { } + + /// + public CHD(Header model, Stream data, long offset) : base(model, data, offset) { } + + /// + public CHD(Header model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/CIA.cs b/SabreTools.Serialization/Wrappers/CIA.cs index 835a215e..3b122a0b 100644 --- a/SabreTools.Serialization/Wrappers/CIA.cs +++ b/SabreTools.Serialization/Wrappers/CIA.cs @@ -15,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public CIA(Models.N3DS.CIA model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public CIA(Models.N3DS.CIA model, Stream data) : base(model, data) { } + + /// + public CIA(Models.N3DS.CIA model, Stream data, long offset) : base(model, data, offset) { } + + /// + public CIA(Models.N3DS.CIA model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/GCF.cs b/SabreTools.Serialization/Wrappers/GCF.cs index 62c00c3b..569df8a7 100644 --- a/SabreTools.Serialization/Wrappers/GCF.cs +++ b/SabreTools.Serialization/Wrappers/GCF.cs @@ -164,18 +164,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public GCF(Models.GCF.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public GCF(Models.GCF.File model, Stream data) : base(model, data) { } + + /// + public GCF(Models.GCF.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public GCF(Models.GCF.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/GZip.cs b/SabreTools.Serialization/Wrappers/GZip.cs index e2c53d6a..1144d092 100644 --- a/SabreTools.Serialization/Wrappers/GZip.cs +++ b/SabreTools.Serialization/Wrappers/GZip.cs @@ -71,18 +71,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public GZip(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public GZip(Archive model, Stream data) : base(model, data) { } + + /// + public GZip(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public GZip(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/IRD.cs b/SabreTools.Serialization/Wrappers/IRD.cs index 6504e5f7..64553818 100644 --- a/SabreTools.Serialization/Wrappers/IRD.cs +++ b/SabreTools.Serialization/Wrappers/IRD.cs @@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public IRD(Models.IRD.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public IRD(Models.IRD.File model, Stream data) : base(model, data) { } + + /// + public IRD(Models.IRD.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public IRD(Models.IRD.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs index 26440f2b..230282d3 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldArchiveV3.cs @@ -108,18 +108,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public InstallShieldArchiveV3(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public InstallShieldArchiveV3(Archive model, Stream data) : base(model, data) { } + + /// + public InstallShieldArchiveV3(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public InstallShieldArchiveV3(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs index 0cbaa1a9..c804f7b4 100644 --- a/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs +++ b/SabreTools.Serialization/Wrappers/InstallShieldCabinet.cs @@ -68,18 +68,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public InstallShieldCabinet(Cabinet model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public InstallShieldCabinet(Cabinet model, Stream data) : base(model, data) { } + + /// + public InstallShieldCabinet(Cabinet model, Stream data, long offset) : base(model, data, offset) { } + + /// + public InstallShieldCabinet(Cabinet model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/LZKWAJ.cs b/SabreTools.Serialization/Wrappers/LZKWAJ.cs index 04a5106f..b711ca9b 100644 --- a/SabreTools.Serialization/Wrappers/LZKWAJ.cs +++ b/SabreTools.Serialization/Wrappers/LZKWAJ.cs @@ -31,18 +31,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public LZKWAJ(KWAJFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public LZKWAJ(KWAJFile model, Stream data) : base(model, data) { } + + /// + public LZKWAJ(KWAJFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public LZKWAJ(KWAJFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/LZQBasic.cs b/SabreTools.Serialization/Wrappers/LZQBasic.cs index 1d5f4fc4..73d7d41a 100644 --- a/SabreTools.Serialization/Wrappers/LZQBasic.cs +++ b/SabreTools.Serialization/Wrappers/LZQBasic.cs @@ -15,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public LZQBasic(QBasicFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public LZQBasic(QBasicFile model, Stream data) : base(model, data) { } + + /// + public LZQBasic(QBasicFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public LZQBasic(QBasicFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/LZSZDD.cs b/SabreTools.Serialization/Wrappers/LZSZDD.cs index a645406a..9cff2305 100644 --- a/SabreTools.Serialization/Wrappers/LZSZDD.cs +++ b/SabreTools.Serialization/Wrappers/LZSZDD.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public LZSZDD(SZDDFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public LZSZDD(SZDDFile model, Stream data) : base(model, data) { } + + /// + public LZSZDD(SZDDFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public LZSZDD(SZDDFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/LinearExecutable.cs b/SabreTools.Serialization/Wrappers/LinearExecutable.cs index ff6ff533..6691033d 100644 --- a/SabreTools.Serialization/Wrappers/LinearExecutable.cs +++ b/SabreTools.Serialization/Wrappers/LinearExecutable.cs @@ -33,18 +33,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public LinearExecutable(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public LinearExecutable(Executable model, Stream data) : base(model, data) { } + + /// + public LinearExecutable(Executable model, Stream data, long offset) : base(model, data, offset) { } + + /// + public LinearExecutable(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/MSDOS.cs b/SabreTools.Serialization/Wrappers/MSDOS.cs index 870ad769..2a4d969e 100644 --- a/SabreTools.Serialization/Wrappers/MSDOS.cs +++ b/SabreTools.Serialization/Wrappers/MSDOS.cs @@ -1,8 +1,9 @@ using System.IO; +using SabreTools.Models.MSDOS; namespace SabreTools.Serialization.Wrappers { - public class MSDOS : WrapperBase + public class MSDOS : WrapperBase { #region Descriptive Properties @@ -14,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public MSDOS(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public MSDOS(Executable model, Stream data) : base(model, data) { } + + /// + public MSDOS(Executable model, Stream data, long offset) : base(model, data, offset) { } + + /// + public MSDOS(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs index 4b01b77f..6955e663 100644 --- a/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs +++ b/SabreTools.Serialization/Wrappers/MicrosoftCabinet.cs @@ -42,18 +42,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public MicrosoftCabinet(Cabinet model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public MicrosoftCabinet(Cabinet model, Stream data) : base(model, data) { } + + /// + public MicrosoftCabinet(Cabinet model, Stream data, long offset) : base(model, data, offset) { } + + /// + public MicrosoftCabinet(Cabinet model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/MoPaQ.cs b/SabreTools.Serialization/Wrappers/MoPaQ.cs index ada9b35a..942ac796 100644 --- a/SabreTools.Serialization/Wrappers/MoPaQ.cs +++ b/SabreTools.Serialization/Wrappers/MoPaQ.cs @@ -16,7 +16,7 @@ namespace SabreTools.Serialization.Wrappers /// /// This should only be used for until MPQ parsing is fixed - 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 /// /// This should only be used for until MPQ parsing is fixed - public MoPaQ(Stream? data) + public MoPaQ(Stream data) : base(new Archive(), data) { // All logic is handled by the base class } /// - 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) { } /// - 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) { } + + /// + public MoPaQ(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public MoPaQ(Archive model, Stream data) : base(model, data) { } + + /// + public MoPaQ(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public MoPaQ(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/N3DS.cs b/SabreTools.Serialization/Wrappers/N3DS.cs index be845be6..ace7874d 100644 --- a/SabreTools.Serialization/Wrappers/N3DS.cs +++ b/SabreTools.Serialization/Wrappers/N3DS.cs @@ -209,18 +209,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public N3DS(Cart model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public N3DS(Cart model, Stream data) : base(model, data) { } + + /// + public N3DS(Cart model, Stream data, long offset) : base(model, data, offset) { } + + /// + public N3DS(Cart model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/NCF.cs b/SabreTools.Serialization/Wrappers/NCF.cs index 42fa6d97..9aec0386 100644 --- a/SabreTools.Serialization/Wrappers/NCF.cs +++ b/SabreTools.Serialization/Wrappers/NCF.cs @@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public NCF(Models.NCF.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public NCF(Models.NCF.File model, Stream data) : base(model, data) { } + + /// + public NCF(Models.NCF.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public NCF(Models.NCF.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/NewExecutable.cs b/SabreTools.Serialization/Wrappers/NewExecutable.cs index 8133b004..27922237 100644 --- a/SabreTools.Serialization/Wrappers/NewExecutable.cs +++ b/SabreTools.Serialization/Wrappers/NewExecutable.cs @@ -287,18 +287,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public NewExecutable(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public NewExecutable(Executable model, Stream data) : base(model, data) { } + + /// + public NewExecutable(Executable model, Stream data, long offset) : base(model, data, offset) { } + + /// + public NewExecutable(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/Nitro.cs b/SabreTools.Serialization/Wrappers/Nitro.cs index aefdb830..d36e7d9c 100644 --- a/SabreTools.Serialization/Wrappers/Nitro.cs +++ b/SabreTools.Serialization/Wrappers/Nitro.cs @@ -28,18 +28,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public Nitro(Cart model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public Nitro(Cart model, Stream data) : base(model, data) { } + + /// + public Nitro(Cart model, Stream data, long offset) : base(model, data, offset) { } + + /// + public Nitro(Cart model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PAK.cs b/SabreTools.Serialization/Wrappers/PAK.cs index ef034b63..bba1d8b3 100644 --- a/SabreTools.Serialization/Wrappers/PAK.cs +++ b/SabreTools.Serialization/Wrappers/PAK.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public PAK(Models.PAK.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public PAK(Models.PAK.File model, Stream data) : base(model, data) { } + + /// + public PAK(Models.PAK.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PAK(Models.PAK.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PFF.cs b/SabreTools.Serialization/Wrappers/PFF.cs index 052b52ff..40884831 100644 --- a/SabreTools.Serialization/Wrappers/PFF.cs +++ b/SabreTools.Serialization/Wrappers/PFF.cs @@ -27,18 +27,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public PFF(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public PFF(Archive model, Stream data) : base(model, data) { } + + /// + public PFF(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PFF(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PIC.cs b/SabreTools.Serialization/Wrappers/PIC.cs index 942e9f16..0136c2e9 100644 --- a/SabreTools.Serialization/Wrappers/PIC.cs +++ b/SabreTools.Serialization/Wrappers/PIC.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public PIC(DiscInformation model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public PIC(DiscInformation model, Stream data) : base(model, data) { } + + /// + public PIC(DiscInformation model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PIC(DiscInformation model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PKZIP.cs b/SabreTools.Serialization/Wrappers/PKZIP.cs index cc045d5c..8d537046 100644 --- a/SabreTools.Serialization/Wrappers/PKZIP.cs +++ b/SabreTools.Serialization/Wrappers/PKZIP.cs @@ -34,34 +34,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - /// This should only be used for WinZipSFX - 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) { } /// - /// This should only be used for WinZipSFX - 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) { } /// - 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) { } /// - 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) { } + + /// + public PKZIP(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PKZIP(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PlayJAudioFile.cs b/SabreTools.Serialization/Wrappers/PlayJAudioFile.cs index 164cfedd..eac2d84d 100644 --- a/SabreTools.Serialization/Wrappers/PlayJAudioFile.cs +++ b/SabreTools.Serialization/Wrappers/PlayJAudioFile.cs @@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public PlayJAudioFile(Models.PlayJ.AudioFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data) : base(model, data) { } + + /// + public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PlayJAudioFile(Models.PlayJ.AudioFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PlayJPlaylist.cs b/SabreTools.Serialization/Wrappers/PlayJPlaylist.cs index e502e983..ca7bf4b4 100644 --- a/SabreTools.Serialization/Wrappers/PlayJPlaylist.cs +++ b/SabreTools.Serialization/Wrappers/PlayJPlaylist.cs @@ -14,18 +14,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public PlayJPlaylist(Models.PlayJ.Playlist model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public PlayJPlaylist(Models.PlayJ.Playlist model, Stream data) : base(model, data) { } + + /// + public PlayJPlaylist(Models.PlayJ.Playlist model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PlayJPlaylist(Models.PlayJ.Playlist model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index 7358d19e..5f274991 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -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 + public partial class PortableExecutable : WrapperBase { #region Descriptive Properties @@ -19,8 +20,8 @@ namespace SabreTools.Serialization.Wrappers #region Extension Properties - /// - public Models.PortableExecutable.COFFFileHeader? COFFFileHeader => Model.COFFFileHeader; + /// + public COFFFileHeader? COFFFileHeader => Model.COFFFileHeader; /// /// Dictionary of debug data @@ -46,8 +47,8 @@ namespace SabreTools.Serialization.Wrappers } } - /// - public Models.PortableExecutable.DebugDirectoryEntry[]? DebugDirectoryTable + /// + public DebugDirectoryEntry[]? DebugDirectoryTable => Model.DebugTable?.DebugDirectoryTable; /// @@ -100,8 +101,8 @@ namespace SabreTools.Serialization.Wrappers } } - /// - public Models.PortableExecutable.ExportTable? ExportTable => Model.ExportTable; + /// + public ExportTable? ExportTable => Model.ExportTable; /// /// Header padding data, if it exists @@ -181,11 +182,11 @@ namespace SabreTools.Serialization.Wrappers } } - /// - public Models.PortableExecutable.ImportTable? ImportTable => Model.ImportTable; + /// + public ImportTable? ImportTable => Model.ImportTable; - /// - public Models.PortableExecutable.OptionalHeader? OptionalHeader => Model.OptionalHeader; + /// + public OptionalHeader? OptionalHeader => Model.OptionalHeader; /// /// Address of the overlay, if it exists @@ -340,8 +341,8 @@ namespace SabreTools.Serialization.Wrappers } } - /// - public Models.PortableExecutable.ResourceDirectoryTable? ResourceDirectoryTable => Model.ResourceDirectoryTable; + /// + public ResourceDirectoryTable? ResourceDirectoryTable => Model.ResourceDirectoryTable; /// /// Sanitized section names @@ -385,8 +386,8 @@ namespace SabreTools.Serialization.Wrappers } } - /// - public Models.PortableExecutable.SectionHeader[]? SectionTable => Model.SectionTable; + /// + public SectionHeader[]? SectionTable => Model.SectionTable; /// /// Data after the section table, if it exists @@ -429,7 +430,7 @@ namespace SabreTools.Serialization.Wrappers } } - /// + /// public Models.MSDOS.Executable? Stub => Model.Stub; /// @@ -837,18 +838,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public PortableExecutable(Executable model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public PortableExecutable(Executable model, Stream data) : base(model, data) { } + + /// + public PortableExecutable(Executable model, Stream data, long offset) : base(model, data, offset) { } + + /// + public PortableExecutable(Executable model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 /// /// Wise section on success, null otherwise - 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 /// /// Parse the resource directory table information /// - private void ParseResourceDirectoryTable(Models.PortableExecutable.ResourceDirectoryTable table, List types) + private void ParseResourceDirectoryTable(ResourceDirectoryTable table, List types) { if (table?.Entries == null) return; @@ -1491,7 +1499,7 @@ namespace SabreTools.Serialization.Wrappers /// /// Parse the name resource directory entry information /// - private void ParseResourceDirectoryEntry(Models.PortableExecutable.ResourceDirectoryEntry entry, List types) + private void ParseResourceDirectoryEntry(ResourceDirectoryEntry entry, List 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. /// - private void ParseResourceDataEntry(Models.PortableExecutable.ResourceDataEntry entry, List types) + private void ParseResourceDataEntry(ResourceDataEntry entry, List 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 /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section data on success, null on error - 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 /// Name of the section to check for /// True to enable exact matching of names, false for starts-with /// Section data on success, null on error - 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 /// /// Index of the section to check for /// Section data on success, null on error - 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 /// /// Index of the table to check for /// Table on success, null on error - 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) diff --git a/SabreTools.Serialization/Wrappers/Quantum.cs b/SabreTools.Serialization/Wrappers/Quantum.cs index e30b6fe8..9e1af4a2 100644 --- a/SabreTools.Serialization/Wrappers/Quantum.cs +++ b/SabreTools.Serialization/Wrappers/Quantum.cs @@ -31,18 +31,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public Quantum(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public Quantum(Archive model, Stream data) : base(model, data) { } + + /// + public Quantum(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public Quantum(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/RAR.cs b/SabreTools.Serialization/Wrappers/RAR.cs index 28450bbc..e27c3dcf 100644 --- a/SabreTools.Serialization/Wrappers/RAR.cs +++ b/SabreTools.Serialization/Wrappers/RAR.cs @@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - public RAR(byte[]? data, int offset) - : base(data, offset) - { - // All logic is handled by the base class - } + public RAR(byte[] data) : base(data) { } /// - public RAR(Stream? data) - : base(data) - { - // All logic is handled by the base class - } + public RAR(byte[] data, int offset) : base(data, offset) { } + + /// + public RAR(byte[] data, int offset, int length) : base(data, offset, length) { } + + /// + public RAR(Stream data) : base(data) { } + + /// + public RAR(Stream data, long offset) : base(data, offset) { } + + /// + public RAR(Stream data, long offset, long length) : base(data, offset, length) { } + + #endregion + + #region Static Constructors /// /// Create a RAR archive (or derived format) from a byte array and offset diff --git a/SabreTools.Serialization/Wrappers/SGA.cs b/SabreTools.Serialization/Wrappers/SGA.cs index 2f383edc..3fb03e25 100644 --- a/SabreTools.Serialization/Wrappers/SGA.cs +++ b/SabreTools.Serialization/Wrappers/SGA.cs @@ -59,18 +59,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public SGA(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public SGA(Archive model, Stream data) : base(model, data) { } + + /// + public SGA(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public SGA(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/SecuROMDFA.cs b/SabreTools.Serialization/Wrappers/SecuROMDFA.cs index cf8787ae..c334da99 100644 --- a/SabreTools.Serialization/Wrappers/SecuROMDFA.cs +++ b/SabreTools.Serialization/Wrappers/SecuROMDFA.cs @@ -15,18 +15,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public SecuROMDFA(DFAFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public SecuROMDFA(DFAFile model, Stream data) : base(model, data) { } + + /// + public SecuROMDFA(DFAFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public SecuROMDFA(DFAFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/SevenZip.cs b/SabreTools.Serialization/Wrappers/SevenZip.cs index b0f5b2cb..10eeb677 100644 --- a/SabreTools.Serialization/Wrappers/SevenZip.cs +++ b/SabreTools.Serialization/Wrappers/SevenZip.cs @@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - public SevenZip(byte[]? data, int offset) - : base(data, offset) - { - // All logic is handled by the base class - } + public SevenZip(byte[] data) : base(data) { } /// - public SevenZip(Stream? data) - : base(data) - { - // All logic is handled by the base class - } + public SevenZip(byte[] data, int offset) : base(data, offset) { } + + /// + public SevenZip(byte[] data, int offset, int length) : base(data, offset, length) { } + + /// + public SevenZip(Stream data) : base(data) { } + + /// + public SevenZip(Stream data, long offset) : base(data, offset) { } + + /// + public SevenZip(Stream data, long offset, long length) : base(data, offset, length) { } + + #endregion + + #region Static Constructors /// /// Create a SevenZip archive (or derived format) from a byte array and offset diff --git a/SabreTools.Serialization/Wrappers/TapeArchive.cs b/SabreTools.Serialization/Wrappers/TapeArchive.cs index 2ac83fb3..bff443b2 100644 --- a/SabreTools.Serialization/Wrappers/TapeArchive.cs +++ b/SabreTools.Serialization/Wrappers/TapeArchive.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public TapeArchive(Archive model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public TapeArchive(Archive model, Stream data) : base(model, data) { } + + /// + public TapeArchive(Archive model, Stream data, long offset) : base(model, data, offset) { } + + /// + public TapeArchive(Archive model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/VBSP.cs b/SabreTools.Serialization/Wrappers/VBSP.cs index 99340ef3..542e120b 100644 --- a/SabreTools.Serialization/Wrappers/VBSP.cs +++ b/SabreTools.Serialization/Wrappers/VBSP.cs @@ -22,18 +22,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public VBSP(VbspFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public VBSP(VbspFile model, Stream data) : base(model, data) { } + + /// + public VBSP(VbspFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public VBSP(VbspFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/VPK.cs b/SabreTools.Serialization/Wrappers/VPK.cs index e08e25f8..609727e8 100644 --- a/SabreTools.Serialization/Wrappers/VPK.cs +++ b/SabreTools.Serialization/Wrappers/VPK.cs @@ -87,18 +87,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public VPK(Models.VPK.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public VPK(Models.VPK.File model, Stream data) : base(model, data) { } + + /// + public VPK(Models.VPK.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public VPK(Models.VPK.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/WAD3.cs b/SabreTools.Serialization/Wrappers/WAD3.cs index 69db48e7..ab4f514f 100644 --- a/SabreTools.Serialization/Wrappers/WAD3.cs +++ b/SabreTools.Serialization/Wrappers/WAD3.cs @@ -21,18 +21,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public WAD3(Models.WAD3.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public WAD3(Models.WAD3.File model, Stream data) : base(model, data) { } + + /// + public WAD3(Models.WAD3.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public WAD3(Models.WAD3.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs index 27857b3b..0437de71 100644 --- a/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs +++ b/SabreTools.Serialization/Wrappers/WiseOverlayHeader.cs @@ -152,18 +152,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public WiseOverlayHeader(OverlayHeader model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public WiseOverlayHeader(OverlayHeader model, Stream data) : base(model, data) { } + + /// + public WiseOverlayHeader(OverlayHeader model, Stream data, long offset) : base(model, data, offset) { } + + /// + public WiseOverlayHeader(OverlayHeader model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/WiseScript.cs b/SabreTools.Serialization/Wrappers/WiseScript.cs index 458dcba5..bbbbc98e 100644 --- a/SabreTools.Serialization/Wrappers/WiseScript.cs +++ b/SabreTools.Serialization/Wrappers/WiseScript.cs @@ -62,18 +62,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public WiseScript(ScriptFile model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public WiseScript(ScriptFile model, Stream data) : base(model, data) { } + + /// + public WiseScript(ScriptFile model, Stream data, long offset) : base(model, data, offset) { } + + /// + public WiseScript(ScriptFile model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs b/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs index 8b48b298..a826b4c5 100644 --- a/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs +++ b/SabreTools.Serialization/Wrappers/WiseSectionHeader.cs @@ -96,18 +96,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public WiseSectionHeader(SectionHeader model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public WiseSectionHeader(SectionHeader model, Stream data) : base(model, data) { } + + /// + public WiseSectionHeader(SectionHeader model, Stream data, long offset) : base(model, data, offset) { } + + /// + public WiseSectionHeader(SectionHeader model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/WrapperBase.cs b/SabreTools.Serialization/Wrappers/WrapperBase.cs index 599a1236..047af8dd 100644 --- a/SabreTools.Serialization/Wrappers/WrapperBase.cs +++ b/SabreTools.Serialization/Wrappers/WrapperBase.cs @@ -65,32 +65,71 @@ namespace SabreTools.Serialization.Wrappers #endregion - #region Constructors + #region Byte Array Constructors /// /// Construct a new instance of the wrapper from a byte array /// - protected WrapperBase(byte[]? data, int offset) + protected WrapperBase(byte[] data) + : this(data, 0, data.Length) + { + } + + /// + /// Construct a new instance of the wrapper from a byte array + /// + protected WrapperBase(byte[] data, int offset) + : this(data, offset, data.Length - offset) + { + } + + /// + /// Construct a new instance of the wrapper from a byte array + /// + 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 + + /// + /// Construct a new instance of the wrapper from a Stream + /// + /// Uses the current stream position as the offset + protected WrapperBase(Stream data) + : this(data, data.Position, data.Length - data.Position) + { } /// /// Construct a new instance of the wrapper from a Stream /// - protected WrapperBase(Stream? data) + protected WrapperBase(Stream data, long offset) + : this(data, offset, data.Length - offset) + { + } + + /// + /// Construct a new instance of the wrapper from a Stream + /// + 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 diff --git a/SabreTools.Serialization/Wrappers/WrapperBaseT.cs b/SabreTools.Serialization/Wrappers/WrapperBaseT.cs index 8ba68457..3f4a58cc 100644 --- a/SabreTools.Serialization/Wrappers/WrapperBaseT.cs +++ b/SabreTools.Serialization/Wrappers/WrapperBaseT.cs @@ -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 /// /// Construct a new instance of the wrapper from a byte array /// - 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)); + } + /// + /// Construct a new instance of the wrapper from a byte array + /// + protected WrapperBase(T model, byte[] data, int offset) + : this(model, data, offset, data.Length - offset) + { + } + + /// + /// Construct a new instance of the wrapper from a byte array + /// + protected WrapperBase(T model, byte[] data, int offset, int length) + : base(data, offset, length) + { Model = model; } + #endregion + + #region Stream Constructors + + /// + /// Construct a new instance of the wrapper from a Stream + /// + /// Uses the current stream position as the offset + protected WrapperBase(T model, Stream data) + : this(model, data, data.Position, data.Length - data.Position) + { + } + /// /// Construct a new instance of the wrapper from a Stream /// - 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)); + } + /// + /// Construct a new instance of the wrapper from a Stream + /// + protected WrapperBase(T model, Stream data, long offset, long length) + : base(data, offset, length) + { Model = model; } diff --git a/SabreTools.Serialization/Wrappers/XMID.cs b/SabreTools.Serialization/Wrappers/XMID.cs index 8e4c9c3d..08bfcef0 100644 --- a/SabreTools.Serialization/Wrappers/XMID.cs +++ b/SabreTools.Serialization/Wrappers/XMID.cs @@ -63,18 +63,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public XMID(Models.Xbox.XMID model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public XMID(Models.Xbox.XMID model, Stream data) : base(model, data) { } + + /// + public XMID(Models.Xbox.XMID model, Stream data, long offset) : base(model, data, offset) { } + + /// + public XMID(Models.Xbox.XMID model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// Create a XMID from a string diff --git a/SabreTools.Serialization/Wrappers/XZ.cs b/SabreTools.Serialization/Wrappers/XZ.cs index f791f729..ab4f6dfa 100644 --- a/SabreTools.Serialization/Wrappers/XZ.cs +++ b/SabreTools.Serialization/Wrappers/XZ.cs @@ -19,18 +19,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - public XZ(byte[]? data, int offset) - : base(data, offset) - { - // All logic is handled by the base class - } + public XZ(byte[] data) : base(data) { } /// - public XZ(Stream? data) - : base(data) - { - // All logic is handled by the base class - } + public XZ(byte[] data, int offset) : base(data, offset) { } + + /// + public XZ(byte[] data, int offset, int length) : base(data, offset, length) { } + + /// + public XZ(Stream data) : base(data) { } + + /// + public XZ(Stream data, long offset) : base(data, offset) { } + + /// + public XZ(Stream data, long offset, long length) : base(data, offset, length) { } + + #endregion + + #region Static Constructors /// /// Create a XZ archive from a byte array and offset diff --git a/SabreTools.Serialization/Wrappers/XZP.cs b/SabreTools.Serialization/Wrappers/XZP.cs index 01f5454d..c70b161e 100644 --- a/SabreTools.Serialization/Wrappers/XZP.cs +++ b/SabreTools.Serialization/Wrappers/XZP.cs @@ -24,18 +24,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public XZP(Models.XZP.File model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public XZP(Models.XZP.File model, Stream data) : base(model, data) { } + + /// + public XZP(Models.XZP.File model, Stream data, long offset) : base(model, data, offset) { } + + /// + public XZP(Models.XZP.File model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// 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 { diff --git a/SabreTools.Serialization/Wrappers/XeMID.cs b/SabreTools.Serialization/Wrappers/XeMID.cs index a5c02087..af80fdfe 100644 --- a/SabreTools.Serialization/Wrappers/XeMID.cs +++ b/SabreTools.Serialization/Wrappers/XeMID.cs @@ -78,18 +78,26 @@ namespace SabreTools.Serialization.Wrappers #region Constructors /// - 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) { } /// - 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) { } + + /// + public XeMID(Models.Xbox.XeMID model, byte[] data, int offset, int length) : base(model, data, offset, length) { } + + /// + public XeMID(Models.Xbox.XeMID model, Stream data) : base(model, data) { } + + /// + public XeMID(Models.Xbox.XeMID model, Stream data, long offset) : base(model, data, offset) { } + + /// + public XeMID(Models.Xbox.XeMID model, Stream data, long offset, long length) : base(model, data, offset, length) { } + + #endregion + + #region Static Constructors /// /// Create a XeMID from a string