Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
Rockstar games bought on Epic start through an EpicGamesLauncher.exe stand-in so the Rockstar launcher accepts the entitlement (#93)
Gauthier Piarrettea854c7349b23
diff --git a/.gitignore b/.gitignoreindex 0cc6177..3f3dbde 100644--- a/.gitignore+++ b/.gitignore@@ -12,3 +12,4 @@ private/*.d*.swiftdepsScripts/winlist+spike/epic-stub/EpicGamesLauncher.exediff --git a/Scripts/make-app.sh b/Scripts/make-app.shindex 0a501df..5769652 100755--- a/Scripts/make-app.sh+++ b/Scripts/make-app.sh@@ -24,6 +24,17 @@ cp spike/engine-manifest.json "$APP/Contents/Resources/engine-manifest.json"# Other engines the app can offer (previous ones for rollback, candidates for Advanced).if ls spike/engines/*.json >/dev/null 2>&1; then mkdir -p "$APP/Contents/Resources/engines"; cp spike/engines/*.json "$APP/Contents/Resources/engines/"; ficp spike/d3dmetal-license.txt "$APP/Contents/Resources/d3dmetal-license.txt"+# The EpicGamesLauncher.exe stand-in for Rockstar games bought on Epic (highball#93), built from+# spike/epic-stub/EpicGamesLauncher.c with mingw. A release must carry it; a debug build without+# mingw goes on without it and the Epic launch path says so in the log.+if command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1; then+ spike/epic-stub/build.sh >/dev/null+ cp spike/epic-stub/EpicGamesLauncher.exe "$APP/Contents/Resources/EpicGamesLauncher.exe"+elif [ "$CONFIG" = release ]; then+ echo "error: release build needs mingw-w64 (brew install mingw-w64) to build spike/epic-stub" >&2; exit 1+else+ echo "note: no mingw-w64, the Epic launcher stand-in is not bundled (debug build)"+fiRECIPES="../highball-db/recipes"if [ ! -d "$RECIPES" ]; thenRECIPES=".build/highball-db/recipes"diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swiftindex 0d8e9d8..c0931d1 100644--- a/Sources/HighballApp/AppState.swift+++ b/Sources/HighballApp/AppState.swift@@ -303,7 +303,8 @@ final class AppState {launchGame(game, in: bottle, renderer: renderer)case .epic:guard let game = epicOwned.first(where: { $0.app_name == item.epicAppName }) else { return }- epicPlay(game, in: bottle, renderer: renderer)+ epicPlay(game, in: bottle, renderer: renderer,+ throughEpicLauncherStandIn: fixRecipe(for: item)?.requires?.contains("rockstar") == true)case .pin:guard let pin = bottle.settings.pins.first(where: { $0.id == item.pinID }) else { return }launch(pin: pin, in: bottle)@@ -1653,7 +1654,13 @@ final class AppState {}// renderer nil = the bottle's own renderer (the old hardcoded .dxvk default ignored it).- func epicPlay(_ game: EpicStore.Game, in bottle: Bottle, renderer: Renderer? = nil) {+ /// `throughEpicLauncherStandIn`: a Rockstar game bought on Epic (its recipe requires the+ /// Rockstar launcher) starts through a stand-in named EpicGamesLauncher.exe placed in the+ /// game folder, because the Rockstar launcher accepts the Epic entitlement only while a+ /// process of that name exists (highball#93). The stand-in ships in the app bundle, built+ /// from spike/epic-stub; it starts the real executable with Legendary's arguments and lives+ /// as long as the game.+ func epicPlay(_ game: EpicStore.Game, in bottle: Bottle, renderer: Renderer? = nil, throughEpicLauncherStandIn: Bool = false) {guard let engine = engine(for: bottle) else { return }if runningSessions.contains(where: { $0.title == game.app_title && $0.bottleName == bottle.name }) {fail(HighballError.failed("\(game.app_title) is already running."))@@ -1666,8 +1673,18 @@ final class AppState {let runner = WineRunner(paths: paths, engine: engine, bottle: bottle)let box = LaunchOutcome()let log = logLine(box)+ var executable = info.executable, arguments = info.arguments+ if throughEpicLauncherStandIn {+ if let standIn = Self.placeEpicLauncherStandIn(in: info.executable.deletingLastPathComponent()) {+ appendLog("\(game.app_title): Rockstar game bought on Epic, starting through the EpicGamesLauncher.exe stand-in")+ executable = standIn+ arguments = [info.executable.lastPathComponent] + info.arguments+ } else {+ appendLog("\(game.app_title): this build has no EpicGamesLauncher.exe stand-in, the Rockstar launcher may not accept the Epic copy")+ }+ }watchedLaunch(box) {- try await runner.start(info.executable, arguments: info.arguments,+ try await runner.start(executable, arguments: arguments,renderer: renderer, extraEnvironment: info.environment,workingDirectory: info.workingDirectory, onOutput: log)}@@ -1687,6 +1704,18 @@ final class AppState {}}+ /// Copies the bundled EpicGamesLauncher.exe stand-in into the game folder when it is missing+ /// or differs, and returns its location. Nil when this build has none (a debug build without+ /// mingw) or the folder cannot be written.+ nonisolated static func placeEpicLauncherStandIn(in gameDir: URL) -> URL? {+ guard let bundled = Bundle.main.url(forResource: "EpicGamesLauncher", withExtension: "exe"),+ let data = try? Data(contentsOf: bundled) else { return nil }+ let target = gameDir.appending(path: "EpicGamesLauncher.exe")+ if let existing = try? Data(contentsOf: target), existing == data { return target }+ do { try data.write(to: target, options: .atomic) } catch { return nil }+ return target+ }+func setDpi(_ scale: Int, in bottle: Bottle) {guard let engine = engine(for: bottle) else { return }var copy = bottlediff --git a/spike/epic-stub/EpicGamesLauncher.c b/spike/epic-stub/EpicGamesLauncher.cnew file mode 100644index 0000000..22c197e--- /dev/null+++ b/spike/epic-stub/EpicGamesLauncher.c@@ -0,0 +1,55 @@+/* EpicGamesLauncher.exe stand-in for Rockstar games bought on Epic (highball#93).+ *+ * The Rockstar Games Launcher accepts an Epic entitlement only while a process named+ * EpicGamesLauncher.exe exists. Highball starts this program under that name from the game's+ * folder with the real executable and Legendary's launch arguments after it; it starts that+ * command in the same folder and stays alive until the game exits, which is all the launcher+ * checks. Same idea as Heroic's stand-in (BananaWorks07/heroic-epic-integration, MIT), written+ * from scratch here so the source ships with Highball and builds with mingw at app build time.+ *+ * Usage: EpicGamesLauncher.exe <program.exe> [arguments...]+ */+#include <windows.h>+#include <stdio.h>+#include <string.h>+#include <wchar.h>++int wmain(int argc, wchar_t **argv)+{+ if (argc < 2) { fwprintf(stderr, L"usage: EpicGamesLauncher.exe <program.exe> [arguments...]\n"); return 2; }++ /* Run from the folder this stand-in lives in, which is the game folder. */+ wchar_t dir[MAX_PATH];+ GetModuleFileNameW(NULL, dir, MAX_PATH);+ wchar_t *slash = wcsrchr(dir, L'\\');+ if (slash) *slash = 0;++ /* Command line: "<program>" then the arguments, each quoted if it has a space. */+ size_t len = 4;+ for (int i = 1; i < argc; i++) len += wcslen(argv[i]) + 4;+ wchar_t *cmd = (wchar_t *)HeapAlloc(GetProcessHeap(), 0, len * sizeof(wchar_t));+ if (!cmd) return 3;+ cmd[0] = 0;+ for (int i = 1; i < argc; i++) {+ if (i > 1) wcscat(cmd, L" ");+ int quote = wcschr(argv[i], L' ') != NULL;+ if (quote) wcscat(cmd, L"\"");+ wcscat(cmd, argv[i]);+ if (quote) wcscat(cmd, L"\"");+ }++ /* A leftover Steam id would make the game look for Steam instead of Epic. */+ SetEnvironmentVariableW(L"SteamAppId", NULL);+ SetEnvironmentVariableW(L"SteamGameId", NULL);++ STARTUPINFOW si; PROCESS_INFORMATION pi;+ ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); ZeroMemory(&pi, sizeof(pi));+ if (!CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, dir, &si, &pi)) {+ fwprintf(stderr, L"EpicGamesLauncher stand-in: could not start %ls (error %lu)\n", argv[1], GetLastError());+ return 1;+ }+ WaitForSingleObject(pi.hProcess, INFINITE);+ DWORD code = 0; GetExitCodeProcess(pi.hProcess, &code);+ CloseHandle(pi.hThread); CloseHandle(pi.hProcess);+ return (int)code;+}diff --git a/spike/epic-stub/build.sh b/spike/epic-stub/build.shnew file mode 100755index 0000000..a88b9c2--- /dev/null+++ b/spike/epic-stub/build.sh@@ -0,0 +1,8 @@+#!/bin/bash+# Builds spike/epic-stub/EpicGamesLauncher.exe with mingw (brew install mingw-w64). make-app.sh+# runs this and ships the result in the app bundle; the source is the pinned input.+set -euo pipefail+cd "$(dirname "$0")"+x86_64-w64-mingw32-gcc -O2 -s -municode -mwindows -static -o EpicGamesLauncher.exe EpicGamesLauncher.c+ls -la EpicGamesLauncher.exe | awk '{print $5, $9}'+shasum -a 256 EpicGamesLauncher.exe