Skip to content

Commit

Permalink
⚒️ Implement Dive into WinRE feature
Browse files Browse the repository at this point in the history
valnoxy committed Mar 12, 2023
1 parent 42cdc9c commit f57dbb4
Showing 17 changed files with 455 additions and 75 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@
<a href="https://github.com/valnoxy/dive/issues">Report Bug</a>
·
<a href="https://github.com/valnoxy/dive/discussions/">Discussions</a>
·
<a href="https://www.youtube.com/watch?v=DkE-EamEDdc">Demo Video</a>
</p>
</p>

71 changes: 70 additions & 1 deletion deploya/deployaCore/Actions.cs
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using deployaCore.Assets;
using Microsoft.Dism;

namespace deployaCore
{
@@ -280,8 +282,9 @@ public static void InstallBootloader(Entities.Firmware firmware, Entities.Bootlo
/// <param name="ui">User Interface type</param>
/// <param name="windowsPath">Path to the Windows directory</param>
/// <param name="recoveryLetter">Drive letter of the recovery partition</param>
/// <param name="implementDive">Implement Dive as a custom recovery tool into Windows RE</param>
/// <param name="worker">Background worker for Graphical user interface</param>
public static void InstallRecovery(Entities.UI ui, string windowsPath, string recoveryLetter, BackgroundWorker worker = null)
public static void InstallRecovery(Entities.UI ui, string windowsPath, string recoveryLetter, bool implementDive = false, BackgroundWorker worker = null)
{
Output.Write("Installing Recovery ... ");
ConsoleUtility.WriteProgressBar(0);
@@ -363,6 +366,61 @@ public static void InstallRecovery(Entities.UI ui, string windowsPath, string re
}
}

// Implement Dive
if (implementDive)
{
try
{
// Initialize Dism API
DismApi.Initialize(DismLogLevel.LogErrors);

// Prepare session
var imageFile = System.IO.Path.Combine(recoveryLetter, "Recovery", "WindowsRE", "Winre.wim");
var mountPath = System.IO.Path.Combine(windowsPath, "..", "dive-tmp", "mount");
var targetPath = System.IO.Path.Combine(mountPath, "sources", "recovery", "tools");
const int imageIndex = 1;
Directory.CreateDirectory(mountPath);

// Mount image
DismApi.MountImage(imageFile, mountPath, imageIndex);

// Copy Dive
var strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
var strWorkPath = System.IO.Path.GetDirectoryName(strExeFilePath);
Common.FileIO.CopyFilesRecursively(new DirectoryInfo(strWorkPath), new DirectoryInfo(Path.Combine(targetPath, "Dive")));

// Create WinREConfig.xml
File.WriteAllText(Path.Combine(targetPath, "WinREConfig.xml"), WinRE.WinREConfig);

// Unmount image
DismApi.UnmountImage(mountPath, true);
}
catch
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("");
Console.WriteLine(" An Error has occurred.");
Console.WriteLine(" Error: Cannot modify WinRE");
if (ui == Entities.UI.Command)
Console.WriteLine(); // Only write new line if ui mode is disabled, so that the ui can read the error code above.
Console.ResetColor();
switch (ui)
{
case Entities.UI.Graphical:
worker.ReportProgress(304, "");
break;
case Entities.UI.Command:
Environment.Exit(1);
break;
}
}
finally
{
// Close Dism API
DismApi.Shutdown();
}
}

// Register recovery partition
try
{
@@ -373,6 +431,17 @@ public static void InstallRecovery(Entities.UI ui, string windowsPath, string re
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();

if (implementDive)
{
var recoveryBootMenuPath = System.IO.Path.Combine(recoveryLetter, "Recovery", "BootMenu");
Directory.CreateDirectory(recoveryBootMenuPath);

File.WriteAllText(Path.Combine(recoveryBootMenuPath, "AddDiagnosticsToolToBootMenu.xml"), WinRE.AddDiagnosticsToolToBootMenu);
p.StartInfo.Arguments = $"/setbootshelllink /configfile {Path.Combine(recoveryBootMenuPath, "AddDiagnosticsToolToBootMenu.xml")}";
p.Start();
p.WaitForExit();
}
}
catch
{
99 changes: 99 additions & 0 deletions deploya/deployaCore/Assets/WinRE.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 127 additions & 0 deletions deploya/deployaCore/Assets/WinRE.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AddDiagnosticsToolToBootMenu" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\adddiagnosticstooltobootmenu.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="WinREConfig" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\winreconfig.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
11 changes: 11 additions & 0 deletions deploya/deployaCore/Common/Helpers.cs
Original file line number Diff line number Diff line change
@@ -54,4 +54,15 @@ public class Utf8StringWriter : StringWriter
public override Encoding Encoding => Encoding.UTF8;
}
}

internal class FileIO
{
public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target)
{
foreach (var dir in source.GetDirectories())
CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
foreach (var file in source.GetFiles())
file.CopyTo(Path.Combine(target.FullName, file.Name));
}
}
}
12 changes: 12 additions & 0 deletions deploya/deployaCore/Resources/AddDiagnosticsToolToBootMenu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- AddDiagnosticsToolToBootMenu.xml -->
<BootShell>
<WinRETool locale="en-us">
<Name>Dive</Name>
<Description>Install, capture and tweak Windows on this device.</Description>
</WinRETool>
<WinRETool locale="de-de">
<Name>Dive</Name>
<Description>Installiere, erfasse und optimiere Windows auf diesem Gerät.</Description>
</WinRETool>
</BootShell>
8 changes: 8 additions & 0 deletions deploya/deployaCore/Resources/WinREConfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- WinREConfig.xml -->
<Recovery>
<RecoveryTools>
<RelativeFilePath>Dive\Dive.exe</RelativeFilePath>
<CommandLineParam></CommandLineParam>
</RecoveryTools>
</Recovery>
17 changes: 17 additions & 0 deletions deploya/deployaCore/deployaCore.csproj
Original file line number Diff line number Diff line change
@@ -28,6 +28,10 @@
<PackageReleaseNotes>Dive Core</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\WinREConfig.xml" />
</ItemGroup>

<ItemGroup>
<Content Include="deploya.ico" />
</ItemGroup>
@@ -37,19 +41,32 @@
<PackageReference Include="Microsoft.Wim" Version="1.2.11" />
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\WinREConfig.xml" />
</ItemGroup>

<ItemGroup>
<Compile Update="Assets\UefiSevenResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>UefiSevenResources.resx</DependentUpon>
</Compile>
<Compile Update="Assets\WinRE.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>WinRE.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Assets\UefiSevenResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>UefiSevenResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Assets\WinRE.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>WinRE.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions deploya/deployaUI/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -176,9 +176,9 @@ private void Application_Startup(object sender, StartupEventArgs e)
Common.UnattendMode? um = Common.UnattendMode.Admin;
Common.DeploymentInfo.Username = "Administrator";
Common.DeploymentInfo.Password = "Pa$$w0rd";
Common.DeploymentOption.UseCopyProfile = true;
Common.DeploymentOption.UseSMode = true;
Common.OemInfo.UseOemInfo = true;
Common.DeploymentOption.UseCopyProfile = false;
Common.DeploymentOption.UseSMode = false;
Common.OemInfo.UseOemInfo = false;
Common.OemInfo.Model = "Toaster";
Common.OemInfo.Manufacturer = "Fabrikam";
Common.OemInfo.SupportHours = "24/7";
2 changes: 1 addition & 1 deletion deploya/deployaUI/AutoDive/AutoDiveUI.xaml.cs
Original file line number Diff line number Diff line change
@@ -517,7 +517,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e)
if (bootloader == Entities.Bootloader.BOOTMGR && Common.ApplyDetails.UseRecovery)
{
worker.ReportProgress(204, ""); // Installing Bootloader Text
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, worker);
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, false, worker);

if (IsCanceled)
{
2 changes: 1 addition & 1 deletion deploya/deployaUI/AutoDiveOld.xaml.cs
Original file line number Diff line number Diff line change
@@ -357,7 +357,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e)
if (bootloader == Entities.Bootloader.BOOTMGR && Common.ApplyDetails.UseRecovery)
{
worker.ReportProgress(204, ""); // Installing Bootloader Text
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, worker);
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, false, worker);

if (IsCanceled)
{
1 change: 1 addition & 0 deletions deploya/deployaUI/Common/ObjectState.cs
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ public static class DeploymentOption
{
public static bool UseSMode { get; set; }
public static bool UseCopyProfile { get; set; }
public static bool AddDiveToWinRE { get; set;}
}

public static class Tweaks
139 changes: 75 additions & 64 deletions deploya/deployaUI/Common/UnattendBuilder.cs
Original file line number Diff line number Diff line change
@@ -715,9 +715,11 @@ public static string Build(Common.UnattendMode? mode)
if (mode != Common.UnattendMode.AdminWithoutPassword ||
mode != Common.UnattendMode.AdminWithoutPasswordAndOem)
{
uc.settings[0].component.AutoLogon.Password = new UnattendXmlClass.unattendSettingsComponentAutoLogonPassword();
uc.settings[0].component.AutoLogon.Password.Value = Common.DeploymentInfo.Password;
uc.settings[0].component.AutoLogon.Password.PlainText = true;
uc.settings[0].component.AutoLogon.Password = new UnattendXmlClass.unattendSettingsComponentAutoLogonPassword
{
Value = Common.DeploymentInfo.Password,
PlainText = true
};
}

}
@@ -726,51 +728,58 @@ public static string Build(Common.UnattendMode? mode)
if (mode != Common.UnattendMode.OnlyOem)
{
uc.settings[0].component.UserAccounts = new UnattendXmlClass.unattendSettingsComponentUserAccounts();

// Administrator Password
if (mode == Common.UnattendMode.Admin ||
mode == Common.UnattendMode.AdminWithoutOem)
{
uc.settings[0].component.UserAccounts.AdministratorPassword =
new UnattendXmlClass.unattendSettingsComponentUserAccountsAdministratorPassword
{
Value = Common.DeploymentInfo.Password,
PlainText = true
};
}

// Local account
if (mode == Common.UnattendMode.User ||
mode == Common.UnattendMode.UserWithoutOem ||
mode == Common.UnattendMode.UserWithoutPassword ||
mode == Common.UnattendMode.UserWithoutPasswordAndOem)
{
uc.settings[0].component.UserAccounts.LocalAccounts =
new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccounts
{
LocalAccount = new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccountsLocalAccount
switch (mode)
{
// Administrator Password
case Common.UnattendMode.Admin:
case Common.UnattendMode.AdminWithoutOem:
uc.settings[0].component.UserAccounts.AdministratorPassword =
new UnattendXmlClass.unattendSettingsComponentUserAccountsAdministratorPassword
{
Value = Common.DeploymentInfo.Password,
PlainText = true
};
break;

// Local account
case Common.UnattendMode.User:
case Common.UnattendMode.UserWithoutOem:
case Common.UnattendMode.UserWithoutPassword:
case Common.UnattendMode.UserWithoutPasswordAndOem:
{
uc.settings[0].component.UserAccounts.LocalAccounts =
new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccounts
{
LocalAccount = new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccountsLocalAccount
{
action = "add"
}
};
};

// Password
if (mode != Common.UnattendMode.UserWithoutPassword ||
mode != Common.UnattendMode.UserWithoutPasswordAndOem)
{
uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Password =
new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccountsLocalAccountPassword
// Password
if (mode != Common.UnattendMode.UserWithoutPassword ||
mode != Common.UnattendMode.UserWithoutPasswordAndOem)
{
uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Password =
new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccountsLocalAccountPassword
{
Value = Common.DeploymentInfo.Password,
PlainText = true
};
}
}

uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Name = Common.DeploymentInfo.Username;
uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Group = "Administrators";
uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Name = Common.DeploymentInfo.Username;
uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Group = "Administrators";
break;
}
}
}

var oemLogo = "";
if (!string.IsNullOrEmpty(Common.OemInfo.LogoPath))
oemLogo = "%WINDIR%\\System32\\logo.bmp";

// OEM Information
if (mode != Common.UnattendMode.AdminWithoutOem ||
mode != Common.UnattendMode.AdminWithoutPasswordAndOem ||
@@ -779,7 +788,7 @@ public static string Build(Common.UnattendMode? mode)
{
uc.settings[0].component.OEMInformation = new UnattendXmlClass.unattendSettingsComponentOEMInformation
{
Logo = "%WINDIR%\\System32\\logo.bmp",
Logo = oemLogo,
Manufacturer = Common.OemInfo.Manufacturer,
Model = Common.OemInfo.Model,
SupportHours = Common.OemInfo.SupportHours,
@@ -791,49 +800,51 @@ public static string Build(Common.UnattendMode? mode)
// S-Mode (Windows 10 1709 and up)
if (Common.DeploymentOption.UseSMode)
{
uc.settings[1] = new UnattendXmlClass.unattendSettings();
uc.settings[1].pass = "offlineServicing";
uc.settings[1].component = new UnattendXmlClass.unattendSettingsComponent
uc.settings[1] = new UnattendXmlClass.unattendSettings
{
name = "Microsoft-Windows-CodeIntegrity",
processorArchitecture = "amd64",
publicKeyToken = "31bf3856ad364e35",
language = "neutral",
versionScope = "nonSxS"
pass = "offlineServicing",
component = new UnattendXmlClass.unattendSettingsComponent
{
name = "Microsoft-Windows-CodeIntegrity",
processorArchitecture = "amd64",
publicKeyToken = "31bf3856ad364e35",
language = "neutral",
versionScope = "nonSxS",
SkuPolicyRequired = 1,
SkuPolicyRequiredSpecified = true
}
};
uc.settings[1].component.SkuPolicyRequired = 1;
uc.settings[1].component.SkuPolicyRequiredSpecified = true;
}

// Copy Profile (only for syspreped user profiles)
if (Common.DeploymentOption.UseCopyProfile)
{
int nextIndex = Common.DeploymentOption.UseSMode ? 2 : 1;
uc.settings[nextIndex] = new UnattendXmlClass.unattendSettings();
uc.settings[nextIndex].pass = "specialize";
uc.settings[nextIndex].component = new UnattendXmlClass.unattendSettingsComponent
var nextIndex = Common.DeploymentOption.UseSMode ? 2 : 1;
uc.settings[nextIndex] = new UnattendXmlClass.unattendSettings
{
name = "Microsoft-Windows-Shell-Setup",
processorArchitecture = "amd64",
publicKeyToken = "31bf3856ad364e35",
language = "neutral",
versionScope = "nonSxS"
pass = "specialize",
component = new UnattendXmlClass.unattendSettingsComponent
{
name = "Microsoft-Windows-Shell-Setup",
processorArchitecture = "amd64",
publicKeyToken = "31bf3856ad364e35",
language = "neutral",
versionScope = "nonSxS",
CopyProfile = true,
CopyProfileSpecified = true
}
};
uc.settings[nextIndex].component.CopyProfile = true;
uc.settings[nextIndex].component.CopyProfileSpecified = true;
}

XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
var ns = new XmlSerializerNamespaces();
ns.Add("", "");

// Create the serializer
XmlSerializer slz = new XmlSerializer(typeof(UnattendXmlClass.unattend), "urn:schemas-microsoft-com:unattend");
var slz = new XmlSerializer(typeof(UnattendXmlClass.unattend), "urn:schemas-microsoft-com:unattend");

using (StringWriter textWriter = new Utf8StringWriter())
{
slz.Serialize(textWriter, uc, ns);
return textWriter.ToString();
}
using StringWriter textWriter = new Utf8StringWriter();
slz.Serialize(textWriter, uc, ns);
return textWriter.ToString();
}

public class Utf8StringWriter : StringWriter
2 changes: 1 addition & 1 deletion deploya/deployaUI/Pages/ApplyPages/ApplySelectStep.xaml.cs
Original file line number Diff line number Diff line change
@@ -416,7 +416,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e)
if (bootloader == Entities.Bootloader.BOOTMGR && Common.ApplyDetails.UseRecovery)
{
worker.ReportProgress(204, ""); // Installing Bootloader Text
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, worker);
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, Common.DeploymentOption.AddDiveToWinRE, worker);

if (IsCanceled)
{
7 changes: 4 additions & 3 deletions deploya/deployaUI/Pages/ApplyPages/DiskSelectStep.xaml
Original file line number Diff line number Diff line change
@@ -64,12 +64,13 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="75"/>
<ColumnDefinition Width="75"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<ToggleButton Grid.Column="2" x:Name="SModeToggle" Content="Windows Code Integrity Mode (S-Mode)" Click="SModeToggle_OnClick" Margin="0,15,15,0"/>
<ToggleButton Grid.Column="3" x:Name="CopyProfileToggle" Content="Copy Profile (for syspreped Images)" Click="CopyProfileToggle_OnClick" Margin="0,15,15,0"/>
<ToggleButton Grid.Column="3" x:Name="CopyProfileToggle" Content="Copy Profile (syspreped Images)" Click="CopyProfileToggle_OnClick" Margin="0,15,15,0"/>
<ToggleButton Grid.Column="4" x:Name="DiveToRecovery" Content="Add Dive into WinRE" Click="DiveToRecovery_OnClick" Margin="0,15,15,0"/>

</Grid>
</StackPanel>

22 changes: 22 additions & 0 deletions deploya/deployaUI/Pages/ApplyPages/DiskSelectStep.xaml.cs
Original file line number Diff line number Diff line change
@@ -70,11 +70,18 @@ public DiskSelectStep()
UseNTLDRBtn.IsChecked = true;
BIOSRadio.IsChecked = true;
UseRecoveryBtn.IsChecked = false;
DiveToRecovery.IsChecked = false;
}
else if (Common.ApplyDetails.Name.ToLower().Contains("windows vista"))
{
UseRecoveryBtn.IsChecked = false;
UseNTLDRBtn.IsChecked = false;
DiveToRecovery.IsChecked = false;
}
else if (Common.ApplyDetails.Name.ToLower().Contains("windows 7"))
{
UseRecoveryBtn.IsChecked = true;
DiveToRecovery.IsChecked = false;
}
else if (Common.ApplyDetails.Name.Contains("(") || Common.ApplyDetails.Name.Contains(")"))
{
@@ -85,6 +92,7 @@ public DiskSelectStep()
{
UseNTLDRBtn.IsChecked = false;
UseRecoveryBtn.IsChecked = true;
DiveToRecovery.IsChecked = true;
}
}

@@ -291,5 +299,19 @@ private void CopyProfileToggle_OnClick(object sender, RoutedEventArgs e)
Common.Debug.WriteLine("Disabled 'CopyProfile'");
}
}

private void DiveToRecovery_OnClick(object sender, RoutedEventArgs e)
{
if (DiveToRecovery.IsChecked == true)
{
Common.DeploymentOption.AddDiveToWinRE = true;
Common.Debug.WriteLine("Enabled 'AddDiveToWinRE'");
}
else
{
Common.DeploymentOption.AddDiveToWinRE = false;
Common.Debug.WriteLine("Disabled 'AddDiveToWinRE'");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -427,7 +427,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e)
if (bootloader == Entities.Bootloader.BOOTMGR && Common.ApplyDetails.UseRecovery)
{
worker.ReportProgress(204, ""); // Installing Bootloader Text
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, worker);
Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, false, worker);

if (IsCanceled)
{

0 comments on commit f57dbb4

Please sign in to comment.