Skip to main content

GeneralUpdate.Drivelution

Namespace: GeneralUpdate.Drivelution | Main Entry Point: GeneralDrivelution (static class) | NuGet Package: GeneralUpdate.Drivelution

1. Component Overview

1.1 Introduction

GeneralUpdate.Drivelution is a cross-platform driver update component. It structures the error-prone steps of driver updates into a unified pipeline: platform detection → permission check → file validation (hash/signature/compatibility) → backup → install → verification → rollback on failure, invoking native system tools on Windows, Linux, and macOS respectively.

Driver updates differ fundamentally from application file replacement. Drivers affect the kernel, device nodes, system extensions, or driver repositories, requiring special attention to administrator privileges, signature trust, target OS and CPU architecture, install command return values, reboot requirements, and failure recovery paths.

Core Capabilities:

CapabilityDescription
Cross-Platform AbstractionGeneralDrivelution.Create() auto-detects platform and creates the appropriate implementation
Standard Update PipelinePermission check → file validation → backup → install → verify → rollback
File ValidationFile existence, SHA256/MD5 hash, Authenticode/GPG/codesign signature, OS/arch compatibility
Backup & RollbackRequireBackup defaults to true; auto-rollback on failure with RollbackAsync for explicit recovery
Windows InstallationVia pnputil.exe /add-driver /install for INF driver packages
Linux InstallationSupports .ko (insmod/modprobe), .deb (dpkg -i), .rpm (rpm -ivh/dnf install)
macOS InstallationSupports .kext (kextload), .dext (SystemExtensions), .pkg (installer)
Batch UpdatesBatchUpdateAsync with BatchMode.Sequential and BatchMode.Parallel
Progress ReportingVia IProgress<UpdateProgress> reporting step-level progress, status, and messages
Trace LoggingGeneralTracer with console + daily-rotating file output

Business Problems Solved:

  • Hardware vendor clients need to deliver driver updates alongside apps, but OS-specific driver installation methods vary widely
  • Driver installation requires administrator privileges, signature verification, architecture compatibility, and other safeguards
  • Failed driver installations need reliable rollback to avoid leaving devices unusable

Use Cases:

  • Hardware vendor clients: network cards, capture cards, USB devices, virtual device drivers
  • Enterprise/industrial sites: batch scan driver packages and update by manifest
  • Installer/maintenance tools: unified handling of Windows/Linux/macOS driver differences

1.2 Environment & Dependencies

ItemDescription
Version10.5.0-beta.2
Target Frameworksnet8.0 / net10.0 (multi-target)
DependenciesMicrosoft.Extensions.DependencyInjection, Microsoft.Extensions.Logging.Abstractions, Microsoft.Extensions.Options
CompatibilityWindows (full, admin required) / Linux (root/sudo) / macOS (SIP & system extension policies apply)

2. Feature List

FeatureDescriptionTypeRequiredNotes
Single Driver Quick UpdateQuickUpdateAsync with default safe strategyCoreOptionalCustom strategy recommended for production
Custom Strategy UpdateUpdateAsync with UpdateStrategy and DrivelutionOptionsCoreRecommendedControl backup, retry, timeout, restart
Driver ValidationFile existence, SHA256 hash, signature, OS/arch compatibilityCoreOptionalValidateAsync; can skip via strategy flags
Driver BackupBackup driver files before updateCoreAutomaticRequireBackup defaults to true
Driver RollbackRestore driver from backup pathCoreOptionalRollbackAsync(backupPath)
Directory ScanningScan and parse driver info (.inf/.ko/.kext etc.)CoreOptionalGetDriversFromDirectoryAsync
Batch UpdatesBatch update by manifest, sequential or parallelExtendedOptionalBatchUpdateAsync
Platform Info QueryGet current OS/arch/version/support statusCoreOptionalGetPlatformInfo()
Restart Behavior ControlUpdateStrategy.RestartMode sets restart intentExtendedOptionalPipeline does not auto-restart; use RestartHelper
DI RegistrationAddDrivelution extension registers platform servicesExtendedOptionalSupports Generic Host / ASP.NET Core
Trace LoggingGeneralTracer runtime diagnostic logsExtendedOptionalEnabled by default, can be disabled

3. API Configuration Reference

3.1 Configuration Properties (Props)

DriverInfo:

FieldTypeDefaultRequiredValuesDescription
Namestring""YesDriver name
Versionstring""RecommendedSemVer formatDriver version
FilePathstring""YesValid file pathWin: .inf; Linux: .ko/.deb/.rpm; macOS: .kext/.dext/.pkg
TargetOSstring""Optional"Windows"/"Linux"/"MacOS"No restriction when empty
Architecturestring""Optional"x64"/"amd64"/"x86"/"arm64"/"arm"Common alias normalization; no restriction when empty
HardwareIdstring""OptionalHardware ID or module alias
Hashstring""OptionalSHA256/MD5 valueHash verified when non-empty and SkipHashValidation = false
HashAlgorithmstring"SHA256"Optional"SHA256" / "MD5"Hash algorithm
TrustedPublishersList<string>new()OptionalSignature verified when non-empty and SkipSignatureValidation = false
Descriptionstring""OptionalDriver description
ReleaseDateDateTimeOptionalRelease date
MetadataDictionary<string, string>new()OptionalExtended metadata

UpdateStrategy:

FieldTypeDefaultRequiredValuesDescription
RequireBackupbooltrueOptionaltrue / falseExecute backup step
BackupPathstring""RecommendedValid directory pathBackup root path
RestartModeRestartModePromptOptionalNone, Prompt, Delayed, ImmediatePipeline does not auto-restart system
SkipHashValidationboolfalseOptionaltrue / falseSkip hash check (debug only)
SkipSignatureValidationboolfalseOptionaltrue / falseSkip signature check (debug only)
TimeoutSecondsint300OptionalPositive integerSingle update timeout
RetryCountint3OptionalPositive integerRetry count (actual retry from DrivelutionOptions)
ModeUpdateModeFullOptionalFull, IncrementalUpdate mode
ForceUpdateboolfalseOptionaltrue / falseForce update
Priorityint0OptionalPriority

DrivelutionOptions:

FieldTypeDefaultRequiredDescription
DefaultBackupPathstring"./DriverBackups"OptionalDefault backup path
DefaultRetryCountint3OptionalDefault retry count
DefaultRetryIntervalSecondsint5OptionalDefault retry interval
DefaultTimeoutSecondsint300OptionalDefault timeout
DebugModeSkipSignatureboolfalseOptionalDebug: skip signature
DebugModeSkipHashboolfalseOptionalDebug: skip hash
ForceTerminateOnPermissionFailurebooltrueOptionalTerminate on permission failure
AutoCleanupBackupsbooltrueOptionalAuto-clean old backups
BackupsToKeepint5OptionalNumber of backups to keep
UseExponentialBackoffboolfalseOptionalUse exponential backoff

3.2 Instance Methods

GeneralDrivelution (static):

MethodParametersReturnsUse CaseNotes
Create(DrivelutionOptions?)optionsIGeneralDrivelutionCreate platform driver updaterAuto-detects platform
Create(IServiceProvider)serviceProviderIGeneralDrivelutionFrom DI containerFalls back to auto-detect if not registered
QuickUpdateAsync(DriverInfo, UpdateStrategy?, IProgress<UpdateProgress>?, CancellationToken)driverInfo, strategy?, progress?, ctTask<UpdateResult>Quick single driver updateUses safe defaults
ValidateAsync(DriverInfo, CancellationToken)driverInfo, ctTask<bool>Standalone validation
GetPlatformInfo()NonePlatformInfoQuery platform infoOS/arch/version/support status
GetDriversFromDirectoryAsync(string, string?, CancellationToken)path, searchPattern?, ctTask<List<DriverInfo>>Scan directory for driversDefault pattern varies by platform
BatchUpdateAsync(IEnumerable<DriverInfo>, UpdateStrategy, BatchMode, IProgress<UpdateProgress>?, CancellationToken)drivers, strategy, mode, progress?, ctTask<BatchUpdateResult>Batch update multiple driversParallel may contend for system resources

IGeneralDrivelution:

MethodParametersReturnsUse Case
UpdateAsync(...)Same as QuickUpdateAsyncTask<UpdateResult>Full update pipeline
ValidateAsync(...)Task<bool>Standalone validation
BackupAsync(DriverInfo, string, CancellationToken)driverInfo, backupPath, ctTask<bool>Standalone backup
RollbackAsync(string, CancellationToken)backupPath, ctTask<bool>Restore from backup
GetDriversFromDirectoryAsync(...)Task<List<DriverInfo>>Scan directory
BatchUpdateAsync(...)Task<BatchUpdateResult>Batch update

3.3 Callback Events

Drivelution reports progress via IProgress<UpdateProgress> rather than a dedicated event system.

Progress FieldTypeDescription
CurrentStatusUpdateStatusCurrent status (Validating/BackingUp/Updating/Verifying/Succeeded/Failed/RolledBack)
StepNamestringCurrent step name
PercentageintProgress percentage (0-100)
MessagestringProgress message
StepIndexintCurrent step index
TotalStepsintTotal step count

4. Advanced Examples

4.1 Extension Points Overview

Extension InterfaceDescription
IGeneralDrivelutionFully replace driver updater behavior
IDriverValidatorCustom file validation logic
IDriverBackupCustom backup/restore strategy
ICommandRunnerCustom system command executor
INetworkDownloaderReserved interface (network download)
BaseDriverUpdaterAbstract base class for new platform implementations

4.2 Examples by Scenario

Scenario 1: Custom Strategy + Rollback

Description: Production driver update with all security checks enabled; explicit rollback on failure.

using GeneralUpdate.Drivelution;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
using GeneralUpdate.Drivelution.Abstractions.Models;

var updater = GeneralDrivelution.Create(new DrivelutionOptions
{
DefaultBackupPath = @"C:\DriverBackups",
DefaultRetryCount = 3,
DefaultTimeoutSeconds = 600,
UseExponentialBackoff = true
});

var strategy = new UpdateStrategy
{
RequireBackup = true,
BackupPath = @"C:\DriverBackups\graphics",
TimeoutSeconds = 600,
RestartMode = RestartMode.Prompt
};

var driver = new DriverInfo
{
Name = "Graphics Driver",
Version = "2.1.0",
FilePath = @"C:\Drivers\graphics.inf",
TargetOS = "Windows",
Architecture = "x64",
Hash = "expected-sha256...",
TrustedPublishers = { "Contoso Hardware Inc." }
};

var progress = new Progress<UpdateProgress>(p =>
Console.WriteLine($"[{p.StepName}] {p.Percentage}%: {p.Message}"));

var result = await updater.UpdateAsync(driver, strategy, progress);

if (!result.Success && result.BackupPath is not null)
await updater.RollbackAsync(result.BackupPath);

if (result.Success && RestartHelper.IsRestartRequired(strategy.RestartMode))
await RestartHelper.HandleRestartAsync(strategy.RestartMode, 60, "Driver updated. Restart now?");

Scenario 2: DI Container Integration

Description: Register driver update services via DI in ASP.NET Core / Generic Host apps.

using GeneralUpdate.Drivelution.Core;

builder.Services.AddDrivelution(options =>
{
options.DefaultBackupPath = "./DriverBackups";
options.DefaultTimeoutSeconds = 600;
options.DefaultRetryCount = 3;
});

// Use in controller or service
app.MapPost("/drivers/update", async (DriverInfo driver, IGeneralDrivelution updater) =>
{
var result = await updater.UpdateAsync(driver, new UpdateStrategy());
return result.Success ? Results.Ok(result) : Results.BadRequest(result.Error);
});

Scenario 3: Batch Parallel Scanning + Sequential Installation

Description: Large projects scan and validate all drivers in parallel, then install core drivers sequentially by risk group.

var drivers = await GeneralDrivelution.GetDriversFromDirectoryAsync(@"C:\DriverPackages");

var validDrivers = new List<DriverInfo>();
foreach (var d in drivers)
if (await GeneralDrivelution.ValidateAsync(d))
validDrivers.Add(d);

var coreDrivers = validDrivers.Where(d => IsCoreDriver(d)).ToList();
var optionalDrivers = validDrivers.Except(coreDrivers).ToList();

// Core drivers: sequential install
if (coreDrivers.Any())
await GeneralDrivelution.BatchUpdateAsync(coreDrivers, new UpdateStrategy { RequireBackup = true }, BatchMode.Sequential);

// Optional drivers: parallel install
if (optionalDrivers.Any())
await GeneralDrivelution.BatchUpdateAsync(optionalDrivers, new UpdateStrategy { RequireBackup = true }, BatchMode.Parallel);

5. Basic Usage Examples

5.1 Quick Start (Minimal Demo)

using GeneralUpdate.Drivelution;
using GeneralUpdate.Drivelution.Abstractions.Models;

var driver = new DriverInfo
{
Name = "MyDevice Driver",
Version = "1.2.0",
FilePath = @"C:\Drivers\mydevice.inf",
TargetOS = "Windows",
Architecture = "x64",
Hash = "driver-file-sha256",
HashAlgorithm = "SHA256",
TrustedPublishers = { "Contoso Hardware" }
};

var result = await GeneralDrivelution.QuickUpdateAsync(driver);

if (result.Success)
Console.WriteLine($"Driver updated successfully in {result.DurationMs}ms.");
else
Console.WriteLine($"Update failed: {result.Error?.Message}");

5.2 Basic Parameter Combination

var platform = GeneralDrivelution.GetPlatformInfo();
Console.WriteLine($"OS: {platform.OperatingSystem}, Arch: {platform.Architecture}");

var drivers = await GeneralDrivelution.GetDriversFromDirectoryAsync(@"C:\Drivers");
Console.WriteLine($"Found {drivers.Count} driver(s).");

var updater = GeneralDrivelution.Create(new DrivelutionOptions
{
DefaultBackupPath = @"C:\DriverBackups",
DefaultRetryCount = 3,
DefaultTimeoutSeconds = 600
});

var strategy = new UpdateStrategy
{
RequireBackup = true,
BackupPath = @"C:\DriverBackups\mydevice",
TimeoutSeconds = 300
};

var result = await updater.UpdateAsync(drivers[0], strategy,
new Progress<UpdateProgress>(p => Console.WriteLine($"{p.StepName}: {p.Percentage}%")));

5.3 Production-Ready Example

See the Chinese documentation for a full workflow covering scan, validate, install, rollback, and restart.


6. Global Configuration

Platform Quick Reference

PlatformDriver FormatInstall CommandSignature VerificationPermission Required
Windows.infpnputil.exe /add-driver /installAuthenticodeAdministrator
Linux.ko / .deb / .rpminsmod/modprobe / dpkg -i / rpm -ivhGPG (.sig/.asc)root/sudo
macOS.kext / .dext / .pkgkextload / SystemExtensions / installercodesign -vroot (SIP & user approval)

Logging Configuration

GeneralTracer.SetTracingEnabled(false);  // Disable for performance
GeneralTracer.SetTracingEnabled(true); // Re-enable for troubleshooting