[WIN32SS:ENG/NTUSER] Use shared locks for display list lookups (#9090)

- Use shared locks for the display device and PDEV lookup paths.
  These functions only walk existing lists and take references, while list updates
  and mode-switch paths still use exclusive locking.
  This avoids serializing read-only display queries unnecessarily.

- Use shared locks for other read-only NtUser calls.
This commit is contained in:
Ahmed Arif
2026-06-26 14:07:15 +02:00
committed by GitHub
parent a45e91cb3d
commit 6e95a132bd
6 changed files with 34 additions and 8 deletions
+1 -1
View File
@@ -803,7 +803,7 @@ EngpFindGraphicsDevice(
pustrDevice, iDevNum);
/* Lock list */
EngAcquireSemaphore(ghsemGraphicsDeviceList);
EngAcquireSemaphoreShared(ghsemGraphicsDeviceList);
if (pustrDevice && pustrDevice->Buffer)
{
+1 -1
View File
@@ -805,7 +805,7 @@ EngpGetPDEV(
ULONG i;
/* Acquire PDEV lock */
EngAcquireSemaphore(ghsemPDEV);
EngAcquireSemaphoreShared(ghsemPDEV);
/* Did the caller pass a device name? */
if (pustrDeviceName)
+1 -1
View File
@@ -6315,7 +6315,7 @@ NtUserMenuItemFromPoint(
int Ret = -1;
TRACE("Enter NtUserMenuItemFromPoint\n");
UserEnterExclusive();
UserEnterShared();
if (!(Menu = UserGetMenuObject(hMenu)))
{
+29 -3
View File
@@ -61,7 +61,19 @@ NtUserCallNoParam(DWORD Routine)
DWORD_PTR Result = 0;
TRACE("Enter NtUserCallNoParam\n");
UserEnterExclusive();
/* Read-only routines only need a shared lock; the rest stay exclusive */
switch (Routine)
{
case NOPARAM_ROUTINE_GETMSESSAGEPOS:
case NOPARAM_ROUTINE_GETIMESHOWSTATUS:
case NOPARAM_ROUTINE_ISCONSOLEMODE:
UserEnterShared();
break;
default:
UserEnterExclusive();
break;
}
switch (Routine)
{
@@ -158,7 +170,22 @@ NtUserCallOneParam(
TRACE("Enter NtUserCallOneParam\n");
UserEnterExclusive();
/* Read-only routines only need a shared lock; the rest stay exclusive */
switch (Routine)
{
case ONEPARAM_ROUTINE_GETDESKTOPMAPPING:
case ONEPARAM_ROUTINE_WINDOWFROMDC:
case ONEPARAM_ROUTINE_GETKEYBOARDTYPE:
case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT:
case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
case ONEPARAM_ROUTINE_GETCURSORPOS:
case ONEPARAM_ROUTINE_GETPROCDEFLAYOUT:
UserEnterShared();
break;
default:
UserEnterExclusive();
break;
}
switch (Routine)
{
@@ -319,7 +346,6 @@ NtUserCallOneParam(
}
case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
/* FIXME: Should use UserEnterShared */
Result = UserEnumClipboardFormats(Param);
break;
+1 -1
View File
@@ -1527,7 +1527,7 @@ NtUserBuildHwndList(
if (pcHwndNeeded == NULL)
return STATUS_INVALID_PARAMETER;
UserEnterExclusive();
UserEnterShared();
if (hwndParent || !dwThreadId)
{
+1 -1
View File
@@ -3283,7 +3283,7 @@ NtUserChildWindowFromPointEx(HWND hwndParent,
{
PWND pwndParent;
TRACE("Enter NtUserChildWindowFromPointEx\n");
UserEnterExclusive();
UserEnterShared();
if ((pwndParent = UserGetWindowObject(hwndParent)))
{
pwndParent = IntChildWindowFromPointEx(pwndParent, x, y, uiFlags);