Author: jimtabor Date: Sat Oct 10 06:40:36 2009 New Revision: 43352 URL: http://svn.reactos.org/svn/reactos?rev=43352&view=rev Log: - [Win32k] Implement AttachThreadInput, not yet connected to the thread message queue, update related. - See http://www.codeproject.com/KB/cpp/onscreenkeyboard.aspx for test program.
Modified: trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/include/input.h trunk/reactos/subsystems/win32/win32k/include/tags.h trunk/reactos/subsystems/win32/win32k/include/win32.h trunk/reactos/subsystems/win32/win32k/ntuser/input.c trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntuser.h?rev=43352&r1=43351&r2=43352&view=diff ============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sat Oct 10 06:40:36 2009 @@ -124,7 +124,13 @@ PVOID pvWnd; } CALLBACKWND, *PCALLBACKWND; -#define CI_CURTHPRHOOK 0x00000010 +#define CI_TRANSACTION 0x00000001 +#define CI_QUEUEMSG 0x00000002 +#define CI_WOW 0x00000004 +#define CI_INITTHREAD 0x00000008 +#define CI_CURTHPRHOOK 0x00000010 +#define CI_CLASSESREGISTERED 0x00000020 +#define CI_IMMACTIVATE 0x00000040 typedef struct _CLIENTINFO { Modified: trunk/reactos/subsystems/win32/win32k/include/input.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/input.h?rev=43352&r1=43351&r2=43352&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/input.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/input.h [iso-8859-1] Sat Oct 10 06:40:36 2009 @@ -14,6 +14,15 @@ HKL hkl; DWORD klid; // Low word - language id. High word - device id. } KBL, *PKBL; + +typedef struct _ATTACHINFO +{ + struct _ATTACHINFO* paiNext; + PTHREADINFO pti1; + PTHREADINFO pti2; +} ATTACHINFO, *PATTACHINFO; + +extern PATTACHINFO gpai; #define KBL_UNLOAD 1 #define KBL_PRELOAD 2 @@ -33,6 +42,7 @@ BOOL UserInitDefaultKeyboardLayout(); PKBL UserHklToKbl(HKL hKl); +BOOL FASTCALL UserAttachThreadInput(PTHREADINFO,PTHREADINFO,BOOL); #define ThreadHasInputAccess(W32Thread) \ (TRUE) Modified: trunk/reactos/subsystems/win32/win32k/include/tags.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/tags.h?rev=43352&r1=43351&r2=43352&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/tags.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/tags.h [iso-8859-1] Sat Oct 10 06:40:36 2009 @@ -26,6 +26,7 @@ #define TAG_CALLBACK 'KCBC' /* callback memory */ #define TAG_WINSTA 'ATSW' /* window station */ #define TAG_PDCE 'cdsU' /* dce */ +#define TAG_ATTACHINFO 'iasU' /* Attach Info Input */ #define TAG_INPUT 'yssU' /* Input */ /* gdi objects from the handle table */ Modified: trunk/reactos/subsystems/win32/win32k/include/win32.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/win32.h?rev=43352&r1=43351&r2=43352&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Sat Oct 10 06:40:36 2009 @@ -105,10 +105,18 @@ PDESKTOPINFO pDeskInfo; PCLIENTINFO pClientInfo; FLONG TIF_flags; + PUNICODE_STRING pstrAppName; LONG timeLast; + ULONG_PTR idLast; + INT exitCode; HANDLE hDesktop; UINT cPaintsReady; /* Count of paints pending. */ UINT cTimersReady; /* Count of timers pending. */ + DWORD dwExpWinVer; + DWORD dwCompatFlags; + DWORD dwCompatFlags2; + struct _USER_MESSAGE_QUEUE* pqAttach; + PTHREADINFO ptiSibling; ULONG fsHooks; PHOOK sphkCurrent; LIST_ENTRY PtiLink; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/input.c?rev=43352&r1=43351&r2=43352&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Sat Oct 10 06:40:36 2009 @@ -1,23 +1,4 @@ /* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -/* $Id$ - * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Window classes @@ -42,6 +23,7 @@ PTHREADINFO ptiRawInput; PKTIMER MasterTimer; +PATTACHINFO gpai = NULL; static HANDLE MouseDeviceHandle; static HANDLE MouseThreadHandle; @@ -1324,6 +1306,57 @@ return FALSE; } +BOOL FASTCALL +UserAttachThreadInput( PTHREADINFO pti, PTHREADINFO ptiTo, BOOL fAttach) +{ + PATTACHINFO pai; + + /* Can not be the same thread.*/ + if (pti == ptiTo) return FALSE; + + /* Do not attach if IMM is in activate mode or between different desktops. */ + if ( pti->pClientInfo->CI_flags & CI_IMMACTIVATE || + ptiTo->pClientInfo->CI_flags & CI_IMMACTIVATE || + pti->Desktop != ptiTo->Desktop ) + return FALSE; + + /* If Attach set, allocate and link. */ + if ( fAttach ) + { + pai = ExAllocatePoolWithTag(PagedPool, sizeof(ATTACHINFO), TAG_ATTACHINFO); + if ( !pai ) return FALSE; + + pai->paiNext = gpai; + pai->pti1 = pti; + pai->pti2 = ptiTo; + gpai = pai; + } + else /* If clear, unlink and free it. */ + { + PATTACHINFO paiprev = NULL; + + if ( !gpai ) return FALSE; + + pai = gpai; + + /* Search list and free if found or return false. */ + do + { + if ( pai->pti2 == ptiTo && pai->pti1 == pti ) break; + paiprev = pai; + pai = pai->paiNext; + } while (pai); + + if ( !pai ) return FALSE; + + if (paiprev) paiprev->paiNext = pai->paiNext; + + ExFreePoolWithTag(pai, TAG_ATTACHINFO); + } + + return TRUE; +} + UINT APIENTRY NtUserSendInput( Modified: trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c?rev=43352&r1=43351&r2=43352&view=diff ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/ntstubs.c [iso-8859-1] Sat Oct 10 06:40:36 2009 @@ -31,9 +31,36 @@ IN DWORD idAttachTo, IN BOOL fAttach) { - UNIMPLEMENTED - - return 0; + NTSTATUS Status; + PETHREAD Thread, ThreadTo; + PTHREADINFO pti, ptiTo; + BOOL Ret = FALSE; + + UserEnterExclusive(); + Status = PsLookupThreadByThreadId((HANDLE)idAttach, &Thread); + if (!NT_SUCCESS(Status)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + goto Exit; + } + Status = PsLookupThreadByThreadId((HANDLE)idAttachTo, &ThreadTo); + if (!NT_SUCCESS(Status)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + ObDereferenceObject(Thread); + goto Exit; + } + + pti = PsGetThreadWin32Thread(Thread); + ptiTo = PsGetThreadWin32Thread(ThreadTo); + ObDereferenceObject(Thread); + ObDereferenceObject(ThreadTo); + + Ret = UserAttachThreadInput( pti, ptiTo, fAttach); + +Exit: + UserLeave(); + return Ret; } //