From 57e046cd71cd66637caf3411fc884b52505c9231 Mon Sep 17 00:00:00 2001 From: Mino <1381835+Minoost@users.noreply.github.com> Date: Thu, 27 Feb 2020 17:53:26 +0900 Subject: [PATCH] wip --- Dalamud.Injector/DalamudLauncher.cs | 2 +- Dalamud.sln | 8 ++-- Dalamud/Dalamud.csproj | 1 - Dalamud/EntryPoint.cs | 73 ++++++----------------------- 4 files changed, 19 insertions(+), 65 deletions(-) diff --git a/Dalamud.Injector/DalamudLauncher.cs b/Dalamud.Injector/DalamudLauncher.cs index 1c78d9887..d7e43ac4d 100644 --- a/Dalamud.Injector/DalamudLauncher.cs +++ b/Dalamud.Injector/DalamudLauncher.cs @@ -42,7 +42,7 @@ namespace Dalamud.Injector VerboseLog = false, }; - RemoteInjector.Inject(pid, corehookConfig, ); + RemoteInjector.Inject((int)pid, corehookConfig, new PipePlatform(), m_options.RootDirectory); } } diff --git a/Dalamud.sln b/Dalamud.sln index ddda912ab..15a926f7f 100644 --- a/Dalamud.sln +++ b/Dalamud.sln @@ -51,14 +51,14 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|x64.ActiveCfg = Debug|x64 - {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|x64.Build.0 = Debug|x64 + {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|x64.ActiveCfg = Debug|Any CPU + {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|x64.Build.0 = Debug|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|x86.ActiveCfg = Debug|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Debug|x86.Build.0 = Debug|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|Any CPU.Build.0 = Release|Any CPU - {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|x64.ActiveCfg = Release|x64 - {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|x64.Build.0 = Release|x64 + {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|x64.ActiveCfg = Release|Any CPU + {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|x64.Build.0 = Release|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|x86.ActiveCfg = Release|Any CPU {B92DAB43-2279-4A2C-96E3-D9D5910EDBEA}.Release|x86.Build.0 = Release|Any CPU {5B832F73-5F54-4ADC-870F-D0095EF72C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index e780a1fe5..9ead7d04f 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -19,7 +19,6 @@ - diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index 417fa1255..cf4be768e 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -2,70 +2,25 @@ using System; using System.IO; using System.Net; using Dalamud.Interface; -using EasyHook; using Serilog; using Serilog.Core; +using CoreHook; -namespace Dalamud { - public sealed class EntryPoint : IEntryPoint { - public EntryPoint(RemoteHooking.IContext ctx, DalamudStartInfo info) { - // Required by EasyHook - } +namespace Dalamud +{ + /// + /// + /// + /// + /// + /// + public sealed class EntryPoint : IEntryPoint + { + public EntryPoint(IContext context, string rootDirectory) { } - public void Run(RemoteHooking.IContext ctx, DalamudStartInfo info) { - // Setup logger - Log.Logger = NewLogger(info.WorkingDirectory); + public void Run(IContext context, string rootDirectory) + { - try { - 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 += OnUnhandledException; - - using (var dalamud = new Dalamud(info)) { - Log.Information("Starting a session.."); - - // Run session - dalamud.Start(); - dalamud.WaitForUnload(); - } - } catch (Exception ex) { - Log.Fatal(ex, "Unhandled exception on main thread."); - } finally { - AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException; - - Log.Information("Session has ended."); - Log.CloseAndFlush(); - } - } - - private Logger NewLogger(string baseDirectory) { - var logPath = Path.Combine(baseDirectory, "dalamud.txt"); - - return new LoggerConfiguration() - .WriteTo.Async(a => a.File(logPath)) - .WriteTo.EventSink() -#if DEBUG - .MinimumLevel.Verbose() -#else - .MinimumLevel.Information() -#endif - .CreateLogger(); - } - - private void OnUnhandledException(object sender, UnhandledExceptionEventArgs arg) { - switch (arg.ExceptionObject) { - case Exception ex: - Log.Fatal(ex, "Unhandled exception on AppDomain"); - break; - default: - Log.Fatal("Unhandled SEH object on AppDomain: {Object}", arg.ExceptionObject); - break; - } } } }