From 5af935bbcaa36de3dd9e444f2d2832dd3142e40b Mon Sep 17 00:00:00 2001 From: srkizer Date: Fri, 19 Jul 2024 17:20:30 +0900 Subject: [PATCH] Disable module load/unload logging (#1948) --- Dalamud/Support/CurrentProcessModules.cs | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Dalamud/Support/CurrentProcessModules.cs b/Dalamud/Support/CurrentProcessModules.cs index 961c9828f..bc0abcf50 100644 --- a/Dalamud/Support/CurrentProcessModules.cs +++ b/Dalamud/Support/CurrentProcessModules.cs @@ -57,8 +57,22 @@ internal sealed unsafe partial class CurrentProcessModules : IInternalDisposable } /// Gets all the loaded modules, up to date. - public static ProcessModuleCollection ModuleCollection => - (cookie == 0 ? Process.GetCurrentProcess() : process ??= Process.GetCurrentProcess()).Modules; + public static ProcessModuleCollection ModuleCollection + { + get + { + if (cookie == 0) + { + // This service has not been initialized; return a fresh copy without storing it. + return Process.GetCurrentProcess().Modules; + } + + if (process is null) + Log.Verbose("{what}: Fetchling fresh copy of current process modules.", nameof(CurrentProcessModules)); + + return (process ??= Process.GetCurrentProcess()).Modules; + } + } /// void IInternalDisposableService.DisposeService() @@ -77,14 +91,7 @@ internal sealed unsafe partial class CurrentProcessModules : IInternalDisposable private static void DllNotificationCallback( LdrDllNotificationReason reason, LdrDllNotificationData* data, - nint context) - { - process = null; - var name = new ReadOnlySpan(data->FullDllName->Buffer, data->FullDllName->Length / 2); - LogQueue.Enqueue( - $"[{nameof(CurrentProcessModules)}]: {reason}: {name} @ 0x{data->DllBase:X} ({data->SizeOfImage}:X bytes)"); - LogSemaphore.Release(); - } + nint context) => process = null; /// /// Registers for notification when a DLL is first loaded.