mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-20 06:47:44 +01:00
duck tape tier quality(TM)
This commit is contained in:
parent
33145ea0f2
commit
c1ed673f22
5 changed files with 44 additions and 32 deletions
17
Dalamud.Bootstrap/BootstrapException.cs
Normal file
17
Dalamud.Bootstrap/BootstrapException.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Dalamud.Bootstrap
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An error that is thrown when bootstraping Dalamud failed.
|
||||||
|
/// </summary>
|
||||||
|
public class BootstrapException : Exception
|
||||||
|
{
|
||||||
|
internal BootstrapException() : base() { }
|
||||||
|
|
||||||
|
internal BootstrapException(string message) : base(message) { }
|
||||||
|
|
||||||
|
internal BootstrapException(string message, Exception innerException) : base(message, innerException) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,37 +27,34 @@ namespace Dalamud.Bootstrap.SqexArg
|
||||||
m_key = key;
|
m_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryParse(string argument, out EncodedArgument? value)
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="argument"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static EncodedArgument Parse(string argument)
|
||||||
{
|
{
|
||||||
if (argument.Length <= 17)
|
if (argument.Length <= 17)
|
||||||
{
|
{
|
||||||
// does not contain: //**sqex0003 + payload + checksum + **//
|
// does not contain: //**sqex0003 + payload + checksum + **//
|
||||||
value = null;
|
var exMessage = $"The string ({argument}) is too short to parse encoded argument.";
|
||||||
return false;
|
throw new SqexArgException(exMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!argument.StartsWith("//**sqex0003") || !argument.EndsWith("**//"))
|
if (!argument.StartsWith("//**sqex0003") || !argument.EndsWith("**//"))
|
||||||
{
|
{
|
||||||
value = null;
|
var exMessage = $"The string ({argument}) doesn't look like valid encoded argument format."
|
||||||
return false;
|
+ $"It either doesn't start with //**sqeex003 or end with **// marker.";
|
||||||
|
throw new SqexArgException(exMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
var checksum = argument[^5];
|
var checksum = argument[^5];
|
||||||
var payload = DecodeUrlSafeBase64(argument.Substring(12, argument.Length - 1 - 12 - 4)); // //**sqex0003, checksum, **//
|
var payload = DecodeUrlSafeBase64(argument.Substring(12, argument.Length - 1 - 12 - 4)); // //**sqex0003, checksum, **//
|
||||||
|
|
||||||
if (!FindPartialKey(checksum, out var partialKey))
|
// ...
|
||||||
{
|
|
||||||
value = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0u; i <= 0xFFF; i++)
|
|
||||||
{
|
|
||||||
var key = (i << 20) | partialKey;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool FindPartialKey(char checksum, out uint recoveredKey)
|
private static bool GetKeyFragmentFromChecksum(char checksum, out uint recoveredKey)
|
||||||
{
|
{
|
||||||
var index = MemoryExtensions.IndexOf(ChecksumTable, checksum);
|
var index = MemoryExtensions.IndexOf(ChecksumTable, checksum);
|
||||||
|
|
||||||
|
|
|
||||||
11
Dalamud.Bootstrap/SqexArg/SqexArgException.cs
Normal file
11
Dalamud.Bootstrap/SqexArg/SqexArgException.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Dalamud.Bootstrap.SqexArg
|
||||||
|
{
|
||||||
|
public class SqexArgException : Exception
|
||||||
|
{
|
||||||
|
public SqexArgException() { }
|
||||||
|
public SqexArgException(string message) : base(message) { }
|
||||||
|
public SqexArgException(string message, Exception inner) : base(message, inner) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,21 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace Dalamud.Bootstrap
|
namespace Dalamud.Bootstrap.Windows
|
||||||
{
|
{
|
||||||
/// <summary>
|
public class ProcessException : Exception
|
||||||
/// An error that is thrown when bootstraping Dalamud failed.
|
|
||||||
/// </summary>
|
|
||||||
public class BootstrapException : Exception
|
|
||||||
{
|
|
||||||
internal BootstrapException() : base() { }
|
|
||||||
|
|
||||||
internal BootstrapException(string message) : base(message) { }
|
|
||||||
|
|
||||||
internal BootstrapException(string message, Exception innerException) : base(message, innerException) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ProcessException : BootstrapException
|
|
||||||
{
|
{
|
||||||
public uint Pid { get; }
|
public uint Pid { get; }
|
||||||
|
|
||||||
|
|
@ -69,6 +69,6 @@ class DalamudBuild : NukeBuild
|
||||||
.Executes(() =>
|
.Executes(() =>
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
Direct
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue