/// <summary> /// Loads the specified driver. /// </summary> public bool LoadDriver() { if (!this.IsCreated) { throw new Exception("Service is not created."); } if (this.IsLoaded) { return(true); } DSEFix.DisableSecurity(); try { this.Service.Start(); } catch (InvalidOperationException Exception) { DSEFix.EnableSecurity(); return(false); } catch (Win32Exception Exception) { DSEFix.EnableSecurity(); if (Exception.Message.Contains("signature")) { Log.Warning(typeof(DseLoad), "The driver is not signed, unable to load it using the service manager."); } return(false); } try { this.Service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(10)); } catch (TimeoutException) { Log.Error(typeof(DseLoad), "Failed to start the service in 10 seconds."); } DSEFix.EnableSecurity(); if (this.Service.Status != ServiceControllerStatus.Running) { return(false); } this.IsLoaded = true; return(true); }
/// <summary> /// Loads the specified driver. /// </summary> public bool LoadDriver() { if (!this.IsCreated) { throw new Exception("Driver is not created."); } if (this.IsLoaded) { if (this.Service.Status != ServiceControllerStatus.Running) { return(false); } return(true); } DSEFix.DisableSecurity(); try { this.Service.Start(); } catch (InvalidOperationException Exception) { DSEFix.EnableSecurity(); return(false); } catch (Win32Exception Exception) { DSEFix.EnableSecurity(); return(false); } DSEFix.EnableSecurity(); try { this.Service.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(5)); } catch (System.ServiceProcess.TimeoutException) { return(false); } this.IsLoaded = true; return(true); }