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 e0dd85d
Showing 1 changed file with 30 additions and 39 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

0 comments on commit e0dd85d

Please sign in to comment.