From e0dd85db1a7633c358dcc087026b6f29db402460 Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Fri, 5 Jan 2024 00:06:44 +0100 Subject: [PATCH] FIx path issue with driver install offline --- DriverUpdater/DismProvider.cs | 69 +++++++++++++++-------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/DriverUpdater/DismProvider.cs b/DriverUpdater/DismProvider.cs index 37470ec..15365a1 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(string DriverRepo, IEnumerable definitionPaths) + public bool InstallDrivers(IEnumerable infFiles) { Logging.Log("Enumerating existing drivers..."); @@ -190,55 +190,46 @@ public bool InstallDrivers(string DriverRepo, IEnumerable definitionPath Logging.Log("Installing new drivers..."); - foreach (string path in definitionPaths) - { - Logging.Log(path); + Progress = 0; + startTime = DateTime.Now; - // The where LINQ call is because directory can return .inf_ as well... - IEnumerable infFiles = Directory.EnumerateFiles($"{DriverRepo}\\{path}", "*.inf", SearchOption.AllDirectories) - .Where(x => x.EndsWith(".inf", StringComparison.InvariantCultureIgnoreCase)); + // Install every inf present in the component folder + foreach (string inf in infFiles) + { + // First add the driver package to the image + Console.Title = $"Driver Updater - DismApi->AddDriver - {inf}"; + Logging.ShowProgress(Progress++, infFiles.Count(), startTime, false); - Progress = 0; - startTime = DateTime.Now; + const int maxAttempts = 3; + int currentFails = 0; + ntStatus = 0; - // Install every inf present in the component folder - foreach (string inf in infFiles) + while (currentFails < maxAttempts) { - // First add the driver package to the image - Console.Title = $"Driver Updater - DismApi->AddDriver - {inf}"; - Logging.ShowProgress(Progress++, infFiles.Count(), startTime, false); - - const int maxAttempts = 3; - int currentFails = 0; - ntStatus = 0; + ntStatus = AddOfflineDriver(inf); - while (currentFails < maxAttempts) + // Invalid ARG can be thrown when an issue happens with a specific driver inf + // No investigation done yet, but for now, this will do just fine + if ((ntStatus & 0x80000000) != 0) { - ntStatus = AddOfflineDriver(inf); - - // Invalid ARG can be thrown when an issue happens with a specific driver inf - // No investigation done yet, but for now, this will do just fine - if ((ntStatus & 0x80000000) != 0) - { - currentFails++; - } - else - { - break; - } + currentFails++; } - - if ((ntStatus & 0x80000000) != 0) + else { - Logging.Log(""); - Logging.Log($"DismApi->AddDriver: ntStatus=0x{ntStatus:X8}, driverInf={inf}", Logging.LoggingLevel.Error); - - //return false; + break; } } - Logging.ShowProgress(infFiles.Count(), infFiles.Count(), startTime, false); - Logging.Log(""); + + if ((ntStatus & 0x80000000) != 0) + { + Logging.Log(""); + Logging.Log($"DismApi->AddDriver: ntStatus=0x{ntStatus:X8}, driverInf={inf}", Logging.LoggingLevel.Error); + + //return false; + } } + Logging.ShowProgress(infFiles.Count(), infFiles.Count(), startTime, false); + Logging.Log(""); return true; }