mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
feat: set boot defaults via json
This commit is contained in:
parent
5c3c22490d
commit
192396abdc
3 changed files with 112 additions and 56 deletions
|
|
@ -1,7 +1,5 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include <codecvt>
|
||||
|
||||
#include "DalamudStartInfo.h"
|
||||
#include "logging.h"
|
||||
#include "utils.h"
|
||||
|
|
@ -12,8 +10,6 @@ HMODULE g_hModule;
|
|||
HINSTANCE g_hGameInstance = GetModuleHandleW(nullptr);
|
||||
|
||||
DllExport DWORD WINAPI Initialize(LPVOID lpParam, HANDLE hMainThreadContinue) {
|
||||
MessageBoxW(nullptr, L"", L"", MB_OK);
|
||||
|
||||
g_startInfo.from_envvars();
|
||||
|
||||
std::string jsonParseError;
|
||||
|
|
|
|||
|
|
@ -56,11 +56,6 @@ namespace Dalamud.Injector
|
|||
return;
|
||||
}
|
||||
|
||||
// Set boot defaults
|
||||
SetEnvDefaultIfNotExist("DALAMUD_GAMEFIX_LIST", "prevent_devicechange_crashes,disable_game_openprocess_access_check,redirect_openprocess");
|
||||
SetEnvDefaultIfNotExist("DALAMUD_DOTNET_OPENPROCESS_HOOKMODE", "0");
|
||||
//SetEnvDefaultIfNotExist("DALAMUD_UNHOOK_DLLS", "kernel32.dll,ntdll.dll,user32.dll");
|
||||
|
||||
DalamudStartInfo startInfo = null;
|
||||
if (args.Count == 1)
|
||||
{
|
||||
|
|
@ -108,15 +103,6 @@ namespace Dalamud.Injector
|
|||
}
|
||||
}
|
||||
|
||||
private static void SetEnvDefaultIfNotExist(string name, string value)
|
||||
{
|
||||
var prevValue = Environment.GetEnvironmentVariable(name);
|
||||
if (string.IsNullOrWhiteSpace(prevValue))
|
||||
{
|
||||
Environment.SetEnvironmentVariable(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetLogPath(string filename)
|
||||
{
|
||||
var baseDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
|
@ -263,8 +249,7 @@ namespace Dalamud.Injector
|
|||
int len;
|
||||
string key;
|
||||
|
||||
if (startInfo == null)
|
||||
startInfo = new();
|
||||
startInfo ??= new DalamudStartInfo();
|
||||
|
||||
var workingDirectory = startInfo.WorkingDirectory;
|
||||
var configurationPath = startInfo.ConfigurationPath;
|
||||
|
|
@ -315,7 +300,7 @@ namespace Dalamud.Injector
|
|||
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 = "deutsche").Length))] == key[0..len])
|
||||
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;
|
||||
|
|
@ -326,17 +311,21 @@ namespace Dalamud.Injector
|
|||
else
|
||||
throw new CommandLineException($"\"{languageStr}\" is not a valid supported language.");
|
||||
|
||||
return new()
|
||||
{
|
||||
WorkingDirectory = workingDirectory,
|
||||
ConfigurationPath = configurationPath,
|
||||
PluginDirectory = pluginDirectory,
|
||||
DefaultPluginDirectory = defaultPluginDirectory,
|
||||
AssetDirectory = assetDirectory,
|
||||
Language = clientLanguage,
|
||||
GameVersion = null,
|
||||
DelayInitializeMs = delayInitializeMs,
|
||||
};
|
||||
startInfo.WorkingDirectory = workingDirectory;
|
||||
startInfo.ConfigurationPath = configurationPath;
|
||||
startInfo.PluginDirectory = pluginDirectory;
|
||||
startInfo.DefaultPluginDirectory = defaultPluginDirectory;
|
||||
startInfo.AssetDirectory = assetDirectory;
|
||||
startInfo.Language = clientLanguage;
|
||||
startInfo.DelayInitializeMs = delayInitializeMs;
|
||||
startInfo.GameVersion = null;
|
||||
|
||||
// Set boot defaults
|
||||
startInfo.BootEnabledGameFixes = new List<string> { "prevent_devicechange_crashes", "disable_game_openprocess_access_check", "redirect_openprocess" };
|
||||
startInfo.BootDotnetOpenProcessHookMode = 0;
|
||||
//startInfo.BootUnhookDlls = new List<string>() { "kernel32.dll", "ntdll.dll", "user32.dll" };
|
||||
|
||||
return startInfo;
|
||||
}
|
||||
|
||||
private static int ProcessHelpCommand(List<string> args, string? particularCommand = default)
|
||||
|
|
@ -689,16 +678,9 @@ namespace Dalamud.Injector
|
|||
var gameVerStr = File.ReadAllText(Path.Combine(ffxivDir, "ffxivgame.ver"));
|
||||
var gameVer = GameVersion.Parse(gameVerStr);
|
||||
|
||||
return new()
|
||||
return new DalamudStartInfo(startInfo)
|
||||
{
|
||||
WorkingDirectory = startInfo.WorkingDirectory,
|
||||
ConfigurationPath = startInfo.ConfigurationPath,
|
||||
PluginDirectory = startInfo.PluginDirectory,
|
||||
DefaultPluginDirectory = startInfo.DefaultPluginDirectory,
|
||||
AssetDirectory = startInfo.AssetDirectory,
|
||||
Language = startInfo.Language,
|
||||
GameVersion = gameVer,
|
||||
DelayInitializeMs = startInfo.DelayInitializeMs,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Game;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
|
@ -11,45 +11,123 @@ namespace Dalamud
|
|||
[Serializable]
|
||||
public record DalamudStartInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DalamudStartInfo"/> class.
|
||||
/// </summary>
|
||||
public DalamudStartInfo()
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DalamudStartInfo"/> class.
|
||||
/// </summary>
|
||||
/// <param name="other">Object to copy values from.</param>
|
||||
public DalamudStartInfo(DalamudStartInfo other)
|
||||
{
|
||||
this.WorkingDirectory = other.WorkingDirectory;
|
||||
this.ConfigurationPath = other.ConfigurationPath;
|
||||
this.PluginDirectory = other.PluginDirectory;
|
||||
this.DefaultPluginDirectory = other.DefaultPluginDirectory;
|
||||
this.AssetDirectory = other.AssetDirectory;
|
||||
this.Language = other.Language;
|
||||
this.GameVersion = other.GameVersion;
|
||||
this.DelayInitializeMs = other.DelayInitializeMs;
|
||||
this.BootShowConsole = other.BootShowConsole;
|
||||
this.BootDisableFallbackConsole = other.BootDisableFallbackConsole;
|
||||
this.BootWaitMessageBox = other.BootWaitMessageBox;
|
||||
this.BootWaitDebugger = other.BootWaitDebugger;
|
||||
this.BootVehEnabled = other.BootVehEnabled;
|
||||
this.BootVehFull = other.BootVehFull;
|
||||
this.BootDotnetOpenProcessHookMode = other.BootDotnetOpenProcessHookMode;
|
||||
this.BootEnabledGameFixes = other.BootEnabledGameFixes;
|
||||
this.BootUnhookDlls = other.BootUnhookDlls;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the working directory of the XIVLauncher installations.
|
||||
/// </summary>
|
||||
public string WorkingDirectory { get; set; }
|
||||
public string? WorkingDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the configuration file.
|
||||
/// Gets or sets the path to the configuration file.
|
||||
/// </summary>
|
||||
public string ConfigurationPath { get; init; }
|
||||
public string? ConfigurationPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the directory for installed plugins.
|
||||
/// Gets or sets the path to the directory for installed plugins.
|
||||
/// </summary>
|
||||
public string PluginDirectory { get; init; }
|
||||
public string? PluginDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the directory for developer plugins.
|
||||
/// Gets or sets the path to the directory for developer plugins.
|
||||
/// </summary>
|
||||
public string DefaultPluginDirectory { get; init; }
|
||||
public string? DefaultPluginDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to core Dalamud assets.
|
||||
/// Gets or sets the path to core Dalamud assets.
|
||||
/// </summary>
|
||||
public string AssetDirectory { get; init; }
|
||||
public string? AssetDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the language of the game client.
|
||||
/// Gets or sets the language of the game client.
|
||||
/// </summary>
|
||||
public ClientLanguage Language { get; init; } = ClientLanguage.English;
|
||||
public ClientLanguage Language { get; set; } = ClientLanguage.English;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current game version code.
|
||||
/// Gets or sets the current game version code.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(GameVersionConverter))]
|
||||
public GameVersion GameVersion { get; init; }
|
||||
public GameVersion? GameVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value that specifies how much to wait before a new Dalamud session.
|
||||
/// Gets or sets a value that specifies how much to wait before a new Dalamud session.
|
||||
/// </summary>
|
||||
public int DelayInitializeMs { get; init; } = 0;
|
||||
public int DelayInitializeMs { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether a Boot console should be shown.
|
||||
/// </summary>
|
||||
public bool BootShowConsole { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the fallback console should be shown, if needed.
|
||||
/// </summary>
|
||||
public bool BootDisableFallbackConsole { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating where Dalamud should wait with a message box.
|
||||
/// </summary>
|
||||
public int BootWaitMessageBox { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether Dalamud should wait for a debugger to be attached before initializing.
|
||||
/// </summary>
|
||||
public bool BootWaitDebugger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the VEH should be enabled.
|
||||
/// </summary>
|
||||
public bool BootVehEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the VEH should be doing full crash dumps.
|
||||
/// </summary>
|
||||
public bool BootVehFull { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value choosing the OpenProcess hookmode.
|
||||
/// </summary>
|
||||
public int BootDotnetOpenProcessHookMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of enabled game fixes.
|
||||
/// </summary>
|
||||
public List<string>? BootEnabledGameFixes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of DLLs that should be unhooked.
|
||||
/// </summary>
|
||||
public List<string>? BootUnhookDlls { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue