[PATCH v2 04/22] ntdll: Use a critical section for guarding ldr_notifications list.
Paul Gofman
pgofman at codeweavers.com
Tue Oct 5 17:49:10 CDT 2021
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
dlls/ntdll/loader.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index f7b96b45b6f..5ee4215f875 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -115,6 +115,15 @@ struct ldr_notification
static struct list ldr_notifications = LIST_INIT( ldr_notifications );
+static CRITICAL_SECTION ldr_notifications_section;
+static CRITICAL_SECTION_DEBUG ldr_notifications_critsect_debug =
+{
+ 0, 0, &ldr_notifications_section,
+ { &ldr_notifications_critsect_debug.ProcessLocksList, &ldr_notifications_critsect_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": ldr_notifications_section") }
+};
+static CRITICAL_SECTION ldr_notifications_section = { &ldr_notifications_critsect_debug, -1, 0, 0, 0, 0 };
+
static const char * const reason_names[] =
{
"PROCESS_DETACH",
@@ -485,6 +494,7 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module )
data.Loaded.DllBase = module->DllBase;
data.Loaded.SizeOfImage = module->SizeOfImage;
+ RtlEnterCriticalSection( &ldr_notifications_section );
LIST_FOR_EACH_ENTRY_SAFE( notify, notify_next, &ldr_notifications, struct ldr_notification, entry )
{
TRACE_(relay)("\1Call LDR notification callback (proc=%p,reason=%u,data=%p,context=%p)\n",
@@ -495,6 +505,7 @@ static void call_ldr_notifications( ULONG reason, LDR_DATA_TABLE_ENTRY *module )
TRACE_(relay)("\1Ret LDR notification callback (proc=%p,reason=%u,data=%p,context=%p)\n",
notify->callback, reason, &data, notify->context );
}
+ RtlLeaveCriticalSection( &ldr_notifications_section );
}
/*************************************************************************
@@ -1681,9 +1692,9 @@ NTSTATUS WINAPI LdrRegisterDllNotification(ULONG flags, PLDR_DLL_NOTIFICATION_FU
notify->callback = callback;
notify->context = context;
- lock_loader_exclusive();
+ RtlEnterCriticalSection( &ldr_notifications_section );
list_add_tail( &ldr_notifications, ¬ify->entry );
- unlock_loader();
+ RtlLeaveCriticalSection( &ldr_notifications_section );
*cookie = notify;
return STATUS_SUCCESS;
@@ -1700,9 +1711,9 @@ NTSTATUS WINAPI LdrUnregisterDllNotification( void *cookie )
if (!notify) return STATUS_INVALID_PARAMETER;
- lock_loader_exclusive();
+ RtlEnterCriticalSection( &ldr_notifications_section );
list_remove( ¬ify->entry );
- unlock_loader();
+ RtlLeaveCriticalSection( &ldr_notifications_section );
RtlFreeHeap( GetProcessHeap(), 0, notify );
return STATUS_SUCCESS;
--
2.31.1
More information about the wine-devel
mailing list