mirror of
https://github.com/Jacobwasbeast/LegacyWeaveLoader.git
synced 2026-07-06 10:48:13 +00:00
feat(launcher): pass through game args
This commit is contained in:
@@ -32,6 +32,7 @@ class Program
|
||||
{
|
||||
var config = Config.Load(configFile);
|
||||
bool extensiveSymbolScan = false;
|
||||
var passthroughArgs = new List<string>();
|
||||
|
||||
foreach (string arg in args)
|
||||
{
|
||||
@@ -46,6 +47,10 @@ class Program
|
||||
config.GameExePath = arg;
|
||||
config.Save(configFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
passthroughArgs.Add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(config.GameExePath) || !File.Exists(config.GameExePath))
|
||||
@@ -144,9 +149,13 @@ class Program
|
||||
if (extensiveSymbolScan)
|
||||
Console.WriteLine("[..] Extensive symbol scan mode enabled");
|
||||
|
||||
if (passthroughArgs.Count > 0)
|
||||
Console.WriteLine($"[..] Passing {passthroughArgs.Count} arg(s) to game");
|
||||
|
||||
string? extraArgs = BuildArgString(passthroughArgs, extensiveSymbolScan);
|
||||
var process = Injector.LaunchSuspended(
|
||||
config.GameExePath,
|
||||
extraArgs: extensiveSymbolScan ? "--extensive-symbol-scan" : null);
|
||||
extraArgs: extraArgs);
|
||||
Console.WriteLine($"[OK] Game process created (PID: {process.ProcessId})");
|
||||
Console.WriteLine($"[..] Injecting {RuntimeDllName}...");
|
||||
|
||||
@@ -220,4 +229,28 @@ class Program
|
||||
Console.WriteLine($"[WARN] Failed to delete {path}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private static string? BuildArgString(List<string> passthroughArgs, bool extensiveSymbolScan)
|
||||
{
|
||||
var args = new List<string>();
|
||||
if (extensiveSymbolScan)
|
||||
args.Add("--extensive-symbol-scan");
|
||||
args.AddRange(passthroughArgs);
|
||||
if (args.Count == 0)
|
||||
return null;
|
||||
for (int i = 0; i < args.Count; i++)
|
||||
args[i] = QuoteArg(args[i]);
|
||||
return string.Join(" ", args);
|
||||
}
|
||||
|
||||
private static string QuoteArg(string arg)
|
||||
{
|
||||
if (string.IsNullOrEmpty(arg))
|
||||
return "\"\"";
|
||||
bool needsQuotes = arg.IndexOfAny(new[] { ' ', '\t', '"' }) >= 0;
|
||||
if (!needsQuotes)
|
||||
return arg;
|
||||
string escaped = arg.Replace("\"", "\\\"");
|
||||
return $"\"{escaped}\"";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user