mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 14:23:40 +01:00
EncodedArg
This commit is contained in:
parent
a01bc259a8
commit
c6a9879498
3 changed files with 46 additions and 48 deletions
|
|
@ -46,7 +46,12 @@ namespace Dalamud.Bootstrap
|
|||
using var process = Process.Open(pid);
|
||||
var commandLine = process.ReadCommandLine();
|
||||
|
||||
var argument = ArgumentDecoder.Decode(commandLine[1]);
|
||||
if (!ArgumentContainer.Parse(commandLine[1], out var container))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO:
|
||||
// .... if arg1 exists
|
||||
// DecodeSqexArg(arguments[1]);
|
||||
|
|
|
|||
40
Dalamud.Bootstrap/SqexArg/ArgumentContainer.cs
Normal file
40
Dalamud.Bootstrap/SqexArg/ArgumentContainer.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Bootstrap.SqexArg
|
||||
{
|
||||
internal sealed class ArgumentContainer
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="argument"></param>
|
||||
/// <param name="container"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Parse(string argument, out ArgumentContainer? container)
|
||||
{
|
||||
if (argument.Length < 17)
|
||||
{
|
||||
// does not contain: //**sqex003 + payload + checksum + **//
|
||||
container = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!argument.StartsWith("//**sqex003") || !argument.EndsWith("**//"))
|
||||
{
|
||||
container = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var checksum = argument[^5];
|
||||
var payload = argument[11..^5]
|
||||
.Replace(; // encoded in url-safe variant of base64
|
||||
|
||||
// decode
|
||||
|
||||
Convert.FromBase64String();
|
||||
container = new ArgumentContainer(payload, checksum);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Bootstrap.SqexArg
|
||||
{
|
||||
internal static class ArgumentDecoder
|
||||
{
|
||||
public static ArgumentBuilder Decode(ReadOnlySpan<char> argument, uint key)
|
||||
{
|
||||
// 1. strip //**sqex003 and **//
|
||||
// 2. extract checksum
|
||||
// 3. deduce upper nibble key
|
||||
// 4.
|
||||
|
||||
// //**c**//
|
||||
if (argument.Length <= 9)
|
||||
{
|
||||
throw new ArgumentException(nameof(argument));
|
||||
}
|
||||
|
||||
if (!argument.StartsWith("//**") || !argument.EndsWith("**//"))
|
||||
{
|
||||
throw new ArgumentException(nameof(argument));
|
||||
}
|
||||
|
||||
var payload = argument[4..^5];
|
||||
var checksum = argument[^5];
|
||||
|
||||
// undo url safe
|
||||
//payload.re
|
||||
|
||||
|
||||
|
||||
// stuff
|
||||
throw new NotImplementedException("TODO");
|
||||
}
|
||||
|
||||
private static void DecodeUrlSafeBase64(ReadOnlySpan<char> content)
|
||||
{
|
||||
var buffer = new byte[(content.Length / 3) * 4];
|
||||
if (!Convert.TryFromBase64Chars(payload, buffer, out var _))
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue