/// <summary> /// Initializes a new instance of the <see cref="Dalamud"/> class. /// </summary> /// <param name="info">DalamudStartInfo instance.</param> /// <param name="loggingLevelSwitch">LoggingLevelSwitch to control Serilog level.</param> /// <param name="finishSignal">Signal signalling shutdown.</param> /// <param name="configuration">The Dalamud configuration.</param> public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch, ManualResetEvent finishSignal, DalamudConfiguration configuration) { #if DEBUG Instance = this; #endif this.StartInfo = info; this.LogLevelSwitch = loggingLevelSwitch; this.Configuration = configuration; // this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); this.unloadSignal.Reset(); this.finishUnloadSignal = finishSignal; this.finishUnloadSignal.Reset(); }
/// <summary> /// Initializes a new instance of the <see cref="Dalamud"/> class. /// </summary> /// <param name="info">DalamudStartInfo instance.</param> /// <param name="loggingLevelSwitch">LoggingLevelSwitch to control Serilog level.</param> /// <param name="finishSignal">Signal signalling shutdown.</param> /// <param name="configuration">The Dalamud configuration.</param> public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch, ManualResetEvent finishSignal, DalamudConfiguration configuration) { this.ApplyProcessPatch(); Service <Dalamud> .Set(this); Service <DalamudStartInfo> .Set(info); Service <DalamudConfiguration> .Set(configuration); this.LogLevelSwitch = loggingLevelSwitch; this.unloadSignal = new ManualResetEvent(false); this.unloadSignal.Reset(); this.finishUnloadSignal = finishSignal; this.finishUnloadSignal.Reset(); }
/// <summary> /// Initialize all Dalamud subsystems and start running on the main thread. /// </summary> /// <param name="ctx">The <see cref="RemoteHooking.IContext"/> used to load the DLL.</param> /// <param name="info">The <see cref="DalamudStartInfo"/> containing information needed to initialize Dalamud.</param> public void Run(RemoteHooking.IContext ctx, DalamudStartInfo info) { // Setup logger var(logger, levelSwitch) = this.NewLogger(info.WorkingDirectory); Log.Logger = logger; var finishSignal = new ManualResetEvent(false); try { Log.Information(new string('-', 80)); Log.Information("Initializing a session.."); // This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3; // Log any unhandled exception. AppDomain.CurrentDomain.UnhandledException += this.OnUnhandledException; TaskScheduler.UnobservedTaskException += this.OnUnobservedTaskException; var dalamud = new Dalamud(info, levelSwitch, finishSignal); Log.Information("Starting a session.."); // Run session dalamud.LoadTier1(); dalamud.WaitForUnload(); dalamud.Dispose(); } catch (Exception ex) { Log.Fatal(ex, "Unhandled exception on main thread."); } finally { AppDomain.CurrentDomain.UnhandledException -= this.OnUnhandledException; Log.Information("Session has ended."); Log.CloseAndFlush(); finishSignal.Set(); } }
public Dalamud(DalamudStartInfo info) { this.StartInfo = info; this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); // Initialize the process information. this.targetModule = Process.GetCurrentProcess().MainModule; this.sigScanner = new SigScanner(this.targetModule); // Initialize game subsystem Framework = new Framework(this.sigScanner, this); // Initialize managers. Basically handlers for the logic CommandManager = new CommandManager(this, info.Language); SetupCommands(); ChatHandlers = new ChatHandlers(this); NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection); this.ClientState = new ClientState(this, info, this.sigScanner, this.targetModule); this.BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig); this.PluginManager = new PluginManager(this, info.PluginDirectory, info.DefaultPluginDirectory); this.IconReplacer = new IconReplacer(this, this.sigScanner); this.WinSock2 = new WinSockHandlers(); try { this.PluginManager.LoadPlugins(); } catch (Exception ex) { Framework.Gui.Chat.PrintError( "[XIVLAUNCHER] There was an error loading additional plugins. Please check the log for more details."); Log.Error(ex, "Plugin load failed."); } }
/// <summary> /// Initializes a new instance of the <see cref="Dalamud"/> class. /// </summary> /// <param name="info">DalamudStartInfo instance.</param> /// <param name="loggingLevelSwitch">LoggingLevelSwitch to control Serilog level.</param> /// <param name="finishSignal">Signal signalling shutdown.</param> /// <param name="configuration">The Dalamud configuration.</param> public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch, ManualResetEvent finishSignal, DalamudConfiguration configuration) { this.ApplyProcessPatch(); Service <Dalamud> .Set(this); Service <DalamudStartInfo> .Set(info); Service <DalamudConfiguration> .Set(configuration); this.LogLevelSwitch = loggingLevelSwitch; // TODO: Just for testing, force verbose logging this.LogLevelSwitch.MinimumLevel = LogEventLevel.Verbose; this.unloadSignal = new ManualResetEvent(false); this.unloadSignal.Reset(); this.finishUnloadSignal = finishSignal; this.finishUnloadSignal.Reset(); }
public Dalamud(DalamudStartInfo info) { this.StartInfo = info; this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); // Initialize the process information. this.targetModule = Process.GetCurrentProcess().MainModule; this.SigScanner = new SigScanner(this.targetModule, true); // Initialize game subsystem this.Framework = new Framework(this.SigScanner, this); // Initialize managers. Basically handlers for the logic this.CommandManager = new CommandManager(this, info.Language); SetupCommands(); this.ChatHandlers = new ChatHandlers(this); this.NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection); this.Data = new DataManager(this.StartInfo.Language); this.Data.Initialize(); this.ClientState = new ClientState(this, info, this.SigScanner, this.targetModule); this.BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig); this.WinSock2 = new WinSockHandlers(); try { this.InterfaceManager = new InterfaceManager(this, this.SigScanner); this.InterfaceManager.OnDraw += BuildDalamudUi; } catch (Exception e) { Log.Information(e, "Could not init interface."); } }
public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch) { this.StartInfo = info; this.loggingLevelSwitch = loggingLevelSwitch; this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); // Initialize the process information. this.targetModule = Process.GetCurrentProcess().MainModule; this.SigScanner = new SigScanner(this.targetModule, true); // Initialize game subsystem this.Framework = new Framework(this.SigScanner, this); this.ClientState = new ClientState(this, info, this.SigScanner); this.WinSock2 = new WinSockHandlers(); AssetManager.EnsureAssets(this.baseDirectory).ContinueWith(async task => { if (task.IsCanceled || task.IsFaulted) { throw new Exception("Could not ensure assets.", task.Exception); } this.LocalizationManager = new Localization(this.StartInfo.WorkingDirectory); if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) { this.LocalizationManager.SetupWithLangCode(this.Configuration.LanguageOverride); } else { this.LocalizationManager.SetupWithUiCulture(); } var pluginDir = this.StartInfo.PluginDirectory; if (this.Configuration.DoPluginTest) { pluginDir = Path.Combine(pluginDir, "..", "testPlugins"); } PluginRepository = new PluginRepository(this, pluginDir, this.StartInfo.GameVersion); if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false")) { try { InterfaceManager = new InterfaceManager(this, this.SigScanner); InterfaceManager.OnDraw += BuildDalamudUi; InterfaceManager.Enable(); } catch (Exception e) { Log.Information(e, "Could not init interface."); } } Data = new DataManager(this.StartInfo.Language); await Data.Initialize(this.baseDirectory); SeStringManager = new SeStringManager(Data); NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection); // Initialize managers. Basically handlers for the logic CommandManager = new CommandManager(this, info.Language); SetupCommands(); ChatHandlers = new ChatHandlers(this); // Discord Bot Manager BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig); BotManager.Start(); if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) { try { PluginRepository.CleanupPlugins(); PluginManager = new PluginManager(this, pluginDir, this.StartInfo.DefaultPluginDirectory); PluginManager.LoadPlugins(); } catch (Exception ex) { Log.Error(ex, "Plugin load failed."); } } this.Framework.Enable(); this.ClientState.Enable(); IsReady = true; }); }
public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch) { this.StartInfo = info; this.loggingLevelSwitch = loggingLevelSwitch; this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); // Initialize the process information. this.targetModule = Process.GetCurrentProcess().MainModule; this.SigScanner = new SigScanner(this.targetModule, true); // Initialize game subsystem this.Framework = new Framework(this.SigScanner, this); this.ClientState = new ClientState(this, info, this.SigScanner); this.WinSock2 = new WinSockHandlers(); AssetManager.EnsureAssets(this.baseDirectory).ContinueWith(async task => { if (task.IsCanceled || task.IsFaulted) { throw new Exception("Could not ensure assets.", task.Exception); } this.localizationMgr = new Localization(this.StartInfo.WorkingDirectory); if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) { this.localizationMgr.SetupWithLangCode(this.Configuration.LanguageOverride); } else { this.localizationMgr.SetupWithUiCulture(); } try { this.InterfaceManager = new InterfaceManager(this, this.SigScanner); this.InterfaceManager.OnDraw += BuildDalamudUi; this.InterfaceManager.Enable(); } catch (Exception e) { Log.Information(e, "Could not init interface."); } this.Data = new DataManager(this.StartInfo.Language); await this.Data.Initialize(this.baseDirectory); // TODO: better way to do this? basically for lumina injection SeString.Dalamud = this; this.NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection); // Initialize managers. Basically handlers for the logic this.CommandManager = new CommandManager(this, info.Language); SetupCommands(); this.ChatHandlers = new ChatHandlers(this); // Discord Bot Manager this.BotManager = new DiscordBotManager(this, this.Configuration.DiscordFeatureConfig); this.BotManager.Start(); try { this.PluginManager = new PluginManager(this, this.StartInfo.PluginDirectory, this.StartInfo.DefaultPluginDirectory); this.PluginManager.LoadPlugins(); this.PluginRepository = new PluginRepository(PluginManager, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion); } catch (Exception ex) { Log.Error(ex, "Plugin load failed."); } IsReady = true; }); this.conditionDebugWindow = new ConditionDebugWindow(this); }
public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch) { this.StartInfo = info; this.loggingLevelSwitch = loggingLevelSwitch; this.Configuration = DalamudConfiguration.Load(info.ConfigurationPath); this.baseDirectory = info.WorkingDirectory; this.unloadSignal = new ManualResetEvent(false); // Initialize the process information. this.targetModule = Process.GetCurrentProcess().MainModule; this.SigScanner = new SigScanner(this.targetModule, true); // Initialize game subsystem this.Framework = new Framework(this.SigScanner, this); this.WinSock2 = new WinSockHandlers(); NetworkHandlers = new NetworkHandlers(this, this.Configuration.OptOutMbCollection); this.ClientState = new ClientState(this, info, this.SigScanner); Task.Run(async() => { try { var res = await AssetManager.EnsureAssets(this.baseDirectory); if (!res) { Log.Error("One or more assets failed to download."); Unload(); return; } } catch (Exception e) { Log.Error(e, "Error in asset task."); Unload(); return; } this.LocalizationManager = new Localization(this.StartInfo.WorkingDirectory); if (!string.IsNullOrEmpty(this.Configuration.LanguageOverride)) { this.LocalizationManager.SetupWithLangCode(this.Configuration.LanguageOverride); } else { this.LocalizationManager.SetupWithUiCulture(); } PluginRepository = new PluginRepository(this, this.StartInfo.PluginDirectory, this.StartInfo.GameVersion); var isInterfaceLoaded = false; if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE") ?? "false")) { try { InterfaceManager = new InterfaceManager(this, this.SigScanner); InterfaceManager.OnDraw += BuildDalamudUi; InterfaceManager.Enable(); isInterfaceLoaded = true; } catch (Exception e) { Log.Information(e, "Could not init interface."); } } Data = new DataManager(this.StartInfo.Language); try { await Data.Initialize(this.baseDirectory); } catch (Exception e) { Log.Error(e, "Could not initialize DataManager."); Unload(); return; } SeStringManager = new SeStringManager(Data); #if DEBUG AntiDebug = new AntiDebug(this.SigScanner); AntiDebug.Enable(); #endif // Initialize managers. Basically handlers for the logic CommandManager = new CommandManager(this, info.Language); SetupCommands(); ChatHandlers = new ChatHandlers(this); if (!bool.Parse(Environment.GetEnvironmentVariable("DALAMUD_NOT_HAVE_PLUGINS") ?? "false")) { try { PluginRepository.CleanupPlugins(); PluginManager = new PluginManager(this, this.StartInfo.PluginDirectory, this.StartInfo.DefaultPluginDirectory); PluginManager.LoadPlugins(); } catch (Exception ex) { Log.Error(ex, "Plugin load failed."); } } this.Framework.Enable(); this.ClientState.Enable(); IsReady = true; Troubleshooting.LogTroubleshooting(this, isInterfaceLoaded); }); }
/// <summary> /// Initialize all Dalamud subsystems and start running on the main thread. /// </summary> /// <param name="info">The <see cref="DalamudStartInfo"/> containing information needed to initialize Dalamud.</param> private static void RunThread(DalamudStartInfo info) { if (EnvironmentConfiguration.DalamudWaitForDebugger) { while (!Debugger.IsAttached) { Thread.Sleep(100); } } // Setup logger var levelSwitch = InitLogging(info.WorkingDirectory); // Load configuration first to get some early persistent state, like log level var configuration = DalamudConfiguration.Load(info.ConfigurationPath); // Set the appropriate logging level from the configuration #if !DEBUG levelSwitch.MinimumLevel = configuration.LogLevel; #endif // Log any unhandled exception. AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; var finishSignal = new ManualResetEvent(false); try { if (info.DelayInitializeMs > 0) { Log.Information(string.Format("Waiting for {0}ms before starting a session.", info.DelayInitializeMs)); Thread.Sleep(info.DelayInitializeMs); } Log.Information(new string('-', 80)); Log.Information("Initializing a session.."); // This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls; if (!Util.IsLinux()) { InitSymbolHandler(info); } var dalamud = new Dalamud(info, levelSwitch, finishSignal, configuration); Log.Information("Starting a session.."); // Run session dalamud.LoadTier1(); dalamud.WaitForUnload(); dalamud.Dispose(); } catch (Exception ex) { Log.Fatal(ex, "Unhandled exception on main thread."); } finally { TaskScheduler.UnobservedTaskException -= OnUnobservedTaskException; AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; Log.Information("Session has ended."); Log.CloseAndFlush(); finishSignal.Set(); } }
/// <summary> /// Initializes a new instance of the <see cref="EntryPoint"/> class. /// </summary> /// <param name="ctx">The <see cref="RemoteHooking.IContext"/> used to load the DLL.</param> /// <param name="info">The <see cref="DalamudStartInfo"/> containing information needed to initialize Dalamud.</param> public EntryPoint(RemoteHooking.IContext ctx, DalamudStartInfo info) { // Required by EasyHook }