diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 0d6eb0f77..58660ab09 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -27,72 +27,163 @@ using Serilog.Events; namespace Dalamud { public sealed class Dalamud : IDisposable { - private readonly string baseDirectory; + + #region Native Game Subsystems + + /// + /// Game framework subsystem + /// + internal readonly Framework Framework; + + /// + /// Anti-Debug detection prevention system + /// + internal readonly AntiDebug AntiDebug; + + /// + /// WinSock optimization subsystem + /// + internal readonly WinSockHandlers WinSock2; + + /// + /// ImGui Interface subsystem + /// + internal readonly InterfaceManager InterfaceManager; + + /// + /// ClientState subsystem + /// + public readonly ClientState ClientState; + + #endregion + + #region Dalamud Subsystems + + /// + /// Plugin Manager subsystem + /// + internal readonly PluginManager PluginManager; + + /// + /// Plugin Repository subsystem + /// + internal readonly PluginRepository PluginRepository; + + /// + /// Data provider subsystem + /// + internal readonly DataManager Data; + + /// + /// Command Manager subsystem + /// + internal readonly CommandManager CommandManager; + + /// + /// Localization subsystem facilitating localization for Dalamud and plugins + /// + internal readonly Localization LocalizationManager; + + #endregion + + #region Helpers + + /// + /// SeStringManager subsystem facilitating string parsing + /// + internal readonly SeStringManager SeStringManager; + + /// + /// Copy-enabled SigScanner for target module + /// + internal readonly SigScanner SigScanner; + + /// + /// LoggingLevelSwitch for Dalamud and Plugin logs + /// + internal readonly LoggingLevelSwitch LogLevelSwitch; + + /// + /// StartInfo object passed from injector + /// + internal readonly DalamudStartInfo StartInfo; + + /// + /// Configuration object facilitating save and load of Dalamud configuration + /// + internal readonly DalamudConfiguration Configuration; + + #endregion + + #region Dalamud Core functionality + + /// + /// Dalamud base UI + /// + internal readonly DalamudInterface DalamudUi; + + /// + /// Dalamud chat commands + /// + internal readonly DalamudCommands DalamudCommands; + + /// + /// Dalamud chat-based features + /// + internal readonly ChatHandlers ChatHandlers; + + /// + /// Dalamud network-based features + /// + internal readonly NetworkHandlers NetworkHandlers; + + #endregion + + #region Internals private readonly ManualResetEvent unloadSignal; - private readonly ProcessModule targetModule; + private readonly string baseDirectory; - public readonly SigScanner SigScanner; + #endregion - public readonly Framework Framework; + /// + /// Injected process module + /// + internal readonly ProcessModule TargetModule; - public CommandManager CommandManager { get; private set; } - private DalamudCommands DalamudCommands { get; set; } + /// + /// Value indicating if Dalamud was successfully loaded + /// + internal bool IsReady { get; private set; } - public ChatHandlers ChatHandlers { get; private set; } - - public NetworkHandlers NetworkHandlers { get; private set; } - - public AntiDebug AntiDebug { get; set; } - - internal PluginManager PluginManager { get; private set; } - internal PluginRepository PluginRepository { get; private set; } - - public readonly ClientState ClientState; - - public readonly DalamudStartInfo StartInfo; - internal LoggingLevelSwitch LogLevelSwitch { get; } - - internal readonly DalamudConfiguration Configuration; - - private readonly WinSockHandlers WinSock2; - - internal InterfaceManager InterfaceManager { get; private set; } - - internal DalamudInterface DalamudUi { get; private set; } - - public DataManager Data { get; private set; } - - internal SeStringManager SeStringManager { get; private set; } - - - internal Localization LocalizationManager; - - public bool IsReady { get; private set; } - - public DirectoryInfo AssetDirectory => new DirectoryInfo(this.StartInfo.AssetDirectory); + /// + /// Location of stored assets + /// + internal DirectoryInfo AssetDirectory => new DirectoryInfo(this.StartInfo.AssetDirectory); public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch) { this.StartInfo = info; this.LogLevelSwitch = loggingLevelSwitch; - this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); - this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); + this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); + // Initialize the process information. - this.targetModule = Process.GetCurrentProcess().MainModule; - this.SigScanner = new SigScanner(this.targetModule, true); + this.TargetModule = Process.GetCurrentProcess().MainModule; + this.SigScanner = new SigScanner(this.TargetModule, true); + + this.AntiDebug = new AntiDebug(this.SigScanner); // Initialize game subsystem this.Framework = new Framework(this.SigScanner, this); this.WinSock2 = new WinSockHandlers(); - NetworkHandlers = new NetworkHandlers(this, info.OptOutMbCollection); + this.NetworkHandlers = new NetworkHandlers(this, info.OptOutMbCollection); this.ClientState = new ClientState(this, info, this.SigScanner); @@ -102,19 +193,19 @@ namespace Dalamud { else this.LocalizationManager.SetupWithUiCulture(); - PluginRepository = new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion); + this.PluginRepository = new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion); - DalamudUi = new DalamudInterface(this); + this.DalamudUi = new DalamudInterface(this); var isInterfaceLoaded = false; if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false")) { try { - InterfaceManager = new InterfaceManager(this, this.SigScanner); - InterfaceManager.OnDraw += DalamudUi.Draw; + this.InterfaceManager = new InterfaceManager(this, this.SigScanner); + this.InterfaceManager.OnDraw += this.DalamudUi.Draw; - InterfaceManager.Enable(); + this.InterfaceManager.Enable(); isInterfaceLoaded = true; } catch (Exception e) @@ -123,10 +214,10 @@ namespace Dalamud { } } - Data = new DataManager(this.StartInfo.Language); + this.Data = new DataManager(this.StartInfo.Language); try { - Data.Initialize(AssetDirectory.FullName); + this.Data.Initialize(AssetDirectory.FullName); } catch (Exception e) { @@ -135,18 +226,18 @@ namespace Dalamud { return; } - SeStringManager = new SeStringManager(Data); + this.SeStringManager = new SeStringManager(this.Data); #if DEBUG - AntiDebug = new AntiDebug(this.SigScanner); + this.AntiDebug = new AntiDebug(this.SigScanner); #endif // Initialize managers. Basically handlers for the logic - CommandManager = new CommandManager(this, info.Language); - DalamudCommands = new DalamudCommands(this); - DalamudCommands.SetupCommands(); + this.CommandManager = new CommandManager(this, info.Language); + this.DalamudCommands = new DalamudCommands(this); + this.DalamudCommands.SetupCommands(); - ChatHandlers = new ChatHandlers(this); + this.ChatHandlers = new ChatHandlers(this); if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) { diff --git a/Dalamud/Game/Internal/AntiDebug.cs b/Dalamud/Game/Internal/AntiDebug.cs index a0083fab5..8cd243c59 100644 --- a/Dalamud/Game/Internal/AntiDebug.cs +++ b/Dalamud/Game/Internal/AntiDebug.cs @@ -30,8 +30,8 @@ namespace Dalamud.Game.Internal } public void Dispose() { - if (this.DebugCheckAddress != IntPtr.Zero && this.original != null) - Marshal.Copy(this.original, 0, DebugCheckAddress, this.nop.Length); + //if (this.DebugCheckAddress != IntPtr.Zero && this.original != null) + // Marshal.Copy(this.original, 0, DebugCheckAddress, this.nop.Length); } } } diff --git a/Dalamud/Interface/DalamudInterface.cs b/Dalamud/Interface/DalamudInterface.cs index eb51b9b25..420b26820 100644 --- a/Dalamud/Interface/DalamudInterface.cs +++ b/Dalamud/Interface/DalamudInterface.cs @@ -110,7 +110,6 @@ namespace Dalamud.Interface } if (this.dalamud.AntiDebug == null && ImGui.MenuItem("Enable AntiDebug")) { - this.dalamud.AntiDebug = new AntiDebug(this.dalamud.SigScanner); this.dalamud.AntiDebug.Enable(); } ImGui.Separator();