Added launcher
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Prospect.Launcher.Invoke;
|
||||
using Prospect.Launcher.Invoke.Structs;
|
||||
|
||||
namespace Prospect.Launcher
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Steam AppId.
|
||||
/// </summary>
|
||||
private const string AppId = "1600360";
|
||||
|
||||
/// <summary>
|
||||
/// Executable name of the game.
|
||||
/// </summary>
|
||||
private const string FileName = "Prospect-Win64-Shipping.exe";
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
Console.WriteLine("Usage: ./Prospect.Launcher <Game directory>");
|
||||
return;
|
||||
}
|
||||
|
||||
var gamePath = Path.Combine(args[0], "Prospect", "Binaries", "Win64");
|
||||
var gameBinary = Path.Combine(gamePath, FileName);
|
||||
var gameArgs = new List<string>();
|
||||
|
||||
// 2EA46 = Default
|
||||
// A22AB = The Cycle Playtest
|
||||
gameArgs.Add("-log");
|
||||
gameArgs.Add("-windowed");
|
||||
gameArgs.Add("-noeac");
|
||||
gameArgs.Add("-nointro");
|
||||
gameArgs.Add("-steam_auth");
|
||||
gameArgs.Add("PF_TITLEID=A22AB");
|
||||
|
||||
// Ensure "steam_appid.txt" exists, to fix steam authentication.
|
||||
var steamAppId = Path.Combine(gamePath, "steam_appid.txt");
|
||||
|
||||
if (!File.Exists(steamAppId))
|
||||
{
|
||||
File.WriteAllText(steamAppId, AppId);
|
||||
}
|
||||
|
||||
// Spawn.
|
||||
var startupInfo = new StartupInfo();
|
||||
|
||||
if (!Kernel32.CreateProcess(gameBinary, string.Join(' ', gameArgs), ProcessCreationFlags.ZERO_FLAG, ref startupInfo, out var processInfo))
|
||||
{
|
||||
Console.WriteLine("Failed to spawn game.");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Spawned.");
|
||||
|
||||
// Modify.
|
||||
MemoryHelper memory;
|
||||
|
||||
while ((memory = MemoryHelper.CreateForHandle(processInfo.hProcess, gameBinary)) == null)
|
||||
{
|
||||
Console.WriteLine("Failed to obtain MemoryHelper.");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
if (!Patches.ChangePlayFabUrl(memory, ".localhost"))
|
||||
{
|
||||
Console.WriteLine("Failed to patch playfab url.");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Patched.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user