Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make steam hook work with Unreal Engine games #283

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 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,20 @@ IHook<T> HookExportedFunction<T>(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
Expand Down
Loading