Skip to content

Commit

Permalink
FIx path issue with driver install offline
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Jan 4, 2024
1 parent fb65c89 commit 2f259b2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 40 deletions.
69 changes: 30 additions & 39 deletions DriverUpdater/DismProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public bool InstallApps(IEnumerable<(string, string)> deps)
return true;
}

public bool InstallDrivers(string DriverRepo, IEnumerable<string> definitionPaths)
public bool InstallDrivers(IEnumerable<string> infFiles)
{
Logging.Log("Enumerating existing drivers...");

Expand Down Expand Up @@ -190,55 +190,46 @@ public bool InstallDrivers(string DriverRepo, IEnumerable<string> 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<string> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion DriverUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private static bool Install(string Definition, string DriverRepo, string DrivePa

using DismProvider dismProvider = new(DrivePath);

return dismProvider.InstallDrivers(DriverRepo, driverPathsToInstall) && dismProvider.InstallDepApps(appPaths) && dismProvider.InstallApps(appPaths);
return dismProvider.InstallDrivers(driverPathsToInstall) && dismProvider.InstallDepApps(appPaths) && dismProvider.InstallApps(appPaths);
}

private static bool OnlineInstall(string Definition, string DriverRepo)
Expand Down

0 comments on commit 2f259b2

Please sign in to comment.