diff --git a/reactos/iface/addsys/w32ksvc.db b/reactos/iface/addsys/w32ksvc.db index 05a153c42c8..44e6b9782e3 100644 --- a/reactos/iface/addsys/w32ksvc.db +++ b/reactos/iface/addsys/w32ksvc.db @@ -545,3 +545,4 @@ NtUserYieldTask 0 NtUserGetDesktopWindow 0 # ReactOS only system calls NtUserAcquireOrReleaseInputOwnership 1 +NtUserGetWindowThreadProcessId 2 diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index ae329a63c7c..32f218d476b 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -1741,6 +1741,9 @@ DWORD STDCALL NtUserYieldTask(VOID); +DWORD STDCALL +NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid); + #endif /* __WIN32K_NTUSER_H */ /* EOF */ diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index d75adbf84e6..f54f5e49d9f 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -83,6 +83,7 @@ typedef struct _WINDOW_OBJECT PSCROLLBARINFO wExtra; LONG UserData; WNDPROC WndProc; + PETHREAD OwnerThread; } WINDOW_OBJECT, *PWINDOW_OBJECT; /* Window flags. */ @@ -108,6 +109,10 @@ BOOL FASTCALL W32kIsChildWindow (HWND Parent, HWND Child); HWND FASTCALL W32kGetDesktopWindow (VOID); HWND FASTCALL W32kGetFocusWindow (VOID); HWND FASTCALL W32kSetFocusWindow (HWND hWnd); + +DWORD FASTCALL +W32kGetWindowThreadProcessId(PWINDOW_OBJECT Wnd, PDWORD pid); + #endif /* __WIN32K_WINDOW_H */ /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 73c2ca8ce8a..f834d00ccdf 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.66 2003/07/24 15:59:34 rcampbell Exp $ +/* $Id: window.c,v 1.67 2003/07/25 19:35:51 gdalsnes Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -490,6 +490,7 @@ W32kCreateDesktopWindow(PWINSTATION_OBJECT WindowStation, WindowObject->ClientRect = WindowObject->WindowRect; WindowObject->UserData = 0; WindowObject->WndProc = DesktopClass->Class.lpfnWndProc; + WindowObject->OwnerThread = PsGetCurrentThread(); InitializeListHead(&WindowObject->ChildrenListHead); ExInitializeFastMutex(&WindowObject->ChildrenListLock); @@ -631,6 +632,7 @@ NtUserCreateWindowEx(DWORD dwExStyle, WindowObject->Parent = ParentWindow; WindowObject->UserData = 0; WindowObject->WndProc = ClassObject->Class.lpfnWndProc; + WindowObject->OwnerThread = PsGetCurrentThread(); ExAcquireFastMutexUnsafe(&ParentWindow->ChildrenListLock); InsertHeadList(&ParentWindow->ChildrenListHead, @@ -1964,4 +1966,36 @@ NtUserGetDesktopWindow() return W32kGetDesktopWindow(); } + +DWORD FASTCALL +W32kGetWindowThreadProcessId(PWINDOW_OBJECT Wnd, PDWORD pid) +{ + if (pid) *pid = (DWORD) Wnd->OwnerThread->Cid.UniqueThread; + return (DWORD) Wnd->OwnerThread->ThreadsProcess->UniqueProcessId; +} + + +DWORD STDCALL +NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid) +{ + PWINDOW_OBJECT Wnd; + DWORD tid, pid; + + //W32kAcquireWindowsLockShared(); + + if (!(Wnd = W32kGetWindowObject(hWnd))) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return 0; + } + + tid = W32kGetWindowThreadProcessId(Wnd, &pid); + W32kReleaseWindowObject(Wnd); + //W32kReleaseWindowsLock(); + + if (UnsafePid) MmCopyToCaller(UnsafePid, &pid, sizeof(DWORD)); + + return tid; +} + /* EOF */