diff --git a/IPA/Program.cs b/IPA/Program.cs index 2dd05d27..2f4faa8a 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -95,10 +95,13 @@ namespace IPA AppDomain.CurrentDomain.AssemblyResolve += AssemblyLibLoader; var argExeName = Arguments.CmdLine.PositionalArgs.FirstOrDefault(s => s.EndsWith(".exe")); + argExeName ??= new DirectoryInfo(Directory.GetCurrentDirectory()).GetFiles() + .FirstOrDefault(o => o.Extension == ".exe" && o.FullName != Assembly.GetEntryAssembly().Location) + ?.FullName; if (argExeName == null) - context = PatchContext.Create(new DirectoryInfo(Directory.GetCurrentDirectory()).GetFiles() - .First(o => o.Extension == ".exe" && o.FullName != Assembly.GetEntryAssembly().Location) - .FullName); + { + Fail("Could not locate game executable"); + } else context = PatchContext.Create(argExeName); @@ -341,7 +344,7 @@ namespace IPA } } - + [DoesNotReturn] private static void Fail(string message) { Console.Error.WriteLine("ERROR: " + message); diff --git a/IPA/_Attributes.cs b/IPA/_Attributes.cs new file mode 100644 index 00000000..72f7b779 --- /dev/null +++ b/IPA/_Attributes.cs @@ -0,0 +1,10 @@ +#if NET461 +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + public sealed class DoesNotReturnAttribute : Attribute + { + public DoesNotReturnAttribute() { } + } +} +#endif \ No newline at end of file