From be3841c91d50208f656448551c1f5b1aa3f2b464 Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Tue, 27 Feb 2024 22:57:27 +0100 Subject: [PATCH] Remodel from device profile interface to device profile data structure --- FirmwareGen/CommonLogic.cs | 22 +++++++++---------- FirmwareGen/DeviceProfile.cs | 19 ++++++++++++++++ .../DeviceProfiles/EpsilonHalfSplit128GB.cs | 22 +++++++++---------- .../DeviceProfiles/EpsilonHalfSplit256GB.cs | 22 +++++++++---------- .../EpsilonMaximizedForWindows.cs | 22 +++++++++---------- .../MTP8150MaximizedForWindows.cs | 22 +++++++++---------- .../DeviceProfiles/ZetaHalfSplit128GB.cs | 22 +++++++++---------- .../DeviceProfiles/ZetaHalfSplit256GB.cs | 22 +++++++++---------- .../DeviceProfiles/ZetaHalfSplit512GB.cs | 22 +++++++++---------- .../DeviceProfiles/ZetaMaximizedForWindows.cs | 22 +++++++++---------- FirmwareGen/IDeviceProfile.cs | 19 ---------------- FirmwareGen/MainLogic.cs | 12 +++++----- 12 files changed, 124 insertions(+), 124 deletions(-) create mode 100644 FirmwareGen/DeviceProfile.cs delete mode 100644 FirmwareGen/IDeviceProfile.cs diff --git a/FirmwareGen/CommonLogic.cs b/FirmwareGen/CommonLogic.cs index baeb46e..0fdfdfc 100644 --- a/FirmwareGen/CommonLogic.cs +++ b/FirmwareGen/CommonLogic.cs @@ -6,10 +6,10 @@ namespace FirmwareGen { internal class CommonLogic { - public static byte[] GetPrimaryGPT(IDeviceProfile deviceProfile) + public static byte[] GetPrimaryGPT(DeviceProfile deviceProfile) { - ulong DiskSize = deviceProfile.GetDiskTotalSize(); - uint SectorSize = deviceProfile.GetDiskSectorSize(); + ulong DiskSize = deviceProfile.DiskTotalSize; + uint SectorSize = deviceProfile.DiskSectorSize; byte[] PrimaryMBR = new byte[SectorSize]; PrimaryMBR[0x1C0] = 0x01; @@ -27,22 +27,22 @@ public static byte[] GetPrimaryGPT(IDeviceProfile deviceProfile) return [ .. PrimaryMBR, - .. GPTUtils.MakeGPT(DiskSize, SectorSize, deviceProfile.GetPartitionLayout(), deviceProfile.GetDiskGuid(), IsBackupGPT: false, SplitInHalf: deviceProfile.GetSplittingStrategy() == SplittingStrategy.HalfSplit, AndroidDesiredSpace: deviceProfile.GetSplittingStrategy() == SplittingStrategy.Custom ? deviceProfile.GetCustomSplittingAndroidDesiredSpace() : 4_294_967_296) + .. GPTUtils.MakeGPT(DiskSize, SectorSize, deviceProfile.PartitionLayout, deviceProfile.DiskGuid, IsBackupGPT: false, SplitInHalf: deviceProfile.SplittingStrategy == SplittingStrategy.HalfSplit, AndroidDesiredSpace: deviceProfile.SplittingStrategy == SplittingStrategy.Custom ? deviceProfile.CustomSplittingAndroidDesiredSpace : 4_294_967_296) ]; } - public static byte[] GetBackupGPT(IDeviceProfile deviceProfile) + public static byte[] GetBackupGPT(DeviceProfile deviceProfile) { - ulong DiskSize = deviceProfile.GetDiskTotalSize(); - uint SectorSize = deviceProfile.GetDiskSectorSize(); + ulong DiskSize = deviceProfile.DiskTotalSize; + uint SectorSize = deviceProfile.DiskSectorSize; - return GPTUtils.MakeGPT(DiskSize, SectorSize, deviceProfile.GetPartitionLayout(), deviceProfile.GetDiskGuid(), IsBackupGPT: true, SplitInHalf: deviceProfile.GetSplittingStrategy() == SplittingStrategy.HalfSplit, AndroidDesiredSpace: deviceProfile.GetSplittingStrategy() == SplittingStrategy.Custom ? deviceProfile.GetCustomSplittingAndroidDesiredSpace() : 4_294_967_296); + return GPTUtils.MakeGPT(DiskSize, SectorSize, deviceProfile.PartitionLayout, deviceProfile.DiskGuid, IsBackupGPT: true, SplitInHalf: deviceProfile.SplittingStrategy == SplittingStrategy.HalfSplit, AndroidDesiredSpace: deviceProfile.SplittingStrategy == SplittingStrategy.Custom ? deviceProfile.CustomSplittingAndroidDesiredSpace : 4_294_967_296); } - public static string GetBlankVHD(IDeviceProfile deviceProfile) + public static string GetBlankVHD(DeviceProfile deviceProfile) { - ulong DiskSize = deviceProfile.GetDiskTotalSize(); - uint SectorSize = deviceProfile.GetDiskSectorSize(); + ulong DiskSize = deviceProfile.DiskTotalSize; + uint SectorSize = deviceProfile.DiskSectorSize; const string tmp = "tmp"; const string TmpVHD = $@"{tmp}\temp.vhdx"; diff --git a/FirmwareGen/DeviceProfile.cs b/FirmwareGen/DeviceProfile.cs new file mode 100644 index 0000000..6813fd2 --- /dev/null +++ b/FirmwareGen/DeviceProfile.cs @@ -0,0 +1,19 @@ +using FirmwareGen.GPT; +using System; + +namespace FirmwareGen +{ + public class DeviceProfile + { + public virtual string[] SupplementaryBCDCommands { get; set; } + public virtual string[] PlatformIDs { get; set; } + public virtual string FFUFileName { get; set; } + public virtual string DriverDefinitionPath { get; set; } + public virtual ulong DiskTotalSize { get; set; } + public virtual uint DiskSectorSize { get; set; } + public virtual GPTPartition[] PartitionLayout { get; set; } + public virtual SplittingStrategy SplittingStrategy { get; set; } + public virtual ulong CustomSplittingAndroidDesiredSpace { get; set; } + public virtual Guid DiskGuid { get; set; } + } +} \ No newline at end of file diff --git a/FirmwareGen/DeviceProfiles/EpsilonHalfSplit128GB.cs b/FirmwareGen/DeviceProfiles/EpsilonHalfSplit128GB.cs index 148b783..e585feb 100644 --- a/FirmwareGen/DeviceProfiles/EpsilonHalfSplit128GB.cs +++ b/FirmwareGen/DeviceProfiles/EpsilonHalfSplit128GB.cs @@ -3,25 +3,25 @@ namespace FirmwareGen.DeviceProfiles { - public class EpsilonHalfSplit128GB : IDeviceProfile + public class EpsilonHalfSplit128GB : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo.1930", "OEMB1.*.OEMB1 Product.*", "OEMEP.*.OEMEP Product.*"]; + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo.1930", "OEMB1.*.OEMB1 Product.*", "OEMEP.*.OEMEP Product.*"]; - public string GetFFUFileName() => $"OEMEP_128GB_HalfSplit.ffu"; + public override string FFUFileName => $"OEMEP_128GB_HalfSplit.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\epsilon.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\epsilon.xml"; - public ulong GetDiskTotalSize() => + public override ulong DiskTotalSize => //return 239_683_502_080; // 256GB (Bigger variant); //return 239_651_758_080; // 256GB (Smaller variant); 111_723_675_648; // 128GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMEP DV UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -78,10 +78,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.HalfSplit; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.HalfSplit; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/EpsilonHalfSplit256GB.cs b/FirmwareGen/DeviceProfiles/EpsilonHalfSplit256GB.cs index e4b9b12..49d45d1 100644 --- a/FirmwareGen/DeviceProfiles/EpsilonHalfSplit256GB.cs +++ b/FirmwareGen/DeviceProfiles/EpsilonHalfSplit256GB.cs @@ -3,24 +3,24 @@ namespace FirmwareGen.DeviceProfiles { - internal class EpsilonHalfSplit256GB : IDeviceProfile + internal class EpsilonHalfSplit256GB : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo.1930", "OEMB1.*.OEMB1 Product.*", "OEMEP.*.OEMEP Product.*"]; + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo.1930", "OEMB1.*.OEMB1 Product.*", "OEMEP.*.OEMEP Product.*"]; - public string GetFFUFileName() => $"OEMEP_256GB_HalfSplit.ffu"; + public override string FFUFileName => $"OEMEP_256GB_HalfSplit.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\epsilon.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\epsilon.xml"; - public ulong GetDiskTotalSize() => + public override ulong DiskTotalSize => //return 239_683_502_080; // 256GB (Bigger variant); 239_651_758_080; // 256GB (Smaller variant);//return 111_723_675_648; // 128GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMEP DV UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -77,10 +77,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.HalfSplit; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.HalfSplit; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/EpsilonMaximizedForWindows.cs b/FirmwareGen/DeviceProfiles/EpsilonMaximizedForWindows.cs index c194a27..b253e59 100644 --- a/FirmwareGen/DeviceProfiles/EpsilonMaximizedForWindows.cs +++ b/FirmwareGen/DeviceProfiles/EpsilonMaximizedForWindows.cs @@ -3,25 +3,25 @@ namespace FirmwareGen.DeviceProfiles { - internal class EpsilonMaximizedForWindows : IDeviceProfile + internal class EpsilonMaximizedForWindows : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo.1930", "OEMB1.*.OEMB1 Product.*", "OEMEP.*.OEMEP Product.*"]; + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo.1930", "OEMB1.*.OEMB1 Product.*", "OEMEP.*.OEMEP Product.*"]; - public string GetFFUFileName() => $"OEMEP_128GB_HalfSplit.ffu"; + public override string FFUFileName => $"OEMEP_128GB_HalfSplit.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\epsilon.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\epsilon.xml"; - public ulong GetDiskTotalSize() => + public override ulong DiskTotalSize => //return 239_683_502_080; // 256GB (Bigger variant); //return 239_651_758_080; // 256GB (Smaller variant); 111_723_675_648; // 128GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMEP DV UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -78,10 +78,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.MaximizedForWindows; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.MaximizedForWindows; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/MTP8150MaximizedForWindows.cs b/FirmwareGen/DeviceProfiles/MTP8150MaximizedForWindows.cs index 78c8897..07199b5 100644 --- a/FirmwareGen/DeviceProfiles/MTP8150MaximizedForWindows.cs +++ b/FirmwareGen/DeviceProfiles/MTP8150MaximizedForWindows.cs @@ -3,22 +3,22 @@ namespace FirmwareGen.DeviceProfiles { - internal class MTP8150MaximizedForWindows : IDeviceProfile + internal class MTP8150MaximizedForWindows : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.MTP.SM8150"]; + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.MTP.SM8150"]; - public string GetFFUFileName() => $"QCOM_MTP_8150_MaximizedForWindows.ffu"; + public override string FFUFileName => $"QCOM_MTP_8150_MaximizedForWindows.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\mtp855.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\mtp855.xml"; - public ulong GetDiskTotalSize() => 123_371_257_856; // 128GB; + public override ulong DiskTotalSize => 123_371_257_856; // 128GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // MTP855 UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -129,10 +129,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.MaximizedForWindows; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.MaximizedForWindows; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/ZetaHalfSplit128GB.cs b/FirmwareGen/DeviceProfiles/ZetaHalfSplit128GB.cs index 85d4412..d4d0344 100644 --- a/FirmwareGen/DeviceProfiles/ZetaHalfSplit128GB.cs +++ b/FirmwareGen/DeviceProfiles/ZetaHalfSplit128GB.cs @@ -3,25 +3,25 @@ namespace FirmwareGen.DeviceProfiles { - public class ZetaHalfSplit128GB : IDeviceProfile + public class ZetaHalfSplit128GB : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo 2.1995", + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo 2.1995", "Microsoft Corporation.Surface.Surface Duo 2.1968", "OEMC1.*.OEMC1 Product.*", "OEMZE.*.OEMZE Product.*"]; - public string GetFFUFileName() => $"OEMZE_128GB_HalfSplit.ffu"; + public override string FFUFileName => $"OEMZE_128GB_HalfSplit.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; - public ulong GetDiskTotalSize() => 110_394_081_280; // 128GB; + public override ulong DiskTotalSize => 110_394_081_280; // 128GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMZE MP UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -96,10 +96,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.HalfSplit; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.HalfSplit; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/ZetaHalfSplit256GB.cs b/FirmwareGen/DeviceProfiles/ZetaHalfSplit256GB.cs index 74a1f66..7c1bb70 100644 --- a/FirmwareGen/DeviceProfiles/ZetaHalfSplit256GB.cs +++ b/FirmwareGen/DeviceProfiles/ZetaHalfSplit256GB.cs @@ -3,25 +3,25 @@ namespace FirmwareGen.DeviceProfiles { - internal class ZetaHalfSplit256GB : IDeviceProfile + internal class ZetaHalfSplit256GB : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo 2.1995", + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo 2.1995", "Microsoft Corporation.Surface.Surface Duo 2.1968", "OEMC1.*.OEMC1 Product.*", "OEMZE.*.OEMZE Product.*"]; - public string GetFFUFileName() => $"OEMZE_256GB_HalfSplit.ffu"; + public override string FFUFileName => $"OEMZE_256GB_HalfSplit.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; - public ulong GetDiskTotalSize() => 238_353_907_712; // 256GB; + public override ulong DiskTotalSize => 238_353_907_712; // 256GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMZE MP UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -96,10 +96,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.HalfSplit; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.HalfSplit; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/ZetaHalfSplit512GB.cs b/FirmwareGen/DeviceProfiles/ZetaHalfSplit512GB.cs index 0f33992..ba06ddd 100644 --- a/FirmwareGen/DeviceProfiles/ZetaHalfSplit512GB.cs +++ b/FirmwareGen/DeviceProfiles/ZetaHalfSplit512GB.cs @@ -3,25 +3,25 @@ namespace FirmwareGen.DeviceProfiles { - internal class ZetaHalfSplit512GB : IDeviceProfile + internal class ZetaHalfSplit512GB : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo 2.1995", + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo 2.1995", "Microsoft Corporation.Surface.Surface Duo 2.1968", "OEMC1.*.OEMC1 Product.*", "OEMZE.*.OEMZE Product.*"]; - public string GetFFUFileName() => $"OEMZE_512GB_HalfSplit.ffu"; + public override string FFUFileName => $"OEMZE_512GB_HalfSplit.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; - public ulong GetDiskTotalSize() => throw new NotImplementedException(); + public override ulong DiskTotalSize => throw new NotImplementedException(); - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMZE MP UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -96,10 +96,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.HalfSplit; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.HalfSplit; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/DeviceProfiles/ZetaMaximizedForWindows.cs b/FirmwareGen/DeviceProfiles/ZetaMaximizedForWindows.cs index 242acf6..e5937ce 100644 --- a/FirmwareGen/DeviceProfiles/ZetaMaximizedForWindows.cs +++ b/FirmwareGen/DeviceProfiles/ZetaMaximizedForWindows.cs @@ -3,25 +3,25 @@ namespace FirmwareGen.DeviceProfiles { - internal class ZetaMaximizedForWindows : IDeviceProfile + internal class ZetaMaximizedForWindows : DeviceProfile { - public string[] GetSupplementaryBCDCommands() => []; + public override string[] SupplementaryBCDCommands => []; - public string[] GetPlatformIDs() => ["Microsoft Corporation.Surface.Surface Duo 2.1995", + public override string[] PlatformIDs => ["Microsoft Corporation.Surface.Surface Duo 2.1995", "Microsoft Corporation.Surface.Surface Duo 2.1968", "OEMC1.*.OEMC1 Product.*", "OEMZE.*.OEMZE Product.*"]; - public string GetFFUFileName() => $"OEMZE_MaximizedForWindows.ffu"; + public override string FFUFileName => $"OEMZE_MaximizedForWindows.ffu"; - public string GetDriverDefinitionPath() => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; + public override string DriverDefinitionPath => $@"\definitions\Desktop\ARM64\Internal\zeta.xml"; - public ulong GetDiskTotalSize() => 110_394_081_280; // 128GB; + public override ulong DiskTotalSize => 110_394_081_280; // 128GB; - public uint GetDiskSectorSize() => 4096; + public override uint DiskSectorSize => 4096; // OEMZE MP UFS LUN 0 Partition Layout - public GPTPartition[] GetPartitionLayout() => [ + public override GPTPartition[] PartitionLayout => [ new() { TypeGUID = new Guid("2c86e742-745e-4fdd-bfd8-b6a7ac638772"), @@ -96,10 +96,10 @@ public GPTPartition[] GetPartitionLayout() => [ } ]; - public SplittingStrategy GetSplittingStrategy() => SplittingStrategy.MaximizedForWindows; + public override SplittingStrategy SplittingStrategy => SplittingStrategy.MaximizedForWindows; - public Guid GetDiskGuid() => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); + public override Guid DiskGuid => new Guid("efa6243a-085f-e745-f2ce-54d39ef34351"); - public ulong GetCustomSplittingAndroidDesiredSpace() => 4_294_967_296; + public override ulong CustomSplittingAndroidDesiredSpace => 4_294_967_296; } } diff --git a/FirmwareGen/IDeviceProfile.cs b/FirmwareGen/IDeviceProfile.cs deleted file mode 100644 index 430139d..0000000 --- a/FirmwareGen/IDeviceProfile.cs +++ /dev/null @@ -1,19 +0,0 @@ -using FirmwareGen.GPT; -using System; - -namespace FirmwareGen -{ - public interface IDeviceProfile - { - string[] GetSupplementaryBCDCommands(); - string[] GetPlatformIDs(); - string GetFFUFileName(); - string GetDriverDefinitionPath(); - ulong GetDiskTotalSize(); - uint GetDiskSectorSize(); - GPTPartition[] GetPartitionLayout(); - SplittingStrategy GetSplittingStrategy(); - ulong GetCustomSplittingAndroidDesiredSpace(); - Guid GetDiskGuid(); - } -} \ No newline at end of file diff --git a/FirmwareGen/MainLogic.cs b/FirmwareGen/MainLogic.cs index a8a3f90..695fd89 100644 --- a/FirmwareGen/MainLogic.cs +++ b/FirmwareGen/MainLogic.cs @@ -7,7 +7,7 @@ namespace FirmwareGen { public static class MainLogic { - private static readonly IDeviceProfile[] deviceProfiles = + private static readonly DeviceProfile[] deviceProfiles = [ new EpsilonHalfSplit128GB(), new EpsilonHalfSplit256GB(), @@ -51,7 +51,7 @@ public static void GenerateWindowsFFU(GenerateWindowsFFUOptions options) const string DriverUpdater = "DriverUpdater.exe"; const string SystemPartition = "Y:"; - foreach (IDeviceProfile deviceProfile in deviceProfiles) + foreach (DeviceProfile deviceProfile in deviceProfiles) { string TmpVHD = CommonLogic.GetBlankVHD(deviceProfile); string DiskId = VolumeUtils.MountVirtualHardDisk(TmpVHD, false); @@ -64,12 +64,12 @@ public static void GenerateWindowsFFU(GenerateWindowsFFUOptions options) VolumeUtils.ConfigureBootManager(VHDLetter, SystemPartition); VolumeUtils.UnmountSystemPartition(DiskId, SystemPartition); - if (deviceProfile.GetSupplementaryBCDCommands().Length > 0) + if (deviceProfile.SupplementaryBCDCommands.Length > 0) { VolumeUtils.MountSystemPartition(DiskId, SystemPartition); Logging.Log("Configuring supplemental boot"); - foreach (string command in deviceProfile.GetSupplementaryBCDCommands()) + foreach (string command in deviceProfile.SupplementaryBCDCommands) { VolumeUtils.RunProgram("bcdedit.exe", $"{$@"/store {SystemPartition}\EFI\Microsoft\Boot\BCD "}{command}"); } @@ -78,7 +78,7 @@ public static void GenerateWindowsFFU(GenerateWindowsFFUOptions options) } Logging.Log("Adding drivers"); - VolumeUtils.RunProgram(DriverUpdater, $@"-d ""{options.DriverPack}{deviceProfile.GetDriverDefinitionPath()}"" -r ""{options.DriverPack}"" -p ""{VHDLetter}"""); + VolumeUtils.RunProgram(DriverUpdater, $@"-d ""{options.DriverPack}{deviceProfile.DriverDefinitionPath}"" -r ""{options.DriverPack}"" -p ""{VHDLetter}"""); VolumeUtils.DismountVirtualHardDisk(TmpVHD); @@ -89,7 +89,7 @@ public static void GenerateWindowsFFU(GenerateWindowsFFUOptions options) version = string.Join(".", version.Split(".").Skip(2)); } - VolumeUtils.RunProgram(Img2Ffu, $@"-i {TmpVHD} -f ""{options.Output}\{deviceProfile.GetFFUFileName()}"" -c {deviceProfile.GetDiskSectorSize() * 4} -s {deviceProfile.GetDiskSectorSize()} -p ""{string.Join(";", deviceProfile.GetPlatformIDs())}"" -o {options.WindowsVer} -b 4000"); + VolumeUtils.RunProgram(Img2Ffu, $@"-i {TmpVHD} -f ""{options.Output}\{deviceProfile.FFUFileName}"" -c {deviceProfile.DiskSectorSize * 4} -s {deviceProfile.DiskSectorSize} -p ""{string.Join(";", deviceProfile.PlatformIDs)}"" -o {options.WindowsVer} -b 4000"); Logging.Log("Deleting Temp VHD"); File.Delete(TmpVHD);