Disable module load/unload logging (#1948)

This commit is contained in:
srkizer 2024-07-19 17:20:30 +09:00 committed by GitHub
parent 7707da079c
commit 5af935bbca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -57,8 +57,22 @@ internal sealed unsafe partial class CurrentProcessModules : IInternalDisposable
}
/// <summary>Gets all the loaded modules, up to date.</summary>
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;
}
}
/// <inheritdoc/>
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<char>(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;
/// <summary>
/// Registers for notification when a DLL is first loaded.