[ros-diffs] [jimtabor] 49653: [Wine32k|User32] - Implement client thread information for the beginning of QS flag support and signaling synchronization of messages. - Set and clear idle event when setting clea...

jimtabor at svn.reactos.org jimtabor at svn.reactos.org
Sat Nov 20 04:24:45 UTC 2010


Author: jimtabor
Date: Sat Nov 20 04:24:44 2010
New Revision: 49653

URL: http://svn.reactos.org/svn/reactos?rev=49653&view=rev
Log:
[Wine32k|User32]
- Implement client thread information for the beginning of QS flag support and signaling synchronization of messages.
- Set and clear idle event when setting clearing masks. This fixed the idle foreground hook call from user mode.
- Fixed wine ListBox and ReactOS ComboBox tests. Critical note: SendMessageA/W, when IsThreadHooked is used and any global hooks are affirmed, all messages are sent to Win32k and the result is, A to W and W to A mismatch via UMToKM. Fixing Global hook support exposed a critical bug in ReactOS message system. Enable the appropriate hooks will temporarily remedy this bug.
- All patches are from a checked out revision from 49475. Upping ntuser.h, win32k and user32 to sync.

Modified:
    trunk/reactos/dll/win32/user32/include/user32p.h
    trunk/reactos/dll/win32/user32/windows/hook.c
    trunk/reactos/dll/win32/user32/windows/message.c
    trunk/reactos/include/reactos/win32k/ntuser.h
    trunk/reactos/subsystems/win32/win32k/include/misc.h
    trunk/reactos/subsystems/win32/win32k/include/msgqueue.h
    trunk/reactos/subsystems/win32/win32k/main/dllmain.c
    trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
    trunk/reactos/subsystems/win32/win32k/ntuser/message.c
    trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
    trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
    trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c

Modified: trunk/reactos/dll/win32/user32/include/user32p.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/user32p.h?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -28,7 +28,7 @@
 
 /* One/Two Param Functions */
 #define NtUserMsqSetWakeMask(dwWaitMask) \
-  (HANDLE)NtUserCallOneParam(dwWaitMask, ONEPARAM_ROUTINE_MSQSETWAKEMASK)
+  (HANDLE)NtUserCallOneParam(dwWaitMask, ONEPARAM_ROUTINE_GETINPUTEVENT)
 
 #define NtUserMsqClearWakeMask() \
   NtUserCallNoParam(NOPARAM_ROUTINE_MSQCLEARWAKEMASK)

Modified: trunk/reactos/dll/win32/user32/windows/hook.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/hook.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/hook.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/hook.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -19,8 +19,8 @@
 /*
  *
  * PROJECT:         ReactOS user32.dll
- * FILE:            lib/user32/windows/input.c
- * PURPOSE:         Input
+ * FILE:            dll/win32/user32/windows/hook.c
+ * PURPOSE:         Hooks
  * PROGRAMMER:      Casper S. Hornstrup (chorns at users.sourceforge.net)
  * UPDATE HISTORY:
  *      09-05-2001  CSH  Created
@@ -155,7 +155,8 @@
   int nCode)
 {
   MSG Msg;
-  if (NtCurrentTeb()->Win32ThreadInfo && IsThreadHooked(GetWin32ClientInfo()))
+  if ( NtCurrentTeb()->Win32ThreadInfo &&
+      (ISITHOOKED(WH_MSGFILTER) || ISITHOOKED(WH_SYSMSGFILTER)) )
   {
      if ( lpMsg->message & ~WM_MAXIMUM )
      {
@@ -179,7 +180,8 @@
   int nCode)
 {
   MSG Msg;
-  if (NtCurrentTeb()->Win32ThreadInfo && IsThreadHooked(GetWin32ClientInfo()))
+  if ( NtCurrentTeb()->Win32ThreadInfo &&
+      (ISITHOOKED(WH_MSGFILTER) || ISITHOOKED(WH_SYSMSGFILTER)) )
   {
      if ( lpMsg->message & ~WM_MAXIMUM )
      {

Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/message.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -2066,14 +2066,16 @@
   {
       if ( Window != NULL &&
            Window->head.pti == ti &&
-          !IsThreadHooked(GetWin32ClientInfo()) &&
+//          !IsThreadHooked(GetWin32ClientInfo()) && // Enable to test message system bug.
+          !ISITHOOKED(WH_CALLWNDPROC) &&
+          !ISITHOOKED(WH_CALLWNDPROCRET) &&
           !(Window->state & WNDS_SERVERSIDEWINDOWPROC) )
       {
           /* NOTE: We can directly send messages to the window procedure
                    if *all* the following conditions are met:
 
                    * Window belongs to calling thread
-                   * The calling thread is not being hooked
+                   * The calling thread is not being hooked for CallWndProc
                    * Not calling a server side proc:
                      Desktop, Switch, ScrollBar, Menu, IconTitle, or hWndMessage
            */
@@ -2137,14 +2139,16 @@
   {
       if ( Window != NULL &&
            Window->head.pti == ti &&
-          !IsThreadHooked(GetWin32ClientInfo()) &&
+//          !IsThreadHooked(GetWin32ClientInfo()) && // Enable to test message system bug.
+          !ISITHOOKED(WH_CALLWNDPROC) &&
+          !ISITHOOKED(WH_CALLWNDPROCRET) &&
           !(Window->state & WNDS_SERVERSIDEWINDOWPROC) )
       {
           /* NOTE: We can directly send messages to the window procedure
                    if *all* the following conditions are met:
 
                    * Window belongs to calling thread
-                   * The calling thread is not being hooked
+                   * The calling thread is not being hooked for CallWndProc
                    * Not calling a server side proc: 
                      Desktop, Switch, ScrollBar, Menu, IconTitle, or hWndMessage
            */
@@ -2694,9 +2698,8 @@
 DWORD gfMessagePumpHook = 0;
 
 BOOL WINAPI IsInsideMessagePumpHook()
-{  // Fixme: Need to fully implement this! FF uses this and polls it when Min/Max
+{  // FF uses this and polls it when Min/Max
    PCLIENTTHREADINFO pcti = GetWin32ClientInfo()->pClientThreadInfo;
-//   FIXME("IIMPH %x\n",pcti);
    return (gfMessagePumpHook && pcti && (pcti->dwcPumpHook > 0));
 }
 

Modified: trunk/reactos/include/reactos/win32k/ntuser.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntuser.h?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -3161,7 +3161,6 @@
 #define ONEPARAM_ROUTINE_SWITCHCARETSHOWING   0xfffe0008
 #define ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING 0xfffe000d
 #define ONEPARAM_ROUTINE_GETDESKTOPMAPPING    0xfffe000e
-#define ONEPARAM_ROUTINE_MSQSETWAKEMASK       0xfffe0027
 #define ONEPARAM_ROUTINE_GETCURSORPOSITION    0xfffe0048 // use ONEPARAM_ or TWOPARAM routine ?
 #define TWOPARAM_ROUTINE_GETWINDOWRGNBOX    0xfffd0048 // user mode
 #define TWOPARAM_ROUTINE_GETWINDOWRGN       0xfffd0049 // user mode

Modified: trunk/reactos/subsystems/win32/win32k/include/misc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/misc.h?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/misc.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/misc.h [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -24,7 +24,7 @@
 extern SHORT gusLanguageID;
 
 SHORT FASTCALL IntGdiGetLanguageID(VOID);
-DWORD APIENTRY IntGetQueueStatus(BOOL ClearChanges);
+DWORD APIENTRY IntGetQueueStatus(DWORD);
 VOID FASTCALL IntUserManualGuiCheck(LONG Check);
 PVOID APIENTRY HackSecureVirtualMemory(IN PVOID,IN SIZE_T,IN ULONG,OUT PVOID *);
 VOID APIENTRY HackUnsecureVirtualMemory(IN PVOID);

Modified: trunk/reactos/subsystems/win32/win32k/include/msgqueue.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/msgqueue.h?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/msgqueue.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/msgqueue.h [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -275,4 +275,7 @@
     return (LONG)(TickCount->QuadPart * (KeQueryTimeIncrement() / 10000));
 }
 
+VOID FASTCALL IdlePing(VOID);
+VOID FASTCALL IdlePong(VOID);
+
 /* EOF */

Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/main/dllmain.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -279,7 +279,6 @@
         { /* Attempt to startup client support which should have been initialized in IntSetThreadDesktop. */
            PCLIENTINFO pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
            Win32Thread->pClientInfo = pci;
-           pci->pClientThreadInfo = NULL;
            pci->ppi = Win32Thread->ppi;
            pci->fsHooks = Win32Thread->fsHooks;
            if (Win32Thread->KeyboardLayout) pci->hKL = Win32Thread->KeyboardLayout->hkl;
@@ -291,6 +290,10 @@
 
               pci->pDeskInfo = (PVOID)((ULONG_PTR)Win32Thread->pDeskInfo - pci->ulClientDelta);
            }
+           if (Win32Thread->pcti && pci->pDeskInfo)
+              pci->pClientThreadInfo = (PVOID)((ULONG_PTR)Win32Thread->pcti - pci->ulClientDelta);
+           else
+              pci->pClientThreadInfo = NULL;
         }
         else
         {
@@ -331,6 +334,7 @@
 
         IntSetThreadDesktop(NULL,
                             TRUE);
+
 
         PsSetThreadWin32Thread(Thread, NULL);
     }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -1835,7 +1835,6 @@
 static NTSTATUS
 IntMapDesktopView(IN PDESKTOP DesktopObject)
 {
-    PTHREADINFO ti;
     PPROCESSINFO CurrentWin32Process;
     PW32HEAP_USER_MAPPING HeapMapping, *PrevLink;
     PVOID UserBase = NULL;
@@ -1898,19 +1897,6 @@
 
     ObReferenceObject(DesktopObject);
 
-    /* create a W32THREADINFO structure if not already done, or update it */
-    ti = GetW32ThreadInfo();
-    GetWin32ClientInfo()->ulClientDelta = DesktopHeapGetUserDelta();
-    if (ti != NULL)
-    {
-        if (GetWin32ClientInfo()->pDeskInfo == NULL)
-        {
-           GetWin32ClientInfo()->pDeskInfo = 
-                (PVOID)((ULONG_PTR)DesktopObject->pDeskInfo - 
-                                          GetWin32ClientInfo()->ulClientDelta);
-        }
-    }
-
     return STATUS_SUCCESS;
 }
 
@@ -1922,6 +1908,7 @@
     PTHREADINFO W32Thread;
     NTSTATUS Status;
     BOOL MapHeap;
+    CLIENTTHREADINFO ctiSave;
 
     DPRINT("IntSetThreadDesktop() DO=%p, FOF=%d\n", DesktopObject, FreeOnFailure);
     MapHeap = (PsGetCurrentProcess() != PsInitialSystemProcess);
@@ -1948,9 +1935,27 @@
                 SetLastNtError(Status);
                 return FALSE;
             }
+            W32Thread->pDeskInfo = DesktopObject->pDeskInfo;
         }
 
-        /* Hack for system threads */
+        RtlZeroMemory(&ctiSave, sizeof(CLIENTTHREADINFO));
+
+        if (W32Thread->pcti && OldDesktop)
+        {
+           RtlCopyMemory(&ctiSave, W32Thread->pcti, sizeof(CLIENTTHREADINFO));
+           DPRINT("Free ClientThreadInfo\n");
+           DesktopHeapFree(OldDesktop, W32Thread->pcti);
+           W32Thread->pcti = NULL;
+        }
+
+        if (!W32Thread->pcti && DesktopObject)
+        { 
+           DPRINT("Allocate ClientThreadInfo\n");
+           W32Thread->pcti = DesktopHeapAlloc( DesktopObject,
+                                               sizeof(CLIENTTHREADINFO));
+           RtlCopyMemory(W32Thread->pcti, &ctiSave, sizeof(CLIENTTHREADINFO));
+        }
+
         if (NtCurrentTeb())
         {
             PCLIENTINFO pci = GetWin32ClientInfo();
@@ -1958,6 +1963,7 @@
             if (DesktopObject)
             {
                 pci->pDeskInfo = (PVOID)((ULONG_PTR)DesktopObject->pDeskInfo - pci->ulClientDelta);
+                if (W32Thread->pcti) pci->pClientThreadInfo = (PVOID)((ULONG_PTR)W32Thread->pcti - pci->ulClientDelta);
             }
         }
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/message.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/message.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/message.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -1901,7 +1901,7 @@
 
 
 DWORD APIENTRY
-IntGetQueueStatus(BOOL ClearChanges)
+IntGetQueueStatus(DWORD Changes)
 {
     PTHREADINFO pti;
     PUSER_MESSAGE_QUEUE Queue;
@@ -1909,12 +1909,18 @@
 
     pti = PsGetCurrentThreadWin32Thread();
     Queue = pti->MessageQueue;
-
-    Result = MAKELONG(Queue->QueueBits, Queue->ChangedBits);
-    if (ClearChanges)
-    {
-        Queue->ChangedBits = 0;
-    }
+// wine:
+    Changes &= (QS_ALLINPUT|QS_ALLPOSTMESSAGE|QS_SMRESULT);
+
+    Result = MAKELONG(Queue->ChangedBits & Changes, Queue->QueueBits & Changes);
+
+    if (pti->pcti)
+    {
+       pti->pcti->fsChangeBits = Queue->ChangedBits;
+       pti->pcti->fsChangeBits &= ~Changes;
+    }
+
+    Queue->ChangedBits &= ~Changes;
 
     return Result;
 }
@@ -2089,7 +2095,6 @@
 {
     NTUSERGETMESSAGEINFO Info;
     NTSTATUS Status;
-    /* FIXME: if initialization is removed, gcc complains that this may be used before initialization. Please review */
     PMSGMEMORY MsgMemoryEntry;
     PVOID UserMem;
     ULONG Size;
@@ -2110,7 +2115,7 @@
 
     UserLeave();
 
-    Info.Msg = Msg; //.Msg;
+    Info.Msg = Msg;
     /* See if this message type is present in the table */
     MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
 

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/misc.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -125,7 +125,7 @@
          break;
 
       case THREADSTATE_GETINPUTSTATE:
-         ret = HIWORD(IntGetQueueStatus(FALSE)) & (QS_KEY | QS_MOUSEBUTTON);
+         ret = LOWORD(IntGetQueueStatus(QS_POSTMESSAGE|QS_TIMER|QS_PAINT|QS_SENDMESSAGE|QS_INPUT)) & (QS_KEY | QS_MOUSEBUTTON);
          break;
    }
 
@@ -471,8 +471,6 @@
     }
     /* initialize it */
     pti->ppi = ppi = GetW32ProcessInfo();
-
-    pti->pcti = &pti->cti; // FIXME Need to set it in desktop.c!
 
     if (pti->rpdesk != NULL)
     {
@@ -494,7 +492,6 @@
 
         Teb->Win32ThreadInfo = (PW32THREAD) pti;
 
-        pci->pClientThreadInfo = NULL; // FIXME Need to set it in desktop.c!
         pci->ppi = ppi;
         pci->fsHooks = pti->fsHooks;
         if (pti->KeyboardLayout) pci->hKL = pti->KeyboardLayout->hkl;
@@ -506,6 +503,11 @@
 
            pci->pDeskInfo = (PVOID)((ULONG_PTR)pti->pDeskInfo - pci->ulClientDelta);
         }
+        if (pti->pcti && pci->pDeskInfo)
+           pci->pClientThreadInfo = (PVOID)((ULONG_PTR)pti->pcti - pci->ulClientDelta);
+        else
+           pci->pClientThreadInfo = NULL;
+
     }
     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
     {

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -77,6 +77,11 @@
    MessageQueue->WakeMask = WakeMask;
    MessageEventHandle = MessageQueue->NewMessagesHandle;
 
+   if (Win32Thread->pcti)
+      Win32Thread->pcti->fsWakeMask = WakeMask;
+
+   IdlePing();
+
    return MessageEventHandle;
 }
 
@@ -93,6 +98,11 @@
    MessageQueue = Win32Thread->MessageQueue;
 // HACK!!!!!!! Newbies that wrote this should hold your head down in shame! (jt)
    MessageQueue->WakeMask = ~0;
+
+   if (Win32Thread->pcti)
+      Win32Thread->pcti->fsWakeMask = 0;
+
+   IdlePong();
 
    return TRUE;
 }

Modified: trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c?rev=49653&r1=49652&r2=49653&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] Sat Nov 20 04:24:44 2010
@@ -252,7 +252,7 @@
             RETURN( FALSE);
          }
 
-      case ONEPARAM_ROUTINE_MSQSETWAKEMASK:
+      case ONEPARAM_ROUTINE_GETINPUTEVENT:
          RETURN( (DWORD_PTR)IntMsqSetWakeMask(Param));
 
       case ONEPARAM_ROUTINE_GETKEYBOARDTYPE:
@@ -269,12 +269,7 @@
 
       case ONEPARAM_ROUTINE_GETQUEUESTATUS:
       {
-         DWORD Ret;
-         WORD changed_bits, wake_bits;
-         Ret = IntGetQueueStatus(FALSE);
-         changed_bits = LOWORD(Ret);
-         wake_bits = HIWORD(Ret);
-         RETURN( MAKELONG(changed_bits & Param, wake_bits & Param));
+         RETURN (IntGetQueueStatus((DWORD)Param));
       }
       case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS:
          /* FIXME: Should use UserEnterShared */




More information about the Ros-diffs mailing list