diff --git a/Il2CppInspector.CLI/PathUtils.cs b/Il2CppInspector.CLI/PathUtils.cs
new file mode 100644
index 0000000..3ad11f7
--- /dev/null
+++ b/Il2CppInspector.CLI/PathUtils.cs
@@ -0,0 +1,47 @@
+// Copyright (c) 2017-2021 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
+// All rights reserved
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace Il2CppInspector.CLI;
+
+public static class PathUtils
+{
+ public static string FindPath(string pathWithWildcards) {
+ var absolutePath = Path.GetFullPath(pathWithWildcards);
+
+ if (!absolutePath.Contains('*', StringComparison.Ordinal))
+ return absolutePath;
+
+ // Backslash is a special character when evaluating regexes so Windows path separator must be escaped... with a backslash
+ var sections = new Regex(string.Format(@"((?:[^*]*){0})((?:.*?)\*.*?)(?:$|{0})",
+ Path.DirectorySeparatorChar == '\\' ? @"\\" : Path.DirectorySeparatorChar.ToString()));
+ var matches = sections.Matches(absolutePath);
+
+ var pathLength = 0;
+ var path = "";
+ foreach (Match match in matches)
+ {
+ path += match.Groups[1].Value;
+ var search = match.Groups[2].Value;
+
+ if (!Directory.Exists(path))
+ return null;
+
+ var dir = Directory.GetDirectories(path, search, SearchOption.TopDirectoryOnly)
+ .OrderByDescending(x => x)
+ .FirstOrDefault();
+
+ path = dir + Path.DirectorySeparatorChar;
+ pathLength += match.Groups[1].Value.Length + match.Groups[2].Value.Length + 1;
+ }
+
+ if (pathLength < absolutePath.Length)
+ path += absolutePath[pathLength..];
+
+ return path;
+ }
+}
\ No newline at end of file
diff --git a/Il2CppInspector.CLI/Program.cs b/Il2CppInspector.CLI/Program.cs
index 7cc7786..313f145 100644
--- a/Il2CppInspector.CLI/Program.cs
+++ b/Il2CppInspector.CLI/Program.cs
@@ -172,11 +172,10 @@ namespace Il2CppInspector.CLI
}
private static int Run(Options options) {
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
// Banner
- var location = Assembly.GetEntryAssembly().Location;
- if (location == "") // Single file executables don't have an assembly location
- location = Path.Join(AppContext.BaseDirectory, "Il2CppInspector.exe");
+ var location = Path.Join(AppContext.BaseDirectory, "Il2CppInspector.exe");
var asmInfo = FileVersionInfo.GetVersionInfo(location);
Console.WriteLine(asmInfo.ProductName);
@@ -189,7 +188,7 @@ namespace Il2CppInspector.CLI
try {
PluginManager.EnsureInit();
}
- catch (Exception ex) when (ex is InvalidOperationException || ex is DirectoryNotFoundException) {
+ catch (Exception ex) when (ex is InvalidOperationException or DirectoryNotFoundException) {
Console.Error.WriteLine(ex.Message);
return 1;
}
@@ -260,8 +259,8 @@ namespace Il2CppInspector.CLI
var unityAssembliesPath = string.Empty;
if (options.CreateSolution) {
- unityPath = Utils.FindPath(options.UnityPath);
- unityAssembliesPath = Utils.FindPath(options.UnityAssembliesPath);
+ unityPath = PathUtils.FindPath(options.UnityPath);
+ unityAssembliesPath = PathUtils.FindPath(options.UnityAssembliesPath);
if (!Directory.Exists(unityPath)) {
Console.Error.WriteLine($"Unity path {unityPath} does not exist");
diff --git a/Il2CppInspector.CLI/Utils.cs b/Il2CppInspector.CLI/Utils.cs
deleted file mode 100644
index 1fa0c9a..0000000
--- a/Il2CppInspector.CLI/Utils.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2017-2021 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
-// All rights reserved
-
-using System;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
-
-namespace Il2CppInspector
-{
- public class Utils
- {
- public static string FindPath(string pathWithWildcards) {
- var absolutePath = Path.GetFullPath(pathWithWildcards);
-
- if (absolutePath.IndexOf("*", StringComparison.Ordinal) == -1)
- return absolutePath;
-
- // Backslash is a special character when evaluating regexes so Windows path separator must be escaped... with a backslash
- Regex sections = new Regex(string.Format(@"((?:[^*]*){0})((?:.*?)\*.*?)(?:$|{0})",
- Path.DirectorySeparatorChar == '\\' ? @"\\" : Path.DirectorySeparatorChar.ToString()));
- var matches = sections.Matches(absolutePath);
-
- var pathLength = 0;
- var path = "";
- foreach (Match match in matches) {
- path += match.Groups[1].Value;
- var search = match.Groups[2].Value;
-
- if (!Directory.Exists(path))
- return null;
-
- var dir = Directory.GetDirectories(path, search, SearchOption.TopDirectoryOnly)
- .OrderByDescending(x => x)
- .FirstOrDefault();
-
- path = dir + Path.DirectorySeparatorChar;
- pathLength += match.Groups[1].Value.Length + match.Groups[2].Value.Length + 1;
- }
-
- if (pathLength < absolutePath.Length)
- path += absolutePath.Substring(pathLength);
-
- return path;
- }
- }
-}
\ No newline at end of file
diff --git a/Il2CppInspector.GUI/Il2CppInspector.GUI.csproj b/Il2CppInspector.GUI/Il2CppInspector.GUI.csproj
index 58dc43a..0a4bef8 100644
--- a/Il2CppInspector.GUI/Il2CppInspector.GUI.csproj
+++ b/Il2CppInspector.GUI/Il2CppInspector.GUI.csproj
@@ -23,10 +23,6 @@
false
-
-
-
-
diff --git a/Il2CppInspector.GUI/MainWindow.xaml.cs b/Il2CppInspector.GUI/MainWindow.xaml.cs
index b198a5b..8b97cb6 100644
--- a/Il2CppInspector.GUI/MainWindow.xaml.cs
+++ b/Il2CppInspector.GUI/MainWindow.xaml.cs
@@ -58,8 +58,8 @@ namespace Il2CppInspectorGUI
// Find Unity paths
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
- txtUnityPath.Text = Utils.FindPath($@"{programFiles}\Unity\Hub\Editor\*") ?? "";
- txtUnityScriptPath.Text = Utils.FindPath($@"{programFiles}\Unity\Hub\Editor\*\Editor\Data\Resources\PackageManager\ProjectTemplates\libcache\com.unity.template.3d-*\ScriptAssemblies") ?? "";
+ txtUnityPath.Text = PathUtils.FindPath($@"{programFiles}\Unity\Hub\Editor\*") ?? "";
+ txtUnityScriptPath.Text = PathUtils.FindPath($@"{programFiles}\Unity\Hub\Editor\*\Editor\Data\Resources\PackageManager\ProjectTemplates\libcache\com.unity.template.3d-*\ScriptAssemblies") ?? "";
// Populate script target combo box and select IDA by default
cboPyTarget.ItemsSource = PythonScript.GetAvailableTargets();
diff --git a/Il2CppInspector.GUI/PathUtils.cs b/Il2CppInspector.GUI/PathUtils.cs
new file mode 100644
index 0000000..1aac04d
--- /dev/null
+++ b/Il2CppInspector.GUI/PathUtils.cs
@@ -0,0 +1,48 @@
+// Copyright (c) 2017-2021 Katy Coe - https://www.djkaty.com - https://github.com/djkaty
+// All rights reserved
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace Il2CppInspector.GUI;
+
+public static class PathUtils
+{
+ public static string FindPath(string pathWithWildcards)
+ {
+ var absolutePath = Path.GetFullPath(pathWithWildcards);
+
+ if (!absolutePath.Contains('*', StringComparison.Ordinal))
+ return absolutePath;
+
+ // Backslash is a special character when evaluating regexes so Windows path separator must be escaped... with a backslash
+ var sections = new Regex(string.Format(@"((?:[^*]*){0})((?:.*?)\*.*?)(?:$|{0})",
+ Path.DirectorySeparatorChar == '\\' ? @"\\" : Path.DirectorySeparatorChar.ToString()));
+ var matches = sections.Matches(absolutePath);
+
+ var pathLength = 0;
+ var path = "";
+ foreach (Match match in matches)
+ {
+ path += match.Groups[1].Value;
+ var search = match.Groups[2].Value;
+
+ if (!Directory.Exists(path))
+ return null;
+
+ var dir = Directory.GetDirectories(path, search, SearchOption.TopDirectoryOnly)
+ .OrderByDescending(x => x)
+ .FirstOrDefault();
+
+ path = dir + Path.DirectorySeparatorChar;
+ pathLength += match.Groups[1].Value.Length + match.Groups[2].Value.Length + 1;
+ }
+
+ if (pathLength < absolutePath.Length)
+ path += absolutePath[pathLength..];
+
+ return path;
+ }
+}
\ No newline at end of file