mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Fix devplugins again & bump CS (#1221)
* reapply devplugins directory removal, without breaking everything
Revert "Revert "Remove support for legacy devplugins directory (#1219)" (#1220)"
This reverts commit 681cda91a4.
* bump CS
This commit is contained in:
parent
5af1425c97
commit
95b0565976
5 changed files with 103 additions and 42 deletions
|
|
@ -200,15 +200,21 @@ namespace Dalamud.Injector
|
|||
var logFile = new FileInfo(logPath);
|
||||
|
||||
if (!logFile.Exists)
|
||||
{
|
||||
logFile.Create();
|
||||
}
|
||||
|
||||
if (logFile.Length <= cullingFileSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var amountToCull = logFile.Length - cullingFileSize;
|
||||
|
||||
if (amountToCull < bufferSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using var reader = new BinaryReader(logFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
|
||||
using var writer = new BinaryWriter(logFile.Open(FileMode.Open, FileAccess.Write, FileShare.ReadWrite));
|
||||
|
|
@ -247,7 +253,6 @@ namespace Dalamud.Injector
|
|||
var workingDirectory = startInfo.WorkingDirectory;
|
||||
var configurationPath = startInfo.ConfigurationPath;
|
||||
var pluginDirectory = startInfo.PluginDirectory;
|
||||
var defaultPluginDirectory = startInfo.DefaultPluginDirectory;
|
||||
var assetDirectory = startInfo.AssetDirectory;
|
||||
var delayInitializeMs = startInfo.DelayInitializeMs;
|
||||
var logName = startInfo.LogName;
|
||||
|
|
@ -257,25 +262,41 @@ namespace Dalamud.Injector
|
|||
for (var i = 2; i < args.Count; i++)
|
||||
{
|
||||
if (args[i].StartsWith(key = "--dalamud-working-directory="))
|
||||
{
|
||||
workingDirectory = args[i][key.Length..];
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--dalamud-configuration-path="))
|
||||
{
|
||||
configurationPath = args[i][key.Length..];
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--dalamud-plugin-directory="))
|
||||
{
|
||||
pluginDirectory = args[i][key.Length..];
|
||||
else if (args[i].StartsWith(key = "--dalamud-dev-plugin-directory="))
|
||||
defaultPluginDirectory = args[i][key.Length..];
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--dalamud-asset-directory="))
|
||||
{
|
||||
assetDirectory = args[i][key.Length..];
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--dalamud-delay-initialize="))
|
||||
{
|
||||
delayInitializeMs = int.Parse(args[i][key.Length..]);
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--dalamud-client-language="))
|
||||
{
|
||||
languageStr = args[i][key.Length..].ToLowerInvariant();
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--dalamud-tspack-b64="))
|
||||
{
|
||||
troubleshootingData = Encoding.UTF8.GetString(Convert.FromBase64String(args[i][key.Length..]));
|
||||
}
|
||||
else if (args[i].StartsWith(key = "--logname="))
|
||||
{
|
||||
logName = args[i][key.Length..];
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
args.RemoveAt(i);
|
||||
i--;
|
||||
|
|
@ -287,33 +308,49 @@ namespace Dalamud.Injector
|
|||
workingDirectory ??= Directory.GetCurrentDirectory();
|
||||
configurationPath ??= Path.Combine(xivlauncherDir, "dalamudConfig.json");
|
||||
pluginDirectory ??= Path.Combine(xivlauncherDir, "installedPlugins");
|
||||
defaultPluginDirectory ??= Path.Combine(xivlauncherDir, "devPlugins");
|
||||
assetDirectory ??= Path.Combine(xivlauncherDir, "dalamudAssets", "dev");
|
||||
|
||||
ClientLanguage clientLanguage;
|
||||
if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "english").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.English;
|
||||
}
|
||||
else if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "japanese").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.Japanese;
|
||||
}
|
||||
else if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "日本語").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.Japanese;
|
||||
}
|
||||
else if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "german").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.German;
|
||||
}
|
||||
else if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "deutsch").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.German;
|
||||
}
|
||||
else if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "french").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.French;
|
||||
}
|
||||
else if (languageStr[0..(len = Math.Min(languageStr.Length, (key = "français").Length))] == key[0..len])
|
||||
{
|
||||
clientLanguage = ClientLanguage.French;
|
||||
}
|
||||
else if (int.TryParse(languageStr, out var languageInt) && Enum.IsDefined((ClientLanguage)languageInt))
|
||||
{
|
||||
clientLanguage = (ClientLanguage)languageInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new CommandLineException($"\"{languageStr}\" is not a valid supported language.");
|
||||
}
|
||||
|
||||
startInfo.WorkingDirectory = workingDirectory;
|
||||
startInfo.ConfigurationPath = configurationPath;
|
||||
startInfo.PluginDirectory = pluginDirectory;
|
||||
startInfo.DefaultPluginDirectory = defaultPluginDirectory;
|
||||
startInfo.AssetDirectory = assetDirectory;
|
||||
startInfo.Language = clientLanguage;
|
||||
startInfo.DelayInitializeMs = delayInitializeMs;
|
||||
|
|
@ -350,10 +387,14 @@ namespace Dalamud.Injector
|
|||
exeSpaces += " ";
|
||||
|
||||
if (particularCommand is null or "help")
|
||||
{
|
||||
Console.WriteLine("{0} help [command]", exeName);
|
||||
}
|
||||
|
||||
if (particularCommand is null or "inject")
|
||||
{
|
||||
Console.WriteLine("{0} inject [-h/--help] [-a/--all] [--warn] [--fix-acl] [--se-debug-privilege] [pid1] [pid2] [pid3] ...", exeName);
|
||||
}
|
||||
|
||||
if (particularCommand is null or "launch")
|
||||
{
|
||||
|
|
@ -367,7 +408,7 @@ namespace Dalamud.Injector
|
|||
}
|
||||
|
||||
Console.WriteLine("Specifying dalamud start info: [--dalamud-working-directory=path] [--dalamud-configuration-path=path]");
|
||||
Console.WriteLine(" [--dalamud-plugin-directory=path] [--dalamud-dev-plugin-directory=path]");
|
||||
Console.WriteLine(" [--dalamud-plugin-directory=path]");
|
||||
Console.WriteLine(" [--dalamud-asset-directory=path] [--dalamud-delay-initialize=0(ms)]");
|
||||
Console.WriteLine(" [--dalamud-client-language=0-3|j(apanese)|e(nglish)|d|g(erman)|f(rench)]");
|
||||
|
||||
|
|
@ -431,7 +472,7 @@ namespace Dalamud.Injector
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new CommandLineException($"\"{args[i]}\" is not a command line argument.");
|
||||
Log.Warning($"\"{args[i]}\" is not a valid command line argument, ignoring.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -505,29 +546,53 @@ namespace Dalamud.Injector
|
|||
}
|
||||
|
||||
if (args[i] == "-h" || args[i] == "--help")
|
||||
{
|
||||
showHelp = true;
|
||||
}
|
||||
else if (args[i] == "-f" || args[i] == "--fake-arguments")
|
||||
{
|
||||
useFakeArguments = true;
|
||||
}
|
||||
else if (args[i] == "--without-dalamud")
|
||||
{
|
||||
withoutDalamud = true;
|
||||
}
|
||||
else if (args[i] == "--no-wait")
|
||||
{
|
||||
waitForGameWindow = false;
|
||||
}
|
||||
else if (args[i] == "--no-fix-acl" || args[i] == "--no-acl-fix")
|
||||
{
|
||||
noFixAcl = true;
|
||||
}
|
||||
else if (args[i] == "-g")
|
||||
{
|
||||
gamePath = args[++i];
|
||||
}
|
||||
else if (args[i].StartsWith("--game="))
|
||||
{
|
||||
gamePath = args[i].Split('=', 2)[1];
|
||||
}
|
||||
else if (args[i] == "-m")
|
||||
{
|
||||
mode = args[++i];
|
||||
}
|
||||
else if (args[i].StartsWith("--mode="))
|
||||
{
|
||||
mode = args[i].Split('=', 2)[1];
|
||||
}
|
||||
else if (args[i].StartsWith("--handle-owner="))
|
||||
{
|
||||
handleOwner = IntPtr.Parse(args[i].Split('=', 2)[1]);
|
||||
}
|
||||
else if (args[i] == "--")
|
||||
{
|
||||
parsingGameArgument = true;
|
||||
}
|
||||
else
|
||||
throw new CommandLineException($"\"{args[i]}\" is not a command line argument.");
|
||||
{
|
||||
Log.Warning($"\"{args[i]}\" is not a valid command line argument, ignoring.");
|
||||
}
|
||||
}
|
||||
|
||||
var checksumTable = "fX1pGtdS5CAP4_VL";
|
||||
|
|
@ -536,11 +601,15 @@ namespace Dalamud.Injector
|
|||
gameArguments = gameArguments.SelectMany(x =>
|
||||
{
|
||||
if (!x.StartsWith("//**sqex0003") || !x.EndsWith("**//"))
|
||||
{
|
||||
return new List<string>() { x };
|
||||
}
|
||||
|
||||
var checksum = checksumTable.IndexOf(x[x.Length - 5]);
|
||||
if (checksum == -1)
|
||||
{
|
||||
return new List<string>() { x };
|
||||
}
|
||||
|
||||
var encData = Convert.FromBase64String(x.Substring(12, x.Length - 12 - 5).Replace('-', '+').Replace('_', '/').Replace('*', '='));
|
||||
var rawData = new byte[encData.Length];
|
||||
|
|
@ -554,13 +623,25 @@ namespace Dalamud.Injector
|
|||
encryptArguments = true;
|
||||
var args = argDelimiterRegex.Split(rawString).Skip(1).Select(y => string.Join('=', kvDelimiterRegex.Split(y, 2)).Replace(" ", " ")).ToList();
|
||||
if (!args.Any())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!args.First().StartsWith("T="))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!uint.TryParse(args.First().Substring(2), out var tickCount))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tickCount >> 16 != i)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return args.Skip(1);
|
||||
}
|
||||
|
||||
|
|
@ -712,7 +793,9 @@ namespace Dalamud.Injector
|
|||
if (handleOwner != IntPtr.Zero)
|
||||
{
|
||||
if (!DuplicateHandle(Process.GetCurrentProcess().Handle, process.Handle, handleOwner, out processHandleForOwner, 0, false, DuplicateOptions.SameAccess))
|
||||
{
|
||||
Log.Warning("Failed to call DuplicateHandle: Win32 error code {0}", Marshal.GetLastWin32Error());
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"{{\"pid\": {process.Id}, \"handle\": {processHandleForOwner}}}");
|
||||
|
|
@ -755,7 +838,9 @@ namespace Dalamud.Injector
|
|||
helperProcess.BeginErrorReadLine();
|
||||
helperProcess.WaitForExit();
|
||||
if (helperProcess.ExitCode != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var result = JsonSerializer.CreateDefault().Deserialize<Dictionary<string, int>>(new JsonTextReader(helperProcess.StandardOutput));
|
||||
var pid = result["pid"];
|
||||
|
|
@ -812,7 +897,9 @@ namespace Dalamud.Injector
|
|||
var startInfoAddress = startInfoBuffer.Add(startInfoBytes);
|
||||
|
||||
if (startInfoAddress == 0)
|
||||
{
|
||||
throw new Exception("Unable to allocate start info JSON");
|
||||
}
|
||||
|
||||
injector.GetFunctionAddress(bootModule, "Initialize", out var initAddress);
|
||||
injector.CallRemoteFunction(initAddress, startInfoAddress, out var exitCode);
|
||||
|
|
@ -847,7 +934,10 @@ namespace Dalamud.Injector
|
|||
/// </param>
|
||||
private static string EncodeParameterArgument(string argument, bool force = false)
|
||||
{
|
||||
if (argument == null) throw new ArgumentNullException(nameof(argument));
|
||||
if (argument == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(argument));
|
||||
}
|
||||
|
||||
// Unless we're told otherwise, don't quote unless we actually
|
||||
// need to do so --- hopefully avoid problems if programs won't
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public record DalamudStartInfo : IServiceType
|
|||
this.ConfigurationPath = other.ConfigurationPath;
|
||||
this.LogName = other.LogName;
|
||||
this.PluginDirectory = other.PluginDirectory;
|
||||
this.DefaultPluginDirectory = other.DefaultPluginDirectory;
|
||||
this.AssetDirectory = other.AssetDirectory;
|
||||
this.Language = other.Language;
|
||||
this.GameVersion = other.GameVersion;
|
||||
|
|
@ -72,11 +71,6 @@ public record DalamudStartInfo : IServiceType
|
|||
/// </summary>
|
||||
public string? PluginDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to the directory for developer plugins.
|
||||
/// </summary>
|
||||
public string? DefaultPluginDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the path to core Dalamud assets.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class DevPluginsSettingsEntry : SettingsEntry
|
|||
}
|
||||
}
|
||||
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsDevPluginLocationsHint", "Add additional dev plugin load locations.\nThese can be either the directory or DLL path."));
|
||||
ImGuiHelpers.SafeTextColoredWrapped(ImGuiColors.DalamudGrey, Loc.Localize("DalamudSettingsDevPluginLocationsHint", "Add dev plugin load locations.\nThese can be either the directory or DLL path."));
|
||||
|
||||
ImGuiHelpers.ScaledDummy(5);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,15 +57,6 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
/// </summary>
|
||||
public const int PluginWaitBeforeFreeDefault = 1000; // upped from 500ms, seems more stable
|
||||
|
||||
private const string DevPluginsDisclaimerFilename = "DONT_USE_THIS_FOLDER.txt";
|
||||
|
||||
private const string DevPluginsDisclaimerText = @"Hey!
|
||||
The devPlugins folder is deprecated and will be removed soon. Please don't use it anymore for plugin development.
|
||||
Instead, open the Dalamud settings and add the path to your plugins build output folder as a dev plugin location.
|
||||
Remove your devPlugin from this folder.
|
||||
|
||||
Thanks and have fun!";
|
||||
|
||||
private static readonly ModuleLog Log = new("PLUGINM");
|
||||
|
||||
private readonly object pluginListLock = new();
|
||||
|
|
@ -88,18 +79,10 @@ Thanks and have fun!";
|
|||
private PluginManager()
|
||||
{
|
||||
this.pluginDirectory = new DirectoryInfo(this.startInfo.PluginDirectory!);
|
||||
this.devPluginDirectory = new DirectoryInfo(this.startInfo.DefaultPluginDirectory!);
|
||||
|
||||
if (!this.pluginDirectory.Exists)
|
||||
this.pluginDirectory.Create();
|
||||
|
||||
if (!this.devPluginDirectory.Exists)
|
||||
this.devPluginDirectory.Create();
|
||||
|
||||
var disclaimerFileName = Path.Combine(this.devPluginDirectory.FullName, DevPluginsDisclaimerFilename);
|
||||
if (!File.Exists(disclaimerFileName))
|
||||
File.WriteAllText(disclaimerFileName, DevPluginsDisclaimerText);
|
||||
|
||||
this.SafeMode = EnvironmentConfiguration.DalamudNoPlugins || this.configuration.PluginSafeMode || this.startInfo.NoLoadPlugins;
|
||||
|
||||
try
|
||||
|
|
@ -394,9 +377,6 @@ Thanks and have fun!";
|
|||
if (!this.pluginDirectory.Exists)
|
||||
this.pluginDirectory.Create();
|
||||
|
||||
if (!this.devPluginDirectory.Exists)
|
||||
this.devPluginDirectory.Create();
|
||||
|
||||
// Add installed plugins. These are expected to be in a specific format so we can look for exactly that.
|
||||
foreach (var pluginDir in this.pluginDirectory.GetDirectories())
|
||||
{
|
||||
|
|
@ -437,7 +417,7 @@ Thanks and have fun!";
|
|||
}
|
||||
|
||||
// devPlugins are more freeform. Look for any dll and hope to get lucky.
|
||||
var devDllFiles = this.devPluginDirectory.GetFiles("*.dll", SearchOption.AllDirectories).ToList();
|
||||
var devDllFiles = new List<FileInfo>();
|
||||
|
||||
foreach (var setting in this.configuration.DevPluginLoadLocations)
|
||||
{
|
||||
|
|
@ -660,11 +640,8 @@ Thanks and have fun!";
|
|||
/// </summary>
|
||||
public void ScanDevPlugins()
|
||||
{
|
||||
if (!this.devPluginDirectory.Exists)
|
||||
this.devPluginDirectory.Create();
|
||||
|
||||
// devPlugins are more freeform. Look for any dll and hope to get lucky.
|
||||
var devDllFiles = this.devPluginDirectory.GetFiles("*.dll", SearchOption.AllDirectories).ToList();
|
||||
var devDllFiles = new List<FileInfo>();
|
||||
|
||||
foreach (var setting in this.configuration.DevPluginLoadLocations)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 010e878febb631c8f3ff5ff90d656f318e35b1de
|
||||
Subproject commit 08d8bfc64d31ac1a2bfa5bc2cb927459254bb635
|
||||
Loading…
Add table
Add a link
Reference in a new issue