diff --git a/source/Reloaded.Mod.Loader/EntryPoint.cs b/source/Reloaded.Mod.Loader/EntryPoint.cs index a4039b4f..af0fb08e 100644 --- a/source/Reloaded.Mod.Loader/EntryPoint.cs +++ b/source/Reloaded.Mod.Loader/EntryPoint.cs @@ -63,7 +63,7 @@ private static void SetupLoader() private static void CreateHost() => _server = new Host(_loader); private static unsafe void PerformPeOperations() { - _basicPeParser = new BasicPeParser(Process.GetCurrentProcess().MainModule.FileName); + _basicPeParser = new BasicPeParser(Environment.CurrentProcessLocation.Value); // Check for Steam DRM. DRMNotifier.PrintWarnings(_basicPeParser, _loader.Console); diff --git a/source/Reloaded.Mod.Loader/Loader.cs b/source/Reloaded.Mod.Loader/Loader.cs index ac6b16fc..7f734050 100644 --- a/source/Reloaded.Mod.Loader/Loader.cs +++ b/source/Reloaded.Mod.Loader/Loader.cs @@ -213,7 +213,7 @@ private HashSet GetDependenciesForMods(IEnumerable mods, I private IApplicationConfig FindThisApplication() { var configurations = ApplicationConfig.GetAllApplications(LoaderConfig.ApplicationConfigDirectory); - var fullPath = NormalizePath(Path.GetFullPath(Process.GetCurrentProcess().MainModule.FileName)); + var fullPath = NormalizePath(Environment.CurrentProcessLocation.Value); foreach (var configuration in configurations) { diff --git a/source/Reloaded.Mod.Shared/Environment.cs b/source/Reloaded.Mod.Shared/Environment.cs index 28dd6a31..9d80cf72 100644 --- a/source/Reloaded.Mod.Shared/Environment.cs +++ b/source/Reloaded.Mod.Shared/Environment.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.IO; using System.Runtime.InteropServices; namespace Reloaded.Mod.Shared @@ -10,6 +12,11 @@ public static class Environment /// public static bool IsWine { get; private set; } + /// + /// Gets the full path to the current process. + /// + public static Lazy CurrentProcessLocation { get; private set; } = new Lazy(() => Path.GetFullPath(Process.GetCurrentProcess().MainModule.FileName)); + static Environment() { var ntdll = GetModuleHandle("ntdll.dll");