Author: jimtabor
Date: Fri Sep 16 23:58:51 2016
New Revision: 72699

URL: http://svn.reactos.org/svn/reactos?rev=72699&view=rev
Log:
[NtUser]
- Use desktop thread list to search for related active desktop threads. See 
CORE-11983.

Modified:
    trunk/reactos/win32ss/user/ntuser/kbdlayout.c

Modified: trunk/reactos/win32ss/user/ntuser/kbdlayout.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/kbdlayout.c?rev=72699&r1=72698&r2=72699&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/kbdlayout.c       [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/kbdlayout.c       [iso-8859-1] Fri Sep 16 
23:58:51 2016
@@ -450,31 +450,37 @@
 UserGetKeyboardLayout(
     DWORD dwThreadId)
 {
-    NTSTATUS Status;
-    PETHREAD pThread;
     PTHREADINFO pti;
+    PLIST_ENTRY ListEntry;
     PKL pKl;
-    HKL hKl;
+
+    pti = PsGetCurrentThreadWin32Thread();
 
     if (!dwThreadId)
     {
-        pti = PsGetCurrentThreadWin32Thread();
         pKl = pti->KeyboardLayout;
         return pKl ? pKl->hkl : NULL;
     }
 
-    Status = PsLookupThreadByThreadId((HANDLE)(DWORD_PTR)dwThreadId, &pThread);
-    if (!NT_SUCCESS(Status))
-    {
-        EngSetLastError(ERROR_INVALID_PARAMETER);
-        return NULL;
-    }
-
-    pti = PsGetThreadWin32Thread(pThread);
-    pKl = pti->KeyboardLayout;
-    hKl = pKl ? pKl->hkl : NULL;
-    ObDereferenceObject(pThread);
-    return hKl;
+    ListEntry = pti->rpdesk->PtiList.Flink;
+
+    //
+    // Search the Desktop Thread list for related Desktop active Threads.
+    //
+    while(ListEntry != &pti->rpdesk->PtiList)
+    {
+        pti = CONTAINING_RECORD(ListEntry, THREADINFO, PtiLink);
+
+        if (PsGetThreadId(pti->pEThread) == UlongToHandle(dwThreadId))
+        {
+           pKl = pti->KeyboardLayout;
+           return pKl ? pKl->hkl : NULL;
+        }
+
+        ListEntry = ListEntry->Flink;
+    }
+
+    return NULL;
 }
 
 /*


Reply via email to