duck tape tier quality(TM)

This commit is contained in:
Mino 2020-03-14 14:45:12 +09:00
parent 33145ea0f2
commit c1ed673f22
5 changed files with 44 additions and 32 deletions

View 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) { }
}
}

View file

@ -27,37 +27,34 @@ namespace Dalamud.Bootstrap.SqexArg
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)
{
// does not contain: //**sqex0003 + payload + checksum + **//
value = null;
return false;
var exMessage = $"The string ({argument}) is too short to parse encoded argument.";
throw new SqexArgException(exMessage);
}
if (!argument.StartsWith("//**sqex0003") || !argument.EndsWith("**//"))
{
value = null;
return false;
var exMessage = $"The string ({argument}) doesn't look like valid encoded argument format."
+ $"It either doesn't start with //**sqeex003 or end with **// marker.";
throw new SqexArgException(exMessage);
}
var checksum = argument[^5];
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);

View 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) { }
}
}

View file

@ -1,21 +1,8 @@
using System;
using System.ComponentModel;
namespace Dalamud.Bootstrap
namespace Dalamud.Bootstrap.Windows
{
/// <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) { }
}
public class ProcessException : BootstrapException
public class ProcessException : Exception
{
public uint Pid { get; }

View file

@ -69,6 +69,6 @@ class DalamudBuild : NukeBuild
.Executes(() =>
{
// TODO
Direct
});
}