/// <summary> /// Performs driver installation. /// </summary> /// <returns>true if driver was installed successfully, false otherwise.</returns> public static async Task <bool> InstallDriver() { return(await Task.Factory.StartNew(() => { try { var processStartInfo = new ProcessStartInfo { FileName = Path.Combine(DriverDirectory, PlatformPath, InstallerExecutable), Arguments = $"install \"{Path.Combine(DriverDirectory, PlatformPath, InfFileName)}\" \"{Hwid}\"", CreateNoWindow = true, UseShellExecute = false, Verb = "runas", RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }; var installerProcess = Process.Start(processStartInfo); installerProcess?.WaitForExit(); return installerProcess?.ExitCode == 0; } catch (Exception e) { HydraLogger.Error("Could not install TAP driver: {0}", e); return false; } })); }
/// <summary> /// Performs logging initialization. /// </summary> private void InitializeLogging() { var loggerListener = new EventLoggerListener(); loggerListener.LogEntryArrived += (sender, args) => AddLogEntry(args.Entry); HydraLogger.AddHandler(loggerListener); }
/// <summary> /// Runs hydra service installer. /// </summary> /// <param name="verb">One of the following: "install", "uninstall".</param> /// <returns>true if the process was successful</returns> private static async Task <bool> RunServiceInstaller(string verb) { return(await Task.Factory.StartNew(() => { try { var processStartInfo = new ProcessStartInfo { FileName = HydraSdkWindowsServiceExecutable, Arguments = $"-{verb} {ServiceName}", CreateNoWindow = true, UseShellExecute = false, Verb = "runas", RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }; var installerProcess = Process.Start(processStartInfo); installerProcess?.WaitForExit(); return installerProcess?.ExitCode == 0; } catch (Exception e) { HydraLogger.Error("Could not install hydra service: {0}", e); return false; } })); }