Skip to content

Commit

Permalink
Make steam hook work with Unreal Engine games
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimatedSwine37 committed Jan 28, 2024
1 parent 069bb53 commit 50d1d46
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/Reloaded.Mod.Loader/Utilities/Steam/SteamHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,6 +48,19 @@ IHook<T> HookExportedFunction<T>(IntPtr libraryHandle, string functionName, T ha
}
}

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
Expand Down

0 comments on commit 50d1d46

Please sign in to comment.