diff --git a/reactos/subsystems/win32/win32k/include/callback.h b/reactos/subsystems/win32/win32k/include/callback.h index f9ca3cc15c8..1bc822bdecf 100644 --- a/reactos/subsystems/win32/win32k/include/callback.h +++ b/reactos/subsystems/win32/win32k/include/callback.h @@ -46,7 +46,7 @@ co_IntCallEventProc(HWINEVENTHOOK hook, WINEVENTPROC Proc); VOID FASTCALL -IntCleanupThreadCallbacks(PW32THREAD W32Thread); +IntCleanupThreadCallbacks(PTHREADINFO W32Thread); PVOID FASTCALL IntCbAllocateMemory(ULONG Size); diff --git a/reactos/subsystems/win32/win32k/include/caret.h b/reactos/subsystems/win32/win32k/include/caret.h index 6d3a1dac719..dc6dae5dd81 100644 --- a/reactos/subsystems/win32/win32k/include/caret.h +++ b/reactos/subsystems/win32/win32k/include/caret.h @@ -7,7 +7,7 @@ #define IDCARETTIMER (0xffff) BOOL FASTCALL -co_IntDestroyCaret(PW32THREAD Win32Thread); +co_IntDestroyCaret(PTHREADINFO Win32Thread); BOOL FASTCALL IntSetCaretBlinkTime(UINT uMSeconds); diff --git a/reactos/subsystems/win32/win32k/include/desktop.h b/reactos/subsystems/win32/win32k/include/desktop.h index 81da0c6277c..796366c870c 100644 --- a/reactos/subsystems/win32/win32k/include/desktop.h +++ b/reactos/subsystems/win32/win32k/include/desktop.h @@ -198,11 +198,13 @@ static __inline ULONG_PTR DesktopHeapGetUserDelta(VOID) { PW32HEAP_USER_MAPPING Mapping; + PTHREADINFO pti; HANDLE hDesktopHeap; ULONG_PTR Delta = 0; - ASSERT(PsGetCurrentThreadWin32Thread()->Desktop != NULL); - hDesktopHeap = PsGetCurrentThreadWin32Thread()->Desktop->hDesktopHeap; + pti = PsGetCurrentThreadWin32Thread(); + ASSERT(pti->Desktop != NULL); + hDesktopHeap = pti->Desktop->hDesktopHeap; Mapping = PsGetCurrentProcessWin32Process()->HeapMappings.Next; while (Mapping != NULL) diff --git a/reactos/subsystems/win32/win32k/include/hook.h b/reactos/subsystems/win32/win32k/include/hook.h index 0a020bfaed1..f471362820a 100644 --- a/reactos/subsystems/win32/win32k/include/hook.h +++ b/reactos/subsystems/win32/win32k/include/hook.h @@ -18,7 +18,7 @@ typedef struct tagHOOK #define NB_HOOKS (WH_MAXHOOK-WH_MINHOOK+1) #define HOOKID_TO_INDEX(HookId) (HookId - WH_MINHOOK) #define HOOKID_TO_FLAG(HookId) (1 << ((HookId) + 1)) -#define ISITHOOKED(HookId) (PsGetCurrentThreadWin32Thread()->Hooks & HOOKID_TO_FLAG(HookId)) +#define ISITHOOKED(HookId) (((PTHREADINFO)PsGetCurrentThreadWin32Thread())->Hooks & HOOKID_TO_FLAG(HookId)) typedef struct tagHOOKTABLE { diff --git a/reactos/subsystems/win32/win32k/include/input.h b/reactos/subsystems/win32/win32k/include/input.h index a74ef1f1c8e..41e4eda629e 100644 --- a/reactos/subsystems/win32/win32k/include/input.h +++ b/reactos/subsystems/win32/win32k/include/input.h @@ -27,7 +27,7 @@ PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue(VOID); VOID W32kUnregisterPrimitiveMessageQueue(VOID); PKBL W32kGetDefaultKeyLayout(VOID); VOID FASTCALL W32kKeyProcessMessage(LPMSG Msg, PKBDTABLES KeyLayout, BYTE Prefix); -BOOL FASTCALL IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt); +BOOL FASTCALL IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt); BOOL FASTCALL IntMouseInput(MOUSEINPUT *mi); BOOL FASTCALL IntKeyboardInput(KEYBDINPUT *ki); diff --git a/reactos/subsystems/win32/win32k/include/object.h b/reactos/subsystems/win32/win32k/include/object.h index e8b9a9d9dfe..7ec00b7be40 100644 --- a/reactos/subsystems/win32/win32k/include/object.h +++ b/reactos/subsystems/win32/win32k/include/object.h @@ -87,7 +87,7 @@ typedef struct _USER_REFERENCE_ENTRY static __inline VOID UserAssertLastRef(PVOID obj, const char *file, int line) { - PW32THREAD W32Thread; + PTHREADINFO W32Thread; PSINGLE_LIST_ENTRY ReferenceEntry; PUSER_REFERENCE_ENTRY UserReferenceEntry; @@ -122,7 +122,7 @@ VOID UserInitHandleTable(PUSER_HANDLE_TABLE ht, PVOID mem, ULONG bytes); static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry) { - PW32THREAD W32Thread; + PTHREADINFO W32Thread; W32Thread = PsGetCurrentThreadWin32Thread(); ASSERT(W32Thread != NULL); @@ -135,7 +135,7 @@ UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry) static __inline VOID UserDerefObjectCo(PVOID obj) { - PW32THREAD W32Thread; + PTHREADINFO W32Thread; PSINGLE_LIST_ENTRY ReferenceEntry; PUSER_REFERENCE_ENTRY UserReferenceEntry; diff --git a/reactos/subsystems/win32/win32k/include/painting.h b/reactos/subsystems/win32/win32k/include/painting.h index f3eccf2f1f0..1c80319c41c 100644 --- a/reactos/subsystems/win32/win32k/include/painting.h +++ b/reactos/subsystems/win32/win32k/include/painting.h @@ -10,7 +10,7 @@ co_UserRedrawWindow(PWINDOW_OBJECT Wnd, const RECT* UpdateRect, HRGN UpdateRgn, VOID FASTCALL IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags); BOOL FASTCALL -IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, PW32THREAD Thread, +IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, PTHREADINFO Thread, MSG *Message, BOOL Remove); INT FASTCALL UserRealizePalette(HDC); diff --git a/reactos/subsystems/win32/win32k/include/win32.h b/reactos/subsystems/win32/win32k/include/win32.h index 10316479777..679281d5b6e 100644 --- a/reactos/subsystems/win32/win32k/include/win32.h +++ b/reactos/subsystems/win32/win32k/include/win32.h @@ -3,22 +3,42 @@ #include +typedef struct _TL +{ + struct _TL* next; + PVOID pobj; + PVOID pfnFree; +} TL, *PTL; + typedef struct _W32THREAD { + PETHREAD pEThread; + ULONG RefCount; + PTL ptlW32; + PVOID pgdiDcattr; + PVOID pgdiBrushAttr; + PVOID pUMPDObjs; + PVOID pUMPDHeap; + DWORD dwEngAcquireCount; + PVOID pSemTable; + PVOID pUMPDObj; +} W32THREAD, *PW32THREAD; + +typedef struct _THREADINFO +{ + W32THREAD W32Thread; + struct _USER_MESSAGE_QUEUE* MessageQueue; LIST_ENTRY WindowListHead; LIST_ENTRY W32CallbackListHead; struct _KBL* KeyboardLayout; struct _DESKTOP_OBJECT* Desktop; HANDLE hDesktop; - PVOID pgdiDcattr; - PVOID pgdiBrushAttr; - DWORD dwEngAcquireCount; BOOLEAN IsExiting; SINGLE_LIST_ENTRY ReferencesList; ULONG Hooks; PW32THREADINFO ThreadInfo; -} W32THREAD, *PW32THREAD; +} THREADINFO, *PTHREADINFO; #include @@ -49,5 +69,4 @@ typedef struct _W32PROCESS PW32PROCESSINFO ProcessInfo; } W32PROCESS, *PW32PROCESS; - #endif /* __INCLUDE_NAPI_WIN32_H */ diff --git a/reactos/subsystems/win32/win32k/main/dllmain.c b/reactos/subsystems/win32/win32k/main/dllmain.c index 161e206649b..1fcb5a65d36 100644 --- a/reactos/subsystems/win32/win32k/main/dllmain.c +++ b/reactos/subsystems/win32/win32k/main/dllmain.c @@ -174,7 +174,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, PSW32THREADCALLOUTTYPE Type) { struct _EPROCESS *Process; - PW32THREAD Win32Thread; + PTHREADINFO Win32Thread; DECLARE_RETURN(NTSTATUS); DPRINT("Enter Win32kThreadCallback\n"); @@ -190,12 +190,12 @@ Win32kThreadCallback(struct _ETHREAD *Thread, { /* FIXME - lock the process */ Win32Thread = ExAllocatePoolWithTag(NonPagedPool, - sizeof(W32THREAD), + sizeof(THREADINFO), TAG('W', '3', '2', 't')); if (Win32Thread == NULL) RETURN( STATUS_NO_MEMORY); - RtlZeroMemory(Win32Thread, sizeof(W32THREAD)); + RtlZeroMemory(Win32Thread, sizeof(THREADINFO)); PsSetThreadWin32Thread(Thread, Win32Thread); /* FIXME - unlock the process */ @@ -344,11 +344,11 @@ Win32kInitWin32Thread(PETHREAD Thread) if (Thread->Tcb.Win32Thread == NULL) { - Thread->Tcb.Win32Thread = ExAllocatePool (NonPagedPool, sizeof(W32THREAD)); + Thread->Tcb.Win32Thread = ExAllocatePool (NonPagedPool, sizeof(THREADINFO)); if (Thread->Tcb.Win32Thread == NULL) return STATUS_NO_MEMORY; - RtlZeroMemory(Thread->Tcb.Win32Thread, sizeof(W32THREAD)); + RtlZeroMemory(Thread->Tcb.Win32Thread, sizeof(THREADINFO)); Win32kThreadCallback(Thread, PsW32ThreadCalloutInitialize); } diff --git a/reactos/subsystems/win32/win32k/ntuser/callback.c b/reactos/subsystems/win32/win32k/ntuser/callback.c index db1cda38c29..6b622ea5d39 100644 --- a/reactos/subsystems/win32/win32k/ntuser/callback.c +++ b/reactos/subsystems/win32/win32k/ntuser/callback.c @@ -42,7 +42,7 @@ typedef struct _INT_CALLBACK_HEADER { - /* list entry in the W32THREAD structure */ + /* list entry in the THREADINFO structure */ LIST_ENTRY ListEntry; } INT_CALLBACK_HEADER, *PINT_CALLBACK_HEADER; @@ -51,7 +51,7 @@ PVOID FASTCALL IntCbAllocateMemory(ULONG Size) { PINT_CALLBACK_HEADER Mem; - PW32THREAD W32Thread; + PTHREADINFO W32Thread; if(!(Mem = ExAllocatePoolWithTag(PagedPool, Size + sizeof(INT_CALLBACK_HEADER), TAG_CALLBACK))) @@ -73,7 +73,7 @@ VOID FASTCALL IntCbFreeMemory(PVOID Data) { PINT_CALLBACK_HEADER Mem; - PW32THREAD W32Thread; + PTHREADINFO W32Thread; ASSERT(Data); @@ -90,7 +90,7 @@ IntCbFreeMemory(PVOID Data) } VOID FASTCALL -IntCleanupThreadCallbacks(PW32THREAD W32Thread) +IntCleanupThreadCallbacks(PTHREADINFO W32Thread) { PLIST_ENTRY CurrentEntry; PINT_CALLBACK_HEADER Mem; diff --git a/reactos/subsystems/win32/win32k/ntuser/caret.c b/reactos/subsystems/win32/win32k/ntuser/caret.c index 01f73630e09..23eb04f85c7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/caret.c +++ b/reactos/subsystems/win32/win32k/ntuser/caret.c @@ -40,7 +40,7 @@ co_IntHideCaret(PTHRDCARETINFO CaretInfo) } BOOL FASTCALL -co_IntDestroyCaret(PW32THREAD Win32Thread) +co_IntDestroyCaret(PTHREADINFO Win32Thread) { PUSER_MESSAGE_QUEUE ThreadQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue; @@ -61,7 +61,8 @@ BOOL FASTCALL IntSetCaretBlinkTime(UINT uMSeconds) { /* Don't save the new value to the registry! */ - PWINSTATION_OBJECT WinStaObject = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PWINSTATION_OBJECT WinStaObject = pti->Desktop->WindowStation; /* windows doesn't do this check */ if((uMSeconds < MIN_CARETBLINKRATE) || (uMSeconds > MAX_CARETBLINKRATE)) @@ -146,10 +147,12 @@ static UINT FASTCALL IntGetCaretBlinkTime(VOID) { + PTHREADINFO pti; PWINSTATION_OBJECT WinStaObject; UINT Ret; - WinStaObject = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; + pti = PsGetCurrentThreadWin32Thread(); + WinStaObject = pti->Desktop->WindowStation; Ret = WinStaObject->CaretBlinkRate; if(!Ret) @@ -171,8 +174,11 @@ IntGetCaretBlinkTime(VOID) BOOL FASTCALL co_IntSetCaretPos(int X, int Y) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if(ThreadQueue->CaretInfo->hWnd) { @@ -194,8 +200,11 @@ co_IntSetCaretPos(int X, int Y) BOOL FASTCALL IntSwitchCaretShowing(PVOID Info) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if(ThreadQueue->CaretInfo->hWnd) { @@ -212,8 +221,11 @@ static VOID FASTCALL co_IntDrawCaret(HWND hWnd) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible && ThreadQueue->CaretInfo->Showing) @@ -228,6 +240,7 @@ co_IntDrawCaret(HWND hWnd) BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; if (Window) ASSERT_REFS_CO(Window); @@ -238,7 +251,8 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL) return FALSE; } - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf) { @@ -261,6 +275,7 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window OPTIONAL) BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; if (Window) ASSERT_REFS_CO(Window); @@ -271,7 +286,8 @@ BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT Window OPTIONAL) return FALSE; } - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if(Window && ThreadQueue->CaretInfo->hWnd != Window->hSelf) { @@ -304,6 +320,7 @@ NtUserCreateCaret( int nHeight) { PWINDOW_OBJECT Window; + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; DECLARE_RETURN(BOOL); @@ -321,7 +338,8 @@ NtUserCreateCaret( RETURN(FALSE); } - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if (ThreadQueue->CaretInfo->Visible) { @@ -374,6 +392,7 @@ STDCALL NtUserGetCaretPos( LPPOINT lpPoint) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; NTSTATUS Status; DECLARE_RETURN(BOOL); @@ -381,7 +400,8 @@ NtUserGetCaretPos( DPRINT("Enter NtUserGetCaretPos\n"); UserEnterShared(); - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT)); if(!NT_SUCCESS(Status)) diff --git a/reactos/subsystems/win32/win32k/ntuser/clipboard.c b/reactos/subsystems/win32/win32k/ntuser/clipboard.c index 10eec715b60..72d23942f94 100644 --- a/reactos/subsystems/win32/win32k/ntuser/clipboard.c +++ b/reactos/subsystems/win32/win32k/ntuser/clipboard.c @@ -15,27 +15,8 @@ #define DATA_DELAYED_RENDER 0 #define DATA_SYNTHESIZED_RENDER -1 -#define USE_WINSTA \ - PWINSTATION_OBJECT WinStaObj; \ - WinStaObj = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; - -#define WINSTA_ClipboardThread WinStaObj->Clipboard->ClipboardThread -#define WINSTA_ClipboardOwnerThread WinStaObj->Clipboard->ClipboardOwnerThread -#define WINSTA_ClipboardWindow WinStaObj->Clipboard->ClipboardWindow -#define WINSTA_ClipboardViewerWindow WinStaObj->Clipboard->ClipboardViewerWindow -#define WINSTA_ClipboardOwnerWindow WinStaObj->Clipboard->ClipboardOwnerWindow -#define WINSTA_sendDrawClipboardMsg WinStaObj->Clipboard->sendDrawClipboardMsg -#define WINSTA_recentlySetClipboard WinStaObj->Clipboard->recentlySetClipboard -#define WINSTA_delayedRender WinStaObj->Clipboard->delayedRender -#define WINSTA_lastEnumClipboardFormats WinStaObj->Clipboard->lastEnumClipboardFormats -#define WINSTA_ClipboardSequenceNumber WinStaObj->Clipboard->ClipboardSequenceNumber -#define WINSTA_WindowsChain WinStaObj->Clipboard->WindowsChain -#define WINSTA_ClipboardData WinStaObj->Clipboard->ClipboardData -#define WINSTA_synthesizedData WinStaObj->Clipboard->synthesizedData -#define WINSTA_synthesizedDataSize WinStaObj->Clipboard->synthesizedDataSize - -PW32THREAD ClipboardThread; -PW32THREAD ClipboardOwnerThread; +PTHREADINFO ClipboardThread; +PTHREADINFO ClipboardOwnerThread; PWINDOW_OBJECT ClipboardWindow; PWINDOW_OBJECT ClipboardViewerWindow; PWINDOW_OBJECT ClipboardOwnerWindow; @@ -1145,11 +1126,13 @@ IntEnumClipboardFormats(UINT uFormat) VOID FASTCALL IntIncrementSequenceNumber(VOID) { + PTHREADINFO pti; + PWINSTATION_OBJECT WinStaObj; - USE_WINSTA - - WINSTA_ClipboardSequenceNumber++; + pti = PsGetCurrentThreadWin32Thread(); + WinStaObj = pti->Desktop->WindowStation; + WinStaObj->Clipboard->ClipboardSequenceNumber++; } DWORD STDCALL diff --git a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c index e7774dfc237..d5542e36bf5 100644 --- a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c +++ b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c @@ -1820,7 +1820,8 @@ int NTAPI UserShowCursor(BOOL bShow) { - PWINSTATION_OBJECT WinSta = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PWINSTATION_OBJECT WinSta = pti->Desktop->WindowStation; PSYSTEM_CURSORINFO CurInfo; HDC Screen; diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 47ed4e3f769..e0974b37f45 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -580,7 +580,8 @@ PWINDOW_OBJECT FASTCALL UserGetDesktopWindow(VOID) HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID) { - PDESKTOP_OBJECT pdo = PsGetCurrentThreadWin32Thread()->Desktop; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT pdo = pti->Desktop; if (NULL == pdo) { DPRINT1("Thread doesn't have a desktop\n"); @@ -782,7 +783,8 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) */ BOOL IntRegisterShellHookWindow(HWND hWnd) { - PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT Desktop = pti->Desktop; PSHELL_HOOK_WINDOW Entry; DPRINT("IntRegisterShellHookWindow\n"); @@ -813,7 +815,8 @@ BOOL IntRegisterShellHookWindow(HWND hWnd) */ BOOL IntDeRegisterShellHookWindow(HWND hWnd) { - PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT Desktop = pti->Desktop; PSHELL_HOOK_WINDOW Current; LIST_FOR_EACH(Current, &Desktop->ShellHookWindows, SHELL_HOOK_WINDOW, ListEntry) @@ -1363,7 +1366,8 @@ NtUserPaintDesktop(HDC hDC) COLORREF color_old; UINT align_old; int mode_old; - PWINSTATION_OBJECT WinSta = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PWINSTATION_OBJECT WinSta = pti->Desktop->WindowStation; DECLARE_RETURN(BOOL); UserEnterExclusive(); @@ -1674,14 +1678,14 @@ NtUserGetThreadDesktop(DWORD dwThreadId, DWORD Unknown1) { /* just return the handle, we queried the desktop handle of a thread running in the same context */ - Ret = ((PW32THREAD)Thread->Tcb.Win32Thread)->hDesktop; + Ret = ((PTHREADINFO)Thread->Tcb.Win32Thread)->hDesktop; ObDereferenceObject(Thread); RETURN(Ret); } /* get the desktop handle and the desktop of the thread */ - if(!(hThreadDesktop = ((PW32THREAD)Thread->Tcb.Win32Thread)->hDesktop) || - !(DesktopObject = ((PW32THREAD)Thread->Tcb.Win32Thread)->Desktop)) + if(!(hThreadDesktop = ((PTHREADINFO)Thread->Tcb.Win32Thread)->hDesktop) || + !(DesktopObject = ((PTHREADINFO)Thread->Tcb.Win32Thread)->Desktop)) { ObDereferenceObject(Thread); DPRINT1("Desktop information of thread 0x%x broken!?\n", dwThreadId); @@ -1854,7 +1858,7 @@ IntSetThreadDesktop(IN PDESKTOP_OBJECT DesktopObject, IN BOOL FreeOnFailure) { PDESKTOP_OBJECT OldDesktop; - PW32THREAD W32Thread; + PTHREADINFO W32Thread; NTSTATUS Status; BOOL MapHeap; diff --git a/reactos/subsystems/win32/win32k/ntuser/event.c b/reactos/subsystems/win32/win32k/ntuser/event.c index 12cca3a551b..43dc0530adf 100644 --- a/reactos/subsystems/win32/win32k/ntuser/event.c +++ b/reactos/subsystems/win32/win32k/ntuser/event.c @@ -105,7 +105,7 @@ IntCallLowLevelEvent( PEVENTHOOK pEH, /* FIXME should get timeout from * HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */ - Status = co_MsqSendMessage(((PW32THREAD)pEH->Thread->Tcb.Win32Thread)->MessageQueue, + Status = co_MsqSendMessage(((PTHREADINFO)pEH->Thread->Tcb.Win32Thread)->MessageQueue, hwnd, event, 0, diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 547dd2cca9f..799be812ce1 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -40,8 +40,11 @@ IntGetFocusWindow() HWND FASTCALL IntGetThreadFocusWindow() { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; return ThreadQueue != NULL ? ThreadQueue->FocusWindow : 0; } @@ -312,6 +315,7 @@ co_IntMouseActivateWindow(PWINDOW_OBJECT Window) HWND FASTCALL co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; HWND hWndPrev; HWND hWnd = 0; @@ -320,7 +324,8 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL) if (Window) ASSERT_REFS_CO(Window); - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; ASSERT(ThreadQueue != 0); if (Window != 0) @@ -358,12 +363,14 @@ HWND FASTCALL co_IntSetFocusWindow(PWINDOW_OBJECT Window OPTIONAL) { HWND hWndPrev = 0; + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; if (Window) ASSERT_REFS_CO(Window); - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; ASSERT(ThreadQueue != 0); hWndPrev = ThreadQueue->FocusWindow; @@ -425,8 +432,11 @@ CLEANUP: HWND FASTCALL UserGetActiveWindow() { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; return( ThreadQueue ? ThreadQueue->ActiveWindow : 0); } @@ -443,6 +453,7 @@ NtUserSetActiveWindow(HWND hWnd) if (hWnd) { PWINDOW_OBJECT Window; + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; HWND hWndPrev; @@ -451,7 +462,8 @@ NtUserSetActiveWindow(HWND hWnd) RETURN( 0); } - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if (Window->MessageQueue != ThreadQueue) { @@ -482,12 +494,14 @@ CLEANUP: HWND STDCALL IntGetCapture(VOID) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; DECLARE_RETURN(HWND); DPRINT("Enter IntGetCapture\n"); - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; RETURN( ThreadQueue ? ThreadQueue->CaptureWindow : 0); CLEANUP: @@ -501,6 +515,7 @@ CLEANUP: HWND STDCALL NtUserSetCapture(HWND hWnd) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; PWINDOW_OBJECT Window; HWND hWndPrev; @@ -509,7 +524,8 @@ NtUserSetCapture(HWND hWnd) DPRINT("Enter NtUserSetCapture(%x)\n", hWnd); UserEnterExclusive(); - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; if((Window = UserGetWindowObject(hWnd))) { @@ -545,6 +561,7 @@ HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window OPTIONAL) { if (Window) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; HWND hWndPrev; PWINDOW_OBJECT TopWnd; @@ -553,7 +570,8 @@ HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window OPTIONAL) ASSERT_REFS_CO(Window); - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; Wnd = Window->Wnd; if (Wnd->Style & (WS_MINIMIZE | WS_DISABLED)) diff --git a/reactos/subsystems/win32/win32k/ntuser/hook.c b/reactos/subsystems/win32/win32k/ntuser/hook.c index 39ade2515d9..f573d2cdadd 100644 --- a/reactos/subsystems/win32/win32k/ntuser/hook.c +++ b/reactos/subsystems/win32/win32k/ntuser/hook.c @@ -72,9 +72,9 @@ PHOOK FASTCALL IntGetHookObject(HHOOK hHook) static PHOOK IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinStaObj) { - PW32THREAD W32Thread; + PTHREADINFO W32Thread; PHOOK Hook; - PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(((PW32THREAD)Thread->Tcb.Win32Thread)->MessageQueue); + PHOOKTABLE Table = Global ? GlobalHooks : MsqGetHooks(((PTHREADINFO)Thread->Tcb.Win32Thread)->MessageQueue); HANDLE Handle; if (NULL == Table) @@ -90,7 +90,7 @@ IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinSt } else { - MsqSetHooks(((PW32THREAD)Thread->Tcb.Win32Thread)->MessageQueue, Table); + MsqSetHooks(((PTHREADINFO)Thread->Tcb.Win32Thread)->MessageQueue, Table); } } @@ -106,7 +106,7 @@ IntAddHook(PETHREAD Thread, int HookId, BOOLEAN Global, PWINSTATION_OBJECT WinSt if (Thread) { - W32Thread = ((PW32THREAD)Thread->Tcb.Win32Thread); + W32Thread = ((PTHREADINFO)Thread->Tcb.Win32Thread); ASSERT(W32Thread != NULL); W32Thread->Hooks |= HOOKID_TO_FLAG(HookId); if (W32Thread->ThreadInfo != NULL) @@ -130,7 +130,7 @@ IntGetTable(PHOOK Hook) return GlobalHooks; } - return MsqGetHooks(((PW32THREAD)Hook->Thread->Tcb.Win32Thread)->MessageQueue); + return MsqGetHooks(((PTHREADINFO)Hook->Thread->Tcb.Win32Thread)->MessageQueue); } /* get the first hook in the chain */ @@ -208,7 +208,7 @@ IntFreeHook(PHOOKTABLE Table, PHOOK Hook, PWINSTATION_OBJECT WinStaObj) static VOID IntRemoveHook(PHOOK Hook, PWINSTATION_OBJECT WinStaObj, BOOL TableAlreadyLocked) { - PW32THREAD W32Thread; + PTHREADINFO W32Thread; PHOOKTABLE Table = IntGetTable(Hook); ASSERT(NULL != Table); @@ -217,7 +217,7 @@ IntRemoveHook(PHOOK Hook, PWINSTATION_OBJECT WinStaObj, BOOL TableAlreadyLocked) return; } - W32Thread = ((PW32THREAD)Hook->Thread->Tcb.Win32Thread); + W32Thread = ((PTHREADINFO)Hook->Thread->Tcb.Win32Thread); ASSERT(W32Thread != NULL); W32Thread->Hooks &= ~HOOKID_TO_FLAG(Hook->HookId); if (W32Thread->ThreadInfo != NULL) @@ -274,7 +274,7 @@ IntCallLowLevelHook(PHOOK Hook, INT Code, WPARAM wParam, LPARAM lParam) /* FIXME should get timeout from * HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */ - Status = co_MsqSendMessage(((PW32THREAD)Hook->Thread->Tcb.Win32Thread)->MessageQueue, + Status = co_MsqSendMessage(((PTHREADINFO)Hook->Thread->Tcb.Win32Thread)->MessageQueue, (HWND) Code, Hook->HookId, wParam, @@ -295,7 +295,7 @@ FASTCALL co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam) { PHOOK Hook, SaveHook; - PW32THREAD Win32Thread; + PTHREADINFO pti; PCLIENTINFO ClientInfo; PHOOKTABLE Table; LRESULT Result; @@ -304,14 +304,14 @@ co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam) ASSERT(WH_MINHOOK <= HookId && HookId <= WH_MAXHOOK); - Win32Thread = PsGetCurrentThreadWin32Thread(); - if (NULL == Win32Thread) + pti = PsGetCurrentThreadWin32Thread(); + if (!pti) { Table = NULL; } else { - Table = MsqGetHooks(Win32Thread->MessageQueue); + Table = MsqGetHooks(pti->MessageQueue); } if (NULL == Table || ! (Hook = IntGetFirstValidHook(Table, HookId))) @@ -361,7 +361,7 @@ co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam) } else { - IntReleaseHookChain(MsqGetHooks(PsGetCurrentThreadWin32Thread()->MessageQueue), HookId, WinStaObj); + IntReleaseHookChain(MsqGetHooks(pti->MessageQueue), HookId, WinStaObj); IntReleaseHookChain(GlobalHooks, HookId, WinStaObj); ObDereferenceObject(WinStaObj); } diff --git a/reactos/subsystems/win32/win32k/ntuser/input.c b/reactos/subsystems/win32/win32k/ntuser/input.c index 4657293394b..1d2163ca2b9 100644 --- a/reactos/subsystems/win32/win32k/ntuser/input.c +++ b/reactos/subsystems/win32/win32k/ntuser/input.c @@ -790,14 +790,14 @@ KeyboardThreadMain(PVOID StartContext) FocusThread = FocusQueue->Thread; if (!(FocusThread && FocusThread->Tcb.Win32Thread && - ((PW32THREAD)FocusThread->Tcb.Win32Thread)->KeyboardLayout)) + ((PTHREADINFO)FocusThread->Tcb.Win32Thread)->KeyboardLayout)) continue; /* This function uses lParam to fill wParam according to the * keyboard layout in use. */ W32kKeyProcessMessage(&msg, - ((PW32THREAD)FocusThread->Tcb.Win32Thread)->KeyboardLayout->KBTables, + ((PTHREADINFO)FocusThread->Tcb.Win32Thread)->KeyboardLayout->KBTables, KeyInput.Flags & KEY_E0 ? 0xE0 : (KeyInput.Flags & KEY_E1 ? 0xE1 : 0)); @@ -892,9 +892,9 @@ NtUserDragDetect( } BOOL FASTCALL -IntBlockInput(PW32THREAD W32Thread, BOOL BlockIt) +IntBlockInput(PTHREADINFO W32Thread, BOOL BlockIt) { - PW32THREAD OldBlock; + PTHREADINFO OldBlock; ASSERT(W32Thread); if(!W32Thread->Desktop || (W32Thread->IsExiting && BlockIt)) @@ -1225,7 +1225,7 @@ NtUserSendInput( LPINPUT pInput, INT cbSize) { - PW32THREAD W32Thread; + PTHREADINFO W32Thread; UINT cnt; DECLARE_RETURN(UINT); diff --git a/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c b/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c index 1695a9c4e40..7c6e05c9078 100644 --- a/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c +++ b/reactos/subsystems/win32/win32k/ntuser/kbdlayout.c @@ -407,7 +407,7 @@ BOOL UserUnloadKbl(PKBL pKbl) return TRUE; } -static PKBL co_UserActivateKbl(PW32THREAD w32Thread, PKBL pKbl, UINT Flags) +static PKBL co_UserActivateKbl(PTHREADINFO w32Thread, PKBL pKbl, UINT Flags) { PKBL Prev; @@ -444,7 +444,7 @@ UserGetKeyboardLayout( { NTSTATUS Status; PETHREAD Thread; - PW32THREAD W32Thread; + PTHREADINFO W32Thread; HKL Ret; if(!dwThreadId) @@ -523,13 +523,15 @@ NtUserGetKeyboardLayoutName( { BOOL ret = FALSE; PKBL pKbl; + PTHREADINFO pti; UserEnterShared(); _SEH_TRY { ProbeForWrite(lpszName, KL_NAMELENGTH*sizeof(WCHAR), 1); - pKbl = PsGetCurrentThreadWin32Thread()->KeyboardLayout; + pti = PsGetCurrentThreadWin32Thread(); + pKbl = pti->KeyboardLayout; RtlCopyMemory(lpszName, pKbl->Name, KL_NAMELENGTH*sizeof(WCHAR)); ret = TRUE; } @@ -614,7 +616,7 @@ NtUserActivateKeyboardLayout( { PKBL pKbl; HKL Ret = NULL; - PW32THREAD pWThread; + PTHREADINFO pWThread; UserEnterExclusive(); diff --git a/reactos/subsystems/win32/win32k/ntuser/keyboard.c b/reactos/subsystems/win32/win32k/ntuser/keyboard.c index c035d8ca4f9..1e1bad40df1 100644 --- a/reactos/subsystems/win32/win32k/ntuser/keyboard.c +++ b/reactos/subsystems/win32/win32k/ntuser/keyboard.c @@ -420,6 +420,7 @@ BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl) { + PTHREADINFO pti; static INT dead_char = 0; LONG UState = 0; WCHAR wp[2] = { 0 }; @@ -428,8 +429,8 @@ IntTranslateKbdMessage(LPMSG lpMsg, BOOL Result = FALSE; DWORD ScanCode = 0; - - keyLayout = PsGetCurrentThreadWin32Thread()->KeyboardLayout->KBTables; + pti = PsGetCurrentThreadWin32Thread(); + keyLayout = pti->KeyboardLayout->KBTables; if( !keyLayout ) return FALSE; @@ -439,7 +440,7 @@ IntTranslateKbdMessage(LPMSG lpMsg, ScanCode = (lpMsg->lParam >> 16) & 0xff; /* All messages have to contain the cursor point. */ - IntGetCursorLocation(PsGetCurrentThreadWin32Thread()->Desktop->WindowStation, + IntGetCursorLocation(pti->Desktop->WindowStation, &NewMsg.pt); UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff, @@ -476,14 +477,14 @@ IntTranslateKbdMessage(LPMSG lpMsg, NewMsg.wParam = dead_char; NewMsg.lParam = lpMsg->lParam; dead_char = 0; - MsqPostMessage(PsGetCurrentThreadWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY); + MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY); } NewMsg.hwnd = lpMsg->hwnd; NewMsg.wParam = wp[0]; NewMsg.lParam = lpMsg->lParam; DPRINT( "CHAR='%c' %04x %08x\n", wp[0], wp[0], lpMsg->lParam ); - MsqPostMessage(PsGetCurrentThreadWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY); + MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY); Result = TRUE; } else if (UState == -1) @@ -494,7 +495,7 @@ IntTranslateKbdMessage(LPMSG lpMsg, NewMsg.wParam = wp[0]; NewMsg.lParam = lpMsg->lParam; dead_char = wp[0]; - MsqPostMessage(PsGetCurrentThreadWin32Thread()->MessageQueue, &NewMsg, FALSE, QS_KEY); + MsqPostMessage(pti->MessageQueue, &NewMsg, FALSE, QS_KEY); Result = TRUE; } @@ -664,13 +665,15 @@ UINT STDCALL NtUserMapVirtualKeyEx( UINT Code, UINT Type, DWORD keyboardId, HKL dwhkl ) { + PTHREADINFO pti; PKBDTABLES keyLayout; DECLARE_RETURN(UINT); DPRINT("Enter NtUserMapVirtualKeyEx\n"); UserEnterExclusive(); - keyLayout = PsGetCurrentThreadWin32Thread() ? PsGetCurrentThreadWin32Thread()->KeyboardLayout->KBTables : 0; + pti = PsGetCurrentThreadWin32Thread(); + keyLayout = pti ? pti->KeyboardLayout->KBTables : 0; if( !keyLayout ) RETURN(0); @@ -695,6 +698,7 @@ NtUserToUnicodeEx( UINT wFlags, HKL dwhkl ) { + PTHREADINFO pti; BYTE KeyStateBuf[0x100]; PWCHAR OutPwszBuff = 0; int ret = 0; @@ -723,14 +727,14 @@ NtUserToUnicodeEx( } RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff ); + pti = PsGetCurrentThreadWin32Thread(); ret = ToUnicodeInner( wVirtKey, wScanCode, KeyStateBuf, OutPwszBuff, cchBuff, wFlags, - PsGetCurrentThreadWin32Thread() ? - PsGetCurrentThreadWin32Thread()->KeyboardLayout->KBTables : 0 ); + pti ? pti->KeyboardLayout->KBTables : 0 ); MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff); ExFreePool(OutPwszBuff); @@ -757,6 +761,7 @@ DWORD STDCALL NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize ) { + PTHREADINFO pti; int i; DWORD ret = 0; UINT CareVk = 0; @@ -770,8 +775,8 @@ NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize ) DPRINT("Enter NtUserGetKeyNameText\n"); UserEnterShared(); - keyLayout = PsGetCurrentThreadWin32Thread() ? - PsGetCurrentThreadWin32Thread()->KeyboardLayout->KBTables : 0; + pti = PsGetCurrentThreadWin32Thread(); + keyLayout = pti ? pti->KeyboardLayout->KBTables : 0; if( !keyLayout || nSize < 1 ) RETURN(0); diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 64908ae0fba..2f546b9b0b6 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -303,7 +303,7 @@ IntCallWndProc { BOOL SameThread = FALSE; - if (Window->ti == PsGetCurrentThreadWin32Thread()->ThreadInfo) + if (Window->ti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->ThreadInfo) SameThread = TRUE; if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROC))) || @@ -325,7 +325,7 @@ IntCallWndProcRet { BOOL SameThread = FALSE; - if (Window->ti == PsGetCurrentThreadWin32Thread()->ThreadInfo) + if (Window->ti == ((PTHREADINFO)PsGetCurrentThreadWin32Thread())->ThreadInfo) SameThread = TRUE; if ((!SameThread && (Window->ti->Hooks & HOOKID_TO_FLAG(WH_CALLWNDPROCRET))) || @@ -740,6 +740,7 @@ co_IntPeekMessage(PUSER_MESSAGE Msg, UINT MsgFilterMax, UINT RemoveMsg) { + PTHREADINFO pti; LARGE_INTEGER LargeTickCount; PUSER_MESSAGE_QUEUE ThreadQueue; PUSER_MESSAGE Message; @@ -751,7 +752,8 @@ co_IntPeekMessage(PUSER_MESSAGE Msg, /* The queues and order in which they are checked are documented in the MSDN article on GetMessage() */ - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; /* Inspect RemoveMsg flags */ /* FIXME: The only flag we process is PM_REMOVE - processing of others must still be implemented */ @@ -827,7 +829,7 @@ CheckMessages: ; /* Check for paint messages. */ - if (IntGetPaintMessage(hWnd, MsgFilterMin, MsgFilterMax, PsGetCurrentThreadWin32Thread(), &Msg->Msg, RemoveMessages)) + if (IntGetPaintMessage(hWnd, MsgFilterMin, MsgFilterMax, pti, &Msg->Msg, RemoveMessages)) { Msg->FreeLParam = FALSE; goto MsgExit; @@ -1056,11 +1058,13 @@ co_IntWaitMessage(HWND Wnd, UINT MsgFilterMin, UINT MsgFilterMax) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE ThreadQueue; NTSTATUS Status; USER_MESSAGE Msg; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; do { @@ -1292,14 +1296,16 @@ UserPostMessage(HWND Wnd, WPARAM wParam, LPARAM lParam) { + PTHREADINFO pti; MSG UserModeMsg, KernelModeMsg; LARGE_INTEGER LargeTickCount; NTSTATUS Status; PMSGMEMORY MsgMemoryEntry; + pti = PsGetCurrentThreadWin32Thread(); if (WM_QUIT == Msg) { - MsqPostQuitMessage(PsGetCurrentThreadWin32Thread()->MessageQueue, wParam); + MsqPostQuitMessage(pti->MessageQueue, wParam); } else if (Wnd == HWND_BROADCAST) { @@ -1344,7 +1350,7 @@ UserPostMessage(HWND Wnd, SetLastWin32Error(ERROR_INVALID_PARAMETER); return FALSE; } - IntGetCursorLocation(PsGetCurrentThreadWin32Thread()->Desktop->WindowStation, + IntGetCursorLocation(pti->Desktop->WindowStation, &KernelModeMsg.pt); KeQueryTickCount(&LargeTickCount); KernelModeMsg.time = MsqCalculateMessageTime(&LargeTickCount); @@ -1386,7 +1392,7 @@ NtUserPostThreadMessage(DWORD idThread, { MSG UserModeMsg, KernelModeMsg; PETHREAD peThread; - PW32THREAD pThread; + PTHREADINFO pThread; NTSTATUS Status; PMSGMEMORY MsgMemoryEntry; DECLARE_RETURN(BOOL); @@ -1398,7 +1404,7 @@ NtUserPostThreadMessage(DWORD idThread, if( Status == STATUS_SUCCESS ) { - pThread = (PW32THREAD)peThread->Tcb.Win32Thread; + pThread = (PTHREADINFO)peThread->Tcb.Win32Thread; if( !pThread || !pThread->MessageQueue ) { ObDereferenceObject( peThread ); @@ -1473,7 +1479,7 @@ co_IntSendMessageTimeoutSingle(HWND hWnd, PMSGMEMORY MsgMemoryEntry; INT lParamBufferSize; LPARAM lParamPacked; - PW32THREAD Win32Thread; + PTHREADINFO Win32Thread; DECLARE_RETURN(LRESULT); USER_REFERENCE_ENTRY Ref; @@ -1642,6 +1648,7 @@ co_IntPostOrSendMessage(HWND hWnd, LPARAM lParam) { ULONG_PTR Result; + PTHREADINFO pti; PWINDOW_OBJECT Window; if(hWnd == HWND_BROADCAST) @@ -1654,7 +1661,8 @@ co_IntPostOrSendMessage(HWND hWnd, return 0; } - if(Window->MessageQueue != PsGetCurrentThreadWin32Thread()->MessageQueue) + pti = PsGetCurrentThreadWin32Thread(); + if(Window->MessageQueue != pti->MessageQueue) { Result = UserPostMessage(hWnd, Msg, wParam, lParam); } @@ -1676,6 +1684,7 @@ co_IntDoSendMessage(HWND hWnd, PDOSENDMESSAGE dsm, PNTUSERSENDMESSAGEINFO UnsafeInfo) { + PTHREADINFO pti; LRESULT Result = TRUE; NTSTATUS Status; PWINDOW_OBJECT Window; @@ -1704,8 +1713,9 @@ co_IntDoSendMessage(HWND hWnd, /* FIXME: Check for an exiting window. */ /* See if the current thread can handle the message */ - if (HWND_BROADCAST != hWnd && NULL != PsGetCurrentThreadWin32Thread() && - Window->MessageQueue == PsGetCurrentThreadWin32Thread()->MessageQueue) + pti = PsGetCurrentThreadWin32Thread(); + if (HWND_BROADCAST != hWnd && NULL != pti && + Window->MessageQueue == pti->MessageQueue) { /* Gather the information usermode needs to call the window proc directly */ Info.HandledByKernel = FALSE; @@ -1870,6 +1880,7 @@ UserSendNotifyMessage(HWND hWnd, else { ULONG_PTR PResult; + PTHREADINFO pti; PWINDOW_OBJECT Window; NTSTATUS Status; MSG UserModeMsg; @@ -1878,7 +1889,8 @@ UserSendNotifyMessage(HWND hWnd, if(!(Window = UserGetWindowObject(hWnd))) return FALSE; - if(Window->MessageQueue != PsGetCurrentThreadWin32Thread()->MessageQueue) + pti = PsGetCurrentThreadWin32Thread(); + if(Window->MessageQueue != pti->MessageQueue) { // Send message w/o waiting for it. Result = UserPostMessage(hWnd, Msg, wParam, lParam); } @@ -1952,13 +1964,15 @@ CLEANUP: DWORD STDCALL IntGetQueueStatus(BOOL ClearChanges) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE Queue; DWORD Result; DECLARE_RETURN(DWORD); DPRINT("Enter IntGetQueueStatus\n"); - Queue = PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + Queue = pti->MessageQueue; Result = MAKELONG(Queue->QueueBits, Queue->ChangedBits); if (ClearChanges) @@ -1976,9 +1990,9 @@ CLEANUP: BOOL STDCALL IntInitMessagePumpHook() { - if (((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo) + if (((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo) { - ((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo->ClientThreadInfo.dwcPumpHook++; + ((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo->ClientThreadInfo.dwcPumpHook++; return TRUE; } return FALSE; @@ -1987,13 +2001,13 @@ IntInitMessagePumpHook() BOOL STDCALL IntUninitMessagePumpHook() { - if (((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo) + if (((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo) { - if (((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo->ClientThreadInfo.dwcPumpHook <= 0) + if (((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo->ClientThreadInfo.dwcPumpHook <= 0) { return FALSE; } - ((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo->ClientThreadInfo.dwcPumpHook--; + ((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->ThreadInfo->ClientThreadInfo.dwcPumpHook--; return TRUE; } return FALSE; diff --git a/reactos/subsystems/win32/win32k/ntuser/misc.c b/reactos/subsystems/win32/win32k/ntuser/misc.c index cbe521285b1..d58060bdf6c 100644 --- a/reactos/subsystems/win32/win32k/ntuser/misc.c +++ b/reactos/subsystems/win32/win32k/ntuser/misc.c @@ -130,12 +130,12 @@ NtUserGetGUIThreadInfo( SetLastWin32Error(ERROR_ACCESS_DENIED); RETURN( FALSE); } - Desktop = ((PW32THREAD)Thread->Tcb.Win32Thread)->Desktop; + Desktop = ((PTHREADINFO)Thread->Tcb.Win32Thread)->Desktop; } else { /* get the foreground thread */ - PW32THREAD W32Thread = (PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread; + PTHREADINFO W32Thread = (PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread; Desktop = W32Thread->Desktop; if(Desktop) { @@ -438,7 +438,7 @@ GetW32ThreadInfo(VOID) PTEB Teb; PW32THREADINFO ti; PCLIENTINFO ci; - PW32THREAD W32Thread = PsGetCurrentThreadWin32Thread(); + PTHREADINFO W32Thread = PsGetCurrentThreadWin32Thread(); if (W32Thread == NULL) { @@ -446,7 +446,7 @@ GetW32ThreadInfo(VOID) return NULL; } - /* allocate a W32THREAD structure if neccessary */ + /* allocate a THREADINFO structure if neccessary */ if (W32Thread->ThreadInfo == NULL) { ti = UserHeapAlloc(sizeof(W32THREADINFO)); diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index ebed9aad710..b5a005dd910 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -93,7 +93,7 @@ IdlePing(VOID) HANDLE FASTCALL IntMsqSetWakeMask(DWORD WakeMask) { - PW32THREAD Win32Thread; + PTHREADINFO Win32Thread; PUSER_MESSAGE_QUEUE MessageQueue; HANDLE MessageEventHandle; @@ -111,7 +111,7 @@ IntMsqSetWakeMask(DWORD WakeMask) BOOL FASTCALL IntMsqClearWakeMask(VOID) { - PW32THREAD Win32Thread; + PTHREADINFO Win32Thread; PUSER_MESSAGE_QUEUE MessageQueue; Win32Thread = PsGetCurrentThreadWin32Thread(); @@ -235,17 +235,19 @@ MsqInsertSystemMessage(MSG* Msg) BOOL FASTCALL MsqIsDblClk(LPMSG Msg, BOOL Remove) { + PTHREADINFO pti; PWINSTATION_OBJECT WinStaObject; PSYSTEM_CURSORINFO CurInfo; LONG dX, dY; BOOL Res; - if (PsGetCurrentThreadWin32Thread()->Desktop == NULL) + pti = PsGetCurrentThreadWin32Thread(); + if (pti->Desktop == NULL) { return FALSE; } - WinStaObject = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; + WinStaObject = pti->Desktop->WindowStation; CurInfo = IntGetSysCursorInfo(WinStaObject); Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) && @@ -811,7 +813,7 @@ VOID FASTCALL MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam) { PWINDOW_OBJECT Window; - PW32THREAD Win32Thread; + PTHREADINFO Win32Thread; PWINSTATION_OBJECT WinSta; MSG Mesg; LARGE_INTEGER LargeTickCount; @@ -1100,6 +1102,7 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, UINT uTimeout, BOOL Block, INT HookMessage, ULONG_PTR *uResult) { + PTHREADINFO pti; PUSER_SENT_MESSAGE Message; KEVENT CompletionEvent; NTSTATUS WaitStatus; @@ -1116,7 +1119,8 @@ co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, KeInitializeEvent(&CompletionEvent, NotificationEvent, FALSE); - ThreadQueue = PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + ThreadQueue = pti->MessageQueue; ASSERT(ThreadQueue != MessageQueue); Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000; @@ -1603,9 +1607,11 @@ LPARAM FASTCALL MsqSetMessageExtraInfo(LPARAM lParam) { LPARAM Ret; + PTHREADINFO pti; PUSER_MESSAGE_QUEUE MessageQueue; - MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + MessageQueue = pti->MessageQueue; if(!MessageQueue) { return 0; @@ -1620,9 +1626,11 @@ MsqSetMessageExtraInfo(LPARAM lParam) LPARAM FASTCALL MsqGetMessageExtraInfo(VOID) { + PTHREADINFO pti; PUSER_MESSAGE_QUEUE MessageQueue; - MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + MessageQueue = pti->MessageQueue; if(!MessageQueue) { return 0; @@ -1822,6 +1830,7 @@ MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue, LARGE_INTEGER LargeTickCount; PLIST_ENTRY EnumEntry; BOOLEAN GotMessage; + PTHREADINFO pti; DPRINT("MsqGetTimerMessage queue %p msg %p restart %s\n", MessageQueue, Msg, Restart ? "TRUE" : "FALSE"); @@ -1873,7 +1882,8 @@ MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue, Msg->lParam = (LPARAM) Timer->TimerFunc; KeQueryTickCount(&LargeTickCount); Msg->time = MsqCalculateMessageTime(&LargeTickCount); - IntGetCursorLocation(PsGetCurrentThreadWin32Thread()->Desktop->WindowStation, + pti = PsGetCurrentThreadWin32Thread(); + IntGetCursorLocation(pti->Desktop->WindowStation, &Msg->pt); if (Restart) diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index b6f970b762e..0e72c95f197 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -636,7 +636,7 @@ IntIsWindowDirty(PWINDOW_OBJECT Window) } HWND FASTCALL -IntFindWindowToRepaint(PWINDOW_OBJECT Window, PW32THREAD Thread) +IntFindWindowToRepaint(PWINDOW_OBJECT Window, PTHREADINFO Thread) { HWND hChild; PWINDOW_OBJECT TempWindow; @@ -680,7 +680,7 @@ IntFindWindowToRepaint(PWINDOW_OBJECT Window, PW32THREAD Thread) BOOL FASTCALL IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, - PW32THREAD Thread, MSG *Message, BOOL Remove) + PTHREADINFO Thread, MSG *Message, BOOL Remove) { PUSER_MESSAGE_QUEUE MessageQueue = (PUSER_MESSAGE_QUEUE)Thread->MessageQueue; @@ -721,7 +721,7 @@ co_IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags) ASSERT_REFS_CO(Window); - Desktop = ((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->Desktop; + Desktop = ((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->Desktop; CaretInfo = ((PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue)->CaretInfo; hWndCaret = CaretInfo->hWnd; diff --git a/reactos/subsystems/win32/win32k/ntuser/simplecall.c b/reactos/subsystems/win32/win32k/ntuser/simplecall.c index b6ee8ab9438..2301ca95806 100644 --- a/reactos/subsystems/win32/win32k/ntuser/simplecall.c +++ b/reactos/subsystems/win32/win32k/ntuser/simplecall.c @@ -493,7 +493,7 @@ NtUserCallTwoParam( case TWOPARAM_ROUTINE_SETGUITHRDHANDLE: { - PUSER_MESSAGE_QUEUE MsgQueue = ((PW32THREAD)PsGetCurrentThread()->Tcb.Win32Thread)->MessageQueue; + PUSER_MESSAGE_QUEUE MsgQueue = ((PTHREADINFO)PsGetCurrentThread()->Tcb.Win32Thread)->MessageQueue; ASSERT(MsgQueue); RETURN( (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2)); diff --git a/reactos/subsystems/win32/win32k/ntuser/sysparams.c b/reactos/subsystems/win32/win32k/ntuser/sysparams.c index 23b998a45b6..d3d9deffb65 100644 --- a/reactos/subsystems/win32/win32k/ntuser/sysparams.c +++ b/reactos/subsystems/win32/win32k/ntuser/sysparams.c @@ -465,7 +465,8 @@ IntSystemParametersInfo( case SPI_SETWORKAREA: { RECT *rc; - PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT Desktop = pti->Desktop; if(!Desktop) { @@ -482,7 +483,8 @@ IntSystemParametersInfo( } case SPI_GETWORKAREA: { - PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT Desktop = pti->Desktop; if(!Desktop) { diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index 9db2c4ca6a9..8bd52e26c55 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -61,6 +61,7 @@ IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL S { PWINDOW_OBJECT Window; UINT_PTR Ret = 0; + PTHREADINFO pti; PUSER_MESSAGE_QUEUE MessageQueue; DPRINT("IntSetTimer wnd %x id %p elapse %u timerproc %p systemtimer %s\n", @@ -84,7 +85,8 @@ IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL S HintIndex = ++IDEvent; IntUnlockWindowlessTimerBitmap(); Ret = IDEvent; - MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue; + pti = PsGetCurrentThreadWin32Thread(); + MessageQueue = pti->MessageQueue; } else { @@ -149,16 +151,18 @@ IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL S BOOL FASTCALL IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer) { + PTHREADINFO pti; PWINDOW_OBJECT Window = NULL; DPRINT("IntKillTimer wnd %x id %p systemtimer %s\n", Wnd, IDEvent, SystemTimer ? "TRUE" : "FALSE"); + pti = PsGetCurrentThreadWin32Thread(); if (Wnd) { Window = UserGetWindowObject(Wnd); - if (! MsqKillTimer(PsGetCurrentThreadWin32Thread()->MessageQueue, Wnd, + if (! MsqKillTimer(pti->MessageQueue, Wnd, IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER)) { // Give it another chance to find the timer. @@ -175,7 +179,7 @@ IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer) /* window-less timer? */ if ((Wnd == NULL) && ! SystemTimer) { - if (! MsqKillTimer(PsGetCurrentThreadWin32Thread()->MessageQueue, Wnd, + if (! MsqKillTimer(pti->MessageQueue, Wnd, IDEvent, SystemTimer ? WM_SYSTIMER : WM_TIMER)) { DPRINT1("Unable to locate timer in message queue for Window-less timer.\n"); diff --git a/reactos/subsystems/win32/win32k/ntuser/useratom.c b/reactos/subsystems/win32/win32k/ntuser/useratom.c index 0cfbecb29f3..f3567b91355 100644 --- a/reactos/subsystems/win32/win32k/ntuser/useratom.c +++ b/reactos/subsystems/win32/win32k/ntuser/useratom.c @@ -33,9 +33,11 @@ RTL_ATOM FASTCALL IntAddAtom(LPWSTR AtomName) { NTSTATUS Status = STATUS_SUCCESS; + PTHREADINFO pti; RTL_ATOM Atom; - if (PsGetCurrentThreadWin32Thread()->Desktop == NULL) + pti = PsGetCurrentThreadWin32Thread(); + if (pti->Desktop == NULL) { SetLastNtError(Status); return (RTL_ATOM)0; @@ -55,9 +57,11 @@ ULONG FASTCALL IntGetAtomName(RTL_ATOM nAtom, LPWSTR lpBuffer, ULONG nSize) { NTSTATUS Status = STATUS_SUCCESS; + PTHREADINFO pti; ULONG Size = nSize; - if (PsGetCurrentThreadWin32Thread()->Desktop == NULL) + pti = PsGetCurrentThreadWin32Thread(); + if (pti->Desktop == NULL) { SetLastNtError(Status); return 0; diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index acca4e9133b..db4b2b190eb 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -363,7 +363,7 @@ UserFreeWindowInfo(PW32THREADINFO ti, PWINDOW_OBJECT WindowObject) */ static LRESULT co_UserFreeWindow(PWINDOW_OBJECT Window, PW32PROCESS ProcessData, - PW32THREAD ThreadData, + PTHREADINFO ThreadData, BOOLEAN SendMessages) { HWND *Children; @@ -697,11 +697,11 @@ IntSetMenu( VOID FASTCALL co_DestroyThreadWindows(struct _ETHREAD *Thread) { - PW32THREAD WThread; + PTHREADINFO WThread; PLIST_ENTRY Current; PWINDOW_OBJECT Wnd; USER_REFERENCE_ENTRY Ref; - WThread = (PW32THREAD)Thread->Tcb.Win32Thread; + WThread = (PTHREADINFO)Thread->Tcb.Win32Thread; while (!IsListEmpty(&WThread->WindowListHead)) { @@ -771,7 +771,7 @@ PMENU_OBJECT FASTCALL IntGetSystemMenu(PWINDOW_OBJECT Window, BOOL bRevert, BOOL RetMenu) { PMENU_OBJECT Menu, NewMenu = NULL, SysMenu = NULL, ret = NULL; - PW32THREAD W32Thread; + PTHREADINFO W32Thread; HMENU hNewMenu, hSysMenu; ROSMENUITEMINFO ItemInfo; @@ -1315,7 +1315,7 @@ NtUserBuildHwndList( else { PETHREAD Thread; - PW32THREAD W32Thread; + PTHREADINFO W32Thread; PLIST_ENTRY Current; PWINDOW_OBJECT Window; @@ -1324,7 +1324,7 @@ NtUserBuildHwndList( { return ERROR_INVALID_PARAMETER; } - if(!(W32Thread = (PW32THREAD)Thread->Tcb.Win32Thread)) + if(!(W32Thread = (PTHREADINFO)Thread->Tcb.Win32Thread)) { ObDereferenceObject(Thread); DPRINT("Thread is not a GUI Thread!\n"); @@ -1523,8 +1523,10 @@ co_IntCreateWindowEx(DWORD dwExStyle, DECLARE_RETURN(HWND); BOOL HasOwner; USER_REFERENCE_ENTRY ParentRef, Ref; + PTHREADINFO pti; - ParentWindowHandle = PsGetCurrentThreadWin32Thread()->Desktop->DesktopWindow; + pti = PsGetCurrentThreadWin32Thread(); + ParentWindowHandle = pti->Desktop->DesktopWindow; OwnerWindowHandle = NULL; if (hWndParent == HWND_MESSAGE) @@ -1568,7 +1570,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, /* Check the window station. */ ti = GetW32ThreadInfo(); - if (ti == NULL || PsGetCurrentThreadWin32Thread()->Desktop == NULL) + if (ti == NULL || pti->Desktop == NULL) { DPRINT1("Thread is not attached to a desktop! Cannot create window!\n"); RETURN( (HWND)0); @@ -1606,7 +1608,7 @@ co_IntCreateWindowEx(DWORD dwExStyle, RETURN(NULL); } - WinSta = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation; + WinSta = pti->Desktop->WindowStation; //FIXME: Reference thread/desktop instead ObReferenceObjectByPointer(WinSta, KernelMode, ExWindowStationObjectType, 0); @@ -1644,11 +1646,11 @@ AllocErr: ObDereferenceObject(WinSta); - if (NULL == PsGetCurrentThreadWin32Thread()->Desktop->DesktopWindow) + if (NULL == pti->Desktop->DesktopWindow) { /* If there is no desktop window yet, we must be creating it */ - PsGetCurrentThreadWin32Thread()->Desktop->DesktopWindow = hWnd; - PsGetCurrentThreadWin32Thread()->Desktop->DesktopInfo->Wnd = Wnd; + pti->Desktop->DesktopWindow = hWnd; + pti->Desktop->DesktopInfo->Wnd = Wnd; } /* @@ -1664,7 +1666,7 @@ AllocErr: Wnd->Instance = hInstance; Window->hSelf = hWnd; - Window->MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue; + Window->MessageQueue = pti->MessageQueue; IntReferenceMessageQueue(Window->MessageQueue); Window->Parent = ParentWindow; Wnd->Parent = ParentWindow ? ParentWindow->Wnd : NULL; @@ -1790,7 +1792,7 @@ AllocErr: Wnd->IDMenu = (UINT) hMenu; /* Insert the window into the thread's window list. */ - InsertTailList (&PsGetCurrentThreadWin32Thread()->WindowListHead, &Window->ThreadListEntry); + InsertTailList (&pti->WindowListHead, &Window->ThreadListEntry); /* Handle "CS_CLASSDC", it is tested first. */ if ((Wnd->Class->Style & CS_CLASSDC) && !(Wnd->Class->Dce)) // One DCE per class to have CLASS. @@ -1842,7 +1844,7 @@ AllocErr: PRTL_USER_PROCESS_PARAMETERS ProcessParams; BOOL CalculatedDefPosSize = FALSE; - IntGetDesktopWorkArea(((PW32THREAD)Window->OwnerThread->Tcb.Win32Thread)->Desktop, &WorkArea); + IntGetDesktopWorkArea(((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop, &WorkArea); rc = WorkArea; ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters; @@ -3650,7 +3652,7 @@ co_UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) /* * Remove extended window style bit WS_EX_TOPMOST for shell windows. */ - WindowStation = ((PW32THREAD)Window->OwnerThread->Tcb.Win32Thread)->Desktop->WindowStation; + WindowStation = ((PTHREADINFO)Window->OwnerThread->Tcb.Win32Thread)->Desktop->WindowStation; if(WindowStation) { if (hWnd == WindowStation->ShellWindow || hWnd == WindowStation->ShellListView) @@ -4485,6 +4487,7 @@ NtUserWindowFromPoint(LONG X, LONG Y) if ((DesktopWindow = UserGetWindowObject(IntGetDesktopWindow()))) { + PTHREADINFO pti; USHORT Hit; pt.x = X; @@ -4494,7 +4497,8 @@ NtUserWindowFromPoint(LONG X, LONG Y) //its possible this referencing is useless, thou it shouldnt hurt... UserRefObjectCo(DesktopWindow, &Ref); - Hit = co_WinPosWindowFromPoint(DesktopWindow, PsGetCurrentThreadWin32Thread()->MessageQueue, &pt, &Window); + pti = PsGetCurrentThreadWin32Thread(); + Hit = co_WinPosWindowFromPoint(DesktopWindow, pti->MessageQueue, &pt, &Window); if(Window) { diff --git a/reactos/subsystems/win32/win32k/ntuser/winpos.c b/reactos/subsystems/win32/win32k/ntuser/winpos.c index d6c435730d4..bc7ec3d95e1 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winpos.c +++ b/reactos/subsystems/win32/win32k/ntuser/winpos.c @@ -257,7 +257,8 @@ WinPosInitInternalPos(PWINDOW_OBJECT Window, POINT *pt, PRECT RestoreRect) if (!Wnd->InternalPosInitialized) { RECT WorkArea; - PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; /* Or rather get it from the window? */ + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT Desktop = pti->Desktop; /* Or rather get it from the window? */ Parent = Window->Parent; if(Parent) @@ -401,7 +402,8 @@ WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info) { UINT XInc, YInc; RECT WorkArea; - PDESKTOP_OBJECT Desktop = PsGetCurrentThreadWin32Thread()->Desktop; /* Or rather get it from the window? */ + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP_OBJECT Desktop = pti->Desktop; /* Or rather get it from the window? */ IntGetDesktopWorkArea(Desktop, &WorkArea); diff --git a/reactos/subsystems/win32/win32k/ntuser/winsta.c b/reactos/subsystems/win32/win32k/ntuser/winsta.c index 43da32dd673..3fcba08a1aa 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winsta.c +++ b/reactos/subsystems/win32/win32k/ntuser/winsta.c @@ -918,6 +918,7 @@ HWINSTA FASTCALL UserGetProcessWindowStation(VOID) { NTSTATUS Status; + PTHREADINFO pti; HWINSTA WinSta; if(PsGetCurrentProcess() != CsrProcess) @@ -927,7 +928,8 @@ UserGetProcessWindowStation(VOID) else { DPRINT1("Should use ObFindHandleForObject\n"); - Status = ObOpenObjectByPointer(PsGetCurrentThreadWin32Thread()->Desktop->WindowStation, + pti = PsGetCurrentThreadWin32Thread(); + Status = ObOpenObjectByPointer(pti->Desktop->WindowStation, 0, NULL, WINSTA_ALL_ACCESS, @@ -970,7 +972,7 @@ PWINSTATION_OBJECT FASTCALL IntGetWinStaObj(VOID) { PWINSTATION_OBJECT WinStaObj; - PW32THREAD Win32Thread; + PTHREADINFO Win32Thread; PEPROCESS CurrentProcess; /* diff --git a/reactos/subsystems/win32/win32k/objects/gdiobj.c b/reactos/subsystems/win32/win32k/objects/gdiobj.c index 5a8eca28765..4d673c36f79 100644 --- a/reactos/subsystems/win32/win32k/objects/gdiobj.c +++ b/reactos/subsystems/win32/win32k/objects/gdiobj.c @@ -366,7 +366,7 @@ LockHandle: PrevProcId = _InterlockedCompareExchangePointer((PVOID*)&Entry->ProcessId, LockedProcessId, 0); if (PrevProcId == NULL) { - PW32THREAD Thread = PsGetCurrentThreadWin32Thread(); + PW32THREAD Thread = (PW32THREAD)PsGetCurrentThreadWin32Thread(); HGDIOBJ Handle; Entry->KernelData = newObject; @@ -803,7 +803,7 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType) if ( (Entry->KernelData != NULL) && ((Entry->Type << GDI_ENTRY_UPPER_SHIFT) == HandleUpper) ) { - PW32THREAD Thread = PsGetCurrentThreadWin32Thread(); + PW32THREAD Thread = (PW32THREAD)PsGetCurrentThreadWin32Thread(); Object = Entry->KernelData; if (Object->cExclusiveLock == 0) @@ -1046,7 +1046,7 @@ GDIOBJ_ConvertToStockObj(HGDIOBJ *phObj) DPRINT("GDIOBJ_ConvertToStockObj: hObj: 0x%08x\n", hObj); - Thread = PsGetCurrentThreadWin32Thread(); + Thread = (PW32THREAD)PsGetCurrentThreadWin32Thread(); if (!GDI_HANDLE_IS_STOCKOBJ(hObj)) { @@ -1172,7 +1172,7 @@ GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS NewOwner) DPRINT("GDIOBJ_SetOwnership: hObj: 0x%x, NewProcess: 0x%x\n", ObjectHandle, (NewOwner ? PsGetProcessId(NewOwner) : 0)); - Thread = PsGetCurrentThreadWin32Thread(); + Thread = (PW32THREAD)PsGetCurrentThreadWin32Thread(); if (!GDI_HANDLE_IS_STOCKOBJ(ObjectHandle)) { @@ -1301,7 +1301,7 @@ GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo) DPRINT("GDIOBJ_CopyOwnership: from: 0x%x, to: 0x%x\n", CopyFrom, CopyTo); - Thread = PsGetCurrentThreadWin32Thread(); + Thread = (PW32THREAD)PsGetCurrentThreadWin32Thread(); if (!GDI_HANDLE_IS_STOCKOBJ(CopyFrom) && !GDI_HANDLE_IS_STOCKOBJ(CopyTo)) {