Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesigned process name filter system, added MS Office to ignore list #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 15 additions & 46 deletions UEVR/ExecutableFilter.cs
Original file line number Diff line number Diff line change
@@ -1,57 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using Newtonsoft.Json;
using System.IO;
using System.Security.Cryptography;
using System.Text.Json;

namespace UEVR {
public class ExecutableFilter {
private HashSet<string> m_invalidExecutables = new HashSet<string>();
namespace UEVR;

public ExecutableFilter() {
var filter = LoadFilterList();
if (filter != null) {
m_invalidExecutables = new HashSet<string>(filter);
}
}

private List<string>? LoadFilterList() {
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "UEVR.FilteredExecutables.json";
public class ExecutableFilter {
const string RESOURCE_NAME = "UEVR.PlainTextFilteredExecutables.json";

using (Stream? stream = assembly.GetManifestResourceStream(resourceName)) {
if (stream == null) {
return new List<String>();
}
readonly List<string> invalidExecutableNames = new();

using (StreamReader reader = new StreamReader(stream)) {
string json = reader.ReadToEnd();
return JsonConvert.DeserializeObject<List<string>>(json);
}
}
}
public ExecutableFilter() {
var assembly = Assembly.GetExecutingAssembly();

private string HashString(string text) {
using (SHA256 sha256 = SHA256.Create()) {
byte[] hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(text));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++) {
sb.Append(hash[i].ToString("X2"));
}
return sb.ToString();
}
}

public bool IsValidExecutable(string executableName) {
// Hash the incoming executable name
string hashedExecutableName = HashString(executableName);

// Return true if the hashed executable is not in the list of non-games
return !m_invalidExecutables.Contains(hashedExecutableName);
using (var stream = assembly.GetManifestResourceStream(RESOURCE_NAME)) {
if (stream == null) return;
var deserializedList = JsonSerializer.Deserialize<List<string>>(stream);
if (deserializedList != null) invalidExecutableNames = deserializedList;
}
}
}

public bool IsValidExecutable(string executableName)
=> !invalidExecutableNames.Any(n => string.Equals(executableName, n, StringComparison.OrdinalIgnoreCase));
}
51 changes: 0 additions & 51 deletions UEVR/FilteredExecutables.json

This file was deleted.

76 changes: 40 additions & 36 deletions UEVR/PlainTextFilteredExecutables.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
[
"adobe audition",
"adobe media encoder",
"applicationframehost",
"calculatorapp",
"chrome",
"devenv",
"ds4windows",
"epicgameslauncher",
"excel",
"explorer",
"svchost",
"systemsettings",
"firefox",
"chrome",
"holoshellapp",
"hxcalendarappimm",
"hxoutlook",
"ida",
"ida64",
"illustrator",
"mpv",
"msedge",
"calculatorapp",
"applicationframehost",
"wwahost",
"microsoft.media.player",
"microsoft.msn.weather",
"notepad",
"notepad++",
"nvidia share",
"textinputhost",
"devenv",
"steam",
"steamwebhelper",
"obs64",
"oculusclient",
"oculusdebugtool",
"outlook",
"ovrserver_x64",
"vrmonitor",
"microsoft.media.player",
"microsoft.msn.weather",
"ida",
"ida64",
"photoshop",
"powerpnt",
"sharex",
"spotify",
"hxoutlook",
"hxcalendarappimm",
"steam",
"steamvr_desktop_game_theater",
"steamwebhelper",
"sublime_merge",
"sublime_text",
"xboxpcapp",
"xboxapp",
"winstore.app",
"virtualdesktop.streamer",
"steamvr_desktop_game_theater",
"ds4windows",
"epicgameslauncher",
"sharex",
"holoshellapp",
"winrar",
"svchost",
"systemsettings",
"taskmgr",
"telegram",
"textinputhost",
"virtualdesktop.streamer",
"vrmonitor",
"vrserver",
"windowsterminal",
"photoshop",
"adobe audition",
"adobe media encoder",
"illustrator",
"obs64",
"notepad",
"notepad++",
"mpv",
"telegram"
"winrar",
"winword",
"winstore.app",
"wwahost",
"xboxapp",
"xboxpcapp"
]
9 changes: 2 additions & 7 deletions UEVR/UEVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<ItemGroup>
<None Remove="discord.png" />
<None Remove="donate.png" />
<None Remove="FilteredExecutables.json" />
<None Remove="github.png" />
<None Remove="PlainTextFilteredExecutables.json" />
<None Remove="UEVR.png" />
<None Remove="UEVR2.png" />
</ItemGroup>
Expand All @@ -34,15 +34,14 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="FilteredExecutables.json" />
<EmbeddedResource Include="PlainTextFilteredExecutables.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MaterialDesignColors" Version="2.1.2" />
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand All @@ -52,10 +51,6 @@
<Resource Include="UEVR2.png" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="python hash_executables.py" />
</Target>

<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
Expand Down