diff --git a/deploya/deployaCore/Action/Apply.cs b/deploya/deployaCore/Action/Apply.cs index 91ad03a..ade8fee 100644 --- a/deploya/deployaCore/Action/Apply.cs +++ b/deploya/deployaCore/Action/Apply.cs @@ -5,6 +5,8 @@ using System.ComponentModel; using System.IO; using System.Linq; +using deployaCore.Common; +using static System.Collections.Specialized.BitVector32; namespace deployaCore.Action { @@ -30,23 +32,55 @@ internal static void WriteToDisk(string imagePath, int index, string drive, Back } } - internal static void AddDriverToDisk(string windowsPath, List driverPath, BackgroundWorker worker = null) + internal static void AddDriverToDisk(string windowsDrive, List driverPath, BackgroundWorker worker = null) { Bw = worker; - - foreach (var driver in driverPath.Where(File.Exists)) + try { - using var session = DismApi.OpenOfflineSession(windowsPath); + Output.WriteLine("[Driver] Entering Injection process ..."); + Output.WriteLine("[Driver] Initialize Dism API ..."); + DismApi.Initialize(DismLogLevel.LogErrors); + Output.WriteLine("[Driver] Open offline session ..."); + DismSession session = null; try { - DismApi.AddDriver(session, driver, true); - if (Bw != null) Bw.ReportProgress(202, ""); // Update progress text + if (Bw != null) Bw.ReportProgress(207, "Initialize"); // Update progress text + session = DismApi.OpenOfflineSession(windowsDrive); + Output.WriteLine("[Driver] Session opened. "); } - catch + catch (Exception ex) { + Output.WriteLine("[Driver] Failed to open offline session: " + ex.Message); + Output.WriteLine("[Driver] Shutdown Dism API ..."); + DismApi.Shutdown(); + return; + } + var currentDriverCount = 0; + foreach (var driver in driverPath.Where(File.Exists)) + { + try + { + currentDriverCount++; + Output.WriteLine($"[Driver] Current Driver ({currentDriverCount}): {driver}"); + if (Bw != null) Bw.ReportProgress(207, currentDriverCount); // Update progress text + DismApi.AddDriver(session, driver, true); + } + catch (Exception ex) + { + Output.WriteLine("[Driver] Failed to inject driver: " + ex.Message); + if (Bw != null) Bw?.ReportProgress(308, ""); + } } + + session.Close(); + DismApi.Shutdown(); + } + catch (Exception ex) + { + Output.WriteLine("[Driver] Unknown error: " + ex.Message); + DismApi.Shutdown(); } } diff --git a/deploya/deployaCore/Actions.cs b/deploya/deployaCore/Actions.cs index f8bb254..d8ec403 100644 --- a/deploya/deployaCore/Actions.cs +++ b/deploya/deployaCore/Actions.cs @@ -1,13 +1,13 @@ /* - * deploya - Fast and Easy way to deploy Windows + * Dive - Deployment is very easy. * Copyright (c) 2018 - 2023 Exploitox. * - * deploya is licensed under MIT License (https://github.com/valnoxy/deploya/blob/main/LICENSE). + * Dive (formally deploya) is licensed under MIT License (https://github.com/valnoxy/dive/blob/main/LICENSE). * So you are allowed to use freely and modify the application. * I will not be responsible for any outcome. * Proceed with any action at your own risk. * - * Source code: https://github.com/valnoxy/deploya + * Source code: https://github.com/valnoxy/dive */ using deployaCore.Action; @@ -534,7 +534,7 @@ public static void InstallUnattend(Entities.UI ui, string windowsPath, string co } // Copy OEM logo to Windows\System32 directory - if (string.IsNullOrEmpty(oemLogoPath)) + if (!string.IsNullOrEmpty(oemLogoPath)) { try { @@ -559,7 +559,7 @@ public static void InstallUnattend(Entities.UI ui, string windowsPath, string co { try { - Output.Write("Applying DISM Unattend ... "); + Output.Write("Registering unattend file with DISM ..."); var f = new FileInfo(windowsPath); var drive = Path.GetPathRoot(f.FullName); @@ -601,16 +601,16 @@ public static void InstallUnattend(Entities.UI ui, string windowsPath, string co /// Installs the specific driver to the Windows Installation (only Vista and higher). /// /// User Interface type - /// Path to the Windows directory + /// Drive letter to the Windows disk /// List of driver paths /// Background worker for Graphical user interface - public static void InstallDriver(Entities.UI ui, string windowsPath, List driverPath, BackgroundWorker worker = null) + public static void InstallDriver(Entities.UI ui, string windowsDrive, List driverPath, BackgroundWorker worker = null) { Output.Write("Installing drivers ... "); ConsoleUtility.WriteProgressBar(0); if (ui == Entities.UI.Graphical) { worker.ReportProgress(102, ""); worker.ReportProgress(0, ""); } - Apply.AddDriverToDisk(windowsPath, driverPath, worker); + Apply.AddDriverToDisk(windowsDrive, driverPath, worker); ConsoleUtility.WriteProgressBar(100, true); Console.WriteLine(); diff --git a/deploya/deployaCore/deployaCore.csproj b/deploya/deployaCore/deployaCore.csproj index 18e7685..719aba1 100644 --- a/deploya/deployaCore/deployaCore.csproj +++ b/deploya/deployaCore/deployaCore.csproj @@ -18,7 +18,7 @@ embedded False deploya - 12.0.0.435 + 12.0.0.448 valnoxy Exploitox deploya diff --git a/deploya/deployaUI/Common/UnattendBuilder.cs b/deploya/deployaUI/Common/UnattendBuilder.cs index 699b761..6fc871f 100644 --- a/deploya/deployaUI/Common/UnattendBuilder.cs +++ b/deploya/deployaUI/Common/UnattendBuilder.cs @@ -685,26 +685,31 @@ public class UnattendBuilder { public static string Build(Common.UnattendMode? mode) { - var uc = new UnattendXmlClass.unattend(); - uc.settings = new UnattendXmlClass.unattendSettings[3]; - uc.settings[0] = new UnattendXmlClass.unattendSettings(); - uc.settings[0].pass = "oobeSystem"; - - uc.settings[0].component = new UnattendXmlClass.unattendSettingsComponent - { - name = "Microsoft-Windows-Shell-Setup", - processorArchitecture = "amd64", - publicKeyToken = "31bf3856ad364e35", - language = "neutral", - versionScope = "nonSxS" + Common.Debug.WriteLine($"[UnattendBuilder] Entering Build process with mode {mode.Value} ..."); + var uc = new UnattendXmlClass.unattend + { + settings = new UnattendXmlClass.unattendSettings[3] + }; + uc.settings[0] = new UnattendXmlClass.unattendSettings + { + pass = "oobeSystem", + component = new UnattendXmlClass.unattendSettingsComponent + { + name = "Microsoft-Windows-Shell-Setup", + processorArchitecture = "amd64", + publicKeyToken = "31bf3856ad364e35", + language = "neutral", + versionScope = "nonSxS" + } }; // Auto Logon for Administrator account - if (mode == Common.UnattendMode.Admin || - mode == Common.UnattendMode.AdminWithoutOem || - mode == Common.UnattendMode.AdminWithoutPassword || - mode == Common.UnattendMode.AdminWithoutPasswordAndOem) + if (mode is Common.UnattendMode.Admin + or Common.UnattendMode.AdminWithoutOem + or Common.UnattendMode.AdminWithoutPassword + or Common.UnattendMode.AdminWithoutPasswordAndOem) { + Common.Debug.WriteLine("[UnattendBuilder] AutoLogon for Admin account"); uc.settings[0].component.AutoLogon = new UnattendXmlClass.unattendSettingsComponentAutoLogon { Enabled = true, @@ -712,9 +717,9 @@ public static string Build(Common.UnattendMode? mode) Username = "Administrator" }; - if (mode != Common.UnattendMode.AdminWithoutPassword || - mode != Common.UnattendMode.AdminWithoutPasswordAndOem) + if (mode is not (Common.UnattendMode.AdminWithoutPassword and Common.UnattendMode.AdminWithoutPasswordAndOem)) { + Common.Debug.WriteLine("[UnattendBuilder] Define Admin password"); uc.settings[0].component.AutoLogon.Password = new UnattendXmlClass.unattendSettingsComponentAutoLogonPassword { Value = Common.DeploymentInfo.Password, @@ -727,6 +732,7 @@ public static string Build(Common.UnattendMode? mode) // User Account if (mode != Common.UnattendMode.OnlyOem) { + Common.Debug.WriteLine("[UnattendBuilder] User Account creation"); uc.settings[0].component.UserAccounts = new UnattendXmlClass.unattendSettingsComponentUserAccounts(); switch (mode) @@ -734,6 +740,7 @@ public static string Build(Common.UnattendMode? mode) // Administrator Password case Common.UnattendMode.Admin: case Common.UnattendMode.AdminWithoutOem: + Common.Debug.WriteLine("[UnattendBuilder] Administrator Password"); uc.settings[0].component.UserAccounts.AdministratorPassword = new UnattendXmlClass.unattendSettingsComponentUserAccountsAdministratorPassword { @@ -748,6 +755,7 @@ public static string Build(Common.UnattendMode? mode) case Common.UnattendMode.UserWithoutPassword: case Common.UnattendMode.UserWithoutPasswordAndOem: { + Common.Debug.WriteLine("[UnattendBuilder] Local account"); uc.settings[0].component.UserAccounts.LocalAccounts = new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccounts { @@ -758,9 +766,9 @@ public static string Build(Common.UnattendMode? mode) }; // Password - if (mode != Common.UnattendMode.UserWithoutPassword || - mode != Common.UnattendMode.UserWithoutPasswordAndOem) + if (mode is not (Common.UnattendMode.UserWithoutPassword and Common.UnattendMode.UserWithoutPasswordAndOem)) { + Common.Debug.WriteLine("[UnattendBuilder] Local Account Password"); uc.settings[0].component.UserAccounts.LocalAccounts.LocalAccount.Password = new UnattendXmlClass.unattendSettingsComponentUserAccountsLocalAccountsLocalAccountPassword { @@ -778,15 +786,29 @@ public static string Build(Common.UnattendMode? mode) var oemLogo = ""; if (!string.IsNullOrEmpty(Common.OemInfo.LogoPath)) + { + Common.Debug.WriteLine("[UnattendBuilder] OEM Logo is not Null or Empty: " + Common.OemInfo.LogoPath); oemLogo = "%WINDIR%\\System32\\logo.bmp"; + } // OEM Information - if (mode != Common.UnattendMode.AdminWithoutOem || - mode != Common.UnattendMode.AdminWithoutPasswordAndOem || - mode != Common.UnattendMode.UserWithoutOem || - mode != Common.UnattendMode.UserWithoutPasswordAndOem) + if (mode is UnattendMode.Admin or UnattendMode.AdminWithoutPassword or UnattendMode.User or UnattendMode.UserWithoutPassword) { - uc.settings[0].component.OEMInformation = new UnattendXmlClass.unattendSettingsComponentOEMInformation + Common.Debug.WriteLine("[UnattendBuilder] OEM Information"); + if (string.IsNullOrEmpty(Common.OemInfo.LogoPath)) + { + uc.settings[0].component.OEMInformation = new UnattendXmlClass.unattendSettingsComponentOEMInformation + { + Manufacturer = Common.OemInfo.Manufacturer, + Model = Common.OemInfo.Model, + SupportHours = Common.OemInfo.SupportHours, + SupportPhone = Common.OemInfo.SupportPhone, + SupportURL = Common.OemInfo.SupportURL + }; + } + else + { + uc.settings[0].component.OEMInformation = new UnattendXmlClass.unattendSettingsComponentOEMInformation { Logo = oemLogo, Manufacturer = Common.OemInfo.Manufacturer, @@ -795,11 +817,13 @@ public static string Build(Common.UnattendMode? mode) SupportPhone = Common.OemInfo.SupportPhone, SupportURL = Common.OemInfo.SupportURL }; + } } // S-Mode (Windows 10 1709 and up) if (Common.DeploymentOption.UseSMode) { + Common.Debug.WriteLine("[UnattendBuilder] Using S Mode"); uc.settings[1] = new UnattendXmlClass.unattendSettings { pass = "offlineServicing", @@ -819,6 +843,7 @@ public static string Build(Common.UnattendMode? mode) // Copy Profile (only for syspreped user profiles) if (Common.DeploymentOption.UseCopyProfile) { + Common.Debug.WriteLine("[UnattendBuilder] Using CopyProfile"); var nextIndex = Common.DeploymentOption.UseSMode ? 2 : 1; uc.settings[nextIndex] = new UnattendXmlClass.unattendSettings { @@ -844,6 +869,8 @@ public static string Build(Common.UnattendMode? mode) using StringWriter textWriter = new Utf8StringWriter(); slz.Serialize(textWriter, uc, ns); + + Common.Debug.WriteLine("[UnattendBuilder] Building completed."); return textWriter.ToString(); } diff --git a/deploya/deployaUI/Pages/ApplyPages/ApplySelectStep.xaml.cs b/deploya/deployaUI/Pages/ApplyPages/ApplySelectStep.xaml.cs index 8f0acac..f6f6e36 100644 --- a/deploya/deployaUI/Pages/ApplyPages/ApplySelectStep.xaml.cs +++ b/deploya/deployaUI/Pages/ApplyPages/ApplySelectStep.xaml.cs @@ -15,8 +15,7 @@ public partial class ApplySelectStep : System.Windows.Controls.UserControl { private BackgroundWorker applyBackgroundWorker; bool IsCanceled = false; - private int currentDriver = 0; - private int driverCount = 0; + private int _driverCount = 0; public ApplySelectStep() { @@ -35,15 +34,8 @@ public ApplySelectStep() CloudContent.ContentWindow.CancelBtn.IsEnabled = false; } - if (DiskSelectStep.ContentWindow.IsNTLDRChecked()) - Common.ApplyDetails.UseNTLDR = true; - else - Common.ApplyDetails.UseNTLDR = false; - - if (DiskSelectStep.ContentWindow.IsRecoveryChecked()) - Common.ApplyDetails.UseRecovery = true; - else - Common.ApplyDetails.UseRecovery = false; + Common.ApplyDetails.UseNTLDR = DiskSelectStep.ContentWindow.IsNTLDRChecked(); + Common.ApplyDetails.UseRecovery = DiskSelectStep.ContentWindow.IsRecoveryChecked(); // Validate deployment settings switch (Common.OemInfo.UseOemInfo) @@ -71,7 +63,7 @@ public ApplySelectStep() // Set active Image to card ImageName.Text = Common.ApplyDetails.Name; ImageFile.Text = Common.ApplyDetails.FileName; - ImageSourceConverter img = new ImageSourceConverter(); + var img = new ImageSourceConverter(); try { ImageIcon.Source = (ImageSource)img.ConvertFromString(Common.ApplyDetails.IconPath); @@ -81,7 +73,7 @@ public ApplySelectStep() // ignored } - // Backgrond worker for deployment + // Background worker for deployment applyBackgroundWorker = new BackgroundWorker(); applyBackgroundWorker.WorkerReportsProgress = true; applyBackgroundWorker.WorkerSupportsCancellation = true; @@ -106,6 +98,7 @@ private void applyBackgroundWorker_ProgressChanged(object? sender, ProgressChang // 204: ProgText -> Install recovery // 205: ProgText -> Install unattend.xml // 206: ProgText -> Install UefiSeven + // 207: ProgText -> Inject drivers // 250: Installation complete // // Error message handling @@ -116,6 +109,7 @@ private void applyBackgroundWorker_ProgressChanged(object? sender, ProgressChang // 305: Failed at installing unattend.xml // 306: Failed at copying oem logo // 307: Failed at installing UefiSeven + // 308: Failed at injecting drivers // // Range 0-100 -> Progressbar percentage // @@ -148,12 +142,15 @@ private void applyBackgroundWorker_ProgressChanged(object? sender, ProgressChang case 205: // 205: ProgText -> Installing unattend.xml ProgrText.Text = "Copying unattend.xml to disk ..."; break; - case 206: // 206: ProgText -> Injecting drivers - ProgrText.Text = $"Injecting drivers ({currentDriver} of {driverCount}) ..."; - break; - case 207: // 206: ProgText -> Injecting drivers + case 206: // 206: ProgText -> Installing UefiSeven ProgrText.Text = $"Installing UefiSeven ..."; break; + case 207: // 207: ProgText -> Injecting drivers + if (e.UserState == "Initialize") + ProgrText.Text = $"Opening Dism Session for Driver injection ..."; + else + ProgrText.Text = $"Injecting drivers ({e.UserState} of {_driverCount}) ..."; + break; case 250: // 250: Installation complete ProgrText.Text = "Installation completed. Press 'Next' to restart your computer."; ProgrBar.Value = 100; @@ -267,7 +264,41 @@ private void applyBackgroundWorker_ProgressChanged(object? sender, ProgressChang } IsCanceled = true; break; - #endregion + case 307: // 307: Failed at installing UefiSeven + ProgrText.Text = "Failed at installing UefiSeven to disk. Please check your disk and try again."; + ProgrBar.Value = 0; + if (ApplyContent.ContentWindow != null) + { + ApplyContent.ContentWindow.NextBtn.IsEnabled = false; + ApplyContent.ContentWindow.BackBtn.IsEnabled = false; + ApplyContent.ContentWindow.CancelBtn.IsEnabled = true; + } + if (CloudContent.ContentWindow != null) + { + CloudContent.ContentWindow.NextBtn.IsEnabled = false; + CloudContent.ContentWindow.BackBtn.IsEnabled = false; + CloudContent.ContentWindow.CancelBtn.IsEnabled = true; + } + IsCanceled = true; + break; + case 308: // 308: Failed at injecting drivers + ProgrText.Text = "Failed at injecting drivers. Please check your drivers and try again."; + ProgrBar.Value = 0; + if (ApplyContent.ContentWindow != null) + { + ApplyContent.ContentWindow.NextBtn.IsEnabled = false; + ApplyContent.ContentWindow.BackBtn.IsEnabled = false; + ApplyContent.ContentWindow.CancelBtn.IsEnabled = true; + } + if (CloudContent.ContentWindow != null) + { + CloudContent.ContentWindow.NextBtn.IsEnabled = false; + CloudContent.ContentWindow.BackBtn.IsEnabled = false; + CloudContent.ContentWindow.CancelBtn.IsEnabled = true; + } + IsCanceled = true; + break; + #endregion } // Progressbar percentage @@ -372,10 +403,10 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) #endregion // Initialize worker progress - worker.ReportProgress(0, ""); // Value 0 + worker?.ReportProgress(0, ""); // Value 0 // Prepare disk - worker.ReportProgress(201, ""); // Prepare Disk Text + worker?.ReportProgress(201, ""); // Prepare Disk Text Actions.PrepareDisk(firmware, bootloader, ui, Common.ApplyDetails.DiskIndex, partStyle, Common.ApplyDetails.UseRecovery, windowsDrive, bootDrive, recoveryDrive, worker); if (IsCanceled) { @@ -384,8 +415,8 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) } // Apply image - worker.ReportProgress(202, ""); // Applying Image Text - worker.ReportProgress(0, ""); // Value 0 + worker?.ReportProgress(202, ""); // Applying Image Text + worker?.ReportProgress(0, ""); // Value 0 Actions.ApplyWim(ui, windowsDrive, Common.ApplyDetails.FileName, Common.ApplyDetails.Index, worker); if (IsCanceled) { @@ -394,7 +425,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) } // Install Bootloader - worker.ReportProgress(203, ""); // Installing Bootloader Text + worker?.ReportProgress(203, ""); // Installing Bootloader Text switch (partStyle) { case Entities.PartitionStyle.SeparateBoot: @@ -415,7 +446,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) // Install Recovery (only for Vista and higher) if (bootloader == Entities.Bootloader.BOOTMGR && Common.ApplyDetails.UseRecovery) { - worker.ReportProgress(204, ""); // Installing Bootloader Text + worker?.ReportProgress(204, ""); // Installing Bootloader Text Actions.InstallRecovery(ui, $"{windowsDrive}Windows", recoveryDrive, Common.DeploymentOption.AddDiveToWinRE, worker); if (IsCanceled) @@ -428,10 +459,10 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) // Install unattend file (only for Vista and higher) if (Common.DeploymentInfo.UseUserInfo || Common.OemInfo.UseOemInfo) { - worker.ReportProgress(205, ""); // Installing unattend file + worker?.ReportProgress(205, ""); // Installing unattend file // Building config - string config = ""; + var config = ""; Common.UnattendMode? um = null; if (!Common.DeploymentInfo.UseUserInfo && Common.OemInfo.UseOemInfo) @@ -496,8 +527,10 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) // Install Drivers (only for Vista and higher) if (Common.ApplyDetails.DriverList != null) { - worker.ReportProgress(206, ""); // Installing Drivers Text - Actions.InstallDriver(ui, $"{windowsDrive}Windows", Common.ApplyDetails.DriverList, worker); + worker?.ReportProgress(207, ""); // Installing Drivers Text + + _driverCount = Common.ApplyDetails.DriverList.Count; + Actions.InstallDriver(ui, windowsDrive, Common.ApplyDetails.DriverList, worker); if (IsCanceled) { @@ -509,7 +542,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) // Install UefiSeven (only for Vista and 7 with EFI) if (Common.WindowsModification.InstallUefiSeven) { - worker.ReportProgress(207, ""); // Installing UefiSeven + worker?.ReportProgress(206, ""); // Installing UefiSeven deployaCore.Action.UefiSeven.InstallUefiSeven(ui, bootDrive, Common.WindowsModification.UsToggleSkipErros, Common.WindowsModification.UsToggleFakeVesa, @@ -525,7 +558,7 @@ private void ApplyWim(object? sender, DoWorkEventArgs e) } // Installation complete - worker.ReportProgress(250, ""); // Installation complete Text + worker?.ReportProgress(250, ""); // Installation complete Text } } } diff --git a/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml b/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml index dadc344..9150695 100644 --- a/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml +++ b/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml @@ -184,6 +184,36 @@ + + + + + + + + + + + + + + + + + + diff --git a/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml.cs b/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml.cs index 2f35069..4bf0769 100644 --- a/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml.cs +++ b/deploya/deployaUI/Pages/ApplyPages/DeploymentSettingsStep.xaml.cs @@ -1,13 +1,16 @@ using Microsoft.Win32; using System; +using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using deployaUI.Common; using System.IO; +using System.Linq; using System.Xml.Serialization; using Path = System.IO.Path; using Wpf.Ui.Common; using System.Xml; +using deployaUI.Pages.Extras; namespace deployaUI.Pages.ApplyPages { @@ -237,5 +240,40 @@ private void Export_OnClicked(object sender, RoutedEventArgs e) } } } + + private void Source_OpenFolderClick(object sender, RoutedEventArgs e) + { + using var dialog = new System.Windows.Forms.FolderBrowserDialog + { + Description = "Select the source directory to capture.", + UseDescriptionForTitle = true, + SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer), + ShowNewFolderButton = false + }; + + if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + TbDrvPath.Text = dialog.SelectedPath; + + List infFiles = Directory.GetFiles(dialog.SelectedPath, "*.inf") + .Select(Path.GetFileName) + .ToList(); + + switch (infFiles.Count) + { + case > 0: + var driverWindow = new LoadDriversLiveSystem(infFiles); + driverWindow.ShowDialog(); + Common.ApplyDetails.DriverList = infFiles; + break; + case 0: + RootSnackbar.Appearance = ControlAppearance.Danger; + RootSnackbar.Icon = SymbolRegular.Settings32; + RootSnackbar.Show("An error has occurred.", $"No inf files found in the selected directory."); + Common.ApplyDetails.DriverList = null; + break; + } + } + } } } diff --git a/deploya/deployaUI/Pages/ApplyPages/DiskSelectStep.xaml b/deploya/deployaUI/Pages/ApplyPages/DiskSelectStep.xaml index 93e35f4..3b9f956 100644 --- a/deploya/deployaUI/Pages/ApplyPages/DiskSelectStep.xaml +++ b/deploya/deployaUI/Pages/ApplyPages/DiskSelectStep.xaml @@ -12,8 +12,8 @@ - - + + @@ -39,21 +39,15 @@ - - - - - - - - - - + + + + diff --git a/deploya/deployaUI/Pages/Extras/LoadDriversLiveSystem.xaml b/deploya/deployaUI/Pages/Extras/LoadDriversLiveSystem.xaml new file mode 100644 index 0000000..92c078d --- /dev/null +++ b/deploya/deployaUI/Pages/Extras/LoadDriversLiveSystem.xaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + Injecting drivers ... + + + + Loading driver 0 of 0 ... + + + + + + + + + + diff --git a/deploya/deployaUI/Pages/Extras/LoadDriversLiveSystem.xaml.cs b/deploya/deployaUI/Pages/Extras/LoadDriversLiveSystem.xaml.cs new file mode 100644 index 0000000..d58085e --- /dev/null +++ b/deploya/deployaUI/Pages/Extras/LoadDriversLiveSystem.xaml.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Threading; +using System.Windows; +using System.Windows.Documents; +using System.Windows.Threading; + +namespace deployaUI.Pages.Extras +{ + /// + /// Interaktionslogik für LoadDriversLiveSystem.xaml + /// + public partial class LoadDriversLiveSystem: Wpf.Ui.Controls.UiWindow + { + private int _driverCount = 0; + private List _driverList = null; + + public LoadDriversLiveSystem(List driverList) + { + InitializeComponent(); + + _driverList = driverList; + _driverCount = driverList.Count; + var backgroundWorker = new BackgroundWorker(); + backgroundWorker.WorkerReportsProgress = true; + backgroundWorker.WorkerSupportsCancellation = true; + backgroundWorker.DoWork += InjectDriver; + backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; + backgroundWorker.RunWorkerCompleted += (sender, args) => Close(); + backgroundWorker.RunWorkerAsync(); + } + + private void backgroundWorker_ProgressChanged(object? sender, ProgressChangedEventArgs e) + { + MessageText.Text = $"Loading driver {e.ProgressPercentage} of {_driverCount} ..."; + } + + private void InjectDriver(object? sender, DoWorkEventArgs e) + { + var worker = sender as BackgroundWorker; + var proc = new System.Diagnostics.Process(); + proc.StartInfo.FileName = "drvload.exe"; + proc.StartInfo.UseShellExecute = false; + proc.StartInfo.CreateNoWindow = true; + proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + + var currentDriverCount = 1; + foreach (var driver in _driverList) + { + worker?.ReportProgress(currentDriverCount); + proc.StartInfo.Arguments = driver; + proc.Start(); + proc.WaitForExit(); + + if (proc.ExitCode != 0) + { + MessageBox.Show($"Error ({proc.ExitCode}) loading driver: {driver}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } + + currentDriverCount++; + } + } + } +} diff --git a/deploya/deployaUI/deployaUI.csproj b/deploya/deployaUI/deployaUI.csproj index 3f82c1d..63ffbb5 100644 --- a/deploya/deployaUI/deployaUI.csproj +++ b/deploya/deployaUI/deployaUI.csproj @@ -16,7 +16,7 @@ Dive Exploitox valnoxy - 1.0.0.347 + 1.0.0.359 Copyright (c) 2018 - 2023 Exploitox. All rights reserved. https://github.com/valnoxy/dive https://github.com/valnoxy/dive