diff --git a/DriverUpdater/DismProvider.cs b/DriverUpdater/DismProvider.cs index 15365a1..6b96363 100644 --- a/DriverUpdater/DismProvider.cs +++ b/DriverUpdater/DismProvider.cs @@ -154,7 +154,7 @@ public bool InstallApps(IEnumerable<(string, string)> deps) return true; } - public bool InstallDrivers(IEnumerable infFiles) + public bool InstallDrivers(IEnumerable infFiles, bool IsUpgrade) { Logging.Log("Enumerating existing drivers..."); @@ -166,27 +166,33 @@ public bool InstallDrivers(IEnumerable infFiles) return false; } - Logging.Log("Uninstalling drivers..."); + long Progress; + DateTime startTime; - long Progress = 0; - DateTime startTime = DateTime.Now; - - foreach (string driver in existingDrivers) + if (IsUpgrade) { - Console.Title = $"Driver Updater - RemoveOfflineDriver - {driver}"; - Logging.ShowProgress(Progress++, existingDrivers.Length, startTime, false); + Logging.Log("Uninstalling drivers..."); - ntStatus = RemoveOfflineDriver(driver); - if ((ntStatus & 0x80000000) != 0) + Progress = 0; + startTime = DateTime.Now; + + foreach (string driver in existingDrivers) { - Logging.Log(""); - Logging.Log($"RemoveOfflineDriver: ntStatus=0x{ntStatus:X8}, driver={driver}", Logging.LoggingLevel.Error); + Console.Title = $"Driver Updater - RemoveOfflineDriver - {driver}"; + Logging.ShowProgress(Progress++, existingDrivers.Length, startTime, false); - return false; + ntStatus = RemoveOfflineDriver(driver); + if ((ntStatus & 0x80000000) != 0) + { + Logging.Log(""); + Logging.Log($"RemoveOfflineDriver: ntStatus=0x{ntStatus:X8}, driver={driver}", Logging.LoggingLevel.Error); + + return false; + } } + Logging.ShowProgress(existingDrivers.Length, existingDrivers.Length, startTime, false); + Logging.Log(""); } - Logging.ShowProgress(existingDrivers.Length, existingDrivers.Length, startTime, false); - Logging.Log(""); Logging.Log("Installing new drivers..."); diff --git a/DriverUpdater/Program.cs b/DriverUpdater/Program.cs index 1591b91..80af4c9 100644 --- a/DriverUpdater/Program.cs +++ b/DriverUpdater/Program.cs @@ -84,19 +84,31 @@ private static void DriverUpdaterAction(string Definition, string DriverRepo, st try { - bool result = ResealForPnPFirstBootUx(DevicePart); + bool upgrade = ResealForPnPFirstBootUx(DevicePart); + // true = first boot completed + // false = first boot not completed - if (result) + if (upgrade) + { + Logging.Log("The device has already been booted once. Reinstalling Board Support Package."); + } + else { - result = Install(Definition, DriverRepo, DevicePart); + Logging.Log("The device has not been booted yet. Installing Board Support Package for the first time prior to first boot."); + } - if (result) + bool result = Install(Definition, DriverRepo, DevicePart, upgrade); + + if (result) + { + if (upgrade) { Logging.Log("Fixing potential registry left overs"); new RegistryFixer(DevicePart).FixRegistryPaths(); - Logging.Log("Enabling Cks"); - new CksLicensing(DevicePart).SetLicensedState(); } + + Logging.Log("Enabling Cks"); + new CksLicensing(DevicePart).SetLicensedState(); } } catch (Exception ex) @@ -188,7 +200,7 @@ private static bool ResealForPnPFirstBootUx(string DevicePart) return result; } - private static bool Install(string Definition, string DriverRepo, string DrivePath) + private static bool Install(string Definition, string DriverRepo, string DrivePath, bool IsUpgrade) { Logging.Log("Reading definition file..."); DefinitionParser definitionParser = new(Definition); @@ -261,7 +273,7 @@ private static bool Install(string Definition, string DriverRepo, string DrivePa using DismProvider dismProvider = new(DrivePath); - return dismProvider.InstallDrivers(driverPathsToInstall) && dismProvider.InstallDepApps(appPaths) && dismProvider.InstallApps(appPaths); + return dismProvider.InstallDrivers(driverPathsToInstall, IsUpgrade) && dismProvider.InstallDepApps(appPaths) && dismProvider.InstallApps(appPaths); } private static bool OnlineInstall(string Definition, string DriverRepo) diff --git a/DriverUpdater/Properties/AssemblyInfo.cs b/DriverUpdater/Properties/AssemblyInfo.cs index 4e37f37..e2b4676 100644 --- a/DriverUpdater/Properties/AssemblyInfo.cs +++ b/DriverUpdater/Properties/AssemblyInfo.cs @@ -8,5 +8,5 @@ [assembly: AssemblyCopyright("Copyright © LumiaWoA and DuoWoA authors")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("2.1.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.1.1.0")] +[assembly: AssemblyFileVersion("2.1.1.0")] \ No newline at end of file