diff --git a/source/Reloaded.Mod.Loader/Utilities/Steam/SteamHook.cs b/source/Reloaded.Mod.Loader/Utilities/Steam/SteamHook.cs index 7a50039b..397333d1 100644 --- a/source/Reloaded.Mod.Loader/Utilities/Steam/SteamHook.cs +++ b/source/Reloaded.Mod.Loader/Utilities/Steam/SteamHook.cs @@ -22,7 +22,7 @@ public SteamHook(IReloadedHooks hooks, Logger logger, string applicationFolder) { _applicationFolder = applicationFolder; var steamApiPath = Environment.Is64BitProcess ? Path.GetFullPath(SteamAPI64) : Path.GetFullPath(SteamAPI32); - if (!File.Exists(steamApiPath)) + if (!File.Exists(steamApiPath) && !TryFindUnrealSteamApi(out steamApiPath)) return; // Hook relevant functions @@ -48,6 +48,20 @@ IHook HookExportedFunction(IntPtr libraryHandle, string functionName, T ha } } + // This is a hack and only applies to UE4 games (leaving as is until R3) + private bool TryFindUnrealSteamApi(out string steamApiPath) + { + steamApiPath = null; + + // Assuming consistent folder structure is used for Unreal Engine games + var steamWorksPath = Path.Combine(_applicationFolder, @"..\..\..\Engine\Binaries\ThirdParty\SteamWorks"); + if (!Directory.Exists(steamWorksPath)) + return false; + + steamApiPath = Directory.EnumerateFiles(steamWorksPath, "steam_api??.dll", SearchOption.AllDirectories).FirstOrDefault(); + return steamApiPath != null; + } + private void DropSteamAppId(Logger logger) { try