mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-21 15:27:43 +01:00
Now we have to implement custom Process.Start()
This commit is contained in:
parent
e216227429
commit
3e6675adc0
3 changed files with 24 additions and 8 deletions
|
|
@ -54,9 +54,18 @@ namespace Dalamud.Bootstrap
|
||||||
// Acquire the process handle and read the command line
|
// Acquire the process handle and read the command line
|
||||||
using var process = Process.Open(pid);
|
using var process = Process.Open(pid);
|
||||||
|
|
||||||
var argument = ReadGameArgument(process);
|
var argument = ReadArgumentFromProcess(process);
|
||||||
|
|
||||||
|
var newTick = Environment.TickCount;
|
||||||
|
var newKey = newTick & 0xFFFF_0000; // only the high nibble is used
|
||||||
|
|
||||||
|
var newArgument = argument.Remove("T")
|
||||||
|
.Add("T", $"{newTick}")
|
||||||
|
.ToString();
|
||||||
|
|
||||||
|
// TODO: encode as a encrypted?
|
||||||
|
// TODO: launch it
|
||||||
|
|
||||||
argument.Remove("T");
|
|
||||||
//var newCommandLine =
|
//var newCommandLine =
|
||||||
// TODO:
|
// TODO:
|
||||||
// .... if arg1 exists
|
// .... if arg1 exists
|
||||||
|
|
@ -85,13 +94,13 @@ namespace Dalamud.Bootstrap
|
||||||
return createdTick & 0xFFFF_0000;
|
return createdTick & 0xFFFF_0000;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArgumentBuilder ReadGameArgument(Process process)
|
private static ArgumentBuilder ReadArgumentFromProcess(Process process)
|
||||||
{
|
{
|
||||||
var arguments = process.ReadArguments();
|
var arguments = process.ReadArguments();
|
||||||
|
|
||||||
if (arguments.Length < 1)
|
if (arguments.Length < 1)
|
||||||
{
|
{
|
||||||
throw new BootstrapException($"Process id {process.Id} does not have any arguments to parse.");
|
throw new BootstrapException($"Process id {process.GetPid()} does not have any arguments to parse.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var argument = arguments[0];
|
var argument = arguments[0];
|
||||||
|
|
@ -99,10 +108,10 @@ namespace Dalamud.Bootstrap
|
||||||
if (EncryptedArgument.TryParse(argument, out var encryptedArgument))
|
if (EncryptedArgument.TryParse(argument, out var encryptedArgument))
|
||||||
{
|
{
|
||||||
var key = RecoverKey(process);
|
var key = RecoverKey(process);
|
||||||
//
|
argument = encryptedArgument.Decrypt(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ArgumentBuilder.TryParse(argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@ namespace Dalamud.Bootstrap.SqexArg
|
||||||
{
|
{
|
||||||
internal static class EncryptedArgumentExtensions
|
internal static class EncryptedArgumentExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argument"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="SqexArgException">Thrown when the data property does not have a valid base64 string.</exception>
|
||||||
public static string Decrypt(this EncryptedArgument argument, uint key)
|
public static string Decrypt(this EncryptedArgument argument, uint key)
|
||||||
{
|
{
|
||||||
Span<byte> keyBytes = stackalloc byte[8];
|
Span<byte> keyBytes = stackalloc byte[8];
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace Dalamud.Bootstrap
|
||||||
return new Process(handle);
|
return new Process(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint GetPid() => Win32.GetProcessId(m_handle);
|
public uint GetPid() => Win32.GetProcessId(m_handle);
|
||||||
|
|
||||||
public void Terminate(uint exitCode = 0)
|
public void Terminate(uint exitCode = 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue