Skip to content

Commit

Permalink
Add ability to detect executable names not adhering to '*-WinGDK-Ship…
Browse files Browse the repository at this point in the history
…ping' convention

Test game for that is 'Submerged Hidden Depths' which has main .exe named just Submerged.exe
  • Loading branch information
keton committed Jan 26, 2024
1 parent 693cfd2 commit 2080c3f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,23 @@ public static async Task WaitBeforeInjectionAsync(StatusContext ctx, int waitTim

public static bool IsUnrealExecutable(string gameExe) {
var ueSuffixes = ImmutableArray.Create("-WinGDK-Shipping", "-Win64-Shipping");
var uePathSuffixes = ImmutableArray.Create("\\Binaries\\Win64", "\\Binaries\\WinGDK");

return ueSuffixes.Any(elem => Path.GetFileNameWithoutExtension(gameExe).EndsWith(elem));
return ueSuffixes.Any(elem => Path.GetFileNameWithoutExtension(gameExe).EndsWith(elem))
|| uePathSuffixes.Any(elem => (Path.GetDirectoryName(gameExe) ?? "").EndsWith(elem));
}

public static string? TryFindMainExecutable(string gameExe) {
if (IsUnrealExecutable(gameExe)) return gameExe;

var mainExeGlobs = ImmutableArray.Create("*\\Binaries\\Win64\\*-Win64-Shipping.exe", "*\\Binaries\\WinGDK\\*-WinGDK-Shipping.exe");
var exeBaseName = Path.GetFileNameWithoutExtension(gameExe);

var mainExeGlobs = ImmutableArray.Create(
"*\\Binaries\\Win64\\*-Win64-Shipping.exe",
"*\\Binaries\\WinGDK\\*-WinGDK-Shipping.exe",
$"*\\Binaries\\Win64\\{exeBaseName}.exe",
$"*\\Binaries\\WinGDK\\{exeBaseName}.exe"
);

var matcher = new Matcher();
matcher.AddIncludePatterns(mainExeGlobs);
Expand Down

0 comments on commit 2080c3f

Please sign in to comment.