mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-05 09:11:38 -05:00
Remove OemKill
This commit is contained in:
parent
5a93b4d147
commit
4e078b1436
6 changed files with 1 additions and 262 deletions
1
.github/workflows/dotnet.yml
vendored
1
.github/workflows/dotnet.yml
vendored
|
@ -15,7 +15,6 @@ jobs:
|
||||||
- { path: OutputMode, plugin: TouchEmu }
|
- { path: OutputMode, plugin: TouchEmu }
|
||||||
- { path: OutputMode, plugin: VMultiMode }
|
- { path: OutputMode, plugin: VMultiMode }
|
||||||
- { path: OutputMode, plugin: WindowsInk }
|
- { path: OutputMode, plugin: WindowsInk }
|
||||||
- { path: Tool, plugin: OemKill }
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,7 @@ VoiDPlugins is a collection of extensions for [OpenTabletDriver](https://github.
|
||||||
Touch input emulation (RawInput incompatible)
|
Touch input emulation (RawInput incompatible)
|
||||||
Natural Scrolling everywhere
|
Natural Scrolling everywhere
|
||||||
|
|
||||||
## Tools
|
## Bindings
|
||||||
|
|
||||||
### [OemKill](https://github.com/X9VoiD/VoiDPlugins/wiki/OemKill)
|
|
||||||
|
|
||||||
Automatically kill OEM Tablet Driver processes
|
|
||||||
|
|
||||||
### [ScriptRunner](https://github.com/X9VoiD/VoiDPlugins/wiki/ScriptRunner)
|
### [ScriptRunner](https://github.com/X9VoiD/VoiDPlugins/wiki/ScriptRunner)
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
namespace VoiDPlugins.Tool
|
|
||||||
{
|
|
||||||
class IndexedInf
|
|
||||||
{
|
|
||||||
public int index;
|
|
||||||
public string inf;
|
|
||||||
public string name;
|
|
||||||
public IndexedInf(int index, string name, string inf)
|
|
||||||
{
|
|
||||||
this.index = index;
|
|
||||||
this.inf = inf;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace VoiDPlugins.Tool
|
|
||||||
{
|
|
||||||
internal static class OemData
|
|
||||||
{
|
|
||||||
public static readonly List<string> OemProcesses = new List<string>
|
|
||||||
{
|
|
||||||
// XP-Pen
|
|
||||||
"PentabletService",
|
|
||||||
"PenTablet",
|
|
||||||
|
|
||||||
// Wacom
|
|
||||||
"WacomDesktopCenter",
|
|
||||||
"Wacom_Tablet",
|
|
||||||
"Pen_Tablet",
|
|
||||||
|
|
||||||
// Gaomon
|
|
||||||
"Gaomon Tablet",
|
|
||||||
"TabletDriverCore",
|
|
||||||
|
|
||||||
// VEIKK
|
|
||||||
"TabletDriverCenter",
|
|
||||||
"TabletDriverSetting"
|
|
||||||
};
|
|
||||||
|
|
||||||
public static readonly List<string> OemDrivers = new List<string>
|
|
||||||
{
|
|
||||||
// Gaomon, Huion
|
|
||||||
"Graphics Tablet"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,191 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
|
||||||
using OpenTabletDriver.Plugin;
|
|
||||||
using OpenTabletDriver.Plugin.Attributes;
|
|
||||||
|
|
||||||
namespace VoiDPlugins.Tool
|
|
||||||
{
|
|
||||||
[PluginName("OEM Kill"), SupportedPlatform(PluginPlatform.Windows)]
|
|
||||||
public class OemKill : ITool
|
|
||||||
{
|
|
||||||
public bool Initialize()
|
|
||||||
{
|
|
||||||
Terminate();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Action("Driver", "Kill OEM Drivers"), ToolTip("Terminate known OEM Drivers")]
|
|
||||||
public static void Terminate()
|
|
||||||
{
|
|
||||||
var processList = Process.GetProcesses();
|
|
||||||
var oemProcesses = from process in processList
|
|
||||||
where OemData.OemProcesses.Contains(process.ProcessName)
|
|
||||||
select process;
|
|
||||||
|
|
||||||
if (oemProcesses.ToList().Count == 0)
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", "No oem process found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var process in oemProcesses)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
process.Kill();
|
|
||||||
Log.Write("OemKill", "Killing " + process.ProcessName);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", "Failed. Reason: " + e.Message, LogLevel.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.Write("OemKill", "Oem process killed successfully");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Action("Driver", "Restore Driver Defaults"), ToolTip("Fix issues with remnant drivers from Huion and Gaomon")]
|
|
||||||
public static void RestoreDriver()
|
|
||||||
{
|
|
||||||
RunRestore(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Action("Driver", "Simulate 'Restore Driver Defaults'"), ToolTip("Simulates driver restoration without actually doing any driver related action, and opens assets folder for inspection")]
|
|
||||||
public static void SimulateRestoreDriver()
|
|
||||||
{
|
|
||||||
RunRestore(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RunRestore(bool simulate)
|
|
||||||
{
|
|
||||||
var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
||||||
var assets = Path.Join(location, "assets");
|
|
||||||
if (!Directory.Exists(assets))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(assets);
|
|
||||||
}
|
|
||||||
|
|
||||||
RunEnum(assets, out var enumOutput);
|
|
||||||
|
|
||||||
List<IndexedInf> oemDrivers = new List<IndexedInf>();
|
|
||||||
|
|
||||||
for (int i = 0; i < enumOutput.Length; i++)
|
|
||||||
{
|
|
||||||
var infMatch = inf.Match(enumOutput[i]);
|
|
||||||
if (infMatch.Success)
|
|
||||||
{
|
|
||||||
var infName = infMatch.Groups[1].Value;
|
|
||||||
var driverName = driver.Match(enumOutput[i + 1]).Groups[1].Value;
|
|
||||||
if (OemData.OemDrivers.Contains(driverName))
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", $"Found '{driverName}' with driver '{infName}'");
|
|
||||||
oemDrivers.Add(new IndexedInf(i, driverName, infName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oemDrivers.Count == 0)
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", "No remnant driver found");
|
|
||||||
if (simulate)
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", $"You may now inspect generated scripts on: '{assets}'");
|
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo("explorer", $"{assets}");
|
|
||||||
Process.Start(startInfo);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var restoreHelperScript = Path.Join(assets, "restore.bat");
|
|
||||||
using (var restoreHelperStream = File.CreateText(restoreHelperScript))
|
|
||||||
{
|
|
||||||
restoreHelperStream.WriteLine("@echo off");
|
|
||||||
restoreHelperStream.WriteLine("echo WARNING! OTD will be closed after you press any key.");
|
|
||||||
restoreHelperStream.WriteLine("pause");
|
|
||||||
restoreHelperStream.WriteLine("taskkill /F /IM OpenTabletDriver.UX.Wpf.exe");
|
|
||||||
restoreHelperStream.WriteLine("taskkill /F /IM OpenTabletDriver.Daemon.exe");
|
|
||||||
restoreHelperStream.WriteLine("echo Script auto-generated by OemKill OTD plugin");
|
|
||||||
foreach (var oemDriver in oemDrivers)
|
|
||||||
{
|
|
||||||
restoreHelperStream.WriteLine($"echo Uninstalling '{oemDriver.name}' with driver '{oemDriver.inf}'...");
|
|
||||||
restoreHelperStream.WriteLine($"pnputil -f -d {oemDriver.inf}");
|
|
||||||
}
|
|
||||||
restoreHelperStream.WriteLine("echo Installing default driver...");
|
|
||||||
restoreHelperStream.WriteLine($"pnputil -i -a %SystemRoot%/INF/input.inf");
|
|
||||||
restoreHelperStream.WriteLine("echo Driver restore done! You may now start OTD again");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (simulate)
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", $"You may now inspect generated scripts on: '{assets}'");
|
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo("explorer", $"{assets}");
|
|
||||||
Process.Start(startInfo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Terminate();
|
|
||||||
Call(restoreHelperScript, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RunEnum(string assetsLocation, out string[] output)
|
|
||||||
{
|
|
||||||
var enumHelperScript = Path.Join(assetsLocation, "enumerator.bat");
|
|
||||||
var enumHelperOutput = Path.Join(assetsLocation, "drivers.txt");
|
|
||||||
|
|
||||||
using (var enumHelperStream = File.CreateText(enumHelperScript))
|
|
||||||
{
|
|
||||||
enumHelperStream.WriteLine(":: Script auto-generated by OemKill OTD plugin");
|
|
||||||
enumHelperStream.WriteLine($"pnputil -e > \"{enumHelperOutput}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.Write("OemKill", "Enumerating oem driver installations");
|
|
||||||
Call(enumHelperScript);
|
|
||||||
|
|
||||||
while (!File.Exists(enumHelperOutput))
|
|
||||||
{
|
|
||||||
Thread.Sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool read = false;
|
|
||||||
while (!read)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
output = File.ReadAllLines(enumHelperOutput);
|
|
||||||
read = true;
|
|
||||||
return;
|
|
||||||
} catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
output = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Call(string file, bool asAdmin = false)
|
|
||||||
{
|
|
||||||
Log.Write("OemKill", $" Calling script: '{file}'");
|
|
||||||
|
|
||||||
var info = new ProcessStartInfo("powershell")
|
|
||||||
{
|
|
||||||
CreateNoWindow = true,
|
|
||||||
Arguments = asAdmin ? $"-c start -verb runas {file}" : $"-c start {file}"
|
|
||||||
};
|
|
||||||
var process = Process.Start(info);
|
|
||||||
process.WaitForExit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly Regex inf = new Regex(":\\s*(.*\\.inf)$", RegexOptions.Compiled);
|
|
||||||
private static readonly Regex driver = new Regex(@":\s*(.*)$", RegexOptions.Compiled);
|
|
||||||
|
|
||||||
public void Dispose() { }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFrameworks>net5</TargetFrameworks>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<DebugSymbols>false</DebugSymbols>
|
|
||||||
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="../../.modules/OpenTabletDriver/OpenTabletDriver.Plugin/OpenTabletDriver.Plugin.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
Loading…
Add table
Reference in a new issue