From 440d769f5ccb400555a2c7d9c05e790830191dee Mon Sep 17 00:00:00 2001 From: commonuserlol Date: Sat, 28 Dec 2024 19:04:52 +0200 Subject: [PATCH 1/2] Program: Resolve ~ as user home C# treats ~ as directory in cwd, so you have to pass absolute path instead (like /home/user) Test: ./bin/Release/net9.0/linux-x64/Cpp2IL --game-path=~/Downloads/merged.apk Result: [Fail] [Program] Execution Failed: Could not find a valid unity game at /home/commonuserlol/projects/Cpp2IL/Cpp2IL/~/Downloads/merged.apk Result after fix: [Warn] [Program] No output format requested, so not outputting anything. The il2cpp game loaded properly though! Credit: https://stackoverflow.com/questions/4796254/relative-path-to-absolute-path-in-c --- Cpp2IL/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cpp2IL/Program.cs b/Cpp2IL/Program.cs index a93af49d..c92d1d8b 100644 --- a/Cpp2IL/Program.cs +++ b/Cpp2IL/Program.cs @@ -522,7 +522,7 @@ private static Cpp2IlRuntimeArgs GetRuntimeOptionsFromCommandLine(string[] comma if (options.ForcedBinaryPath == null) { - ResolvePathsFromCommandLine(options.GamePath, options.ExeName, ref result); + ResolvePathsFromCommandLine(options.GamePath.Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)), options.ExeName, ref result); } else { From 87fff371b52701db92bc7ac6c96689ea5e4314fb Mon Sep 17 00:00:00 2001 From: commonuserlol Date: Sun, 5 Jan 2025 19:42:55 +0200 Subject: [PATCH 2/2] Replace only first character --- Cpp2IL/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Cpp2IL/Program.cs b/Cpp2IL/Program.cs index c92d1d8b..4abf2471 100644 --- a/Cpp2IL/Program.cs +++ b/Cpp2IL/Program.cs @@ -522,7 +522,9 @@ private static Cpp2IlRuntimeArgs GetRuntimeOptionsFromCommandLine(string[] comma if (options.ForcedBinaryPath == null) { - ResolvePathsFromCommandLine(options.GamePath.Replace("~", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)), options.ExeName, ref result); + if (options.GamePath.StartsWith("~")) + options.GamePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + options.GamePath.Substring(1); + ResolvePathsFromCommandLine(options.GamePath, options.ExeName, ref result); } else { @@ -534,7 +536,7 @@ private static Cpp2IlRuntimeArgs GetRuntimeOptionsFromCommandLine(string[] comma if (result.UnityVersion.Type == UnityVersionType.Alpha && result.UnityVersion.Build == 0) //Map a0 to f1 - we assume the user simply didn't provide the final part of the version number result.UnityVersion = new UnityVersion(result.UnityVersion.Major, result.UnityVersion.Minor, result.UnityVersion.Build, UnityVersionType.Final, 1); - + result.Valid = true; }