/// <summary> /// Attempts to stop this kernel service on the local machine. /// </summary> public ulong TryStopDriver() { // // Acquire the privilege to unload kernel drivers. // WinApi.AddPrivilege("SeLoadDriverPrivilege"); // // Manually unload the driver by calling the Windows API. // var ServiceName = new WindowsService.UNICODE_STRING("\\" + string.Join("\\", "Registry", "Machine", this.WindowsService.RegistryPathRelativeToLocalMachine)); var ReturnStatus = 0Lu; unsafe { ReturnStatus = WindowsService.NtUnloadDriver(&ServiceName); } // // Release the privilege to unload kernel drivers. // WinApi.RemovePrivilege("SeLoadDriverPrivilege"); return(ReturnStatus); }