diff --git a/reactos/subsys/win32k/eng/window.c b/reactos/subsys/win32k/eng/window.c index 2b13c486137..5dca0e3fab3 100644 --- a/reactos/subsys/win32k/eng/window.c +++ b/reactos/subsys/win32k/eng/window.c @@ -207,15 +207,22 @@ EngCreateWnd( WNDGDI *WndObjInt = NULL; WNDOBJ *WndObjUser = NULL; PWINDOW_OBJECT Window; + BOOL calledFromUser; + DECLARE_RETURN(WNDOBJ*); DPRINT("EngCreateWnd: pso = 0x%x, hwnd = 0x%x, pfn = 0x%x, fl = 0x%x, pixfmt = %d\n", pso, hwnd, pfn, fl, iPixelFormat); + calledFromUser = UserIsEntered(); + if (!calledFromUser){ + UserEnterShared(); + } + /* Get window object */ Window = IntGetWindowObject(hwnd); if (Window == NULL) { - return NULL; + RETURN( NULL); } /* Create WNDOBJ */ @@ -224,7 +231,7 @@ EngCreateWnd( { IntReleaseWindowObject(Window); DPRINT1("Failed to allocate memory for a WND structure!\n"); - return NULL; + RETURN( NULL); } /* Fill the clipobj */ @@ -233,7 +240,7 @@ EngCreateWnd( { IntReleaseWindowObject(Window); EngFreeMem(WndObjInt); - return NULL; + RETURN( NULL); } /* Fill user object */ @@ -257,7 +264,15 @@ EngCreateWnd( DPRINT("EngCreateWnd: SUCCESS!\n"); - return WndObjUser; + RETURN( WndObjUser); + +CLEANUP: + + if (!calledFromUser){ + UserLeave(); + } + + END_CLEANUP; } @@ -271,9 +286,15 @@ EngDeleteWnd( { WNDGDI *WndObjInt = ObjToGDI(pwo, WND); PWINDOW_OBJECT Window; + BOOL calledFromUser; DPRINT("EngDeleteWnd: pwo = 0x%x\n", pwo); + calledFromUser = UserIsEntered(); + if (!calledFromUser){ + UserEnterExclusive(); + } + /* Get window object */ Window = IntGetWindowObject(WndObjInt->Hwnd); if (Window == NULL) @@ -290,6 +311,10 @@ EngDeleteWnd( IntReleaseWindowObject(Window); } + if (!calledFromUser){ + UserLeave(); + } + /* Free resources */ IntEngDeleteClipRegion(WndObjInt->ClientClipObj); EngFreeMem(WndObjInt); diff --git a/reactos/subsys/win32k/include/callback.h b/reactos/subsys/win32k/include/callback.h index 750619a0b2a..0215f9c7aba 100644 --- a/reactos/subsys/win32k/include/callback.h +++ b/reactos/subsys/win32k/include/callback.h @@ -2,7 +2,7 @@ #define _WIN32K_CALLBACK_H LRESULT STDCALL -IntCallWindowProc(WNDPROC Proc, +co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, @@ -11,7 +11,7 @@ IntCallWindowProc(WNDPROC Proc, INT lParamBufferSize); VOID STDCALL -IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, +co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, @@ -19,13 +19,13 @@ IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HMENU STDCALL -IntLoadSysMenuTemplate(); +co_IntLoadSysMenuTemplate(); BOOL STDCALL -IntLoadDefaultCursors(VOID); +co_IntLoadDefaultCursors(VOID); LRESULT STDCALL -IntCallHookProc(INT HookId, +co_IntCallHookProc(INT HookId, INT Code, WPARAM wParam, LPARAM lParam, diff --git a/reactos/subsys/win32k/include/caret.h b/reactos/subsys/win32k/include/caret.h index 8ca0548fcce..53789863920 100644 --- a/reactos/subsys/win32k/include/caret.h +++ b/reactos/subsys/win32k/include/caret.h @@ -4,13 +4,13 @@ #define IDCARETTIMER (0xffff) BOOL FASTCALL -IntDestroyCaret(PW32THREAD Win32Thread); +co_IntDestroyCaret(PW32THREAD Win32Thread); BOOL FASTCALL IntSetCaretBlinkTime(UINT uMSeconds); BOOL FASTCALL -IntSetCaretPos(int X, int Y); +co_IntSetCaretPos(int X, int Y); BOOL FASTCALL IntSwitchCaretShowing(PVOID Info); @@ -18,6 +18,11 @@ IntSwitchCaretShowing(PVOID Info); VOID FASTCALL IntDrawCaret(HWND hWnd); +BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT WindowObject); + +BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject); + + #endif /* _WIN32K_CARET_H */ /* EOF */ diff --git a/reactos/subsys/win32k/include/csr.h b/reactos/subsys/win32k/include/csr.h index d2f1ff4beab..51cce282619 100644 --- a/reactos/subsys/win32k/include/csr.h +++ b/reactos/subsys/win32k/include/csr.h @@ -13,7 +13,7 @@ extern PEPROCESS CsrProcess; extern NTSTATUS FASTCALL CsrInit(void); -extern NTSTATUS FASTCALL CsrNotify(PCSR_API_MESSAGE Request); +extern NTSTATUS FASTCALL co_CsrNotify(PCSR_API_MESSAGE Request); extern NTSTATUS FASTCALL CsrCloseHandle(HANDLE Handle); NTSTATUS STDCALL diff --git a/reactos/subsys/win32k/include/desktop.h b/reactos/subsys/win32k/include/desktop.h index b9de2f613b1..4edb0453f32 100644 --- a/reactos/subsys/win32k/include/desktop.h +++ b/reactos/subsys/win32k/include/desktop.h @@ -67,6 +67,9 @@ IntGetScreenDC(VOID); HWND FASTCALL IntGetDesktopWindow (VOID); +PWINDOW_OBJECT FASTCALL +UserGetDesktopWindow(VOID); + HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID); @@ -80,7 +83,7 @@ PDESKTOP_OBJECT FASTCALL IntGetActiveDesktop(VOID); NTSTATUS FASTCALL -IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height); +co_IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height); NTSTATUS FASTCALL IntHideDesktop(PDESKTOP_OBJECT Desktop); @@ -107,7 +110,7 @@ IntDesktopUpdatePerUserSettings(BOOL bEnable); BOOL IntRegisterShellHookWindow(HWND hWnd); BOOL IntDeRegisterShellHookWindow(HWND hWnd); -VOID IntShellHookNotify(WPARAM Message, LPARAM lParam); +VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam); #define IntIsActiveDesktop(Desktop) \ ((Desktop)->WindowStation->ActiveDesktop == (Desktop)) diff --git a/reactos/subsys/win32k/include/focus.h b/reactos/subsys/win32k/include/focus.h index 9ef8d1c7843..eee631cc444 100644 --- a/reactos/subsys/win32k/include/focus.h +++ b/reactos/subsys/win32k/include/focus.h @@ -16,10 +16,10 @@ HWND FASTCALL IntGetThreadFocusWindow(); BOOL FASTCALL -IntMouseActivateWindow(PWINDOW_OBJECT Window); +co_IntMouseActivateWindow(PWINDOW_OBJECT Window); BOOL FASTCALL -IntSetForegroundWindow(PWINDOW_OBJECT Window); +co_IntSetForegroundWindow(PWINDOW_OBJECT Window); HWND FASTCALL -IntSetActiveWindow(PWINDOW_OBJECT Window); +co_IntSetActiveWindow(PWINDOW_OBJECT Window); #endif /* _WIN32K_FOCUS_H */ diff --git a/reactos/subsys/win32k/include/guicheck.h b/reactos/subsys/win32k/include/guicheck.h index 24de8c740dc..7878d3fb55e 100644 --- a/reactos/subsys/win32k/include/guicheck.h +++ b/reactos/subsys/win32k/include/guicheck.h @@ -1,7 +1,7 @@ #ifndef _WIN32K_GUICHECK_H #define _WIN32K_GUICHECK_H -BOOL FASTCALL IntGraphicsCheck(BOOL Create); +BOOL FASTCALL co_IntGraphicsCheck(BOOL Create); BOOL FASTCALL IntCreatePrimarySurface(); VOID FASTCALL IntDestroyPrimarySurface(); diff --git a/reactos/subsys/win32k/include/hook.h b/reactos/subsys/win32k/include/hook.h index af8cccc08e0..4e7342fce0f 100644 --- a/reactos/subsys/win32k/include/hook.h +++ b/reactos/subsys/win32k/include/hook.h @@ -24,7 +24,7 @@ typedef struct tagHOOKTABLE UINT Counts[NB_HOOKS]; /* use counts for each hook chain */ } HOOKTABLE, *PHOOKTABLE; -LRESULT FASTCALL HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam); +LRESULT FASTCALL co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam); VOID FASTCALL HOOK_DestroyThreadHooks(PETHREAD Thread); #define IntLockHookTable(HookTable) \ diff --git a/reactos/subsys/win32k/include/msgqueue.h b/reactos/subsys/win32k/include/msgqueue.h index 6c32100f852..987d8e910c0 100644 --- a/reactos/subsys/win32k/include/msgqueue.h +++ b/reactos/subsys/win32k/include/msgqueue.h @@ -1,7 +1,6 @@ #ifndef _WIN32K_MSGQUEUE_H #define _WIN32K_MSGQUEUE_H -#include "caret.h" #include "hook.h" #define MSQ_HUNG 5000 @@ -124,7 +123,7 @@ typedef struct _USER_MESSAGE_QUEUE BOOL FASTCALL MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue); NTSTATUS FASTCALL -MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, +co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uTimeout, BOOL Block, BOOL HookMessage, ULONG_PTR *uResult); @@ -138,7 +137,7 @@ MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue, VOID FASTCALL MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode); BOOLEAN STDCALL -MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, +co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN BOOLEAN Hardware, IN BOOLEAN Remove, IN HWND Wnd, @@ -158,9 +157,9 @@ MsqGetHardwareMessageQueue(VOID); NTSTATUS FASTCALL MsqInitializeImpl(VOID); BOOLEAN FASTCALL -MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue); +co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue); NTSTATUS FASTCALL -MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter, +co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax); VOID FASTCALL MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue, @@ -170,17 +169,17 @@ MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue); VOID FASTCALL MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue); LRESULT FASTCALL -IntSendMessage(HWND hWnd, +co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); LRESULT FASTCALL -IntPostOrSendMessage(HWND hWnd, +co_IntPostOrSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); LRESULT FASTCALL -IntSendMessageTimeout(HWND hWnd, +co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, @@ -193,7 +192,7 @@ BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl); VOID FASTCALL -MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); +co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); VOID FASTCALL MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam); VOID FASTCALL diff --git a/reactos/subsys/win32k/include/painting.h b/reactos/subsys/win32k/include/painting.h index b0b06d62b11..2add4872da7 100644 --- a/reactos/subsys/win32k/include/painting.h +++ b/reactos/subsys/win32k/include/painting.h @@ -8,12 +8,12 @@ VOID FASTCALL IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion); BOOL FASTCALL -IntRedrawWindow(PWINDOW_OBJECT Wnd, const RECT* UpdateRect, HRGN UpdateRgn, ULONG Flags); +co_UserRedrawWindow(PWINDOW_OBJECT Wnd, const RECT* UpdateRect, HRGN UpdateRgn, ULONG Flags); BOOL FASTCALL IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, PW32THREAD Thread, MSG *Message, BOOL Remove); -BOOL STDCALL -NtUserValidateRgn(HWND hWnd, HRGN hRgn); +//BOOL STDCALL +//NtUserValidateRgn(HWND hWnd, HRGN hRgn); #define IntLockWindowUpdate(Window) \ ExAcquireFastMutex(&Window->UpdateLock) diff --git a/reactos/subsys/win32k/include/scroll.h b/reactos/subsys/win32k/include/scroll.h index 2d437a74f58..e09bc2ee4f5 100644 --- a/reactos/subsys/win32k/include/scroll.h +++ b/reactos/subsys/win32k/include/scroll.h @@ -16,7 +16,7 @@ typedef struct _WINDOW_SCROLLINFO #define SBOBJ_TO_SBID(Obj) ((Obj) - OBJID_HSCROLL) #define SBID_IS_VALID(id) (id == SB_HORZ || id == SB_VERT || id == SB_CTL) -BOOL FASTCALL IntCreateScrollBars(PWINDOW_OBJECT Window); +BOOL FASTCALL co_IntCreateScrollBars(PWINDOW_OBJECT Window); BOOL FASTCALL IntDestroyScrollBars(PWINDOW_OBJECT Window); #endif /* _WIN32K_SCROLL_H */ diff --git a/reactos/subsys/win32k/include/userfuncs.h b/reactos/subsys/win32k/include/userfuncs.h new file mode 100644 index 00000000000..270f0a69f23 --- /dev/null +++ b/reactos/subsys/win32k/include/userfuncs.h @@ -0,0 +1,130 @@ +#ifndef _WIN32K_USERFUNCS_H +#define _WIN32K_USERFUNCS_H + +/*************** WINSTA.C ***************/ + +HWINSTA FASTCALL UserGetProcessWindowStation(VOID); + +/*************** INPUT.C ***************/ + +NTSTATUS FASTCALL +UserAcquireOrReleaseInputOwnership(BOOLEAN Release); + +/*************** WINPOS.C ***************/ + +BOOL FASTCALL +UserGetClientOrigin(HWND hWnd, LPPOINT Point); + +/*************** FOCUS.C ***************/ + +HWND FASTCALL UserGetActiveWindow(); + +HWND FASTCALL UserGetForegroundWindow(VOID); + +HWND FASTCALL UserSetFocus(HWND hWnd); + +/*************** WINDC.C ***************/ + +INT FASTCALL +UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc); + +HDC FASTCALL +UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags); + +DWORD FASTCALL +UserGetWindowDC(PWINDOW_OBJECT Wnd); + +/*************** METRIC.C ***************/ + +ULONG FASTCALL +UserGetSystemMetrics(ULONG Index); + +/*************** KEYBOARD.C ***************/ + +DWORD FASTCALL UserGetKeyState(DWORD key); + +DWORD FASTCALL UserGetKeyboardType(DWORD TypeFlag); + +HKL FASTCALL UserGetKeyboardLayout(DWORD dwThreadId); + + +/*************** MISC.C ***************/ + +BOOL FASTCALL +UserSystemParametersInfo( + UINT uiAction, + UINT uiParam, + PVOID pvParam, + UINT fWinIni); + +/*************** MESSAGE.C ***************/ + +BOOL FASTCALL +UserPostMessage(HWND Wnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam); + + + +/*************** PAINTING.C ***************/ + +BOOL FASTCALL UserValidateRgn(HWND hWnd, HRGN hRgn); + + +/*************** WINDOW.C ***************/ + +VOID FASTCALL +co_DestroyThreadWindows(struct _ETHREAD *Thread); + +HWND FASTCALL UserGetShellWindow(); + +HWND FASTCALL UserSetParent(HWND hWndChild, HWND hWndNewParent); + +HWND FASTCALL UserGetWindow(HWND hWnd, UINT Relationship); + +HDC FASTCALL +UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags); + +BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Wnd); + +LONG FASTCALL UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi); + +HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type); + +/*************** MENU.C ***************/ + +HMENU FASTCALL UserCreateMenu(BOOL PopupMenu); + +BOOL FASTCALL +UserSetMenuDefaultItem( + HMENU hMenu, + UINT uItem, + UINT fByPos); + +BOOL FASTCALL UserDestroyMenu(HMENU hMenu); + +BOOL FASTCALL +UserMenuItemInfo( + HMENU Menu, + UINT Item, + BOOL ByPosition, + PROSMENUITEMINFO UnsafeItemInfo, + BOOL SetOrGet); + +BOOL FASTCALL +UserMenuInfo( + HMENU Menu, + PROSMENUINFO UnsafeMenuInfo, + BOOL SetOrGet); + + +/*************** SCROLLBAR.C ***************/ + +DWORD FASTCALL +co_UserShowScrollBar(HWND hWnd, int wBar, DWORD bShow); + + +#endif /* _WIN32K_USERFUNCS_H */ + +/* EOF */ diff --git a/reactos/subsys/win32k/include/vis.h b/reactos/subsys/win32k/include/vis.h index 8f1e95f50e3..50253f36dec 100644 --- a/reactos/subsys/win32k/include/vis.h +++ b/reactos/subsys/win32k/include/vis.h @@ -18,7 +18,7 @@ VIS_ComputeVisibleRegion(PWINDOW_OBJECT Window, BOOLEAN ClientArea, BOOLEAN ClipChildren, BOOLEAN ClipSiblings); VOID FASTCALL -VIS_WindowLayoutChanged(PWINDOW_OBJECT Window, HRGN UncoveredRgn); +co_VIS_WindowLayoutChanged(PWINDOW_OBJECT Window, HRGN UncoveredRgn); #endif /* ! defined(_WIN32K_VIS_H) */ diff --git a/reactos/subsys/win32k/include/win32k.h b/reactos/subsys/win32k/include/win32k.h index 7d9c0793108..06951759b2e 100644 --- a/reactos/subsys/win32k/include/win32k.h +++ b/reactos/subsys/win32k/include/win32k.h @@ -9,11 +9,11 @@ /* INCLUDES ******************************************************************/ /* Internal Win32k Headers */ +#include #include #include #include #include -#include #include #include #include @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/reactos/subsys/win32k/include/winpos.h b/reactos/subsys/win32k/include/winpos.h index 6a97e653a2d..9be9f705d8f 100644 --- a/reactos/subsys/win32k/include/winpos.h +++ b/reactos/subsys/win32k/include/winpos.h @@ -15,25 +15,25 @@ (INT)((y) - (WndObject)->WindowRect.top)))) UINT -FASTCALL WinPosArrangeIconicWindows(PWINDOW_OBJECT parent); +FASTCALL co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent); BOOL FASTCALL IntGetClientOrigin(HWND hWnd, LPPOINT Point); LRESULT FASTCALL -WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect); +co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect); UINT FASTCALL -WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos, +co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos, POINT* MinTrack, POINT* MaxTrack); UINT FASTCALL -WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos); +co_WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos); BOOLEAN FASTCALL -WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, +co_WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags); BOOLEAN FASTCALL -WinPosShowWindow(HWND Wnd, INT Cmd); +co_WinPosShowWindow(HWND Wnd, INT Cmd); USHORT FASTCALL -WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, +co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, PWINDOW_OBJECT* Window); -VOID FASTCALL WinPosActivateOtherWindow(PWINDOW_OBJECT Window); +VOID FASTCALL co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window); PINTERNALPOS FASTCALL WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT *pt, PRECT RestoreRect); diff --git a/reactos/subsys/win32k/include/winsta.h b/reactos/subsys/win32k/include/winsta.h index 64c83eacc2f..7d10a2c1e9b 100644 --- a/reactos/subsys/win32k/include/winsta.h +++ b/reactos/subsys/win32k/include/winsta.h @@ -90,7 +90,7 @@ BOOL FASTCALL IntGetWindowStationObject(PWINSTATION_OBJECT Object); BOOL FASTCALL -IntInitializeDesktopGraphics(VOID); +co_IntInitializeDesktopGraphics(VOID); VOID FASTCALL IntEndDesktopGraphics(VOID); diff --git a/reactos/subsys/win32k/main/dllmain.c b/reactos/subsys/win32k/main/dllmain.c index a9912e70d87..3b77b979eb1 100644 --- a/reactos/subsys/win32k/main/dllmain.c +++ b/reactos/subsys/win32k/main/dllmain.c @@ -42,6 +42,10 @@ Win32kProcessCallback(struct _EPROCESS *Process, BOOLEAN Create) { PW32PROCESS Win32Process; + DECLARE_RETURN(NTSTATUS); + + DPRINT("Enter Win32kProcessCallback\n"); + UserEnterExclusive(); /* Get the Win32 Process */ Win32Process = PsGetProcessWin32Process(Process); @@ -54,7 +58,7 @@ Win32kProcessCallback(struct _EPROCESS *Process, sizeof(W32PROCESS), TAG('W', '3', '2', 'p')); - if (Win32Process == NULL) return STATUS_NO_MEMORY; + if (Win32Process == NULL) RETURN( STATUS_NO_MEMORY); RtlZeroMemory(Win32Process, sizeof(W32PROCESS)); @@ -101,7 +105,7 @@ Win32kProcessCallback(struct _EPROCESS *Process, GDI_CleanupForProcess(Process); - IntGraphicsCheck(FALSE); + co_IntGraphicsCheck(FALSE); /* * Deregister logon application automatically @@ -112,7 +116,12 @@ Win32kProcessCallback(struct _EPROCESS *Process, } } - return STATUS_SUCCESS; + RETURN( STATUS_SUCCESS); + +CLEANUP: + UserLeave(); + DPRINT("Leave Win32kProcessCallback, ret=%i\n",_ret_); + END_CLEANUP; } @@ -123,6 +132,10 @@ Win32kThreadCallback(struct _ETHREAD *Thread, { struct _EPROCESS *Process; PW32THREAD Win32Thread; + DECLARE_RETURN(NTSTATUS); + + DPRINT("Enter Win32kThreadCallback\n"); + UserEnterExclusive(); Process = Thread->ThreadsProcess; @@ -137,7 +150,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, sizeof(W32THREAD), TAG('W', '3', '2', 't')); - if (Win32Thread == NULL) return STATUS_NO_MEMORY; + if (Win32Thread == NULL) RETURN( STATUS_NO_MEMORY); RtlZeroMemory(Win32Thread, sizeof(W32THREAD)); @@ -199,7 +212,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, } } Win32Thread->IsExiting = FALSE; - IntDestroyCaret(Win32Thread); + co_IntDestroyCaret(Win32Thread); Win32Thread->MessageQueue = MsqCreateMessageQueue(Thread); Win32Thread->KeyboardLayout = W32kGetDefaultKeyLayout(); Win32Thread->MessagePumpHookValue = 0; @@ -214,7 +227,7 @@ Win32kThreadCallback(struct _ETHREAD *Thread, Win32Thread->IsExiting = TRUE; HOOK_DestroyThreadHooks(Thread); UnregisterThreadHotKeys(Thread); - DestroyThreadWindows(Thread); + co_DestroyThreadWindows(Thread); IntBlockInput(Win32Thread, FALSE); MsqDestroyMessageQueue(Win32Thread->MessageQueue); IntCleanupThreadCallbacks(Win32Thread); @@ -224,7 +237,12 @@ Win32kThreadCallback(struct _ETHREAD *Thread, } } - return STATUS_SUCCESS; + RETURN( STATUS_SUCCESS); + +CLEANUP: + UserLeave(); + DPRINT("Leave Win32kThreadCallback, ret=%i\n",_ret_); + END_CLEANUP; } /* Only used in ntuser/input.c KeyboardThreadMain(). If it's @@ -316,6 +334,13 @@ DriverEntry ( DPRINT1("Failed to initialize the shared section pool: Status 0x%x\n", Status); } + Status = InitUserImpl(); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to initialize user implementation!\n"); + return STATUS_UNSUCCESSFUL; + } + Status = InitWindowStationImpl(); if (!NT_SUCCESS(Status)) { diff --git a/reactos/subsys/win32k/ntuser/accelerator.c b/reactos/subsys/win32k/ntuser/accelerator.c index ce9091a46ef..591cbec3d79 100644 --- a/reactos/subsys/win32k/ntuser/accelerator.c +++ b/reactos/subsys/win32k/ntuser/accelerator.c @@ -79,15 +79,19 @@ NtUserCopyAcceleratorTable( PACCELERATOR_TABLE AcceleratorTable; NTSTATUS Status; int Ret; + DECLARE_RETURN(int); - Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), + DPRINT("Enter NtUserCopyAcceleratorTable\n"); + UserEnterShared(); + + Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(), UserMode, 0, &WindowStation); if (!NT_SUCCESS(Status)) { SetLastNtError(STATUS_ACCESS_DENIED); - return 0; + RETURN(0); } Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, @@ -98,7 +102,7 @@ NtUserCopyAcceleratorTable( { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); ObDereferenceObject(WindowStation); - return 0; + RETURN(0); } if(Entries) @@ -110,7 +114,7 @@ NtUserCopyAcceleratorTable( ObmDereferenceObject(AcceleratorTable); ObDereferenceObject(WindowStation); SetLastNtError(Status); - return 0; + RETURN(0); } } else @@ -121,7 +125,12 @@ NtUserCopyAcceleratorTable( ObmDereferenceObject(AcceleratorTable); ObDereferenceObject(WindowStation); - return Ret; + RETURN(Ret); + +CLEANUP: + DPRINT("Leave NtUserCopyAcceleratorTable, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } HACCEL @@ -134,11 +143,13 @@ NtUserCreateAcceleratorTable( PACCELERATOR_TABLE AcceleratorTable; NTSTATUS Status; HACCEL Handle; + DECLARE_RETURN(HACCEL); - DPRINT("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n", - Entries, EntriesCount); + DPRINT("Enter NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n", + Entries, EntriesCount); + UserEnterExclusive(); - Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), + Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(), UserMode, 0, &WindowStation); @@ -146,7 +157,7 @@ NtUserCreateAcceleratorTable( { SetLastNtError(STATUS_ACCESS_DENIED); DPRINT1("E1\n"); - return FALSE; + RETURN( FALSE ); } AcceleratorTable = ObmCreateObject( @@ -159,7 +170,7 @@ NtUserCreateAcceleratorTable( ObDereferenceObject(WindowStation); SetLastNtError(STATUS_NO_MEMORY); DPRINT1("E2\n"); - return (HACCEL) 0; + RETURN( (HACCEL) 0 ); } AcceleratorTable->Count = EntriesCount; @@ -172,7 +183,7 @@ NtUserCreateAcceleratorTable( ObDereferenceObject(WindowStation); SetLastNtError(Status); DPRINT1("E3\n"); - return (HACCEL) 0; + RETURN( (HACCEL) 0); } Status = MmCopyFromCaller(AcceleratorTable->Table, Entries, EntriesCount * sizeof(ACCEL)); @@ -183,7 +194,7 @@ NtUserCreateAcceleratorTable( ObDereferenceObject(WindowStation); SetLastNtError(Status); DPRINT1("E4\n"); - return (HACCEL) 0; + RETURN((HACCEL) 0); } } @@ -191,10 +202,13 @@ NtUserCreateAcceleratorTable( /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */ - DPRINT("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x end\n", - Entries, EntriesCount, Handle); - - return (HACCEL) Handle; + RETURN((HACCEL) Handle); + +CLEANUP: + DPRINT("Leave NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x\n", + Entries, EntriesCount,_ret_); + UserLeave(); + END_CLEANUP; } BOOLEAN @@ -205,16 +219,17 @@ NtUserDestroyAcceleratorTable( PWINSTATION_OBJECT WindowStation; PACCELERATOR_TABLE AcceleratorTable; NTSTATUS Status; + DECLARE_RETURN(BOOLEAN); /* FIXME: If the handle table is from a call to LoadAcceleratorTable, decrement it's usage count (and return TRUE). FIXME: Destroy only tables created using CreateAcceleratorTable. */ - DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", - Table); + DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", Table); + UserEnterExclusive(); - Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), + Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(), UserMode, 0, &WindowStation); @@ -222,7 +237,7 @@ NtUserDestroyAcceleratorTable( { SetLastNtError(STATUS_ACCESS_DENIED); DPRINT1("E1\n"); - return FALSE; + RETURN( FALSE); } Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, @@ -234,7 +249,7 @@ NtUserDestroyAcceleratorTable( SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); ObDereferenceObject(WindowStation); DPRINT1("E2\n"); - return FALSE; + RETURN( FALSE); } ObmCloseHandle(WindowStation->HandleTable, Table); @@ -249,11 +264,16 @@ NtUserDestroyAcceleratorTable( DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", Table); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserDestroyAcceleratorTable(Table %x) = %i\n", Table,_ret_); + UserLeave(); + END_CLEANUP; } static BOOLEAN -IntTranslateAccelerator(HWND hWnd, +co_IntTranslateAccelerator(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, @@ -289,15 +309,15 @@ IntTranslateAccelerator(HWND hWnd, wParam, 0xff & HIWORD(lParam)); DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n", - NtUserGetKeyState(VK_SHIFT)); + UserGetKeyState(VK_SHIFT)); DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n", - NtUserGetKeyState(VK_CONTROL)); + UserGetKeyState(VK_CONTROL)); DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n", - NtUserGetKeyState(VK_MENU)); + UserGetKeyState(VK_MENU)); - if (NtUserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; - if (NtUserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; - if (NtUserGetKeyState(VK_MENU) & 0x8000) mask |= FALT; + if (UserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; + if (UserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; + if (UserGetKeyState(VK_MENU) & 0x8000) mask |= FALT; if (mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found; DPRINT("but incorrect SHIFT/CTRL/ALT-state\n"); } @@ -332,7 +352,7 @@ IntTranslateAccelerator(HWND hWnd, HMENU hMenu, hSubMenu, hSysMenu; UINT uSysStat = (UINT)-1, uStat = (UINT)-1, nPos; - hMenu = (NtUserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd); + hMenu = (UserGetWindowLongW(hWnd, GWL_STYLE) & WS_CHILD) ? 0 : GetMenu(hWnd); hSysMenu = get_win_sys_menu(hWnd); /* find menu item and ask application to initialize it */ @@ -341,12 +361,12 @@ IntTranslateAccelerator(HWND hWnd, nPos = cmd; if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND)) { - IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L); + co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L); if(hSubMenu != hSysMenu) { nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu); TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos); - IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE)); + co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE)); } uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND); } @@ -356,12 +376,12 @@ IntTranslateAccelerator(HWND hWnd, nPos = cmd; if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND)) { - IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L); + co_IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L); if(hSubMenu != hMenu) { nPos = MENU_FindSubMenu(&hMenu, hSubMenu); TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos); - IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE)); + co_IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE)); } uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND); } @@ -402,12 +422,12 @@ IntTranslateAccelerator(HWND hWnd, if (mesg == WM_COMMAND) { DPRINT(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd); - IntSendMessage(hWnd, mesg, 0x10000 | cmd, 0L); + co_IntSendMessage(hWnd, mesg, 0x10000 | cmd, 0L); } else if (mesg == WM_SYSCOMMAND) { DPRINT(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd); - IntSendMessage(hWnd, mesg, cmd, 0x00010000L); + co_IntSendMessage(hWnd, mesg, cmd, 0x00010000L); } else { @@ -444,23 +464,25 @@ NtUserTranslateAccelerator( PACCELERATOR_TABLE AcceleratorTable; NTSTATUS Status; ULONG i; + DECLARE_RETURN(int); DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p)\n", hWnd, Table, Message); + UserEnterShared(); if (hWnd == NULL) - return 0; + RETURN( 0); if (Message == NULL) { SetLastNtError(STATUS_INVALID_PARAMETER); - return 0; + RETURN( 0); } if (Table == NULL) { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); - return 0; + RETURN( 0); } if ((Message->message != WM_KEYDOWN) && @@ -468,17 +490,17 @@ NtUserTranslateAccelerator( (Message->message != WM_SYSCHAR) && (Message->message != WM_CHAR)) { - return 0; + RETURN( 0); } - Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), + Status = IntValidateWindowStationHandle(UserGetProcessWindowStation(), UserMode, 0, &WindowStation); if (!NT_SUCCESS(Status)) { SetLastNtError(STATUS_ACCESS_DENIED); - return 0; + RETURN( 0); } Status = ObmReferenceObjectByHandle(WindowStation->HandleTable, @@ -489,21 +511,21 @@ NtUserTranslateAccelerator( { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); ObDereferenceObject(WindowStation); - return 0; + RETURN( 0); } /* FIXME: Associate AcceleratorTable with the current thread */ for (i = 0; i < AcceleratorTable->Count; i++) { - if (IntTranslateAccelerator(hWnd, Message->message, Message->wParam, Message->lParam, + if (co_IntTranslateAccelerator(hWnd, Message->message, Message->wParam, Message->lParam, AcceleratorTable->Table[i].fVirt, AcceleratorTable->Table[i].key, AcceleratorTable->Table[i].cmd)) { ObDereferenceObject(WindowStation); DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n", hWnd, Table, Message, 1); - return 1; + RETURN( 1); } if (((AcceleratorTable->Table[i].fVirt & 0x80) > 0)) { @@ -513,8 +535,11 @@ NtUserTranslateAccelerator( ObDereferenceObject(WindowStation); + RETURN( 0); + +CLEANUP: DPRINT("NtUserTranslateAccelerator(hWnd %x, Table %x, Message %p) = %i end\n", hWnd, Table, Message, 0); - - return 0; + UserLeave(); + END_CLEANUP; } diff --git a/reactos/subsys/win32k/ntuser/callback.c b/reactos/subsys/win32k/ntuser/callback.c index 9f64d2ceb56..40a602ccc34 100644 --- a/reactos/subsys/win32k/ntuser/callback.c +++ b/reactos/subsys/win32k/ntuser/callback.c @@ -108,7 +108,7 @@ IntCleanupThreadCallbacks(PW32THREAD W32Thread) /* FUNCTIONS *****************************************************************/ VOID STDCALL -IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, +co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, HWND hWnd, UINT Msg, ULONG_PTR CompletionCallbackContext, @@ -122,11 +122,17 @@ IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, Arguments.Msg = Msg; Arguments.Context = CompletionCallbackContext; Arguments.Result = Result; + + UserLeaveCo(); + Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC, &Arguments, sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS), NULL, NULL); + + UserEnterCo(); + if (!NT_SUCCESS(Status)) { return; @@ -135,7 +141,7 @@ IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback, } LRESULT STDCALL -IntCallWindowProc(WNDPROC Proc, +co_IntCallWindowProc(WNDPROC Proc, BOOLEAN IsAnsiProc, HWND Wnd, UINT Message, @@ -177,11 +183,17 @@ IntCallWindowProc(WNDPROC Proc, Arguments->lParamBufferSize = lParamBufferSize; ResultPointer = Arguments; ResultLength = ArgumentLength; + + UserLeaveCo(); + Status = NtW32Call(USER32_CALLBACK_WINDOWPROC, Arguments, ArgumentLength, &ResultPointer, &ResultLength); + + UserEnterCo(); + if (!NT_SUCCESS(Status)) { if (0 < lParamBufferSize) @@ -204,7 +216,7 @@ IntCallWindowProc(WNDPROC Proc, } HMENU STDCALL -IntLoadSysMenuTemplate() +co_IntLoadSysMenuTemplate() { LRESULT Result; NTSTATUS Status; @@ -213,11 +225,17 @@ IntLoadSysMenuTemplate() ResultPointer = &Result; ResultLength = sizeof(LRESULT); + + UserLeaveCo(); + Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE, NULL, 0, &ResultPointer, &ResultLength); + + UserEnterCo(); + if (!NT_SUCCESS(Status)) { return(0); @@ -226,7 +244,7 @@ IntLoadSysMenuTemplate() } BOOL STDCALL -IntLoadDefaultCursors(VOID) +co_IntLoadDefaultCursors(VOID) { LRESULT Result; NTSTATUS Status; @@ -236,11 +254,17 @@ IntLoadDefaultCursors(VOID) ResultPointer = &Result; ResultLength = sizeof(LRESULT); + + UserLeaveCo(); + Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS, &DefaultCursor, sizeof(BOOL), &ResultPointer, &ResultLength); + + UserEnterCo(); + if (!NT_SUCCESS(Status)) { return FALSE; @@ -249,7 +273,7 @@ IntLoadDefaultCursors(VOID) } LRESULT STDCALL -IntCallHookProc(INT HookId, +co_IntCallHookProc(INT HookId, INT Code, WPARAM wParam, LPARAM lParam, @@ -361,12 +385,17 @@ IntCallHookProc(INT HookId, ResultPointer = &Result; ResultLength = sizeof(LRESULT); + + UserLeaveCo(); + Status = NtW32Call(USER32_CALLBACK_HOOKPROC, Argument, ArgumentLength, &ResultPointer, &ResultLength); + UserEnterCo(); + IntCbFreeMemory(Argument); if (!NT_SUCCESS(Status)) diff --git a/reactos/subsys/win32k/ntuser/caret.c b/reactos/subsys/win32k/ntuser/caret.c index 36e2da1da36..f769b318931 100644 --- a/reactos/subsys/win32k/ntuser/caret.c +++ b/reactos/subsys/win32k/ntuser/caret.c @@ -21,11 +21,11 @@ #define CARET_VALUENAME L"CursorBlinkRate" BOOL FASTCALL -IntHideCaret(PTHRDCARETINFO CaretInfo) +co_IntHideCaret(PTHRDCARETINFO CaretInfo) { if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing) { - IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); + co_IntSendMessage(CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); CaretInfo->Showing = 0; return TRUE; } @@ -33,7 +33,7 @@ IntHideCaret(PTHRDCARETINFO CaretInfo) } BOOL FASTCALL -IntDestroyCaret(PW32THREAD Win32Thread) +co_IntDestroyCaret(PW32THREAD Win32Thread) { PUSER_MESSAGE_QUEUE ThreadQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue; @@ -41,7 +41,7 @@ IntDestroyCaret(PW32THREAD Win32Thread) if(!ThreadQueue || !ThreadQueue->CaretInfo) return FALSE; - IntHideCaret(ThreadQueue->CaretInfo); + co_IntHideCaret(ThreadQueue->CaretInfo); ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0; ThreadQueue->CaretInfo->hWnd = (HWND)0; ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0; @@ -159,7 +159,7 @@ IntGetCaretBlinkTime(VOID) } BOOL FASTCALL -IntSetCaretPos(int X, int Y) +co_IntSetCaretPos(int X, int Y) { PUSER_MESSAGE_QUEUE ThreadQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; @@ -168,11 +168,11 @@ IntSetCaretPos(int X, int Y) { if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y) { - IntHideCaret(ThreadQueue->CaretInfo); + co_IntHideCaret(ThreadQueue->CaretInfo); ThreadQueue->CaretInfo->Showing = 0; ThreadQueue->CaretInfo->Pos.x = X; ThreadQueue->CaretInfo->Pos.y = Y; - IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); + co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); } return TRUE; @@ -198,7 +198,7 @@ IntSwitchCaretShowing(PVOID Info) } VOID FASTCALL -IntDrawCaret(HWND hWnd) +co_IntDrawCaret(HWND hWnd) { PUSER_MESSAGE_QUEUE ThreadQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; @@ -206,7 +206,7 @@ IntDrawCaret(HWND hWnd) if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible && ThreadQueue->CaretInfo->Showing) { - IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); + co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); ThreadQueue->CaretInfo->Showing = 1; } } @@ -223,19 +223,23 @@ NtUserCreateCaret( { PWINDOW_OBJECT WindowObject; PUSER_MESSAGE_QUEUE ThreadQueue; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserCreateCaret\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_HANDLE); - return FALSE; + RETURN(FALSE); } if(WindowObject->OwnerThread != PsGetCurrentThread()) { IntReleaseWindowObject(WindowObject); SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; + RETURN(FALSE); } ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; @@ -243,7 +247,7 @@ NtUserCreateCaret( if (ThreadQueue->CaretInfo->Visible) { IntKillTimer(hWnd, IDCARETTIMER, TRUE); - IntHideCaret(ThreadQueue->CaretInfo); + co_IntHideCaret(ThreadQueue->CaretInfo); } ThreadQueue->CaretInfo->hWnd = hWnd; @@ -262,14 +266,30 @@ NtUserCreateCaret( ThreadQueue->CaretInfo->Showing = 0; IntReleaseWindowObject(WindowObject); - return TRUE; + + RETURN(TRUE); + +CLEANUP: + DPRINT("Leave NtUserCreateCaret, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } UINT STDCALL NtUserGetCaretBlinkTime(VOID) { - return IntGetCaretBlinkTime(); + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserGetCaretBlinkTime\n"); + UserEnterExclusive(); + + RETURN(IntGetCaretBlinkTime()); + +CLEANUP: + DPRINT("Leave NtUserGetCaretBlinkTime, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL @@ -279,6 +299,10 @@ NtUserGetCaretPos( { PUSER_MESSAGE_QUEUE ThreadQueue; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetCaretPos\n"); + UserEnterShared(); ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; @@ -286,11 +310,48 @@ NtUserGetCaretPos( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); + RETURN(FALSE); + } + + RETURN(TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetCaretPos, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + +BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject) +{ + PUSER_MESSAGE_QUEUE ThreadQueue; + + if(WindowObject->OwnerThread != PsGetCurrentThread()) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); return FALSE; } + ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; + + if(ThreadQueue->CaretInfo->hWnd != WindowObject->Self) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + if(ThreadQueue->CaretInfo->Visible) + { + IntKillTimer(WindowObject->Self, IDCARETTIMER, TRUE); + + co_IntHideCaret(ThreadQueue->CaretInfo); + ThreadQueue->CaretInfo->Visible = 0; + ThreadQueue->CaretInfo->Showing = 0; + } + return TRUE; -} +} + BOOL STDCALL @@ -298,85 +359,88 @@ NtUserHideCaret( HWND hWnd) { PWINDOW_OBJECT WindowObject; - PUSER_MESSAGE_QUEUE ThreadQueue; + DECLARE_RETURN(BOOL); + BOOL ret; + + DPRINT("Enter NtUserHideCaret\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; - } - - if(WindowObject->OwnerThread != PsGetCurrentThread()) - { - IntReleaseWindowObject(WindowObject); - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; - - if(ThreadQueue->CaretInfo->hWnd != hWnd) - { - IntReleaseWindowObject(WindowObject); - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - if(ThreadQueue->CaretInfo->Visible) - { - IntKillTimer(hWnd, IDCARETTIMER, TRUE); - - IntHideCaret(ThreadQueue->CaretInfo); - ThreadQueue->CaretInfo->Visible = 0; - ThreadQueue->CaretInfo->Showing = 0; + RETURN(FALSE); } + ret = co_UserHideCaret(WindowObject); IntReleaseWindowObject(WindowObject); - return TRUE; + + RETURN(ret); + +CLEANUP: + DPRINT("Leave NtUserHideCaret, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } + +BOOL FASTCALL co_UserShowCaret(PWINDOW_OBJECT WindowObject) +{ + PUSER_MESSAGE_QUEUE ThreadQueue; + + if(WindowObject->OwnerThread != PsGetCurrentThread()) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; + + if(ThreadQueue->CaretInfo->hWnd != WindowObject->Self) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return FALSE; + } + + if(!ThreadQueue->CaretInfo->Visible) + { + ThreadQueue->CaretInfo->Visible = 1; + if(!ThreadQueue->CaretInfo->Showing) + { + co_IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); + } + IntSetTimer(WindowObject->Self, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); + } + + return TRUE; +} + + BOOL STDCALL NtUserShowCaret( HWND hWnd) { PWINDOW_OBJECT WindowObject; - PUSER_MESSAGE_QUEUE ThreadQueue; + DECLARE_RETURN(BOOL); + BOOL ret; + + DPRINT("Enter NtUserShowCaret\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; - } - - if(WindowObject->OwnerThread != PsGetCurrentThread()) - { - IntReleaseWindowObject(WindowObject); - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; - - if(ThreadQueue->CaretInfo->hWnd != hWnd) - { - IntReleaseWindowObject(WindowObject); - SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; - } - - if(!ThreadQueue->CaretInfo->Visible) - { - ThreadQueue->CaretInfo->Visible = 1; - if(!ThreadQueue->CaretInfo->Showing) - { - IntSendMessage(ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); - } - IntSetTimer(hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); + RETURN(FALSE); } + ret = co_UserShowCaret(WindowObject); IntReleaseWindowObject(WindowObject); - return TRUE; + RETURN(ret); + +CLEANUP: + DPRINT("Leave NtUserShowCaret, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } diff --git a/reactos/subsys/win32k/ntuser/class.c b/reactos/subsys/win32k/ntuser/class.c index bcf645d75b6..6a2ce6027f5 100644 --- a/reactos/subsys/win32k/ntuser/class.c +++ b/reactos/subsys/win32k/ntuser/class.c @@ -146,16 +146,19 @@ NtUserGetClassInfo( { PWNDCLASS_OBJECT Class; RTL_ATOM Atom; - + DECLARE_RETURN(DWORD); + if (IS_ATOM(lpClassName)) DPRINT("NtUserGetClassInfo - %x (%lx)\n", lpClassName, hInstance); else DPRINT("NtUserGetClassInfo - %S (%lx)\n", lpClassName, hInstance); + UserEnterExclusive(); + if (!ClassReferenceClassByNameOrAtom(&Class, lpClassName, hInstance)) { SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - return 0; + RETURN(0); } lpWndClassEx->cbSize = sizeof(WNDCLASSEXW); @@ -181,7 +184,12 @@ NtUserGetClassInfo( ObmDereferenceObject(Class); - return Atom; + RETURN(Atom); + +CLEANUP: + DPRINT("Leave NtUserGetClassInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } ULONG FASTCALL @@ -232,16 +240,24 @@ NtUserGetClassName ( { PWINDOW_OBJECT WindowObject; LONG Length; - + DECLARE_RETURN(DWORD); + + UserEnterShared(); + WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN(0); } Length = IntGetClassName(WindowObject, lpClassName, nMaxCount); IntReleaseWindowObject(WindowObject); - return Length; + RETURN(Length); + +CLEANUP: + DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD STDCALL @@ -385,31 +401,35 @@ NtUserRegisterClassExWOW( PWNDCLASS_OBJECT ClassObject; NTSTATUS Status; RTL_ATOM Atom; + DECLARE_RETURN(RTL_ATOM); + + DPRINT("Enter NtUserRegisterClassExWOW\n"); + UserEnterExclusive(); if (!lpwcx) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return (RTL_ATOM)0; + RETURN( (RTL_ATOM)0); } if (Flags & ~REGISTERCLASS_ALL) { SetLastWin32Error(ERROR_INVALID_FLAGS); - return (RTL_ATOM)0; + RETURN( (RTL_ATOM)0); } Status = MmCopyFromCaller(&SafeClass, lpwcx, sizeof(WNDCLASSEXW)); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); - return (RTL_ATOM)0; + RETURN( (RTL_ATOM)0); } /* Deny negative sizes */ if (lpwcx->cbClsExtra < 0 || lpwcx->cbWndExtra < 0) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return (RTL_ATOM)0; + RETURN( (RTL_ATOM)0); } WinStaObject = PsGetWin32Thread()->Desktop->WindowStation; @@ -426,7 +446,7 @@ NtUserRegisterClassExWOW( DPRINT1("Failed adding class name (%S) to atom table\n", ClassName->Buffer); SetLastNtError(Status); - return((RTL_ATOM)0); + RETURN((RTL_ATOM)0); } } else @@ -441,13 +461,18 @@ NtUserRegisterClassExWOW( RtlDeleteAtomFromAtomTable(WinStaObject->AtomTable, Atom); } DPRINT("Failed creating window class object\n"); - return((RTL_ATOM)0); + RETURN((RTL_ATOM)0); } IntLockProcessClasses(PsGetWin32Process()); InsertTailList(&PsGetWin32Process()->ClassListHead, &ClassObject->ListEntry); IntUnLockProcessClasses(PsGetWin32Process()); - return(Atom); + RETURN(Atom); + +CLEANUP: + DPRINT("Leave NtUserRegisterClassExWOW, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } ULONG FASTCALL @@ -519,20 +544,29 @@ NtUserGetClassLong(HWND hWnd, DWORD Offset, BOOL Ansi) { PWINDOW_OBJECT WindowObject; LONG Ret; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetClassLong\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN(0); } Ret = IntGetClassLong(WindowObject, Offset, Ansi); IntReleaseWindowObject(WindowObject); - return(Ret); + RETURN(Ret); + +CLEANUP: + DPRINT("Leave NtUserGetClassLong, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } void FASTCALL -IntSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL Ansi) +co_IntSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL Ansi) { PWINDOW_OBJECT Parent, Owner; @@ -569,7 +603,7 @@ IntSetClassLong(PWINDOW_OBJECT WindowObject, ULONG Offset, LONG dwNewLong, BOOL if ((!Owner) && (!Parent)) { - IntShellHookNotify(HSHELL_REDRAW, (LPARAM) WindowObject->Self); + co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) WindowObject->Self); } if (Parent) @@ -635,17 +669,26 @@ NtUserSetClassLong(HWND hWnd, { PWINDOW_OBJECT WindowObject; LONG Ret; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserSetClassLong\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN(0); } Ret = IntGetClassLong(WindowObject, Offset, Ansi); - IntSetClassLong(WindowObject, Offset, dwNewLong, Ansi); + co_IntSetClassLong(WindowObject, Offset, dwNewLong, Ansi); IntReleaseWindowObject(WindowObject); - return(Ret); + RETURN(Ret); + +CLEANUP: + DPRINT("Leave NtUserSetClassLong, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD STDCALL @@ -665,13 +708,15 @@ NtUserUnregisterClass( { PWNDCLASS_OBJECT Class; PWINSTATION_OBJECT WinStaObject; + DECLARE_RETURN(BOOL); - DPRINT("NtUserUnregisterClass(%S)\n", ClassNameOrAtom); + DPRINT("Enter NtUserUnregisterClass(%S)\n", ClassNameOrAtom); + UserEnterExclusive(); if (!ClassNameOrAtom || !PsGetWin32Thread()->Desktop) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } WinStaObject = PsGetWin32Thread()->Desktop->WindowStation; @@ -679,14 +724,14 @@ NtUserUnregisterClass( if (!ClassReferenceClassByNameOrAtom(&Class, ClassNameOrAtom, hInstance)) { SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - return FALSE; + RETURN( FALSE); } if (Class->hInstance && Class->hInstance != hInstance) { ClassDereferenceObject(Class); SetLastWin32Error(ERROR_CLASS_DOES_NOT_EXIST); - return FALSE; + RETURN( FALSE); } IntLockClassWindows(Class); @@ -696,7 +741,7 @@ NtUserUnregisterClass( /* Dereference the ClassReferenceClassByNameOrAtom() call */ ObmDereferenceObject(Class); SetLastWin32Error(ERROR_CLASS_HAS_WINDOWS); - return FALSE; + RETURN( FALSE); } IntUnLockClassWindows(Class); @@ -710,7 +755,12 @@ NtUserUnregisterClass( /* Free the object */ ClassDereferenceObject(Class); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserUnregisterClass, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/csr.c b/reactos/subsys/win32k/ntuser/csr.c index 18782be9a5e..9307c213ba8 100644 --- a/reactos/subsys/win32k/ntuser/csr.c +++ b/reactos/subsys/win32k/ntuser/csr.c @@ -44,7 +44,7 @@ CsrInit(void) NTSTATUS FASTCALL -CsrNotify(PCSR_API_MESSAGE Request) +co_CsrNotify(PCSR_API_MESSAGE Request) { NTSTATUS Status; PEPROCESS OldProcess; @@ -63,9 +63,15 @@ CsrNotify(PCSR_API_MESSAGE Request) { KeAttachProcess(&CsrProcess->Pcb); } + + UserLeaveCo(); + Status = ZwRequestWaitReplyPort(WindowsApiPort, &Request->Header, &Request->Header); + + UserEnterCo(); + if (CsrProcess != OldProcess) { KeDetachProcess(); diff --git a/reactos/subsys/win32k/ntuser/cursoricon.c b/reactos/subsys/win32k/ntuser/cursoricon.c index df61c31ad76..a99d816a282 100644 --- a/reactos/subsys/win32k/ntuser/cursoricon.c +++ b/reactos/subsys/win32k/ntuser/cursoricon.c @@ -583,11 +583,15 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect) PBITMAPOBJ bmp; NTSTATUS Status; HANDLE Ret; + DECLARE_RETURN(HANDLE); + + DPRINT("Enter NtUserCreateCursorIconHandle\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return (HANDLE)0; + RETURN( (HANDLE)0); } CurIconObject = IntCreateCurIconHandle(WinStaObject); @@ -633,12 +637,17 @@ NtUserCreateCursorIconHandle(PICONINFO IconInfo, BOOL Indirect) } ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); ObDereferenceObject(WinStaObject); - return (HANDLE)0; + RETURN( (HANDLE)0); + +CLEANUP: + DPRINT("Leave NtUserCreateCursorIconHandle, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -655,11 +664,15 @@ NtUserGetCursorIconInfo( PWINSTATION_OBJECT WinStaObject; NTSTATUS Status; BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetCursorIconInfo\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurIconObject = IntGetCurIconObject(WinStaObject, Handle); @@ -687,12 +700,17 @@ NtUserGetCursorIconInfo( IntReleaseCurIconObject(CurIconObject); ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserGetCursorIconInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -712,11 +730,15 @@ NtUserGetCursorIconSize( NTSTATUS Status; BOOL Ret = FALSE; SIZE SafeSize; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetCursorIconSize\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurIconObject = IntGetCurIconObject(WinStaObject, Handle); @@ -747,12 +769,17 @@ NtUserGetCursorIconSize( done: IntReleaseCurIconObject(CurIconObject); ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserGetCursorIconSize, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -786,6 +813,10 @@ NtUserGetCursorInfo( PWINSTATION_OBJECT WinStaObject; NTSTATUS Status; PCURICON_OBJECT CursorObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetCursorInfo\n"); + UserEnterExclusive(); #if 1 HDC hDC; @@ -793,7 +824,7 @@ NtUserGetCursorInfo( /* FIXME - get the screen dc from the window station or desktop */ if (!(hDC = IntGetScreenDC())) { - return FALSE; + RETURN( FALSE); } #endif @@ -801,19 +832,19 @@ NtUserGetCursorInfo( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } if(SafeCi.cbSize != sizeof(CURSORINFO)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurInfo = IntGetSysCursorInfo(WinStaObject); @@ -829,11 +860,16 @@ NtUserGetCursorInfo( { ObDereferenceObject(WinStaObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } ObDereferenceObject(WinStaObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetCursorInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -852,18 +888,22 @@ NtUserClipCursor( RECT Rect; PWINDOW_OBJECT DesktopWindow = NULL; POINT MousePos; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserClipCursor\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if (WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT)))) { ObDereferenceObject(WinStaObject); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } CurInfo = IntGetSysCursorInfo(WinStaObject); @@ -892,13 +932,18 @@ NtUserClipCursor( mi.dwExtraInfo = 0; IntMouseInput(&mi); - return TRUE; + RETURN( TRUE); } CurInfo->CursorClipInfo.IsClipped = FALSE; ObDereferenceObject(WinStaObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserClipCursor, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -914,11 +959,15 @@ NtUserDestroyCursorIcon( PWINSTATION_OBJECT WinStaObject; PCURICON_OBJECT Object; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserDestroyCursorIcon\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } Status = ObmReferenceObjectByHandle(WinStaObject->HandleTable, Handle, otCursorIcon, (PVOID*)&Object); @@ -926,20 +975,25 @@ NtUserDestroyCursorIcon( { ObDereferenceObject(WinStaObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } if(IntDestroyCurIconObject(WinStaObject, Object, FALSE)) { ObmDereferenceObject(Object); ObDereferenceObject(WinStaObject); - return TRUE; + RETURN( TRUE); } ObmDereferenceObject(Object); ObDereferenceObject(WinStaObject); SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserDestroyCursorIcon, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -957,11 +1011,15 @@ NtUserFindExistingCursorIcon( PCURICON_OBJECT CurIconObject; PWINSTATION_OBJECT WinStaObject; HANDLE Ret = (HANDLE)0; + DECLARE_RETURN(HICON); + + DPRINT("Enter NtUserFindExistingCursorIcon\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return Ret; + RETURN( Ret); } CurIconObject = IntFindExistingCurIconObject(WinStaObject, hModule, hRsrc, cx, cy); @@ -971,12 +1029,17 @@ NtUserFindExistingCursorIcon( IntReleaseCurIconObject(CurIconObject); ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return (HANDLE)0; + RETURN( (HANDLE)0); + +CLEANUP: + DPRINT("Leave NtUserFindExistingCursorIcon, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -993,14 +1056,18 @@ NtUserGetClipCursor( PWINSTATION_OBJECT WinStaObject; RECT Rect; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetClipCursor\n"); + UserEnterExclusive(); if(!lpRect) - return FALSE; + RETURN( FALSE); WinStaObject = IntGetWinStaObj(); if (WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurInfo = IntGetSysCursorInfo(WinStaObject); @@ -1015,8 +1082,8 @@ NtUserGetClipCursor( { Rect.left = 0; Rect.top = 0; - Rect.right = NtUserGetSystemMetrics(SM_CXSCREEN); - Rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN); + Rect.right = UserGetSystemMetrics(SM_CXSCREEN); + Rect.bottom = UserGetSystemMetrics(SM_CYSCREEN); } Status = MmCopyToCaller((PRECT)lpRect, &Rect, sizeof(RECT)); @@ -1024,12 +1091,17 @@ NtUserGetClipCursor( { ObDereferenceObject(WinStaObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } ObDereferenceObject(WinStaObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetClipCursor, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1044,11 +1116,15 @@ NtUserSetCursor( PCURICON_OBJECT CurIconObject; HICON OldCursor = (HCURSOR)0; PWINSTATION_OBJECT WinStaObject; + DECLARE_RETURN(HCURSOR); + + DPRINT("Enter NtUserSetCursor\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return (HCURSOR)0; + RETURN( (HCURSOR)0); } CurIconObject = IntGetCurIconObject(WinStaObject, hCursor); @@ -1061,7 +1137,12 @@ NtUserSetCursor( SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return OldCursor; + RETURN( OldCursor); + +CLEANUP: + DPRINT("Leave NtUserSetCursor, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1079,11 +1160,15 @@ NtUserSetCursorIconContents( PWINSTATION_OBJECT WinStaObject; NTSTATUS Status; BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetCursorIconContents\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurIconObject = IntGetCurIconObject(WinStaObject, Handle); @@ -1123,12 +1208,17 @@ NtUserSetCursorIconContents( done: IntReleaseCurIconObject(CurIconObject); ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserSetCursorIconContents, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1150,11 +1240,15 @@ NtUserSetCursorIconData( NTSTATUS Status; POINT SafeHotspot; BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetCursorIconData\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurIconObject = IntGetCurIconObject(WinStaObject, Handle); @@ -1202,12 +1296,17 @@ NtUserSetCursorIconData( done: IntReleaseCurIconObject(CurIconObject); ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserSetCursorIconData, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1257,11 +1356,15 @@ NtUserDrawIconEx( #if CANSTRETCHBLT INT nStretchMode; #endif + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserDrawIconEx\n"); + UserEnterExclusive(); WinStaObject = IntGetWinStaObj(); if(WinStaObject == NULL) { - return FALSE; + RETURN( FALSE); } CurIconObject = IntGetCurIconObject(WinStaObject, hIcon); @@ -1295,9 +1398,9 @@ NtUserDrawIconEx( diFlags = DI_NORMAL; if(!cxWidth) - cxWidth = ((diFlags & DI_DEFAULTSIZE) ? NtUserGetSystemMetrics(SM_CXICON) : IconSize.cx); + cxWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CXICON) : IconSize.cx); if(!cyWidth) - cyWidth = ((diFlags & DI_DEFAULTSIZE) ? NtUserGetSystemMetrics(SM_CYICON) : IconSize.cy); + cyWidth = ((diFlags & DI_DEFAULTSIZE) ? UserGetSystemMetrics(SM_CYICON) : IconSize.cy); DoFlickerFree = (hbrFlickerFreeDraw && (NtGdiGetObjectType(hbrFlickerFreeDraw) == OBJ_BRUSH)); @@ -1402,11 +1505,16 @@ NtUserDrawIconEx( done: ObDereferenceObject(WinStaObject); - return Ret; + RETURN( Ret); } SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserDrawIconEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } diff --git a/reactos/subsys/win32k/ntuser/desktop.c b/reactos/subsys/win32k/ntuser/desktop.c index 1d2602ad0e4..e4015805f85 100644 --- a/reactos/subsys/win32k/ntuser/desktop.c +++ b/reactos/subsys/win32k/ntuser/desktop.c @@ -460,6 +460,24 @@ HWND FASTCALL IntGetDesktopWindow(VOID) return pdo->DesktopWindow; } +PWINDOW_OBJECT FASTCALL UserGetDesktopWindow(VOID) +{ + PDESKTOP_OBJECT pdo = IntGetActiveDesktop(); + PWINDOW_OBJECT DeskWnd; + + if (!pdo) + { + DPRINT("No active desktop\n"); + return NULL; + } + + //temp hack + DeskWnd = IntGetWindowObject(pdo->DesktopWindow); + if (DeskWnd) IntReleaseWindowObject(DeskWnd); + return DeskWnd; +} + + HWND FASTCALL IntGetCurrentThreadDesktopWindow(VOID) { PDESKTOP_OBJECT pdo = PsGetWin32Thread()->Desktop; @@ -510,7 +528,7 @@ BOOL FASTCALL IntDesktopUpdatePerUserSettings(BOOL bEnable) /* PUBLIC FUNCTIONS ***********************************************************/ NTSTATUS FASTCALL -IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height) +co_IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height) { CSR_API_MESSAGE Request; @@ -519,7 +537,7 @@ IntShowDesktop(PDESKTOP_OBJECT Desktop, ULONG Width, ULONG Height) Request.Data.ShowDesktopRequest.Width = Width; Request.Data.ShowDesktopRequest.Height = Height; - return CsrNotify(&Request); + return co_CsrNotify(&Request); } NTSTATUS FASTCALL @@ -552,7 +570,7 @@ IntHideDesktop(PDESKTOP_OBJECT Desktop) * notifications. The lParam contents depend on the Message. See * MSDN for more details (RegisterShellHookWindow) */ -VOID IntShellHookNotify(WPARAM Message, LPARAM lParam) +VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) { PDESKTOP_OBJECT Desktop = IntGetActiveDesktop(); PLIST_ENTRY Entry, Entry2; @@ -567,7 +585,7 @@ VOID IntShellHookNotify(WPARAM Message, LPARAM lParam) #if 0 UNICODE_STRING Str; RtlInitUnicodeString(&Str, L"SHELLHOOK"); - MsgType = NtUserRegisterWindowMessage(&Str); + MsgType = UserRegisterWindowMessage(&Str); #endif MsgType = IntAddAtom(L"SHELLHOOK"); @@ -592,7 +610,7 @@ VOID IntShellHookNotify(WPARAM Message, LPARAM lParam) KeReleaseSpinLock(&Desktop->Lock, OldLevel); DPRINT("Sending notify\n"); - IntPostOrSendMessage(Current->hWnd, + co_IntPostOrSendMessage(Current->hWnd, MsgType, Message, lParam); @@ -735,8 +753,10 @@ NtUserCreateDesktop( NTSTATUS Status; HDESK Desktop; CSR_API_MESSAGE Request; + DECLARE_RETURN(HDESK); - DPRINT("CreateDesktop: %wZ\n", lpszDesktopName); + DPRINT("Enter CreateDesktop: %wZ\n", lpszDesktopName); + UserEnterExclusive(); Status = IntValidateWindowStationHandle( hWindowStation, @@ -749,7 +769,7 @@ NtUserCreateDesktop( DPRINT1("Failed validation of window station handle (0x%X), cannot create desktop %wZ\n", hWindowStation, lpszDesktopName); SetLastNtError(Status); - return NULL; + RETURN( NULL); } if (! IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name, @@ -757,7 +777,7 @@ NtUserCreateDesktop( { SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); ObDereferenceObject(WinStaObject); - return NULL; + RETURN( NULL); } ObDereferenceObject(WinStaObject); @@ -789,7 +809,7 @@ NtUserCreateDesktop( { DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName); ExFreePool(DesktopName.Buffer); - return Desktop; + RETURN( Desktop); } /* @@ -812,7 +832,7 @@ NtUserCreateDesktop( DPRINT1("Failed creating desktop (%wZ)\n", &DesktopName); ExFreePool(DesktopName.Buffer); SetLastNtError(STATUS_UNSUCCESSFUL); - return NULL; + RETURN( NULL); } // init desktop area @@ -840,7 +860,7 @@ NtUserCreateDesktop( { DPRINT1("Failed to create desktop handle\n"); SetLastNtError(Status); - return NULL; + RETURN( NULL); } /* @@ -855,20 +875,25 @@ NtUserCreateDesktop( DPRINT1("Failed to create desktop handle for CSRSS\n"); ZwClose(Desktop); SetLastNtError(Status); - return NULL; + RETURN( NULL); } - Status = CsrNotify(&Request); + Status = co_CsrNotify(&Request); if (! NT_SUCCESS(Status)) { CsrCloseHandle(Request.Data.CreateDesktopRequest.DesktopHandle); DPRINT1("Failed to notify CSRSS about new desktop\n"); ZwClose(Desktop); SetLastNtError(Status); - return NULL; + RETURN( NULL); } - return Desktop; + RETURN( Desktop); + +CLEANUP: + DPRINT("Leave NtUserCreateDesktop, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -904,7 +929,11 @@ NtUserOpenDesktop( UNICODE_STRING DesktopName; NTSTATUS Status; HDESK Desktop; - + DECLARE_RETURN(HDESK); + + DPRINT("Enter NtUserOpenDesktop: %wZ\n", lpszDesktopName); + UserEnterExclusive(); + /* * Validate the window station handle and compose the fully * qualified desktop name @@ -921,7 +950,7 @@ NtUserOpenDesktop( DPRINT1("Failed validation of window station handle (0x%X)\n", PsGetCurrentProcess()->Win32WindowStation); SetLastNtError(Status); - return 0; + RETURN( 0); } if (!IntGetFullWindowStationName(&DesktopName, &WinStaObject->Name, @@ -929,7 +958,7 @@ NtUserOpenDesktop( { SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); ObDereferenceObject(WinStaObject); - return 0; + RETURN( 0); } ObDereferenceObject(WinStaObject); @@ -957,13 +986,18 @@ NtUserOpenDesktop( { SetLastNtError(Status); ExFreePool(DesktopName.Buffer); - return 0; + RETURN( 0); } DPRINT("Successfully opened desktop (%wZ)\n", &DesktopName); ExFreePool(DesktopName.Buffer); - return Desktop; + RETURN( Desktop); + +CLEANUP: + DPRINT("Leave NtUserOpenDesktop, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -1064,7 +1098,7 @@ NtUserCloseDesktop(HDESK hDesktop) { PDESKTOP_OBJECT Object; NTSTATUS Status; - + DPRINT("About to close desktop handle (0x%X)\n", hDesktop); Status = IntValidateDesktopHandle( @@ -1139,6 +1173,7 @@ NtUserPaintDesktop(HDC hDC) HBRUSH DesktopBrush, PreviousBrush; HWND hWndDesktop; BOOL doPatBlt = TRUE; + PWINDOW_OBJECT WndDesktop; int len; PWINSTATION_OBJECT WinSta = PsGetWin32Thread()->Desktop->WindowStation; @@ -1146,8 +1181,15 @@ NtUserPaintDesktop(HDC hDC) IntGdiGetClipBox(hDC, &Rect); hWndDesktop = IntGetDesktopWindow(); - DesktopBrush = (HBRUSH)NtUserGetClassLong(hWndDesktop, GCL_HBRBACKGROUND, FALSE); + if (!(WndDesktop = IntGetWindowObject(hWndDesktop))) + return FALSE; + + DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE); //fixme: verify retval + //temp hack + IntReleaseWindowObject(WndDesktop); + + /* * Paint desktop background */ @@ -1213,9 +1255,9 @@ NtUserPaintDesktop(HDC hDC) len = GetSystemVersionString(s_wszVersion); if (len) { - if (!NtUserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0)) { - rect.right = NtUserGetSystemMetrics(SM_CXSCREEN); - rect.bottom = NtUserGetSystemMetrics(SM_CYSCREEN); + if (!UserSystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0)) { + rect.right = UserGetSystemMetrics(SM_CXSCREEN); + rect.bottom = UserGetSystemMetrics(SM_CYSCREEN); } COLORREF color_old = NtGdiSetTextColor(hDC, RGB(255,255,255)); diff --git a/reactos/subsys/win32k/ntuser/focus.c b/reactos/subsys/win32k/ntuser/focus.c index 3309e1134a0..c4b134b6968 100644 --- a/reactos/subsys/win32k/ntuser/focus.c +++ b/reactos/subsys/win32k/ntuser/focus.c @@ -47,33 +47,33 @@ IntGetThreadFocusWindow() } VOID FASTCALL -IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd) +co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd) { if (hWndPrev) { - IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0); - IntPostOrSendMessage(hWndPrev, WM_ACTIVATE, - MAKEWPARAM(WA_INACTIVE, NtUserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE), + co_IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0); + co_IntPostOrSendMessage(hWndPrev, WM_ACTIVATE, + MAKEWPARAM(WA_INACTIVE, UserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE), (LPARAM)hWnd); } } VOID FASTCALL -IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) +co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) { PWINDOW_OBJECT Window, Owner, Parent; if (hWnd) { /* Send palette messages */ - if (IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) + if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) { - IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING, + co_IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING, (WPARAM)hWnd, 0); } - if (NtUserGetWindow(hWnd, GW_HWNDPREV) != NULL) - WinPosSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, + if (UserGetWindow(hWnd, GW_HWNDPREV) != NULL) + co_WinPosSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); Window = IntGetWindowObject(hWnd); @@ -82,7 +82,7 @@ IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) if (!Owner) { Parent = IntGetParent(Window); if (!Parent) - IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd); + co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd); else IntReleaseWindowObject(Parent); } else { @@ -94,30 +94,30 @@ IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) /* FIXME: IntIsWindow */ - IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == NtUserGetForegroundWindow()), 0); + co_IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == UserGetForegroundWindow()), 0); /* FIXME: WA_CLICKACTIVE */ - IntPostOrSendMessage(hWnd, WM_ACTIVATE, + co_IntPostOrSendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE, - NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE), + UserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE), (LPARAM)hWndPrev); } } VOID FASTCALL -IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd) +co_IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd) { if (hWndPrev) { - IntPostOrSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); + co_IntPostOrSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); } } VOID FASTCALL -IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd) +co_IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd) { if (hWnd) { - IntPostOrSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); + co_IntPostOrSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); } } @@ -151,7 +151,7 @@ IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner) } STATIC BOOL FASTCALL -IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWindow, BOOL MouseActivate) +co_IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWindow, BOOL MouseActivate) { HWND hWnd = Window->Self; HWND hWndPrev = NULL; @@ -191,8 +191,8 @@ IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWindow /* FIXME: Call hooks. */ - IntSendDeactivateMessages(hWndPrev, hWnd); - IntSendKillFocusMessages(hWndFocusPrev, hWndFocus); + co_IntSendDeactivateMessages(hWndPrev, hWnd); + co_IntSendKillFocusMessages(hWndFocusPrev, hWndFocus); IntSetFocusMessageQueue(Window->MessageQueue); IntLockMessageQueue(Window->MessageQueue); @@ -213,20 +213,20 @@ IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWindow /* FIXME: Send WM_ACTIVATEAPP to all thread windows. */ } - IntSendSetFocusMessages(hWndFocusPrev, hWndFocus); - IntSendActivateMessages(hWndPrev, hWnd, MouseActivate); + co_IntSendSetFocusMessages(hWndFocusPrev, hWndFocus); + co_IntSendActivateMessages(hWndPrev, hWnd, MouseActivate); return TRUE; } BOOL FASTCALL -IntSetForegroundWindow(PWINDOW_OBJECT Window) +co_IntSetForegroundWindow(PWINDOW_OBJECT Window) { - return IntSetForegroundAndFocusWindow(Window, Window, FALSE); + return co_IntSetForegroundAndFocusWindow(Window, Window, FALSE); } BOOL FASTCALL -IntMouseActivateWindow(PWINDOW_OBJECT Window) +co_IntMouseActivateWindow(PWINDOW_OBJECT Window) { HWND Top; PWINDOW_OBJECT TopWindow; @@ -241,7 +241,7 @@ IntMouseActivateWindow(PWINDOW_OBJECT Window) Top = IntFindChildWindowToOwner(DesktopWindow, Window); if((TopWnd = IntGetWindowObject(Top))) { - Ret = IntMouseActivateWindow(TopWnd); + Ret = co_IntMouseActivateWindow(TopWnd); IntReleaseWindowObject(TopWnd); IntReleaseWindowObject(DesktopWindow); return Ret; @@ -251,7 +251,7 @@ IntMouseActivateWindow(PWINDOW_OBJECT Window) return FALSE; } - Top = NtUserGetAncestor(Window->Self, GA_ROOT); + Top = UserGetAncestor(Window->Self, GA_ROOT); if (Top != Window->Self) { TopWindow = IntGetWindowObject(Top); @@ -267,7 +267,7 @@ IntMouseActivateWindow(PWINDOW_OBJECT Window) } /* TMN: Check return valud from this function? */ - IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE); + co_IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE); if (Top != Window->Self) { @@ -277,7 +277,7 @@ IntMouseActivateWindow(PWINDOW_OBJECT Window) } HWND FASTCALL -IntSetActiveWindow(PWINDOW_OBJECT Window) +co_IntSetActiveWindow(PWINDOW_OBJECT Window) { PUSER_MESSAGE_QUEUE ThreadQueue; HWND hWndPrev; @@ -308,8 +308,8 @@ IntSetActiveWindow(PWINDOW_OBJECT Window) ThreadQueue->ActiveWindow = hWnd; IntUnLockMessageQueue(ThreadQueue); - IntSendDeactivateMessages(hWndPrev, hWnd); - IntSendActivateMessages(hWndPrev, hWnd, FALSE); + co_IntSendDeactivateMessages(hWndPrev, hWnd); + co_IntSendActivateMessages(hWndPrev, hWnd, FALSE); /* FIXME */ /* return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/ @@ -317,7 +317,7 @@ IntSetActiveWindow(PWINDOW_OBJECT Window) } HWND FASTCALL -IntSetFocusWindow(HWND hWnd) +co_IntSetFocusWindow(HWND hWnd) { HWND hWndPrev = 0; PUSER_MESSAGE_QUEUE ThreadQueue; @@ -335,37 +335,80 @@ IntSetFocusWindow(HWND hWnd) ThreadQueue->FocusWindow = hWnd; IntUnLockMessageQueue(ThreadQueue); - IntSendKillFocusMessages(hWndPrev, hWnd); - IntSendSetFocusMessages(hWndPrev, hWnd); + co_IntSendKillFocusMessages(hWndPrev, hWnd); + co_IntSendSetFocusMessages(hWndPrev, hWnd); return hWndPrev; } + +/* + * @implemented + */ +HWND FASTCALL +UserGetForegroundWindow(VOID) +{ + PUSER_MESSAGE_QUEUE ForegroundQueue; + + ForegroundQueue = IntGetFocusMessageQueue(); + return( ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : 0); +} + + /* * @implemented */ HWND STDCALL NtUserGetForegroundWindow(VOID) { - PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue(); - return ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : 0; + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetForegroundWindow\n"); + UserEnterExclusive(); + + RETURN( UserGetForegroundWindow()); + +CLEANUP: + DPRINT("Leave NtUserGetForegroundWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } + +HWND FASTCALL UserGetActiveWindow() +{ + PUSER_MESSAGE_QUEUE ThreadQueue; + ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; + return( ThreadQueue ? ThreadQueue->ActiveWindow : 0); +} + + /* * @implemented */ HWND STDCALL NtUserGetActiveWindow(VOID) { - PUSER_MESSAGE_QUEUE ThreadQueue; - ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; - return ThreadQueue ? ThreadQueue->ActiveWindow : 0; + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetActiveWindow\n"); + UserEnterShared(); + + RETURN( UserGetActiveWindow()); + +CLEANUP: + DPRINT("Leave NtUserGetActiveWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } HWND STDCALL NtUserSetActiveWindow(HWND hWnd) { - DPRINT("NtUserSetActiveWindow(%x)\n", hWnd); + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserSetActiveWindow(%x)\n", hWnd); + UserEnterExclusive(); if (hWnd) { @@ -377,7 +420,7 @@ NtUserSetActiveWindow(HWND hWnd) if (Window == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } DPRINT("(%wZ)\n", &Window->WindowName); @@ -388,18 +431,23 @@ NtUserSetActiveWindow(HWND hWnd) { IntReleaseWindowObject(Window); SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } - hWndPrev = IntSetActiveWindow(Window); + hWndPrev = co_IntSetActiveWindow(Window); IntReleaseWindowObject(Window); - return hWndPrev; + RETURN( hWndPrev); } else { - return IntSetActiveWindow(0); + RETURN( co_IntSetActiveWindow(0)); } + +CLEANUP: + DPRINT("Leave NtUserSetActiveWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -408,9 +456,19 @@ NtUserSetActiveWindow(HWND hWnd) HWND STDCALL NtUserGetCapture(VOID) { + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetCapture\n"); + UserEnterShared(); + PUSER_MESSAGE_QUEUE ThreadQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; - return ThreadQueue ? ThreadQueue->CaptureWindow : 0; + RETURN( ThreadQueue ? ThreadQueue->CaptureWindow : 0); + +CLEANUP: + DPRINT("Leave NtUserGetCapture, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -422,8 +480,10 @@ NtUserSetCapture(HWND hWnd) PUSER_MESSAGE_QUEUE ThreadQueue; PWINDOW_OBJECT Window; HWND hWndPrev; + DECLARE_RETURN(HWND); - DPRINT("NtUserSetCapture(%x)\n", hWnd); + DPRINT("Enter NtUserSetCapture(%x)\n", hWnd); + UserEnterExclusive(); ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; if((Window = IntGetWindowObject(hWnd))) @@ -431,7 +491,7 @@ NtUserSetCapture(HWND hWnd) if(Window->MessageQueue != ThreadQueue) { IntReleaseWindowObject(Window); - return NULL; + RETURN( NULL); } } hWndPrev = MsqSetStateWindow(ThreadQueue, MSQ_STATE_CAPTURE, hWnd); @@ -443,22 +503,23 @@ NtUserSetCapture(HWND hWnd) MsqSetStateWindow(ThreadQueue, MSQ_STATE_MOVESIZE, NULL); } - IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); + co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); IntLockMessageQueue(ThreadQueue); ThreadQueue->CaptureWindow = hWnd; IntUnLockMessageQueue(ThreadQueue); - return hWndPrev; + RETURN( hWndPrev); + +CLEANUP: + DPRINT("Leave NtUserSetCapture, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } -/* - * @implemented - */ -HWND STDCALL -NtUserSetFocus(HWND hWnd) -{ - DPRINT("NtUserSetFocus(%x)\n", hWnd); + +HWND FASTCALL UserSetFocus(HWND hWnd) +{ if (hWnd) { PWINDOW_OBJECT Window; @@ -469,7 +530,7 @@ NtUserSetFocus(HWND hWnd) if (Window == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + return( 0); } ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; @@ -477,31 +538,54 @@ NtUserSetFocus(HWND hWnd) if (Window->Style & (WS_MINIMIZE | WS_DISABLED)) { IntReleaseWindowObject(Window); - return (ThreadQueue ? ThreadQueue->FocusWindow : 0); + return( (ThreadQueue ? ThreadQueue->FocusWindow : 0)); } if (Window->MessageQueue != ThreadQueue) { IntReleaseWindowObject(Window); SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + return( 0); } - hWndTop = NtUserGetAncestor(hWnd, GA_ROOT); - if (hWndTop != NtUserGetActiveWindow()) + hWndTop = UserGetAncestor(hWnd, GA_ROOT); + if (hWndTop != UserGetActiveWindow()) { - NtUserSetActiveWindow(hWndTop); + PWINDOW_OBJECT WndTops = IntGetWindowObject(hWndTop); + co_IntSetActiveWindow(WndTops); + IntReleaseWindowObject(WndTops);//temp hack } - hWndPrev = IntSetFocusWindow(hWnd); + hWndPrev = co_IntSetFocusWindow(hWnd); IntReleaseWindowObject(Window); - return hWndPrev; + return( hWndPrev); } else { - return IntSetFocusWindow(NULL); + return( co_IntSetFocusWindow(NULL)); } + +} + + +/* + * @implemented + */ +HWND STDCALL +NtUserSetFocus(HWND hWnd) +{ + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserSetFocus(%x)\n", hWnd); + UserEnterExclusive(); + + RETURN(UserSetFocus(hWnd)); + +CLEANUP: + DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/guicheck.c b/reactos/subsys/win32k/ntuser/guicheck.c index 2b9fea23173..a071e71c844 100644 --- a/reactos/subsys/win32k/ntuser/guicheck.c +++ b/reactos/subsys/win32k/ntuser/guicheck.c @@ -46,7 +46,7 @@ static FAST_MUTEX GuiSwitchLock; /* FUNCTIONS *****************************************************************/ static BOOL FASTCALL -AddGuiApp(PW32PROCESS W32Data) +co_AddGuiApp(PW32PROCESS W32Data) { W32Data->Flags |= W32PF_CREATEDWINORDC; if (InterlockedIncrement(&NrGuiAppsRunning) == 1) @@ -54,7 +54,7 @@ AddGuiApp(PW32PROCESS W32Data) BOOL Initialized; ExAcquireFastMutex(&GuiSwitchLock); - Initialized = IntInitializeDesktopGraphics(); + Initialized = co_IntInitializeDesktopGraphics(); ExReleaseFastMutex(&GuiSwitchLock); if (!Initialized) @@ -80,7 +80,7 @@ RemoveGuiApp(PW32PROCESS W32Data) } BOOL FASTCALL -IntGraphicsCheck(BOOL Create) +co_IntGraphicsCheck(BOOL Create) { PW32PROCESS W32Data; @@ -89,7 +89,7 @@ IntGraphicsCheck(BOOL Create) { if (! (W32Data->Flags & W32PF_CREATEDWINORDC) && ! (W32Data->Flags & W32PF_MANUALGUICHECK)) { - return AddGuiApp(W32Data); + return co_AddGuiApp(W32Data); } } else @@ -107,6 +107,9 @@ VOID STDCALL NtUserManualGuiCheck(LONG Check) { PW32PROCESS W32Data; + + DPRINT("Enter NtUserManualGuiCheck\n"); + UserEnterExclusive(); W32Data = PsGetWin32Process(); if (0 == Check) @@ -117,7 +120,7 @@ NtUserManualGuiCheck(LONG Check) { if (! (W32Data->Flags & W32PF_CREATEDWINORDC)) { - AddGuiApp(W32Data); + co_AddGuiApp(W32Data); } } else @@ -127,6 +130,10 @@ NtUserManualGuiCheck(LONG Check) RemoveGuiApp(W32Data); } } + + DPRINT("Leave NtUserManualGuiCheck\n"); + UserLeave(); + } NTSTATUS FASTCALL diff --git a/reactos/subsys/win32k/ntuser/hook.c b/reactos/subsys/win32k/ntuser/hook.c index 26a1c0a0715..40e24772458 100644 --- a/reactos/subsys/win32k/ntuser/hook.c +++ b/reactos/subsys/win32k/ntuser/hook.c @@ -265,14 +265,14 @@ IntCallLowLevelHook(INT HookId, INT Code, WPARAM wParam, LPARAM lParam, PHOOK Ho /* FIXME should get timeout from * HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout */ - Status = MsqSendMessage(Hook->Thread->Tcb.Win32Thread->MessageQueue, (HWND) Code, HookId, + Status = co_MsqSendMessage(Hook->Thread->Tcb.Win32Thread->MessageQueue, (HWND) Code, HookId, wParam, lParam, 5000, TRUE, TRUE, &uResult); return NT_SUCCESS(Status) ? uResult : 0; } LRESULT FASTCALL -HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam) +co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam) { PHOOK Hook; PW32THREAD Win32Thread; @@ -326,7 +326,7 @@ HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam) IntUnLockHookTable(GlobalHooks); } - Result = IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc, + Result = co_IntCallHookProc(HookId, Code, wParam, lParam, Hook->Proc, Hook->Ansi, &Hook->ModuleName); Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, @@ -406,6 +406,10 @@ NtUserCallNextHookEx( PHOOK HookObj, NextObj; PWINSTATION_OBJECT WinStaObj; NTSTATUS Status; + DECLARE_RETURN(LRESULT); + + DPRINT("Enter NtUserCallNextHookEx\n"); + UserEnterExclusive(); Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, KernelMode, @@ -415,7 +419,7 @@ NtUserCallNextHookEx( if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook, @@ -425,7 +429,7 @@ NtUserCallNextHookEx( { DPRINT1("Invalid handle passed to NtUserCallNextHookEx\n"); SetLastNtError(Status); - return 0; + RETURN( 0); } ASSERT(Hook == HookObj->Self); @@ -434,7 +438,7 @@ NtUserCallNextHookEx( DPRINT1("Thread mismatch\n"); ObmDereferenceObject(HookObj); SetLastWin32Error(ERROR_INVALID_HANDLE); - return 0; + RETURN( 0); } NextObj = IntGetNextHook(HookObj); @@ -444,10 +448,15 @@ NtUserCallNextHookEx( DPRINT1("Calling next hook not implemented\n"); UNIMPLEMENTED SetLastWin32Error(ERROR_NOT_SUPPORTED); - return 0; + RETURN( 0); } - return 0; + RETURN( 0); + +CLEANUP: + DPRINT("Leave NtUserCallNextHookEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD @@ -479,11 +488,15 @@ NtUserSetWindowsHookEx( UNICODE_STRING ModuleName; NTSTATUS Status; HHOOK Handle; + DECLARE_RETURN(HHOOK); + + DPRINT("Enter NtUserSetWindowsHookEx\n"); + UserEnterExclusive(); if (HookId < WH_MINHOOK || WH_MAXHOOK < HookId || NULL == HookProc) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; + RETURN( NULL); } if (ThreadId) /* thread-local hook */ @@ -496,7 +509,7 @@ NtUserSetWindowsHookEx( { /* these can only be global */ SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; + RETURN( NULL); } Mod = NULL; Global = FALSE; @@ -504,14 +517,14 @@ NtUserSetWindowsHookEx( { DPRINT1("Invalid thread id 0x%x\n", ThreadId); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; + RETURN( NULL); } if (Thread->ThreadsProcess != PsGetCurrentProcess()) { ObDereferenceObject(Thread); DPRINT1("Can't specify thread belonging to another process\n"); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; + RETURN( NULL); } } else /* system-global hook */ @@ -528,13 +541,13 @@ NtUserSetWindowsHookEx( if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return (HANDLE) NULL; + RETURN( (HANDLE) NULL); } } else if (NULL == Mod) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; + RETURN( NULL); } else { @@ -558,7 +571,7 @@ NtUserSetWindowsHookEx( ObDereferenceObject(Thread); } SetLastWin32Error(ERROR_NOT_SUPPORTED); - return NULL; + RETURN( NULL); } Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, @@ -573,7 +586,7 @@ NtUserSetWindowsHookEx( ObDereferenceObject(Thread); } SetLastNtError(Status); - return (HANDLE) NULL; + RETURN( (HANDLE) NULL); } Hook = IntAddHook(Thread, HookId, Global, WinStaObj); @@ -584,7 +597,7 @@ NtUserSetWindowsHookEx( ObDereferenceObject(Thread); } ObDereferenceObject(WinStaObj); - return NULL; + RETURN( NULL); } if (NULL != Thread) @@ -605,7 +618,7 @@ NtUserSetWindowsHookEx( } ObDereferenceObject(WinStaObj); SetLastNtError(Status); - return NULL; + RETURN( NULL); } Hook->ModuleName.Buffer = ExAllocatePoolWithTag(PagedPool, ModuleName.MaximumLength, @@ -620,7 +633,7 @@ NtUserSetWindowsHookEx( } ObDereferenceObject(WinStaObj); SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY); - return NULL; + RETURN( NULL); } Hook->ModuleName.MaximumLength = ModuleName.MaximumLength; Status = MmCopyFromCaller(Hook->ModuleName.Buffer, @@ -636,7 +649,7 @@ NtUserSetWindowsHookEx( } ObDereferenceObject(WinStaObj); SetLastNtError(Status); - return NULL; + RETURN( NULL); } Hook->ModuleName.Length = ModuleName.Length; } @@ -648,7 +661,12 @@ NtUserSetWindowsHookEx( ObmDereferenceObject(Hook); ObDereferenceObject(WinStaObj); - return Handle; + RETURN( Handle); + +CLEANUP: + DPRINT("Leave NtUserSetWindowsHookEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD @@ -676,6 +694,10 @@ NtUserUnhookWindowsHookEx( PWINSTATION_OBJECT WinStaObj; PHOOK HookObj; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserUnhookWindowsHookEx\n"); + UserEnterExclusive(); Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, KernelMode, @@ -685,7 +707,7 @@ NtUserUnhookWindowsHookEx( if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } Status = ObmReferenceObjectByHandle(WinStaObj->HandleTable, Hook, @@ -695,7 +717,7 @@ NtUserUnhookWindowsHookEx( DPRINT1("Invalid handle passed to NtUserUnhookWindowsHookEx\n"); ObDereferenceObject(WinStaObj); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } ASSERT(Hook == HookObj->Self); @@ -704,7 +726,12 @@ NtUserUnhookWindowsHookEx( ObmDereferenceObject(HookObj); ObDereferenceObject(WinStaObj); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserUnhookWindowsHookEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD diff --git a/reactos/subsys/win32k/ntuser/hotkey.c b/reactos/subsys/win32k/ntuser/hotkey.c index 7396c4f28a9..5bffbb04d66 100644 --- a/reactos/subsys/win32k/ntuser/hotkey.c +++ b/reactos/subsys/win32k/ntuser/hotkey.c @@ -209,6 +209,10 @@ NtUserRegisterHotKey(HWND hWnd, PWINDOW_OBJECT Window; PWINSTATION_OBJECT WinStaObject = NULL; PETHREAD HotKeyThread; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserRegisterHotKey\n"); + UserEnterExclusive(); if (hWnd == NULL) { @@ -220,7 +224,7 @@ NtUserRegisterHotKey(HWND hWnd, if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } HotKeyThread = Window->OwnerThread; IntReleaseWindowObject(Window); @@ -232,7 +236,7 @@ NtUserRegisterHotKey(HWND hWnd, if(!WinStaObject) { - return FALSE; + RETURN( FALSE); } IntLockHotKeys(WinStaObject); @@ -241,14 +245,14 @@ NtUserRegisterHotKey(HWND hWnd, if (IsHotKey (WinStaObject, fsModifiers, vk)) { IntUnLockHotKeys(WinStaObject); - return FALSE; + RETURN( FALSE); } HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY); if (HotKeyItem == NULL) { IntUnLockHotKeys(WinStaObject); - return FALSE; + RETURN( FALSE); } HotKeyItem->Thread = HotKeyThread; @@ -262,7 +266,12 @@ NtUserRegisterHotKey(HWND hWnd, IntUnLockHotKeys(WinStaObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserRegisterHotKey, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -274,12 +283,16 @@ NtUserUnregisterHotKey(HWND hWnd, PHOT_KEY_ITEM HotKeyItem; PWINDOW_OBJECT Window; PWINSTATION_OBJECT WinStaObject = NULL; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserUnregisterHotKey\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hWnd); if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if(Window->OwnerThread->ThreadsProcess && Window->OwnerThread->ThreadsProcess->Win32Process) @@ -288,7 +301,7 @@ NtUserUnregisterHotKey(HWND hWnd, if(!WinStaObject) { IntReleaseWindowObject(Window); - return FALSE; + RETURN( FALSE); } IntLockHotKeys(WinStaObject); @@ -307,7 +320,7 @@ NtUserUnregisterHotKey(HWND hWnd, IntUnLockHotKeys(WinStaObject); IntReleaseWindowObject(Window); - return TRUE; + RETURN( TRUE); } Entry = Entry->Flink; @@ -316,7 +329,12 @@ NtUserUnregisterHotKey(HWND hWnd, IntUnLockHotKeys(WinStaObject); IntReleaseWindowObject(Window); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserUnregisterHotKey, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/input.c b/reactos/subsys/win32k/ntuser/input.c index b596176c56a..faee1889d39 100644 --- a/reactos/subsys/win32k/ntuser/input.c +++ b/reactos/subsys/win32k/ntuser/input.c @@ -217,7 +217,11 @@ MouseThreadMain(PVOID StartContext) } DPRINT("MouseEvent\n"); + UserEnterExclusive(); + ProcessMouseInputData(&MouseInput, Iosb.Information / sizeof(MOUSE_INPUT_DATA)); + + UserLeave(); } DPRINT("Mouse Input Thread Stopped...\n"); } @@ -397,9 +401,9 @@ IntKeyboardSendWinKeyMsg() } STATIC VOID STDCALL -IntKeyboardSendAltKeyMsg() +co_IntKeyboardSendAltKeyMsg() { - MsqPostKeyboardMessage(WM_SYSCOMMAND,SC_KEYMENU,0); + co_MsqPostKeyboardMessage(WM_SYSCOMMAND,SC_KEYMENU,0); } STATIC VOID STDCALL @@ -567,7 +571,7 @@ KeyboardThreadMain(PVOID StartContext) if (fsModifiers == MOD_WIN) IntKeyboardSendWinKeyMsg(); else if (fsModifiers == MOD_ALT) - IntKeyboardSendAltKeyMsg(); + co_IntKeyboardSendAltKeyMsg(); continue; } @@ -699,7 +703,7 @@ KeyboardThreadMain(PVOID StartContext) /* * Post a keyboard message. */ - MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam); + co_MsqPostKeyboardMessage(msg.message,msg.wParam,msg.lParam); } } @@ -708,8 +712,9 @@ KeyboardEscape: } } -NTSTATUS STDCALL -NtUserAcquireOrReleaseInputOwnership(BOOLEAN Release) + +NTSTATUS FASTCALL +UserAcquireOrReleaseInputOwnership(BOOLEAN Release) { if (Release && InputThreadsRunning && !pmPrimitiveMessageQueue) { @@ -728,6 +733,24 @@ NtUserAcquireOrReleaseInputOwnership(BOOLEAN Release) return(STATUS_SUCCESS); } + +NTSTATUS STDCALL +NtUserAcquireOrReleaseInputOwnership(BOOLEAN Release) +{ + DECLARE_RETURN(NTSTATUS); + + DPRINT("Enter NtUserAcquireOrReleaseInputOwnership\n"); + UserEnterExclusive(); + + RETURN(UserAcquireOrReleaseInputOwnership(Release)); + +CLEANUP: + DPRINT("Leave NtUserAcquireOrReleaseInputOwnership, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + NTSTATUS FASTCALL InitInputImpl(VOID) { @@ -831,7 +854,17 @@ STDCALL NtUserBlockInput( BOOL BlockIt) { - return IntBlockInput(PsGetWin32Thread(), BlockIt); + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserBlockInput\n"); + UserEnterExclusive(); + + RETURN( IntBlockInput(PsGetWin32Thread(), BlockIt)); + +CLEANUP: + DPRINT("Leave NtUserBlockInput, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL FASTCALL @@ -1099,19 +1132,23 @@ NtUserSendInput( { PW32THREAD W32Thread; UINT cnt; + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserSendInput\n"); + UserEnterExclusive(); W32Thread = PsGetWin32Thread(); ASSERT(W32Thread); if(!W32Thread->Desktop) { - return 0; + RETURN( 0); } if(!nInputs || !pInput || (cbSize != sizeof(INPUT))) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + RETURN( 0); } /* @@ -1122,7 +1159,7 @@ NtUserSendInput( !IntIsActiveDesktop(W32Thread->Desktop)) { SetLastWin32Error(ERROR_ACCESS_DENIED); - return 0; + RETURN( 0); } cnt = 0; @@ -1135,7 +1172,7 @@ NtUserSendInput( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return cnt; + RETURN( cnt); } switch(SafeInput.type) @@ -1162,7 +1199,12 @@ NtUserSendInput( } } - return cnt; + RETURN( cnt); + +CLEANUP: + DPRINT("Leave NtUserSendInput, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/keyboard.c b/reactos/subsys/win32k/ntuser/keyboard.c index 71c565c69fd..0c7bd22be74 100644 --- a/reactos/subsys/win32k/ntuser/keyboard.c +++ b/reactos/subsys/win32k/ntuser/keyboard.c @@ -315,10 +315,8 @@ ToUnicodeInner(UINT wVirtKey, return 0; } -DWORD -STDCALL -NtUserGetKeyState( - DWORD key) + +DWORD FASTCALL UserGetKeyState(DWORD key) { DWORD ret = 0; @@ -331,10 +329,28 @@ NtUserGetKeyState( return ret; } + DWORD STDCALL -NtUserGetAsyncKeyState( +NtUserGetKeyState( DWORD key) +{ + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetKeyState\n"); + UserEnterExclusive(); + + RETURN(UserGetKeyState(key)); + +CLEANUP: + DPRINT("Leave NtUserGetKeyState, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + +DWORD FASTCALL UserGetAsyncKeyState(DWORD key) { DWORD ret = 0; @@ -349,6 +365,26 @@ NtUserGetAsyncKeyState( +DWORD +STDCALL +NtUserGetAsyncKeyState( + DWORD key) +{ + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetAsyncKeyState\n"); + UserEnterExclusive(); + + RETURN(UserGetAsyncKeyState(key)); + +CLEANUP: + DPRINT("Leave NtUserGetAsyncKeyState, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + int STDCALL ToUnicodeEx( UINT wVirtKey, UINT wScanCode, PBYTE lpKeyState, @@ -1107,9 +1143,10 @@ NtUserGetKeyboardLayoutName( return 0; } -HKL -STDCALL -NtUserGetKeyboardLayout( + + +HKL FASTCALL +UserGetKeyboardLayout( DWORD dwThreadId) { NTSTATUS Status; @@ -1121,7 +1158,7 @@ NtUserGetKeyboardLayout( W32Thread = PsGetWin32Thread(); else { - Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread); + Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);//fixme: deref thread if(!NT_SUCCESS(Status)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); @@ -1133,11 +1170,29 @@ NtUserGetKeyboardLayout( if(!layout) return 0; return (HKL)layout; } + + +HKL +STDCALL +NtUserGetKeyboardLayout( + DWORD dwThreadId) +{ + DECLARE_RETURN(HKL); + + UserEnterShared(); + DPRINT("Enter NtUserGetKeyboardLayout\n"); + + RETURN( UserGetKeyboardLayout(dwThreadId)); + +CLEANUP: + DPRINT("Leave NtUserGetKeyboardLayout, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} -DWORD -STDCALL -NtUserGetKeyboardType( +DWORD FASTCALL +UserGetKeyboardType( DWORD TypeFlag) { switch(TypeFlag) @@ -1152,6 +1207,14 @@ NtUserGetKeyboardType( DPRINT1("Unknown type!\n"); return 0; /* The book says 0 here, so 0 */ } +} + +DWORD +STDCALL +NtUserGetKeyboardType( + DWORD TypeFlag) +{ + return UserGetKeyboardType(TypeFlag); } diff --git a/reactos/subsys/win32k/ntuser/menu.c b/reactos/subsys/win32k/ntuser/menu.c index f17021b7899..25c7854a85b 100644 --- a/reactos/subsys/win32k/ntuser/menu.c +++ b/reactos/subsys/win32k/ntuser/menu.c @@ -1182,26 +1182,26 @@ IntGetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT fByPos, UINT gmdiFlags, } VOID FASTCALL -IntInitTracking(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject, BOOL Popup, +co_IntInitTracking(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject, BOOL Popup, UINT Flags) { /* FIXME - hide caret */ if(!(Flags & TPM_NONOTIFY)) - IntSendMessage(WindowObject->Self, WM_SETCURSOR, (WPARAM)WindowObject->Self, HTCAPTION); + co_IntSendMessage(WindowObject->Self, WM_SETCURSOR, (WPARAM)WindowObject->Self, HTCAPTION); /* FIXME - send WM_SETCURSOR message */ if(!(Flags & TPM_NONOTIFY)) - IntSendMessage(WindowObject->Self, WM_INITMENU, (WPARAM)MenuObject->MenuInfo.Self, 0); + co_IntSendMessage(WindowObject->Self, WM_INITMENU, (WPARAM)MenuObject->MenuInfo.Self, 0); } VOID FASTCALL -IntExitTracking(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject, BOOL Popup, +co_IntExitTracking(PWINDOW_OBJECT WindowObject, PMENU_OBJECT MenuObject, BOOL Popup, UINT Flags) { if(!(Flags & TPM_NONOTIFY)) - IntSendMessage(WindowObject->Self, WM_EXITMENULOOP, 0 /* FIXME */, 0); + co_IntSendMessage(WindowObject->Self, WM_EXITMENULOOP, 0 /* FIXME */, 0); /* FIXME - Show caret again */ } @@ -1214,12 +1214,12 @@ IntTrackMenu(PMENU_OBJECT MenuObject, PWINDOW_OBJECT WindowObject, INT x, INT y, } BOOL FASTCALL -IntTrackPopupMenu(PMENU_OBJECT MenuObject, PWINDOW_OBJECT WindowObject, +co_IntTrackPopupMenu(PMENU_OBJECT MenuObject, PWINDOW_OBJECT WindowObject, UINT Flags, POINT *Pos, UINT MenuPos, RECT *ExcludeRect) { - IntInitTracking(WindowObject, MenuObject, TRUE, Flags); + co_IntInitTracking(WindowObject, MenuObject, TRUE, Flags); - IntExitTracking(WindowObject, MenuObject, TRUE, Flags); + co_IntExitTracking(WindowObject, MenuObject, TRUE, Flags); return FALSE; } @@ -1288,11 +1288,17 @@ NtUserBuildMenuItemList( DWORD Reserved) { DWORD res = -1; - PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); + PMENU_OBJECT MenuObject; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserBuildMenuItemList\n"); + UserEnterExclusive(); + + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return (DWORD)-1; + RETURN( (DWORD)-1); } if(Buffer) @@ -1308,7 +1314,12 @@ NtUserBuildMenuItemList( IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserBuildMenuItemList, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1322,25 +1333,32 @@ NtUserCheckMenuItem( UINT uCheck) { DWORD res = 0; - PMENU_OBJECT MenuObject = IntGetMenuObject(hmenu); + PMENU_OBJECT MenuObject; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserCheckMenuItem\n"); + UserEnterExclusive(); + + MenuObject = IntGetMenuObject(hmenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return (DWORD)-1; + RETURN( (DWORD)-1); } IntLockMenuItems(MenuObject); res = IntCheckMenuItem(MenuObject, uIDCheckItem, uCheck); IntUnLockMenuItems(MenuObject); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserCheckMenuItem, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } -/* - * @unimplemented - */ -HMENU STDCALL -NtUserCreateMenu(BOOL PopupMenu) +HMENU FASTCALL UserCreateMenu(BOOL PopupMenu) { PWINSTATION_OBJECT WinStaObject; HANDLE Handle; @@ -1365,6 +1383,25 @@ NtUserCreateMenu(BOOL PopupMenu) } + +HMENU STDCALL +NtUserCreateMenu(BOOL PopupMenu) +{ + DECLARE_RETURN(HMENU); + + DPRINT("Enter NtUserCreateMenu\n"); + UserEnterExclusive(); + + RETURN(UserCreateMenu(PopupMenu)); + +CLEANUP: + DPRINT("Leave NtUserCreateMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + /* * @implemented */ @@ -1375,26 +1412,36 @@ NtUserDeleteMenu( UINT uFlags) { BOOL res; - PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); + PMENU_OBJECT MenuObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserDeleteMenu\n"); + UserEnterExclusive(); + + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + RETURN( FALSE); } res = IntRemoveMenuItem(MenuObject, uPosition, uFlags, TRUE); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserDeleteMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } + /* * @implemented */ -BOOL STDCALL -NtUserDestroyMenu( - HMENU hMenu) +BOOL FASTCALL UserDestroyMenu(HMENU hMenu) { BOOL Ret; @@ -1417,6 +1464,43 @@ NtUserDestroyMenu( return Ret; } +/* + * @implemented + */ +BOOL STDCALL +NtUserDestroyMenu( + HMENU hMenu) +{ + BOOL Ret; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserDestroyMenu\n"); + UserEnterExclusive(); + + PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); + if(!MenuObject) + { + SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + RETURN( FALSE); + } + if(MenuObject->Process != PsGetCurrentProcess()) + { + IntReleaseMenuObject(MenuObject); + SetLastWin32Error(ERROR_ACCESS_DENIED); + RETURN( FALSE); + } + + Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE); + + IntReleaseMenuObject(MenuObject); + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserDestroyMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + /* * @implemented @@ -1429,18 +1513,28 @@ NtUserEnableMenuItem( { UINT res = (UINT)-1; PMENU_OBJECT MenuObject; + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserEnableMenuItem\n"); + UserEnterExclusive(); + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return res; + RETURN( res); } IntLockMenuItems(MenuObject); res = IntEnableMenuItem(MenuObject, uIDEnableItem, uEnable); IntUnLockMenuItems(MenuObject); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserEnableMenuItem, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1458,12 +1552,16 @@ NtUserInsertMenuItem( PMENU_OBJECT MenuObject; NTSTATUS Status; ROSMENUITEMINFO ItemInfo; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserInsertMenuItem\n"); + UserEnterExclusive(); MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return 0; + RETURN( 0); } Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW)); @@ -1471,13 +1569,13 @@ NtUserInsertMenuItem( { IntReleaseMenuObject(MenuObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } if (ItemInfo.cbSize != sizeof(MENUITEMINFOW)) { IntReleaseMenuObject(MenuObject); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } IntLockMenuItems(MenuObject); @@ -1485,7 +1583,12 @@ NtUserInsertMenuItem( IntUnLockMenuItems(MenuObject); IntReleaseMenuObject(MenuObject); - return Res; + RETURN( Res); + +CLEANUP: + DPRINT("Leave NtUserInsertMenuItem, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1513,17 +1616,27 @@ NtUserGetMenuDefaultItem( PMENU_OBJECT MenuObject; UINT res = -1; DWORD gismc = 0; + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserGetMenuDefaultItem\n"); + UserEnterExclusive(); + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return res; + RETURN( res); } IntLockMenuItems(MenuObject); res = IntGetMenuDefaultItem(MenuObject, fByPos, gmdiFlags, &gismc); IntUnLockMenuItems(MenuObject); IntReleaseMenuObject(MenuObject); - return res; + RETURN(res); + +CLEANUP: + DPRINT("Leave NtUserGetMenuDefaultItem, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1576,24 +1689,28 @@ NtUserGetMenuItemRect( LONG XMove, YMove; ULONG i; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetMenuItemRect\n"); + UserEnterShared(); - if(!NtUserMenuItemInfo(hMenu, uItem, MF_BYPOSITION, &mii, FALSE)) - return FALSE; + if(!UserMenuItemInfo(hMenu, uItem, MF_BYPOSITION, &mii, FALSE)) + RETURN( FALSE); referenceHwnd = hWnd; if(!hWnd) { - if(!NtUserMenuInfo(hMenu, &mi, FALSE)) return FALSE; - if(mi.Wnd == 0) return FALSE; + if(!UserMenuInfo(hMenu, &mi, FALSE)) RETURN( FALSE); + if(mi.Wnd == 0) RETURN( FALSE); referenceHwnd = mi.Wnd; } - if (lprcItem == NULL) return FALSE; + if (lprcItem == NULL) RETURN( FALSE); *lpRect = mii.Rect; lpPoints = (LPPOINT)lpRect; - if(!NtUserGetClientOrigin(referenceHwnd, &FromOffset)) return FALSE; + if(!UserGetClientOrigin(referenceHwnd, &FromOffset)) RETURN( FALSE); XMove = FromOffset.x; YMove = FromOffset.y; @@ -1608,9 +1725,14 @@ NtUserGetMenuItemRect( if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetMenuItemRect, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1626,18 +1748,24 @@ NtUserHiliteMenuItem( { BOOL res = FALSE; PMENU_OBJECT MenuObject; - PWINDOW_OBJECT WindowObject = IntGetWindowObject(hwnd); + PWINDOW_OBJECT WindowObject; + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserHiliteMenuItem\n"); + UserEnterExclusive(); + + WindowObject = IntGetWindowObject(hwnd); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_HANDLE); - return res; + RETURN( res); } MenuObject = IntGetMenuObject(hmenu); if(!MenuObject) { IntReleaseWindowObject(WindowObject); SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return res; + RETURN( res); } if(WindowObject->IDMenu == (UINT)hmenu) { @@ -1647,16 +1775,20 @@ NtUserHiliteMenuItem( } IntReleaseMenuObject(MenuObject); IntReleaseWindowObject(WindowObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserHiliteMenuItem, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* * @implemented */ -BOOL -STDCALL -NtUserMenuInfo( +BOOL FASTCALL +UserMenuInfo( HMENU Menu, PROSMENUINFO UnsafeMenuInfo, BOOL SetOrGet) @@ -1671,25 +1803,25 @@ NtUserMenuInfo( if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } if(Size < sizeof(MENUINFO) || sizeof(ROSMENUINFO) < Size) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + return( FALSE); } Status = MmCopyFromCaller(&MenuInfo, UnsafeMenuInfo, Size); if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } MenuObject = IntGetMenuObject(Menu); if (NULL == MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + return( FALSE); } if(SetOrGet) @@ -1707,17 +1839,45 @@ NtUserMenuInfo( if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } } } IntReleaseMenuObject(MenuObject); - return Res; + return( Res); } + + + +/* + * @implemented + */ +BOOL +STDCALL +NtUserMenuInfo( + HMENU Menu, + PROSMENUINFO UnsafeMenuInfo, + BOOL SetOrGet) +{ + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserMenuInfo\n"); + UserEnterShared(); + + RETURN(UserMenuInfo(Menu, UnsafeMenuInfo, SetOrGet)); + +CLEANUP: + DPRINT("Leave NtUserMenuInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + /* * @implemented */ @@ -1732,19 +1892,23 @@ NtUserMenuItemFromPoint( PWINDOW_OBJECT WindowObject = NULL; PMENU_ITEM mi; int i; + DECLARE_RETURN(int); + + DPRINT("Enter NtUserMenuItemFromPoint\n"); + UserEnterExclusive(); MenuObject = IntGetMenuObject(Menu); if (NULL == MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return -1; + RETURN( -1); } WindowObject = IntGetWindowObject(MenuObject->MenuInfo.Wnd); if (NULL == WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return -1; + RETURN( -1); } X -= WindowObject->WindowRect.left; Y -= WindowObject->WindowRect.top; @@ -1764,16 +1928,20 @@ NtUserMenuItemFromPoint( IntReleaseMenuObject(MenuObject); - return (mi ? i : NO_SELECTED_ITEM); + RETURN( (mi ? i : NO_SELECTED_ITEM)); + +CLEANUP: + DPRINT("Leave NtUserMenuItemFromPoint, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } -/* - * @implemented - */ -BOOL -STDCALL -NtUserMenuItemInfo( + + + +BOOL FASTCALL +UserMenuItemInfo( HMENU Menu, UINT Item, BOOL ByPosition, @@ -1791,14 +1959,14 @@ NtUserMenuItemInfo( if (NULL == MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + return( FALSE); } Status = MmCopyFromCaller(&Size, &UnsafeItemInfo->cbSize, sizeof(UINT)); if (! NT_SUCCESS(Status)) { IntReleaseMenuObject(MenuObject); SetLastNtError(Status); - return FALSE; + return( FALSE); } if (sizeof(MENUITEMINFOW) != Size && sizeof(MENUITEMINFOW) - sizeof(HBITMAP) != Size @@ -1806,14 +1974,14 @@ NtUserMenuItemInfo( { IntReleaseMenuObject(MenuObject); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + return( FALSE); } Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, Size); if (! NT_SUCCESS(Status)) { IntReleaseMenuObject(MenuObject); SetLastNtError(Status); - return FALSE; + return( FALSE); } /* If this is a pre-0x0500 _WIN32_WINNT MENUITEMINFOW, you can't set/get hbmpItem */ @@ -1822,7 +1990,7 @@ NtUserMenuItemInfo( { IntReleaseMenuObject(MenuObject); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + return( FALSE); } if (IntGetMenuItemByFlag(MenuObject, Item, @@ -1831,7 +1999,7 @@ NtUserMenuItemInfo( { IntReleaseMenuObject(MenuObject); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + return( FALSE); } if (SetOrGet) @@ -1848,14 +2016,43 @@ NtUserMenuItemInfo( { IntReleaseMenuObject(MenuObject); SetLastNtError(Status); - return FALSE; + return( FALSE); } } } IntReleaseMenuObject(MenuObject); - return Ret; + return( Ret); + +} + + + +/* + * @implemented + */ +BOOL +STDCALL +NtUserMenuItemInfo( + HMENU Menu, + UINT Item, + BOOL ByPosition, + PROSMENUITEMINFO UnsafeItemInfo, + BOOL SetOrGet) +{ + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserMenuItemInfo\n"); + UserEnterExclusive(); + + RETURN( UserMenuItemInfo(Menu, Item, ByPosition, UnsafeItemInfo, SetOrGet)); + +CLEANUP: + DPRINT("Leave NtUserMenuItemInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + } @@ -1869,17 +2066,29 @@ NtUserRemoveMenu( UINT uFlags) { BOOL res; - PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); + PMENU_OBJECT MenuObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserRemoveMenu\n"); + UserEnterExclusive(); + + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + RETURN( FALSE); } res = IntRemoveMenuItem(MenuObject, uPosition, uFlags, FALSE); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserRemoveMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + } @@ -1892,16 +2101,56 @@ NtUserSetMenuContextHelpId( DWORD dwContextHelpId) { BOOL res; - PMENU_OBJECT MenuObject = IntGetMenuObject(hmenu); + PMENU_OBJECT MenuObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetMenuContextHelpId\n"); + UserEnterExclusive(); + + MenuObject = IntGetMenuObject(hmenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + RETURN( FALSE); } res = IntSetMenuContextHelpId(MenuObject, dwContextHelpId); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserSetMenuContextHelpId, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + + +/* + * @implemented + */ +BOOL FASTCALL +UserSetMenuDefaultItem( + HMENU hMenu, + UINT uItem, + UINT fByPos) +{ + BOOL res = FALSE; + PMENU_OBJECT MenuObject; + + MenuObject = IntGetMenuObject(hMenu); + if(!MenuObject) + { + SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); + return( FALSE); + } + IntLockMenuItems(MenuObject); + res = IntSetMenuDefaultItem(MenuObject, uItem, fByPos); + IntUnLockMenuItems(MenuObject); + IntReleaseMenuObject(MenuObject); + + return( res); } @@ -1916,18 +2165,28 @@ NtUserSetMenuDefaultItem( { BOOL res = FALSE; PMENU_OBJECT MenuObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetMenuDefaultItem\n"); + UserEnterExclusive(); + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + RETURN( FALSE); } IntLockMenuItems(MenuObject); res = IntSetMenuDefaultItem(MenuObject, uItem, fByPos); IntUnLockMenuItems(MenuObject); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserSetMenuDefaultItem, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1939,16 +2198,27 @@ NtUserSetMenuFlagRtoL( HMENU hMenu) { BOOL res; - PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); + PMENU_OBJECT MenuObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetMenuFlagRtoL\n"); + UserEnterExclusive(); + + MenuObject = IntGetMenuObject(hMenu); if(!MenuObject) { SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + RETURN( FALSE); } res = IntSetMenuFlagRtoL(MenuObject); IntReleaseMenuObject(MenuObject); - return res; + RETURN( res); + +CLEANUP: + DPRINT("Leave NtUserSetMenuFlagRtoL, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1989,6 +2259,7 @@ NtUserThunkedMenuItemInfo( /* * @implemented */ + /* NOTE: unused function */ BOOL STDCALL NtUserTrackPopupMenuEx( HMENU hmenu, @@ -2042,7 +2313,7 @@ NtUserTrackPopupMenuEx( Pos.x = x; Pos.y = y; - Ret = IntTrackPopupMenu(MenuObject, WindowObject, fuFlags, &Pos, 0, + Ret = co_IntTrackPopupMenu(MenuObject, WindowObject, fuFlags, &Pos, 0, (lptpm ? &Safetpm.rcExclude : NULL)); IntReleaseWindowObject(WindowObject); diff --git a/reactos/subsys/win32k/ntuser/message.c b/reactos/subsys/win32k/ntuser/message.c index 7afc347bb20..9c9c4ed5348 100644 --- a/reactos/subsys/win32k/ntuser/message.c +++ b/reactos/subsys/win32k/ntuser/message.c @@ -296,9 +296,18 @@ NtUserCallMsgFilter( LPMSG msg, INT code) { + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserCallMsgFilter\n"); + UserEnterExclusive(); - if (HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg)) return TRUE; - return HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)msg); + if (co_HOOK_CallHooks( WH_SYSMSGFILTER, code, 0, (LPARAM)msg)) RETURN( TRUE); + RETURN( co_HOOK_CallHooks( WH_MSGFILTER, code, 0, (LPARAM)msg)); + +CLEANUP: + DPRINT("Leave NtUserCallMsgFilter. ret=%i\n", _ret_); + UserLeave(); + END_CLEANUP; } LRESULT STDCALL @@ -308,12 +317,16 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo) NTUSERDISPATCHMESSAGEINFO MsgInfo; PWINDOW_OBJECT WindowObject; LRESULT Result = TRUE; + DECLARE_RETURN(LRESULT); + + DPRINT("Enter NtUserDispatchMessage\n"); + UserEnterExclusive(); Status = MmCopyFromCaller(&MsgInfo, UnsafeMsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO)); if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return 0; + RETURN( 0); } /* Process timer messages. */ @@ -389,10 +402,15 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo) if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return 0; + RETURN( 0); } - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserDispatchMessage. ret=%i\n", _ret_); + UserLeave(); + END_CLEANUP; } @@ -402,20 +420,29 @@ NtUserTranslateMessage(LPMSG lpMsg, { NTSTATUS Status; MSG SafeMsg; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserTranslateMessage\n"); + UserEnterExclusive(); Status = MmCopyFromCaller(&SafeMsg, lpMsg, sizeof(MSG)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } - return IntTranslateKbdMessage(&SafeMsg, dwhkl); + RETURN( IntTranslateKbdMessage(&SafeMsg, dwhkl)); + +CLEANUP: + DPRINT("Leave NtUserTranslateMessage: ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } VOID FASTCALL -IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) +co_IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) { if(!Msg->hwnd || ThreadQueue->CaptureWindow) { @@ -426,12 +453,12 @@ IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) { case WM_MOUSEMOVE: { - IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message)); + co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message)); break; } case WM_NCMOUSEMOVE: { - IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message)); + co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message)); break; } case WM_LBUTTONDOWN: @@ -454,8 +481,8 @@ IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) wParam = (WPARAM)(CurInfo->ButtonsDown); ObDereferenceObject(InputWindowStation); - IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam); - IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message)); + co_IntSendMessage(Msg->hwnd, WM_MOUSEMOVE, wParam, Msg->lParam); + co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(HTCLIENT, Msg->message)); break; } case WM_NCLBUTTONDOWN: @@ -467,15 +494,15 @@ IntSendHitTestMessages(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg) case WM_NCRBUTTONDBLCLK: case WM_NCXBUTTONDBLCLK: { - IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam); - IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message)); + co_IntSendMessage(Msg->hwnd, WM_NCMOUSEMOVE, (WPARAM)Msg->wParam, Msg->lParam); + co_IntSendMessage(Msg->hwnd, WM_SETCURSOR, (WPARAM)Msg->hwnd, MAKELPARAM(Msg->wParam, Msg->message)); break; } } } BOOL FASTCALL -IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJECT MsgWindow, +co_IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJECT MsgWindow, USHORT *HitTest) { ULONG Result; @@ -486,7 +513,7 @@ IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJEC return TRUE; } - Result = IntSendMessage(MsgWindow->Self, WM_MOUSEACTIVATE, (WPARAM)NtUserGetParent(MsgWindow->Self), (LPARAM)MAKELONG(*HitTest, Msg->message)); + Result = co_IntSendMessage(MsgWindow->Self, WM_MOUSEACTIVATE, (WPARAM)IntGetParent(MsgWindow), (LPARAM)MAKELONG(*HitTest, Msg->message)); switch (Result) { case MA_NOACTIVATEANDEAT: @@ -494,11 +521,11 @@ IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJEC case MA_NOACTIVATE: break; case MA_ACTIVATEANDEAT: - IntMouseActivateWindow(MsgWindow); + co_IntMouseActivateWindow(MsgWindow); return TRUE; default: /* MA_ACTIVATE */ - IntMouseActivateWindow(MsgWindow); + co_IntMouseActivateWindow(MsgWindow); break; } @@ -506,7 +533,7 @@ IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OBJEC } BOOL FASTCALL -IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *HitTest, BOOL Remove) +co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *HitTest, BOOL Remove) { PWINDOW_OBJECT Window; @@ -520,7 +547,7 @@ IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *Hit ThreadQueue->CaptureWindow != Window->Self) { /* only send WM_NCHITTEST messages if we're not capturing the window! */ - *HitTest = IntSendMessage(Window->Self, WM_NCHITTEST, 0, + *HitTest = co_IntSendMessage(Window->Self, WM_NCHITTEST, 0, MAKELONG(Msg->pt.x, Msg->pt.y)); if(*HitTest == (USHORT)HTTRANSPARENT) @@ -532,7 +559,7 @@ IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *Hit { PWINDOW_OBJECT Wnd; - WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd); + co_WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd); if(Wnd) { if(Wnd != Window) @@ -612,7 +639,7 @@ IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *Hit * Internal version of PeekMessage() doing all the work */ BOOL FASTCALL -IntPeekMessage(PUSER_MESSAGE Msg, +co_IntPeekMessage(PUSER_MESSAGE Msg, HWND Wnd, UINT MsgFilterMin, UINT MsgFilterMax, @@ -640,7 +667,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, ThreadQueue->LastMsgRead = LargeTickCount.u.LowPart; /* Dispatch sent messages here. */ - while (MsqDispatchOneSentMessage(ThreadQueue)); + while (co_MsqDispatchOneSentMessage(ThreadQueue)); /* Now look for a quit message. */ @@ -661,7 +688,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, } /* Now check for normal messages. */ - Present = MsqFindMessage(ThreadQueue, + Present = co_MsqFindMessage(ThreadQueue, FALSE, RemoveMessages, Wnd, @@ -679,7 +706,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, } /* Check for hardware events. */ - Present = MsqFindMessage(ThreadQueue, + Present = co_MsqFindMessage(ThreadQueue, TRUE, RemoveMessages, Wnd, @@ -697,7 +724,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, } /* Check for sent messages again. */ - while (MsqDispatchOneSentMessage(ThreadQueue)); + while (co_MsqDispatchOneSentMessage(ThreadQueue)); /* Check for paint messages. */ if (IntGetPaintMessage(Wnd, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages)) @@ -728,7 +755,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, { USHORT HitTest; - if(IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE)) + if(co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE)) /* FIXME - check message filter again, if the message doesn't match anymore, search again */ { @@ -738,10 +765,10 @@ IntPeekMessage(PUSER_MESSAGE Msg, } if(ThreadQueue->CaptureWindow == NULL) { - IntSendHitTestMessages(ThreadQueue, &Msg->Msg); + co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg); if((Msg->Msg.message != WM_MOUSEMOVE && Msg->Msg.message != WM_NCMOUSEMOVE) && IS_BTN_MESSAGE(Msg->Msg.message, DOWN) && - IntActivateWindowMouse(ThreadQueue, &Msg->Msg, MsgWindow, &HitTest)) + co_IntActivateWindowMouse(ThreadQueue, &Msg->Msg, MsgWindow, &HitTest)) { IntReleaseWindowObject(MsgWindow); /* eat the message, search again */ @@ -751,7 +778,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, } else { - IntSendHitTestMessages(ThreadQueue, &Msg->Msg); + co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg); } if(MsgWindow) @@ -764,7 +791,7 @@ IntPeekMessage(PUSER_MESSAGE Msg, USHORT HitTest; if((Msg->Msg.hwnd && Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST) && - IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, FALSE)) + co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, FALSE)) /* FIXME - check message filter again, if the message doesn't match anymore, search again */ { @@ -793,6 +820,10 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, PVOID UserMem; UINT Size; USER_MESSAGE Msg; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserPeekMessage\n"); + UserEnterExclusive(); /* Validate input */ if (NULL != Wnd) @@ -814,7 +845,7 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, MsgFilterMax = 0; } - Present = IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, RemoveMsg); + Present = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, RemoveMsg); if (Present) { Info.Msg = Msg.Msg; @@ -838,7 +869,7 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return (BOOL) -1; + RETURN( (BOOL) -1); } /* Transfer lParam data to user-mode mem */ Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size); @@ -847,7 +878,7 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem, &Info.LParamSize, MEM_DECOMMIT); SetLastNtError(Status); - return (BOOL) -1; + RETURN( (BOOL) -1); } Info.Msg.lParam = (LPARAM) UserMem; } @@ -859,15 +890,20 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return (BOOL) -1; + RETURN( (BOOL) -1); } } - return Present; + RETURN( Present); + +CLEANUP: + DPRINT("Leave NtUserPeekMessage, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } static BOOL FASTCALL -IntWaitMessage(HWND Wnd, +co_IntWaitMessage(HWND Wnd, UINT MsgFilterMin, UINT MsgFilterMax) { @@ -879,13 +915,13 @@ IntWaitMessage(HWND Wnd, do { - if (IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_NOREMOVE)) + if (co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_NOREMOVE)) { return TRUE; } /* Nothing found. Wait for new messages. */ - Status = MsqWaitForNewMessages(ThreadQueue, Wnd, MsgFilterMin, MsgFilterMax); + Status = co_MsqWaitForNewMessages(ThreadQueue, Wnd, MsgFilterMin, MsgFilterMax); } while ((STATUS_WAIT_0 <= Status && Status <= STATUS_WAIT_63) || STATUS_TIMEOUT == Status); @@ -918,6 +954,10 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, PVOID UserMem; UINT Size; USER_MESSAGE Msg; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetMessage\n"); + UserEnterExclusive(); /* Validate input */ if (NULL != Wnd) @@ -936,7 +976,7 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, do { - GotMessage = IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_REMOVE); + GotMessage = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_REMOVE); if (GotMessage) { Info.Msg = Msg.Msg; @@ -961,7 +1001,7 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return (BOOL) -1; + RETURN( (BOOL) -1); } /* Transfer lParam data to user-mode mem */ Status = MmCopyToCaller(UserMem, (PVOID) Info.Msg.lParam, Size); @@ -970,7 +1010,7 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, ZwFreeVirtualMemory(NtCurrentProcess(), (PVOID *) &UserMem, &Info.LParamSize, MEM_DECOMMIT); SetLastNtError(Status); - return (BOOL) -1; + RETURN( (BOOL) -1); } Info.Msg.lParam = (LPARAM) UserMem; } @@ -982,17 +1022,22 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return (BOOL) -1; + RETURN( (BOOL) -1); } } - else if (! IntWaitMessage(Wnd, MsgFilterMin, MsgFilterMax)) + else if (! co_IntWaitMessage(Wnd, MsgFilterMin, MsgFilterMax)) { - return (BOOL) -1; + RETURN( (BOOL) -1); } } while (! GotMessage); - return WM_QUIT != Info.Msg.message; + RETURN( WM_QUIT != Info.Msg.message); + +CLEANUP: + DPRINT("Leave NtUserGetMessage\n"); + UserLeave(); + END_CLEANUP; } DWORD @@ -1105,8 +1150,8 @@ CopyMsgToUserMem(MSG *UserModeMsg, MSG *KernelModeMsg) return STATUS_SUCCESS; } -BOOL STDCALL -NtUserPostMessage(HWND Wnd, +BOOL FASTCALL +UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) @@ -1133,7 +1178,7 @@ NtUserPostMessage(HWND Wnd, if (List != NULL) { for (i = 0; List[i]; i++) - NtUserPostMessage(List[i], Msg, wParam, lParam); + UserPostMessage(List[i], Msg, wParam, lParam); ExFreePool(List); } } @@ -1177,6 +1222,28 @@ NtUserPostMessage(HWND Wnd, return TRUE; } + +BOOL STDCALL +NtUserPostMessage(HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam) +{ + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserPostMessage\n"); + UserEnterExclusive(); + + RETURN(UserPostMessage(hWnd, Msg, wParam, lParam)); + +CLEANUP: + DPRINT("Leave NtUserPostMessage, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + BOOL STDCALL NtUserPostThreadMessage(DWORD idThread, UINT Msg, @@ -1188,6 +1255,10 @@ NtUserPostThreadMessage(DWORD idThread, PW32THREAD pThread; NTSTATUS Status; PMSGMEMORY MsgMemoryEntry; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserPostThreadMessage\n"); + UserEnterExclusive(); Status = PsLookupThreadByThreadId((HANDLE)idThread,&peThread); @@ -1196,7 +1267,7 @@ NtUserPostThreadMessage(DWORD idThread, if( !pThread || !pThread->MessageQueue ) { ObDereferenceObject( peThread ); - return FALSE; + RETURN( FALSE); } UserModeMsg.hwnd = NULL; @@ -1209,17 +1280,22 @@ NtUserPostThreadMessage(DWORD idThread, { ObDereferenceObject( peThread ); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } MsqPostMessage(pThread->MessageQueue, &KernelModeMsg, NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam, QS_POSTMESSAGE); ObDereferenceObject( peThread ); - return TRUE; + RETURN( TRUE); } else { SetLastNtError( Status ); - return FALSE; + RETURN( FALSE); } + +CLEANUP: + DPRINT("Leave NtUserPostThreadMessage, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD STDCALL @@ -1231,13 +1307,13 @@ NtUserQuerySendMessage(DWORD Unknown0) } LRESULT FASTCALL -IntSendMessage(HWND hWnd, +co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { ULONG_PTR Result = 0; - if(IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) + if(co_IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) { return (LRESULT)Result; } @@ -1245,7 +1321,7 @@ IntSendMessage(HWND hWnd, } static LRESULT FASTCALL -IntSendMessageTimeoutSingle(HWND hWnd, +co_IntSendMessageTimeoutSingle(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, @@ -1300,12 +1376,12 @@ IntSendMessageTimeoutSingle(HWND hWnd, } if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000)) { - Result = (ULONG_PTR)IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam, + Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam, lParamPacked,lParamBufferSize); } else { - Result = (ULONG_PTR)IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam, + Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam, lParamPacked,lParamBufferSize); } @@ -1340,7 +1416,7 @@ IntSendMessageTimeoutSingle(HWND hWnd, return FALSE; } - Status = MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam, + Status = co_MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam, uTimeout, (uFlags & SMTO_BLOCK), FALSE, uResult); IntReleaseWindowObject(Window); if (STATUS_TIMEOUT == Status) @@ -1359,7 +1435,7 @@ IntSendMessageTimeoutSingle(HWND hWnd, } LRESULT FASTCALL -IntSendMessageTimeout(HWND hWnd, +co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, @@ -1373,7 +1449,7 @@ IntSendMessageTimeout(HWND hWnd, if (HWND_BROADCAST != hWnd) { - return IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult); + return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult); } DesktopWindow = IntGetWindowObject(IntGetDesktopWindow()); @@ -1391,7 +1467,7 @@ IntSendMessageTimeout(HWND hWnd, for (Child = Children; NULL != *Child; Child++) { - IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult); + co_IntSendMessageTimeoutSingle(*Child, Msg, wParam, lParam, uFlags, uTimeout, uResult); } ExFreePool(Children); @@ -1404,7 +1480,7 @@ IntSendMessageTimeout(HWND hWnd, another thread, otherwise it sends the message. It does not support broadcast messages! */ LRESULT FASTCALL -IntPostOrSendMessage(HWND hWnd, +co_IntPostOrSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) @@ -1426,11 +1502,11 @@ IntPostOrSendMessage(HWND hWnd, if(Window->MessageQueue != PsGetWin32Thread()->MessageQueue) { - Result = NtUserPostMessage(hWnd, Msg, wParam, lParam); + Result = UserPostMessage(hWnd, Msg, wParam, lParam); } else { - if(!IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) + if(!co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) { Result = 0; } @@ -1442,7 +1518,7 @@ IntPostOrSendMessage(HWND hWnd, } LRESULT FASTCALL -IntDoSendMessage(HWND Wnd, +co_IntDoSendMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, @@ -1531,12 +1607,12 @@ IntDoSendMessage(HWND Wnd, } if(!dsm) { - Result = IntSendMessage(KernelModeMsg.hwnd, KernelModeMsg.message, + Result = co_IntSendMessage(KernelModeMsg.hwnd, KernelModeMsg.message, KernelModeMsg.wParam, KernelModeMsg.lParam); } else { - Result = IntSendMessageTimeout(KernelModeMsg.hwnd, KernelModeMsg.message, + Result = co_IntSendMessageTimeout(KernelModeMsg.hwnd, KernelModeMsg.message, KernelModeMsg.wParam, KernelModeMsg.lParam, dsm->uFlags, dsm->uTimeout, &dsm->Result); } @@ -1570,10 +1646,14 @@ NtUserSendMessageTimeout(HWND hWnd, { DOSENDMESSAGE dsm; LRESULT Result; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSendMessageTimeout\n"); + UserEnterExclusive(); dsm.uFlags = uFlags; dsm.uTimeout = uTimeout; - Result = IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo); + Result = co_IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo); if(uResult != NULL && Result != 0) { NTSTATUS Status; @@ -1582,10 +1662,15 @@ NtUserSendMessageTimeout(HWND hWnd, if(!NT_SUCCESS(Status)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } } - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserSendMessageTimeout, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } LRESULT STDCALL @@ -1595,7 +1680,17 @@ NtUserSendMessage(HWND Wnd, LPARAM lParam, PNTUSERSENDMESSAGEINFO UnsafeInfo) { - return IntDoSendMessage(Wnd, Msg, wParam, lParam, NULL, UnsafeInfo); + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSendMessage\n"); + UserEnterExclusive(); + + RETURN(co_IntDoSendMessage(Wnd, Msg, wParam, lParam, NULL, UnsafeInfo)); + +CLEANUP: + DPRINT("Leave NtUserSendMessage, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL STDCALL @@ -1625,8 +1720,17 @@ NtUserSendNotifyMessage(HWND hWnd, BOOL STDCALL NtUserWaitMessage(VOID) { + DECLARE_RETURN(BOOL); - return IntWaitMessage(NULL, 0, 0); + DPRINT("EnterNtUserWaitMessage\n"); + UserEnterExclusive(); + + RETURN(co_IntWaitMessage(NULL, 0, 0)); + +CLEANUP: + DPRINT("Leave NtUserWaitMessage, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD STDCALL @@ -1634,6 +1738,10 @@ NtUserGetQueueStatus(BOOL ClearChanges) { PUSER_MESSAGE_QUEUE Queue; DWORD Result; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetQueueStatus\n"); + UserEnterExclusive(); Queue = PsGetWin32Thread()->MessageQueue; @@ -1647,7 +1755,12 @@ NtUserGetQueueStatus(BOOL ClearChanges) IntUnLockMessageQueue(Queue); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserGetQueueStatus, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL STDCALL diff --git a/reactos/subsys/win32k/ntuser/metric.c b/reactos/subsys/win32k/ntuser/metric.c index b960f2b11aa..1c620cc0e71 100644 --- a/reactos/subsys/win32k/ntuser/metric.c +++ b/reactos/subsys/win32k/ntuser/metric.c @@ -37,8 +37,8 @@ /* FUNCTIONS *****************************************************************/ /* FIXME: Alot of thse values should NOT be hardcoded but they are */ -ULONG STDCALL -NtUserGetSystemMetrics(ULONG Index) +ULONG FASTCALL +UserGetSystemMetrics(ULONG Index) { NTSTATUS Status; PWINSTATION_OBJECT WinStaObject; @@ -103,9 +103,9 @@ NtUserGetSystemMetrics(ULONG Index) return(4); case SM_CXFULLSCREEN: /* FIXME: shouldn't we take borders etc into account??? */ - return NtUserGetSystemMetrics(SM_CXSCREEN); + return UserGetSystemMetrics(SM_CXSCREEN); case SM_CYFULLSCREEN: - return NtUserGetSystemMetrics(SM_CYSCREEN); + return UserGetSystemMetrics(SM_CYSCREEN); case SM_CXHSCROLL: case SM_CYHSCROLL: return(16); @@ -119,18 +119,18 @@ NtUserGetSystemMetrics(ULONG Index) case SM_CYICONSPACING: return(64); case SM_CXMAXIMIZED: - return(NtUserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8 + return(UserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8 pixels greater than the screen width */ case SM_CYMAXIMIZED: - return(NtUserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20 + return(UserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20 pixels less than the screen height, taskbar maybe? */ case SM_CXMAXTRACK: - return(NtUserGetSystemMetrics(SM_CYSCREEN) + 12); + return(UserGetSystemMetrics(SM_CYSCREEN) + 12); case SM_CYMAXTRACK: - return(NtUserGetSystemMetrics(SM_CYSCREEN) + 12); + return(UserGetSystemMetrics(SM_CYSCREEN) + 12); case SM_CXMENUCHECK: case SM_CYMENUCHECK: return(13); @@ -218,4 +218,22 @@ NtUserGetSystemMetrics(ULONG Index) } } + + +/* FIXME: Alot of thse values should NOT be hardcoded but they are */ +ULONG STDCALL +NtUserGetSystemMetrics(ULONG Index) +{ + DECLARE_RETURN(ULONG); + + DPRINT("Enter NtUserGetSystemMetrics\n"); + UserEnterExclusive(); + + RETURN(UserGetSystemMetrics(Index)); + +CLEANUP: + DPRINT("Leave NtUserGetSystemMetrics, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/misc.c b/reactos/subsys/win32k/ntuser/misc.c index 4bc6d4e0bdb..f97a6ae575a 100644 --- a/reactos/subsys/win32k/ntuser/misc.c +++ b/reactos/subsys/win32k/ntuser/misc.c @@ -47,7 +47,7 @@ PUSER_MESSAGE_QUEUE W32kGetPrimitiveMessageQueue() } BOOL FASTCALL -IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register) +co_IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register) { PEPROCESS Process; NTSTATUS Status; @@ -90,7 +90,7 @@ IntRegisterLogonProcess(HANDLE ProcessId, BOOL Register) Request.Data.RegisterLogonProcessRequest.ProcessId = ProcessId; Request.Data.RegisterLogonProcessRequest.Register = Register; - Status = CsrNotify(&Request); + Status = co_CsrNotify(&Request); if (! NT_SUCCESS(Status)) { DPRINT1("Failed to register logon process with CSRSS\n"); @@ -108,6 +108,10 @@ STDCALL NtUserCallNoParam(DWORD Routine) { DWORD Result = 0; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserCallNoParam\n"); + UserEnterExclusive(); switch(Routine) { @@ -117,7 +121,7 @@ NtUserCallNoParam(DWORD Routine) break; case NOPARAM_ROUTINE_DESTROY_CARET: - Result = (DWORD)IntDestroyCaret(PsGetCurrentThread()->Tcb.Win32Thread); + Result = (DWORD)co_IntDestroyCaret(PsGetCurrentThread()->Tcb.Win32Thread); break; case NOPARAM_ROUTINE_INIT_MESSAGE_PUMP: @@ -141,14 +145,19 @@ NtUserCallNoParam(DWORD Routine) break; case NOPARAM_ROUTINE_MSQCLEARWAKEMASK: - return (DWORD)IntMsqClearWakeMask(); + RETURN( (DWORD)IntMsqClearWakeMask()); default: DPRINT1("Calling invalid routine number 0x%x in NtUserCallNoParam\n", Routine); SetLastWin32Error(ERROR_INVALID_PARAMETER); break; } - return Result; + RETURN(Result); + +CLEANUP: + DPRINT("Leave NtUserCallNoParam, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -160,6 +169,11 @@ NtUserCallOneParam( DWORD Param, DWORD Routine) { + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserCallOneParam\n"); + UserEnterExclusive(); + switch(Routine) { case ONEPARAM_ROUTINE_GETMENU: @@ -171,13 +185,13 @@ NtUserCallOneParam( if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Result = (DWORD)WindowObject->IDMenu; IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); } case ONEPARAM_ROUTINE_ISWINDOWUNICODE: @@ -189,15 +203,15 @@ NtUserCallOneParam( if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Result = WindowObject->Unicode; IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); } case ONEPARAM_ROUTINE_WINDOWFROMDC: - return (DWORD)IntWindowFromDC((HDC)Param); + RETURN( (DWORD)IntWindowFromDC((HDC)Param)); case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID: { @@ -208,13 +222,13 @@ NtUserCallOneParam( if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Result = WindowObject->ContextHelpId; IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); } case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON: @@ -228,24 +242,24 @@ NtUserCallOneParam( 0, &WinStaObject); if (!NT_SUCCESS(Status)) - return (DWORD)FALSE; + RETURN( (DWORD)FALSE); /* FIXME Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); */ Result = 0; ObDereferenceObject(WinStaObject); - return Result; + RETURN( Result); } case ONEPARAM_ROUTINE_SWITCHCARETSHOWING: - return (DWORD)IntSwitchCaretShowing((PVOID)Param); + RETURN( (DWORD)IntSwitchCaretShowing((PVOID)Param)); case ONEPARAM_ROUTINE_SETCARETBLINKTIME: - return (DWORD)IntSetCaretBlinkTime((UINT)Param); + RETURN( (DWORD)IntSetCaretBlinkTime((UINT)Param)); case ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS: - return (DWORD)IntEnumClipboardFormats((UINT)Param); + RETURN( (DWORD)IntEnumClipboardFormats((UINT)Param)); case ONEPARAM_ROUTINE_GETWINDOWINSTANCE: { @@ -255,16 +269,16 @@ NtUserCallOneParam( if(!(WindowObject = IntGetWindowObject((HWND)Param))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Result = (DWORD)WindowObject->Instance; IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); } case ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO: - return (DWORD)MsqSetMessageExtraInfo((LPARAM)Param); + RETURN( (DWORD)MsqSetMessageExtraInfo((LPARAM)Param)); case ONEPARAM_ROUTINE_GETCURSORPOSITION: { @@ -273,13 +287,13 @@ NtUserCallOneParam( POINT Pos; if(!Param) - return (DWORD)FALSE; + RETURN( (DWORD)FALSE); Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, KernelMode, 0, &WinStaObject); if (!NT_SUCCESS(Status)) - return (DWORD)FALSE; + RETURN( (DWORD)FALSE); /* FIXME - check if process has WINSTA_READATTRIBUTES */ IntGetCursorLocation(WinStaObject, &Pos); @@ -289,12 +303,12 @@ NtUserCallOneParam( { ObDereferenceObject(WinStaObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } ObDereferenceObject(WinStaObject); - return (DWORD)TRUE; + RETURN( (DWORD)TRUE); } case ONEPARAM_ROUTINE_ISWINDOWINDESTROY: @@ -306,13 +320,13 @@ NtUserCallOneParam( if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Result = (DWORD)IntIsWindowInDestroy(WindowObject); IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); } case ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING: @@ -333,25 +347,30 @@ NtUserCallOneParam( Process->Flags |= W32PF_NOWINDOWGHOSTING; } - return TRUE; + RETURN( TRUE); } - return FALSE; + RETURN( FALSE); } case ONEPARAM_ROUTINE_MSQSETWAKEMASK: - return (DWORD)IntMsqSetWakeMask(Param); + RETURN( (DWORD)IntMsqSetWakeMask(Param)); case ONEPARAM_ROUTINE_GETKEYBOARDTYPE: - return NtUserGetKeyboardType(Param); + RETURN( UserGetKeyboardType(Param)); case ONEPARAM_ROUTINE_GETKEYBOARDLAYOUT: - return (DWORD)NtUserGetKeyboardLayout(Param); + RETURN( (DWORD)UserGetKeyboardLayout(Param)); } DPRINT1("Calling invalid routine number 0x%x in NtUserCallOneParam(), Param=0x%x\n", Routine, Param); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + RETURN( 0); + +CLEANUP: + DPRINT("Leave NtUserCallOneParam, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -367,20 +386,24 @@ NtUserCallTwoParam( { NTSTATUS Status; PWINDOW_OBJECT WindowObject; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserCallTwoParam\n"); + UserEnterExclusive(); switch(Routine) { case TWOPARAM_ROUTINE_SETDCPENCOLOR: { - return (DWORD)IntSetDCColor((HDC)Param1, OBJ_PEN, (COLORREF)Param2); + RETURN( (DWORD)IntSetDCColor((HDC)Param1, OBJ_PEN, (COLORREF)Param2)); } case TWOPARAM_ROUTINE_SETDCBRUSHCOLOR: { - return (DWORD)IntSetDCColor((HDC)Param1, OBJ_BRUSH, (COLORREF)Param2); + RETURN( (DWORD)IntSetDCColor((HDC)Param1, OBJ_BRUSH, (COLORREF)Param2)); } case TWOPARAM_ROUTINE_GETDCCOLOR: { - return (DWORD)IntGetDCColor((HDC)Param1, (ULONG)Param2); + RETURN( (DWORD)IntGetDCColor((HDC)Param1, (ULONG)Param2)); } case TWOPARAM_ROUTINE_GETWINDOWRGNBOX: { @@ -391,20 +414,20 @@ NtUserCallTwoParam( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return ERROR; + RETURN( ERROR); } - return Ret; + RETURN( Ret); } case TWOPARAM_ROUTINE_GETWINDOWRGN: { - return (DWORD)IntGetWindowRgn((HWND)Param1, (HRGN)Param2); + RETURN( (DWORD)IntGetWindowRgn((HWND)Param1, (HRGN)Param2)); } case TWOPARAM_ROUTINE_SETMENUBARHEIGHT: { DWORD Ret; PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1); if(!MenuObject) - return 0; + RETURN( 0); if(Param2 > 0) { @@ -414,7 +437,7 @@ NtUserCallTwoParam( else Ret = (DWORD)MenuObject->MenuInfo.Height; IntReleaseMenuObject(MenuObject); - return Ret; + RETURN( Ret); } case TWOPARAM_ROUTINE_SETMENUITEMRECT: { @@ -422,18 +445,18 @@ NtUserCallTwoParam( SETMENUITEMRECT smir; PMENU_OBJECT MenuObject = IntGetMenuObject((HMENU)Param1); if(!MenuObject) - return 0; + RETURN( 0); if(!NT_SUCCESS(MmCopyFromCaller(&smir, (PVOID)Param2, sizeof(SETMENUITEMRECT)))) { IntReleaseMenuObject(MenuObject); - return 0; + RETURN( 0); } Ret = IntSetMenuItemRect(MenuObject, smir.uItem, smir.fByPosition, &smir.rcRect); IntReleaseMenuObject(MenuObject); - return (DWORD)Ret; + RETURN( (DWORD)Ret); } case TWOPARAM_ROUTINE_SETGUITHRDHANDLE: @@ -441,19 +464,19 @@ NtUserCallTwoParam( PUSER_MESSAGE_QUEUE MsgQueue = PsGetCurrentThread()->Tcb.Win32Thread->MessageQueue; ASSERT(MsgQueue); - return (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2); + RETURN( (DWORD)MsqSetStateWindow(MsgQueue, (ULONG)Param1, (HWND)Param2)); } case TWOPARAM_ROUTINE_ENABLEWINDOW: UNIMPLEMENTED - return 0; + RETURN( 0); case TWOPARAM_ROUTINE_UNKNOWN: UNIMPLEMENTED - return 0; + RETURN( 0); case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS: - return (DWORD)IntShowOwnedPopups((HWND) Param1, (BOOL) Param2); + RETURN( (DWORD)IntShowOwnedPopups((HWND) Param1, (BOOL) Param2)); case TWOPARAM_ROUTINE_ROS_SHOWWINDOW: { @@ -463,44 +486,44 @@ NtUserCallTwoParam( if (Window == 0) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if (Param2) { if (!(Window->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP)) { IntReleaseWindowObject(Window); - return TRUE; + RETURN( TRUE); } Window->Flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP; } else Window->Flags |= WIN_NEEDS_SHOW_OWNEDPOPUP; DPRINT1("ROS_SHOWWINDOW ---> 0x%x\n",Window->Flags); IntReleaseWindowObject(Window); - return TRUE; + RETURN( TRUE); } case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW: UNIMPLEMENTED - return 0; + RETURN( 0); case TWOPARAM_ROUTINE_VALIDATERGN: - return (DWORD)NtUserValidateRgn((HWND) Param1, (HRGN) Param2); + RETURN( (DWORD)UserValidateRgn((HWND) Param1, (HRGN) Param2)); case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID: WindowObject = IntGetWindowObject((HWND)Param1); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_HANDLE); - return (DWORD)FALSE; + RETURN( (DWORD)FALSE); } WindowObject->ContextHelpId = Param2; IntReleaseWindowObject(WindowObject); - return (DWORD)TRUE; + RETURN( (DWORD)TRUE); case TWOPARAM_ROUTINE_SETCARETPOS: - return (DWORD)IntSetCaretPos((int)Param1, (int)Param2); + RETURN( (DWORD)co_IntSetCaretPos((int)Param1, (int)Param2)); case TWOPARAM_ROUTINE_GETWINDOWINFO: { @@ -510,7 +533,7 @@ NtUserCallTwoParam( if(!(WindowObject = IntGetWindowObject((HWND)Param1))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } #if 0 @@ -523,14 +546,14 @@ NtUserCallTwoParam( { IntReleaseWindowObject(WindowObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } if(wi.cbSize != sizeof(WINDOWINFO)) { IntReleaseWindowObject(WindowObject); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } #endif @@ -541,16 +564,16 @@ NtUserCallTwoParam( { IntReleaseWindowObject(WindowObject); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } } IntReleaseWindowObject(WindowObject); - return Ret; + RETURN( Ret); } case TWOPARAM_ROUTINE_REGISTERLOGONPROC: - return (DWORD)IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2); + RETURN( (DWORD)co_IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2)); case TWOPARAM_ROUTINE_SETSYSCOLORS: { @@ -568,7 +591,7 @@ NtUserCallTwoParam( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return 0; + RETURN( 0); } Buffer = ExAllocatePool(PagedPool, (Param2 * sizeof(INT)) + (Param2 * sizeof(COLORREF))); @@ -595,7 +618,7 @@ NtUserCallTwoParam( } - return Ret; + RETURN( Ret); } case TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES: @@ -644,14 +667,19 @@ NtUserCallTwoParam( ExFreePool(Buffer.Pointer); } - return Ret; + RETURN( Ret); } } DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n", Routine, Param1, Param2); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + RETURN( 0); + +CLEANUP: + DPRINT("Leave NtUserCallTwoParam, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -666,19 +694,23 @@ NtUserCallHwndLock( { BOOL Ret = 0; PWINDOW_OBJECT Window; + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserCallHwndLock\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hWnd); if (Window == 0) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } /* FIXME: Routine can be 0x53 - 0x5E */ switch (Routine) { case HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS: - WinPosArrangeIconicWindows(Window); + co_WinPosArrangeIconicWindows(Window); break; case HWNDLOCK_ROUTINE_DRAWMENUBAR: @@ -692,7 +724,7 @@ NtUserCallHwndLock( MenuObject->MenuInfo.WndOwner = hWnd; MenuObject->MenuInfo.Height = 0; IntReleaseMenuObject(MenuObject); - WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + co_WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); Ret = TRUE; break; @@ -703,7 +735,7 @@ NtUserCallHwndLock( break; case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW: - Ret = IntSetForegroundWindow(Window); + Ret = co_IntSetForegroundWindow(Window); break; case HWNDLOCK_ROUTINE_UPDATEWINDOW: @@ -713,7 +745,12 @@ NtUserCallHwndLock( IntReleaseWindowObject(Window); - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserCallHwndLock, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -754,12 +791,22 @@ DWORD STDCALL NtUserGetThreadState( DWORD Routine) { + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetThreadState\n"); + UserEnterShared(); + switch (Routine) { case 0: - return (DWORD)IntGetThreadFocusWindow(); + RETURN( (DWORD)IntGetThreadFocusWindow()); } - return 0; + RETURN( 0); + +CLEANUP: + DPRINT("Leave NtUserGetThreadState, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } VOID FASTCALL @@ -822,14 +869,14 @@ IntSystemParametersInfo( IntGetFontMetricSetting(L"IconFont", &IconFont); pMetrics.iBorderWidth = 1; - pMetrics.iScrollWidth = NtUserGetSystemMetrics(SM_CXVSCROLL); - pMetrics.iScrollHeight = NtUserGetSystemMetrics(SM_CYHSCROLL); - pMetrics.iCaptionWidth = NtUserGetSystemMetrics(SM_CXSIZE); - pMetrics.iCaptionHeight = NtUserGetSystemMetrics(SM_CYSIZE); - pMetrics.iSmCaptionWidth = NtUserGetSystemMetrics(SM_CXSMSIZE); - pMetrics.iSmCaptionHeight = NtUserGetSystemMetrics(SM_CYSMSIZE); - pMetrics.iMenuWidth = NtUserGetSystemMetrics(SM_CXMENUSIZE); - pMetrics.iMenuHeight = NtUserGetSystemMetrics(SM_CYMENUSIZE); + pMetrics.iScrollWidth = UserGetSystemMetrics(SM_CXVSCROLL); + pMetrics.iScrollHeight = UserGetSystemMetrics(SM_CYHSCROLL); + pMetrics.iCaptionWidth = UserGetSystemMetrics(SM_CXSIZE); + pMetrics.iCaptionHeight = UserGetSystemMetrics(SM_CYSIZE); + pMetrics.iSmCaptionWidth = UserGetSystemMetrics(SM_CXSMSIZE); + pMetrics.iSmCaptionHeight = UserGetSystemMetrics(SM_CYSMSIZE); + pMetrics.iMenuWidth = UserGetSystemMetrics(SM_CXMENUSIZE); + pMetrics.iMenuHeight = UserGetSystemMetrics(SM_CYMENUSIZE); pMetrics.cbSize = sizeof(NONCLIENTMETRICSW); bInitialized = TRUE; @@ -1037,9 +1084,8 @@ IntSystemParametersInfo( /* * @implemented */ -BOOL -STDCALL -NtUserSystemParametersInfo( +BOOL FASTCALL +UserSystemParametersInfo( UINT uiAction, UINT uiParam, PVOID pvParam, @@ -1066,9 +1112,9 @@ NtUserSystemParametersInfo( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return (DWORD)IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni); + return( (DWORD)IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni)); } case SPI_GETWORKAREA: { @@ -1076,16 +1122,16 @@ NtUserSystemParametersInfo( if(!IntSystemParametersInfo(uiAction, uiParam, &rc, fWinIni)) { - return FALSE; + return( FALSE); } Status = MmCopyToCaller((PRECT)pvParam, &rc, sizeof(RECT)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return TRUE; + return( TRUE); } case SPI_GETFONTSMOOTHING: case SPI_GETGRADIENTCAPTIONS: @@ -1096,16 +1142,16 @@ NtUserSystemParametersInfo( if(!IntSystemParametersInfo(uiAction, uiParam, &Ret, fWinIni)) { - return FALSE; + return( FALSE); } Status = MmCopyToCaller(pvParam, &Ret, sizeof(BOOL)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return TRUE; + return( TRUE); } case SPI_SETDESKWALLPAPER: { @@ -1117,9 +1163,9 @@ NtUserSystemParametersInfo( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return IntSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &hbmWallpaper, fWinIni); + return( IntSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &hbmWallpaper, fWinIni)); } case SPI_GETDESKWALLPAPER: { @@ -1134,9 +1180,9 @@ NtUserSystemParametersInfo( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return Ret; + return( Ret); } case SPI_GETICONTITLELOGFONT: { @@ -1144,16 +1190,16 @@ NtUserSystemParametersInfo( if(!IntSystemParametersInfo(uiAction, uiParam, &IconFont, fWinIni)) { - return FALSE; + return( FALSE); } Status = MmCopyToCaller(pvParam, &IconFont, sizeof(LOGFONTW)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return TRUE; + return( TRUE); } case SPI_GETNONCLIENTMETRICS: { @@ -1163,31 +1209,60 @@ NtUserSystemParametersInfo( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } if(metrics.cbSize != sizeof(NONCLIENTMETRICSW)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + return( FALSE); } if(!IntSystemParametersInfo(uiAction, uiParam, &metrics, fWinIni)) { - return FALSE; + return( FALSE); } Status = MmCopyToCaller(pvParam, &metrics.cbSize, sizeof(NONCLIENTMETRICSW)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + return( FALSE); } - return TRUE; + return( TRUE); } } - return FALSE; + return( FALSE); } + + + +/* + * @implemented + */ +BOOL +STDCALL +NtUserSystemParametersInfo( + UINT uiAction, + UINT uiParam, + PVOID pvParam, + UINT fWinIni) +{ + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserSystemParametersInfo\n"); + UserEnterExclusive(); + + RETURN( UserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni)); + +CLEANUP: + DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + UINT STDCALL NtUserGetDoubleClickTime(VOID) @@ -1196,25 +1271,34 @@ NtUserGetDoubleClickTime(VOID) NTSTATUS Status; PWINSTATION_OBJECT WinStaObject; PSYSTEM_CURSORINFO CurInfo; + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserGetDoubleClickTime\n"); + UserEnterShared(); Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, KernelMode, 0, &WinStaObject); if (!NT_SUCCESS(Status)) - return (DWORD)FALSE; + RETURN( (DWORD)FALSE); CurInfo = IntGetSysCursorInfo(WinStaObject); Result = CurInfo->DblClickSpeed; ObDereferenceObject(WinStaObject); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserGetDoubleClickTime, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL STDCALL NtUserGetGUIThreadInfo( - DWORD idThread, + DWORD idThread, /* if NULL use foreground thread */ LPGUITHREADINFO lpgui) { NTSTATUS Status; @@ -1223,18 +1307,22 @@ NtUserGetGUIThreadInfo( PDESKTOP_OBJECT Desktop; PUSER_MESSAGE_QUEUE MsgQueue; PETHREAD Thread = NULL; + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserGetGUIThreadInfo\n"); + UserEnterShared(); Status = MmCopyFromCaller(&SafeGui, lpgui, sizeof(DWORD)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } if(SafeGui.cbSize != sizeof(GUITHREADINFO)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } if(idThread) @@ -1243,7 +1331,7 @@ NtUserGetGUIThreadInfo( if(!NT_SUCCESS(Status)) { SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; + RETURN( FALSE); } Desktop = Thread->Tcb.Win32Thread->Desktop; } @@ -1267,7 +1355,7 @@ NtUserGetGUIThreadInfo( if(idThread && Thread) ObDereferenceObject(Thread); SetLastWin32Error(ERROR_ACCESS_DENIED); - return FALSE; + RETURN( FALSE); } MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue; @@ -1300,10 +1388,15 @@ NtUserGetGUIThreadInfo( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetGUIThreadInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -1317,6 +1410,10 @@ NtUserGetGuiResources( PW32PROCESS W32Process; NTSTATUS Status; DWORD Ret = 0; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetGuiResources\n"); + UserEnterShared(); Status = ObReferenceObjectByHandle(hProcess, PROCESS_QUERY_INFORMATION, @@ -1328,7 +1425,7 @@ NtUserGetGuiResources( if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return 0; + RETURN( 0); } W32Process = (PW32PROCESS)Process->Win32Process; @@ -1336,7 +1433,7 @@ NtUserGetGuiResources( { ObDereferenceObject(Process); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + RETURN( 0); } switch(uiFlags) @@ -1360,7 +1457,12 @@ NtUserGetGuiResources( ObDereferenceObject(Process); - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserGetGuiResources, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } NTSTATUS FASTCALL @@ -1495,8 +1597,18 @@ NtUserUpdatePerUserSystemParameters( BOOL bEnable) { BOOL Result = TRUE; + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserUpdatePerUserSystemParameters\n"); + UserEnterExclusive(); + Result &= IntDesktopUpdatePerUserSettings(bEnable); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserUpdatePerUserSystemParameters, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c index 2461fd2039d..23c292f0f74 100644 --- a/reactos/subsys/win32k/ntuser/msgqueue.c +++ b/reactos/subsys/win32k/ntuser/msgqueue.c @@ -254,7 +254,7 @@ MsqIsDblClk(LPMSG Msg, BOOL Remove) } BOOL STATIC STDCALL -MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT FilterLow, UINT FilterHigh, +co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT FilterLow, UINT FilterHigh, PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed, PWINDOW_OBJECT ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue) { @@ -271,7 +271,7 @@ MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Filte } else { - WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &Window); + co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &Window); if(Window == NULL) { Window = ScopeWin; @@ -442,7 +442,7 @@ MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Filte } BOOL STDCALL -MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, +co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT FilterLow, UINT FilterHigh, BOOL Remove, PUSER_MESSAGE* Message) { @@ -464,9 +464,14 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, WaitObjects[0] = &HardwareMessageQueueLock; do { + UserLeaveCo(); + WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest, UserMode, FALSE, NULL, NULL); - while (MsqDispatchOneSentMessage(MessageQueue)) + + UserEnterCo(); + + while (co_MsqDispatchOneSentMessage(MessageQueue)) { ; } @@ -486,7 +491,7 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, if (Current->Msg.message >= WM_MOUSEFIRST && Current->Msg.message <= WM_MOUSELAST) { - Accept = MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh, + Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh, Current, Remove, &Freed, DesktopWindow, &ScreenPoint, FALSE); if (Accept) @@ -548,7 +553,7 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, MouseHookData.flags = 0; MouseHookData.time = Msg.time; MouseHookData.dwExtraInfo = 0; - ProcessMessage = (0 == HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, + ProcessMessage = (0 == co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg.message, (LPARAM) &MouseHookData)); } else @@ -588,7 +593,7 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, { const ULONG ActiveStamp = HardwareMessageQueueStamp; /* Translate the message. */ - Accept = MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh, + Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh, Current, Remove, &Freed, DesktopWindow, &ScreenPoint, TRUE); if (Accept) @@ -649,7 +654,7 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, } VOID FASTCALL -MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) +co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { PUSER_MESSAGE_QUEUE FocusMessageQueue; MSG Msg; @@ -676,7 +681,7 @@ MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) (0 == (Msg.lParam & 0x80000000) ? 0 : LLKHF_UP); KbdHookData.time = Msg.time; KbdHookData.dwExtraInfo = 0; - if (HOOK_CallHooks(WH_KEYBOARD_LL, HC_ACTION, Msg.message, (LPARAM) &KbdHookData)) + if (co_HOOK_CallHooks(WH_KEYBOARD_LL, HC_ACTION, Msg.message, (LPARAM) &KbdHookData)) { DPRINT("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n", Msg.message, Msg.wParam, Msg.lParam); @@ -787,7 +792,7 @@ MsqDestroyMessage(PUSER_MESSAGE Message) } VOID FASTCALL -MsqDispatchSentNotifyMessages(PUSER_MESSAGE_QUEUE MessageQueue) +co_MsqDispatchSentNotifyMessages(PUSER_MESSAGE_QUEUE MessageQueue) { PLIST_ENTRY ListEntry; PUSER_SENT_MESSAGE_NOTIFY Message; @@ -800,7 +805,7 @@ MsqDispatchSentNotifyMessages(PUSER_MESSAGE_QUEUE MessageQueue) ListEntry); IntUnLockMessageQueue(MessageQueue); - IntCallSentMessageCallback(Message->CompletionCallback, + co_IntCallSentMessageCallback(Message->CompletionCallback, Message->hWnd, Message->Msg, Message->CompletionCallbackContext, @@ -818,7 +823,7 @@ MsqPeekSentMessages(PUSER_MESSAGE_QUEUE MessageQueue) } BOOLEAN FASTCALL -MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) +co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) { PUSER_SENT_MESSAGE Message; PLIST_ENTRY Entry; @@ -846,7 +851,7 @@ MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) if (Message->HookMessage) { - Result = HOOK_CallHooks(Message->Msg.message, + Result = co_HOOK_CallHooks(Message->Msg.message, (INT) Message->Msg.hwnd, Message->Msg.wParam, Message->Msg.lParam); @@ -854,7 +859,7 @@ MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue) else { /* Call the window procedure. */ - Result = IntSendMessage(Message->Msg.hwnd, + Result = co_IntSendMessage(Message->Msg.hwnd, Message->Msg.message, Message->Msg.wParam, Message->Msg.lParam); @@ -1016,7 +1021,7 @@ MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue, } NTSTATUS FASTCALL -MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, +co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam, UINT uTimeout, BOOL Block, BOOL HookMessage, ULONG_PTR *uResult) @@ -1077,9 +1082,15 @@ MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, if(Block) { + + UserLeaveCo(); + /* don't process messages sent to the thread */ WaitStatus = KeWaitForSingleObject(&CompletionEvent, UserRequest, UserMode, FALSE, (uTimeout ? &Timeout : NULL)); + + UserEnterCo(); + if(WaitStatus == STATUS_TIMEOUT) { /* look up if the message has not yet dispatched, if so @@ -1126,7 +1137,7 @@ MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, DPRINT("MsqSendMessage (blocked) timed out\n"); } - while (MsqDispatchOneSentMessage(ThreadQueue)); + while (co_MsqDispatchOneSentMessage(ThreadQueue)); } else { @@ -1136,8 +1147,14 @@ MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, WaitObjects[1] = ThreadQueue->NewMessages; do { + + UserLeaveCo(); + WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest, UserMode, FALSE, (uTimeout ? &Timeout : NULL), NULL); + + UserEnterCo(); + if(WaitStatus == STATUS_TIMEOUT) { /* look up if the message has not yet been dispatched, if so @@ -1185,7 +1202,7 @@ MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue, DPRINT("MsqSendMessage timed out\n"); break; } - while (MsqDispatchOneSentMessage(ThreadQueue)); + while (co_MsqDispatchOneSentMessage(ThreadQueue)); } while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus); } @@ -1230,7 +1247,7 @@ MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode) } BOOLEAN STDCALL -MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, +co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, IN BOOLEAN Hardware, IN BOOLEAN Remove, IN HWND Wnd, @@ -1244,7 +1261,7 @@ MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, if (Hardware) { - return(MsqPeekHardwareMessage(MessageQueue, Wnd, + return(co_MsqPeekHardwareMessage(MessageQueue, Wnd, MsgFilterLow, MsgFilterHigh, Remove, Message)); } @@ -1276,12 +1293,13 @@ MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue, } NTSTATUS FASTCALL -MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter, +co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax) { PVOID WaitObjects[2] = {MessageQueue->NewMessages, &HardwareMessageEvent}; LARGE_INTEGER TimerExpiry; PLARGE_INTEGER Timeout; + NTSTATUS ret; if (MsqGetFirstTimerExpiry(MessageQueue, WndFilter, MsgFilterMin, MsgFilterMax, &TimerExpiry)) { @@ -1292,14 +1310,20 @@ MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter, Timeout = NULL; } - return(KeWaitForMultipleObjects(2, + UserLeaveCo(); + + ret = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, Executive, UserMode, FALSE, Timeout, - NULL)); + NULL); + + UserEnterCo(); + + return ret; } BOOL FASTCALL diff --git a/reactos/subsys/win32k/ntuser/ntuser.c b/reactos/subsys/win32k/ntuser/ntuser.c new file mode 100644 index 00000000000..f1463f8a5da --- /dev/null +++ b/reactos/subsys/win32k/ntuser/ntuser.c @@ -0,0 +1,100 @@ +/* + * 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: painting.c 16320 2005-06-29 07:09:25Z navaraf $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * PURPOSE: ntuser init. and main funcs. + * FILE: subsys/win32k/ntuser/ntuser.c + * REVISION HISTORY: + * 16 July 2005 Created (hardon) + */ + +/* INCLUDES ******************************************************************/ + +#include + +#define NDEBUG +#include + + +FAST_MUTEX UserLock; + +char* _file; +DWORD _line; +DWORD _locked=0; + +/* FUNCTIONS **********************************************************/ + + +NTSTATUS FASTCALL InitUserImpl(VOID) +{ + //PVOID mem; + +// DPRINT("Enter InitUserImpl\n"); +// ExInitializeResourceLite(&UserLock); + ExInitializeFastMutex(&UserLock); + + return STATUS_SUCCESS; +} + +/* +RETURN + True if current thread owns the lock (possibly shared) +*/ +BOOL FASTCALL UserIsEntered() +{ + return (UserLock.Owner == KeGetCurrentThread()); +} + + +VOID FASTCALL CleanupUser(VOID) +{ +// ExDeleteResourceLite(&UserLock); +} + +VOID FASTCALL UUserEnterShared(VOID) +{ +// DPRINT("Enter IntLockUserShared\n"); +// KeDumpStackFrames((PULONG)__builtin_frame_address(0)); +//DPRINT("%x\n",__builtin_return_address(0)); +// KeEnterCriticalRegion(); +// ExAcquireResourceSharedLite(&UserLock, TRUE); + ExAcquireFastMutex(&UserLock); +} + +VOID FASTCALL UUserEnterExclusive(VOID) +{ +// DPRINT("Enter UserEnterExclusive\n"); +// KeDumpStackFrames((PULONG)__builtin_frame_address(0)); +//DPRINT("%x\n",__builtin_return_address(0)); +// KeEnterCriticalRegion(); +// ExAcquireResourceExclusiveLite(&UserLock, TRUE); + ExAcquireFastMutex(&UserLock); +} + +VOID FASTCALL UUserLeave(VOID) +{ +// DPRINT("Enter UserLeave\n"); +// KeDumpStackFrames((PULONG)__builtin_frame_address(0)); +//DPRINT("%x\n",__builtin_return_address(0)); +// ExReleaseResourceLite(&UserLock); +// KeLeaveCriticalRegion(); + ExReleaseFastMutex(&UserLock); +} diff --git a/reactos/subsys/win32k/ntuser/painting.c b/reactos/subsys/win32k/ntuser/painting.c index 1150f1837fc..c792a0744bb 100644 --- a/reactos/subsys/win32k/ntuser/painting.c +++ b/reactos/subsys/win32k/ntuser/painting.c @@ -80,7 +80,7 @@ IntValidateParent(PWINDOW_OBJECT Child, HRGN ValidRegion) */ STATIC VOID FASTCALL -IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) +co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) { HDC hDC; HWND hWnd = Window->Self; @@ -104,7 +104,7 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT; MsqDecPaintCountQueue(Window->MessageQueue); IntUnLockWindowUpdate(Window); - IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0); + co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)TempRegion, 0); if ((HANDLE) 1 != TempRegion && NULL != TempRegion) { /* NOTE: The region can already be deleted! */ @@ -125,15 +125,15 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) * - Filip */ /* IntValidateParent(Window, Window->UpdateRegion); */ - hDC = NtUserGetDCEx(hWnd, 0, DCX_CACHE | DCX_USESTYLE | + hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE | DCX_INTERSECTUPDATE); if (hDC != NULL) { - if (IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0)) + if (co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0)) { Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND; } - NtUserReleaseDC(hWnd, hDC); + UserReleaseDC(Window, hDC); } } } @@ -143,7 +143,7 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) if (Window->UpdateRegion != NULL || Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) { - IntSendMessage(hWnd, WM_PAINT, 0, 0); + co_IntSendMessage(hWnd, WM_PAINT, 0, 0); } } } @@ -172,7 +172,7 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) Window = IntGetWindowObject(*phWnd); if (Window && (Window->Style & WS_VISIBLE)) { - IntPaintWindows(Window, Flags); + co_IntPaintWindows(Window, Flags); IntReleaseWindowObject(Window); } } @@ -442,7 +442,7 @@ IntIsWindowDrawable(PWINDOW_OBJECT Window) */ BOOL FASTCALL -IntRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn, +co_UserRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn, ULONG Flags) { HRGN hRgn = NULL; @@ -516,7 +516,7 @@ IntRedrawWindow(PWINDOW_OBJECT Window, const RECT* UpdateRect, HRGN UpdateRgn, if (Flags & (RDW_ERASENOW | RDW_UPDATENOW)) { - IntPaintWindows(Window, Flags); + co_IntPaintWindows(Window, Flags); } /* @@ -639,8 +639,9 @@ IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, return FALSE; } +static HWND FASTCALL -IntFixCaret(HWND hWnd, LPRECT lprc, UINT flags) +co_IntFixCaret(HWND hWnd, LPRECT lprc, UINT flags) { PDESKTOP_OBJECT Desktop; PTHRDCARETINFO CaretInfo; @@ -667,7 +668,7 @@ IntFixCaret(HWND hWnd, LPRECT lprc, UINT flags) rcCaret.bottom = pt.y + CaretInfo->Size.cy; if (IntGdiIntersectRect(lprc, lprc, &rcCaret)) { - NtUserHideCaret(0); + co_UserHideCaret(0); lprc->left = pt.x; lprc->top = pt.y; return hWndCaret; @@ -693,14 +694,18 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs) PAINTSTRUCT Ps; PROSRGNDATA Rgn; NTSTATUS Status; + DECLARE_RETURN(HDC); + + DPRINT("Enter NtUserBeginPaint\n"); + UserEnterExclusive(); if (!(Window = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; + RETURN( NULL); } - NtUserHideCaret(hWnd); + co_UserHideCaret(Window); if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT) { @@ -716,7 +721,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs) Window->NCUpdateRegion = NULL; Window->Flags &= ~WINDOWOBJECT_NEED_NCPAINT; MsqDecPaintCountQueue(Window->MessageQueue); - IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)hRgn, 0); + co_IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)hRgn, 0); if (hRgn != (HANDLE)1 && hRgn != NULL) { /* NOTE: The region can already by deleted! */ @@ -725,13 +730,13 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs) } RtlZeroMemory(&Ps, sizeof(PAINTSTRUCT)); - Ps.hdc = NtUserGetDCEx(hWnd, 0, DCX_INTERSECTUPDATE | DCX_WINDOWPAINT | - DCX_USESTYLE); + + Ps.hdc = UserGetDCEx(Window, 0, DCX_INTERSECTUPDATE | DCX_WINDOWPAINT | DCX_USESTYLE); if (!Ps.hdc) { IntReleaseWindowObject(Window); - return NULL; + RETURN( NULL); } IntLockWindowUpdate(Window); @@ -768,7 +773,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs) if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND) { Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND; - Ps.fErase = !IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)Ps.hdc, 0); + Ps.fErase = !co_IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)Ps.hdc, 0); } else { @@ -781,10 +786,16 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs) if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return NULL; + RETURN( NULL); } - return Ps.hdc; + RETURN( Ps.hdc); + +CLEANUP: + DPRINT("Leave NtUserBeginPaint, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + } /* @@ -797,10 +808,28 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs) BOOL STDCALL NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs) { - NtUserReleaseDC(hWnd, lPs->hdc); - NtUserShowCaret(hWnd); + PWINDOW_OBJECT Window; + DECLARE_RETURN(BOOL); - return TRUE; + DPRINT("Enter NtUserEndPaint\n"); + UserEnterExclusive(); + + if (!(Window = IntGetWindowObject(hWnd))) + { + RETURN(FALSE); + } + + UserReleaseDC(Window, lPs->hdc); + co_UserShowCaret(Window); + + IntReleaseWindowObject(Window); //temp hack + + RETURN(TRUE); + +CLEANUP: + DPRINT("Leave NtUserEndPaint, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -829,6 +858,20 @@ NtUserInvalidateRgn(HWND hWnd, HRGN Rgn, BOOL Erase) return NtUserRedrawWindow(hWnd, NULL, Rgn, RDW_INVALIDATE | (Erase ? RDW_ERASE : 0)); } + + +BOOL FASTCALL +UserValidateRgn(HWND hWnd, HRGN hRgn) +{ + PWINDOW_OBJECT Window; + BOOL ret; + + if (!(Window = IntGetWindowObject(hWnd))) return FALSE; + ret = co_UserRedrawWindow(Window, NULL, hRgn, RDW_VALIDATE | RDW_NOCHILDREN); + IntReleaseWindowObject(Window);//temp hack + return ret; +} + /* * NtUserValidateRgn * @@ -855,15 +898,12 @@ NtUserUpdateWindow(HWND hWnd) return NtUserRedrawWindow(hWnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); } -/* - * NtUserGetUpdateRgn - * - * Status - * @implemented - */ -INT STDCALL -NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase) + + + +INT FASTCALL +co_UserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase) { PWINDOW_OBJECT Window; int RegionType; @@ -889,15 +929,37 @@ NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase) } IntUnLockWindowUpdate(Window); - IntReleaseWindowObject(Window); - if (bErase && RegionType != NULLREGION && RegionType != ERROR) { - NtUserRedrawWindow(hWnd, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN); + co_UserRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN); } + IntReleaseWindowObject(Window); + return RegionType; } +/* + * NtUserGetUpdateRgn + * + * Status + * @implemented + */ + +INT STDCALL +NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase) +{ + DECLARE_RETURN(INT); + + DPRINT("Enter NtUserGetUpdateRgn\n"); + UserEnterExclusive(); + + RETURN(co_UserGetUpdateRgn(hWnd, hRgn, bErase)); + +CLEANUP: + DPRINT("Leave NtUserGetUpdateRgn, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} /* * NtUserGetUpdateRect @@ -915,11 +977,15 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase) PROSRGNDATA RgnData; BOOL AlwaysPaint; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetUpdateRect\n"); + UserEnterExclusive(); if (!(Window = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return ERROR; + RETURN( ERROR); } IntLockWindowUpdate(Window); @@ -939,24 +1005,29 @@ NtUserGetUpdateRect(HWND hWnd, LPRECT UnsafeRect, BOOL bErase) (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT); IntUnLockWindowUpdate(Window); - IntReleaseWindowObject(Window); - if (bErase && Rect.left < Rect.right && Rect.top < Rect.bottom) { - NtUserRedrawWindow(hWnd, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN); + co_UserRedrawWindow(Window, NULL, NULL, RDW_ERASENOW | RDW_NOCHILDREN); } + IntReleaseWindowObject(Window); + if (UnsafeRect != NULL) { Status = MmCopyToCaller(UnsafeRect, &Rect, sizeof(RECT)); if (!NT_SUCCESS(Status)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + RETURN( FALSE); } } - return (Rect.left < Rect.right && Rect.top < Rect.bottom) || AlwaysPaint; + RETURN( (Rect.left < Rect.right && Rect.top < Rect.bottom) || AlwaysPaint); + +CLEANUP: + DPRINT("Leave NtUserGetUpdateRect, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -973,11 +1044,15 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate, RECT SafeUpdateRect; NTSTATUS Status; PWINDOW_OBJECT Wnd; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserRedrawWindow\n"); + UserEnterExclusive(); if (!(Wnd = IntGetWindowObject(hWnd ? hWnd : IntGetDesktopWindow()))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if (lprcUpdate != NULL) @@ -989,11 +1064,11 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate, { SetLastWin32Error(ERROR_INVALID_PARAMETER); IntReleaseWindowObject(Wnd); - return FALSE; + RETURN( FALSE); } } - Status = IntRedrawWindow(Wnd, NULL == lprcUpdate ? NULL : &SafeUpdateRect, + Status = co_UserRedrawWindow(Wnd, NULL == lprcUpdate ? NULL : &SafeUpdateRect, hrgnUpdate, flags); if (!NT_SUCCESS(Status)) @@ -1001,22 +1076,23 @@ NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate, /* IntRedrawWindow fails only in case that flags are invalid */ SetLastWin32Error(ERROR_INVALID_PARAMETER); IntReleaseWindowObject(Wnd); - return FALSE; + RETURN( FALSE); } IntReleaseWindowObject(Wnd); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserRedrawWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } -/* - * NtUserScrollDC - * - * Status - * @implemented - */ -DWORD STDCALL -NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll, + +static +DWORD FASTCALL +UserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll, const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate) { RECT rSrc, rClipped_src, rClip, rDst, offset; @@ -1113,6 +1189,34 @@ NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll, return TRUE; } + + + +/* + * NtUserScrollDC + * + * Status + * @implemented + */ + +DWORD STDCALL +NtUserScrollDC(HDC hDC, INT dx, INT dy, const RECT *lprcScroll, + const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate) +{ + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserScrollDC\n"); + UserEnterExclusive(); + + RETURN( UserScrollDC(hDC, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate)); + +CLEANUP: + DPRINT("Leave NtUserScrollDC, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + +} + /* * NtUserScrollWindowEx * @@ -1126,19 +1230,23 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, { RECT rc, cliprc, caretrc, rect, clipRect; INT Result; - PWINDOW_OBJECT Window; + PWINDOW_OBJECT Window, CaretWnd; HDC hDC; HRGN hrgnTemp; HWND hwndCaret; BOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE)); BOOL bOwnRgn = TRUE; NTSTATUS Status; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserScrollWindowEx\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hWnd); if (!Window || !IntIsWindowDrawable(Window)) { IntReleaseWindowObject(Window); - return ERROR; + RETURN( ERROR); } IntGetClientRect(Window, &rc); @@ -1148,7 +1256,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return ERROR; + RETURN( ERROR); } IntGdiIntersectRect(&rc, &rc, &rect); } @@ -1159,7 +1267,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return ERROR; + RETURN( ERROR); } IntGdiIntersectRect(&cliprc, &rc, &clipRect); } @@ -1169,22 +1277,22 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, if (cliprc.right <= cliprc.left || cliprc.bottom <= cliprc.top || (dx == 0 && dy == 0)) { - return NULLREGION; + RETURN( NULLREGION); } caretrc = rc; - hwndCaret = IntFixCaret(hWnd, &caretrc, flags); + hwndCaret = co_IntFixCaret(hWnd, &caretrc, flags); if (hrgnUpdate) bOwnRgn = FALSE; else if (bUpdate) hrgnUpdate = NtGdiCreateRectRgn(0, 0, 0, 0); - hDC = NtUserGetDCEx(hWnd, 0, DCX_CACHE | DCX_USESTYLE); + hDC = UserGetDCEx(Window, 0, DCX_CACHE | DCX_USESTYLE); if (hDC) { - NtUserScrollDC(hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate); - NtUserReleaseDC(hWnd, hDC); + UserScrollDC(hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate); + UserReleaseDC(Window, hDC); } /* @@ -1193,13 +1301,13 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, */ hrgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0); - Result = NtUserGetUpdateRgn(hWnd, hrgnTemp, FALSE); + Result = co_UserGetUpdateRgn(hWnd, hrgnTemp, FALSE); if (Result != NULLREGION) { HRGN hrgnClip = UnsafeIntCreateRectRgnIndirect(&cliprc); NtGdiOffsetRgn(hrgnTemp, dx, dy); NtGdiCombineRgn(hrgnTemp, hrgnTemp, hrgnClip, RGN_AND); - NtUserRedrawWindow(hWnd, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE); + co_UserRedrawWindow(Window, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE); NtGdiDeleteObject(hrgnClip); } NtGdiDeleteObject(hrgnTemp); @@ -1226,7 +1334,7 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, r.bottom -= ClientOrigin.y; IntReleaseWindowObject(WindowObject); if (! UnsafeRect || IntGdiIntersectRect(&dummy, &r, &rc)) - WinPosSetWindowPos(List[i], 0, r.left + dx, r.top + dy, 0, 0, + co_WinPosSetWindowPos(List[i], 0, r.left + dx, r.top + dy, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW); } @@ -1235,22 +1343,28 @@ NtUserScrollWindowEx(HWND hWnd, INT dx, INT dy, const RECT *UnsafeRect, } if (flags & (SW_INVALIDATE | SW_ERASE)) - NtUserRedrawWindow(hWnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE | + co_UserRedrawWindow(Window, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE | ((flags & SW_ERASE) ? RDW_ERASENOW : 0) | ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0)); if (bOwnRgn && hrgnUpdate) NtGdiDeleteObject(hrgnUpdate); - if (hwndCaret) + if ((CaretWnd = IntGetWindowObject(hwndCaret))) { - IntSetCaretPos(caretrc.left + dx, caretrc.top + dy); - NtUserShowCaret(hwndCaret); + co_IntSetCaretPos(caretrc.left + dx, caretrc.top + dy); + co_UserShowCaret(CaretWnd); + IntReleaseWindowObject(CaretWnd); } IntReleaseWindowObject(Window); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserScrollWindowEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/prop.c b/reactos/subsys/win32k/ntuser/prop.c index fef7f8c374b..740d1fb2864 100644 --- a/reactos/subsys/win32k/ntuser/prop.c +++ b/reactos/subsys/win32k/ntuser/prop.c @@ -72,10 +72,14 @@ NtUserBuildPropList(HWND hWnd, PROPLISTITEM listitem, *li; NTSTATUS Status; DWORD Cnt = 0; + DECLARE_RETURN(NTSTATUS); + + DPRINT("Enter NtUserBuildPropList\n"); + UserEnterShared(); if (!(WindowObject = IntGetWindowObject(hWnd))) { - return STATUS_INVALID_HANDLE; + RETURN( STATUS_INVALID_HANDLE); } if(Buffer) @@ -83,7 +87,7 @@ NtUserBuildPropList(HWND hWnd, if(!BufferSize || (BufferSize % sizeof(PROPLISTITEM) != 0)) { IntReleaseWindowObject(WindowObject); - return STATUS_INVALID_PARAMETER; + RETURN( STATUS_INVALID_PARAMETER); } /* copy list */ @@ -102,7 +106,7 @@ NtUserBuildPropList(HWND hWnd, { IntUnLockWindowProperties(WindowObject); IntReleaseWindowObject(WindowObject); - return Status; + RETURN( Status); } BufferSize -= sizeof(PROPLISTITEM); @@ -127,11 +131,16 @@ NtUserBuildPropList(HWND hWnd, Status = MmCopyToCaller(Count, &Cnt, sizeof(DWORD)); if(!NT_SUCCESS(Status)) { - return Status; + RETURN( Status); } } - return STATUS_SUCCESS; + RETURN( STATUS_SUCCESS); + +CLEANUP: + DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } HANDLE STDCALL @@ -140,11 +149,15 @@ NtUserRemoveProp(HWND hWnd, ATOM Atom) PWINDOW_OBJECT WindowObject; PPROPERTY Prop; HANDLE Data; + DECLARE_RETURN(HANDLE); + + DPRINT("Enter NtUserRemoveProp\n"); + UserEnterExclusive(); if (!(WindowObject = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; + RETURN( NULL); } IntLockWindowProperties(WindowObject); @@ -154,7 +167,7 @@ NtUserRemoveProp(HWND hWnd, ATOM Atom) { IntUnLockWindowProperties(WindowObject); IntReleaseWindowObject(WindowObject); - return(NULL); + RETURN(NULL); } Data = Prop->Data; RemoveEntryList(&Prop->PropListEntry); @@ -162,7 +175,12 @@ NtUserRemoveProp(HWND hWnd, ATOM Atom) WindowObject->PropListItems--; IntUnLockWindowProperties(WindowObject); IntReleaseWindowObject(WindowObject); - return(Data); + RETURN(Data); + +CLEANUP: + DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } HANDLE STDCALL @@ -171,11 +189,15 @@ NtUserGetProp(HWND hWnd, ATOM Atom) PWINDOW_OBJECT WindowObject; PPROPERTY Prop; HANDLE Data = NULL; + DECLARE_RETURN(HANDLE); + + DPRINT("Enter NtUserGetProp\n"); + UserEnterShared(); if (!(WindowObject = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } IntLockWindowProperties(WindowObject); @@ -186,7 +208,12 @@ NtUserGetProp(HWND hWnd, ATOM Atom) } IntUnLockWindowProperties(WindowObject); IntReleaseWindowObject(WindowObject); - return(Data); + RETURN(Data); + +CLEANUP: + DPRINT("Leave NtUserGetProp, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL FASTCALL @@ -218,11 +245,15 @@ NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data) { PWINDOW_OBJECT WindowObject; BOOL ret; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetProp\n"); + UserEnterExclusive(); if (!(WindowObject = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } IntLockWindowProperties(WindowObject); @@ -230,7 +261,12 @@ NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data) IntUnLockWindowProperties(WindowObject); IntReleaseWindowObject(WindowObject); - return ret; + RETURN( ret); + +CLEANUP: + DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/scrollbar.c b/reactos/subsys/win32k/ntuser/scrollbar.c index f93dbf6bc3d..c0113072de2 100644 --- a/reactos/subsys/win32k/ntuser/scrollbar.c +++ b/reactos/subsys/win32k/ntuser/scrollbar.c @@ -69,7 +69,7 @@ IntGetScrollBarRect (PWINDOW_OBJECT Window, INT nBar, PRECT lprect) lprect->left = ClientRect.left - WindowRect.left; lprect->top = ClientRect.bottom - WindowRect.top; lprect->right = ClientRect.right - WindowRect.left; - lprect->bottom = lprect->top + NtUserGetSystemMetrics (SM_CYHSCROLL); + lprect->bottom = lprect->top + UserGetSystemMetrics (SM_CYHSCROLL); vertical = FALSE; break; @@ -77,12 +77,12 @@ IntGetScrollBarRect (PWINDOW_OBJECT Window, INT nBar, PRECT lprect) if(Window->ExStyle & WS_EX_LEFTSCROLLBAR) { lprect->right = ClientRect.left - WindowRect.left; - lprect->left = lprect->right - NtUserGetSystemMetrics(SM_CXVSCROLL); + lprect->left = lprect->right - UserGetSystemMetrics(SM_CXVSCROLL); } else { lprect->left = ClientRect.right - WindowRect.left; - lprect->right = lprect->left + NtUserGetSystemMetrics(SM_CXVSCROLL); + lprect->right = lprect->left + UserGetSystemMetrics(SM_CXVSCROLL); } lprect->top = ClientRect.top - WindowRect.top; lprect->bottom = ClientRect.bottom - WindowRect.top; @@ -111,23 +111,23 @@ IntCalculateThumb(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi, LPS switch(idObject) { case SB_HORZ: - Thumb = NtUserGetSystemMetrics(SM_CXHSCROLL); + Thumb = UserGetSystemMetrics(SM_CXHSCROLL); cxy = psbi->rcScrollBar.right - psbi->rcScrollBar.left; break; case SB_VERT: - Thumb = NtUserGetSystemMetrics(SM_CYVSCROLL); + Thumb = UserGetSystemMetrics(SM_CYVSCROLL); cxy = psbi->rcScrollBar.bottom - psbi->rcScrollBar.top; break; case SB_CTL: IntGetClientRect (Window, &ClientRect); if(Window->Style & SBS_VERT) { - Thumb = NtUserGetSystemMetrics(SM_CYVSCROLL); + Thumb = UserGetSystemMetrics(SM_CYVSCROLL); cxy = ClientRect.bottom - ClientRect.top; } else { - Thumb = NtUserGetSystemMetrics(SM_CXHSCROLL); + Thumb = UserGetSystemMetrics(SM_CXHSCROLL); cxy = ClientRect.right - ClientRect.left; } break; @@ -146,7 +146,7 @@ IntCalculateThumb(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi, LPS } else { - ThumbBox = psi->nPage ? MINTRACKTHUMB : NtUserGetSystemMetrics(SM_CXHTHUMB); + ThumbBox = psi->nPage ? MINTRACKTHUMB : UserGetSystemMetrics(SM_CXHTHUMB); cxy -= (2 * Thumb); if(cxy >= ThumbBox) { @@ -194,7 +194,7 @@ IntUpdateSBInfo(PWINDOW_OBJECT Window, int wBar) } static BOOL FASTCALL -IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi) +co_IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi) { UINT Mask; LPSCROLLINFO psi; @@ -206,7 +206,7 @@ IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi) return FALSE; } - if(!IntCreateScrollBars(Window)) + if(!co_IntCreateScrollBars(Window)) { return FALSE; } @@ -247,7 +247,7 @@ IntGetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPSCROLLINFO lpsi) } static DWORD FASTCALL -IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) +co_IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedraw) { /* * Update the scrollbar state and set action flags according to @@ -266,7 +266,7 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedr return FALSE; } - if(!IntCreateScrollBars(Window)) + if(!co_IntCreateScrollBars(Window)) { return FALSE; } @@ -365,7 +365,7 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedr } else if ((nBar != SB_CTL) && bChangeParams) { - NtUserShowScrollBar(Window->Self, nBar, FALSE); + co_UserShowScrollBar(Window->Self, nBar, FALSE); return Info->nPos; } } @@ -374,7 +374,7 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedr /* new_flags = 0;*/ if ((nBar != SB_CTL) && bChangeParams) { - NtUserShowScrollBar(Window->Self, nBar, TRUE); + co_UserShowScrollBar(Window->Self, nBar, TRUE); } } @@ -394,7 +394,7 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedr UpdateRect.right -= Window->ClientRect.left - Window->WindowRect.left; UpdateRect.top -= Window->ClientRect.top - Window->WindowRect.top; UpdateRect.bottom -= Window->ClientRect.top - Window->WindowRect.top; - IntRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); + co_UserRedrawWindow(Window, &UpdateRect, 0, RDW_INVALIDATE | RDW_FRAME); } /* Return current position */ @@ -402,7 +402,7 @@ IntSetScrollInfo(PWINDOW_OBJECT Window, INT nBar, LPCSCROLLINFO lpsi, BOOL bRedr } BOOL FASTCALL -IntGetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi) +co_IntGetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi) { INT Bar; PSCROLLBARINFO sbi; @@ -417,7 +417,7 @@ IntGetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi) return FALSE; } - if(!IntCreateScrollBars(Window)) + if(!co_IntCreateScrollBars(Window)) { return FALSE; } @@ -434,7 +434,7 @@ IntGetScrollBarInfo(PWINDOW_OBJECT Window, LONG idObject, PSCROLLBARINFO psbi) } BOOL FASTCALL -IntCreateScrollBars(PWINDOW_OBJECT Window) +co_IntCreateScrollBars(PWINDOW_OBJECT Window) { PSCROLLBARINFO psbi; LPSCROLLINFO psi; @@ -458,7 +458,7 @@ IntCreateScrollBars(PWINDOW_OBJECT Window) RtlZeroMemory(Window->Scroll, Size); - Result = WinPosGetNonClientSize(Window->Self, + Result = co_WinPosGetNonClientSize(Window->Self, &Window->WindowRect, &Window->ClientRect); @@ -539,12 +539,16 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi) SCROLLBARINFO sbi; PWINDOW_OBJECT Window; BOOL Ret; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetScrollBarInfo\n"); + UserEnterExclusive(); Status = MmCopyFromCaller(&sbi, psbi, sizeof(SCROLLBARINFO)); if(!NT_SUCCESS(Status) || (sbi.cbSize != sizeof(SCROLLBARINFO))) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } Window = IntGetWindowObject(hWnd); @@ -552,10 +556,10 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi) if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } - Ret = IntGetScrollBarInfo(Window, idObject, &sbi); + Ret = co_IntGetScrollBarInfo(Window, idObject, &sbi); Status = MmCopyToCaller(psbi, &sbi, sizeof(SCROLLBARINFO)); if(!NT_SUCCESS(Status)) @@ -564,7 +568,13 @@ NtUserGetScrollBarInfo(HWND hWnd, LONG idObject, PSCROLLBARINFO psbi) Ret = FALSE; } IntReleaseWindowObject(Window); - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserGetScrollBarInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + } @@ -577,20 +587,24 @@ NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi) SCROLLINFO psi; DWORD sz; BOOL Ret; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetScrollInfo\n"); + UserEnterShared(); Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT)); if(!NT_SUCCESS(Status) || !((psi.cbSize == sizeof(SCROLLINFO)) || (psi.cbSize == sizeof(SCROLLINFO) - sizeof(psi.nTrackPos)))) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } sz = psi.cbSize; Status = MmCopyFromCaller(&psi, lpsi, sz); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } Window = IntGetWindowObject(hwnd); @@ -598,10 +612,10 @@ NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi) if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } - Ret = IntGetScrollInfo(Window, fnBar, &psi); + Ret = co_IntGetScrollInfo(Window, fnBar, &psi); IntReleaseWindowObject(Window); @@ -609,10 +623,15 @@ NtUserGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi) if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserGetScrollInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -626,13 +645,17 @@ NtUserEnableScrollBar( PWINDOW_OBJECT Window; PSCROLLBARINFO InfoV = NULL, InfoH = NULL; BOOL Chg = FALSE; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserEnableScrollBar\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hWnd); if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if(wSBflags == SB_CTL) @@ -643,7 +666,7 @@ NtUserEnableScrollBar( Chg = IntEnableScrollBar(FALSE, InfoV ,wArrows); /* Chg? Scrollbar is Refresh in user32/controls/scrollbar.c. */ IntReleaseWindowObject(Window); - return TRUE; + RETURN( TRUE); } if(wSBflags != SB_BOTH && !SBID_IS_VALID(wSBflags)) @@ -651,13 +674,13 @@ NtUserEnableScrollBar( IntReleaseWindowObject(Window); SetLastWin32Error(ERROR_INVALID_PARAMETER); DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", wSBflags); - return FALSE; + RETURN( FALSE); } - if(!IntCreateScrollBars(Window)) + if(!co_IntCreateScrollBars(Window)) { IntReleaseWindowObject(Window); - return FALSE; + RETURN( FALSE); } switch(wSBflags) @@ -673,7 +696,7 @@ NtUserEnableScrollBar( break; default: IntReleaseWindowObject(Window); - return FALSE; + RETURN( FALSE); } if(InfoV) @@ -686,7 +709,13 @@ NtUserEnableScrollBar( /* FIXME - repaint scrollbars */ IntReleaseWindowObject(Window); - return TRUE; + RETURN( TRUE); + + +CLEANUP: + DPRINT("Leave NtUserEnableScrollBar, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } BOOL @@ -702,13 +731,17 @@ NtUserSetScrollBarInfo( LPSCROLLINFO psi; NTSTATUS Status; LONG Obj; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetScrollBarInfo\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hwnd); if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Obj = SBOBJ_TO_SBID(idObject); @@ -717,13 +750,13 @@ NtUserSetScrollBarInfo( IntReleaseWindowObject(Window); SetLastWin32Error(ERROR_INVALID_PARAMETER); DPRINT1("Trying to set scrollinfo for unknown scrollbar type %d", Obj); - return FALSE; + RETURN( FALSE); } - if(!IntCreateScrollBars(Window)) + if(!co_IntCreateScrollBars(Window)) { IntReleaseWindowObject(Window); - return FALSE; + RETURN(FALSE); } Status = MmCopyFromCaller(&Safeinfo, info, sizeof(SETSCROLLBARINFO)); @@ -731,7 +764,7 @@ NtUserSetScrollBarInfo( { IntReleaseWindowObject(Window); SetLastNtError(Status); - return FALSE; + RETURN(FALSE); } sbi = IntGetScrollbarInfoFromWindow(Window, Obj); @@ -742,7 +775,12 @@ NtUserSetScrollBarInfo( RtlCopyMemory(&sbi->rgstate, &Safeinfo.rgstate, sizeof(Safeinfo.rgstate)); IntReleaseWindowObject(Window); - return TRUE; + RETURN(TRUE); + +CLEANUP: + DPRINT("Leave NtUserSetScrollBarInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD @@ -757,13 +795,17 @@ NtUserSetScrollInfo( NTSTATUS Status; SCROLLINFO ScrollInfo; DWORD Ret; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserSetScrollInfo\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hwnd); if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } Status = MmCopyFromCaller(&ScrollInfo, lpsi, sizeof(SCROLLINFO) - sizeof(ScrollInfo.nTrackPos)); @@ -771,18 +813,24 @@ NtUserSetScrollInfo( { IntReleaseWindowObject(Window); SetLastNtError(Status); - return 0; + RETURN( 0); } - Ret = IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw); + Ret = co_IntSetScrollInfo(Window, fnBar, &ScrollInfo, bRedraw); IntReleaseWindowObject(Window); - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserSetScrollInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + } /* Ported from WINE20020904 (SCROLL_ShowScrollBar) */ -DWORD STDCALL -NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow) +DWORD FASTCALL +co_UserShowScrollBar(HWND hWnd, int wBar, DWORD bShow) { DWORD Style, OldStyle; PWINDOW_OBJECT Window = IntGetWindowObject(hWnd); @@ -790,7 +838,7 @@ NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow) if (!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + return( FALSE); } switch(wBar) @@ -810,22 +858,22 @@ NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow) default: IntReleaseWindowObject(Window); SetLastWin32Error(ERROR_INVALID_PARAMETER); - return FALSE; + return( FALSE); } - if(!IntCreateScrollBars(Window)) + if(!co_IntCreateScrollBars(Window)) { IntReleaseWindowObject(Window); - return FALSE; + return( FALSE); } if (wBar == SB_CTL) { IntUpdateSBInfo(Window, SB_CTL); - WinPosShowWindow(hWnd, bShow ? SW_SHOW : SW_HIDE); + co_WinPosShowWindow(hWnd, bShow ? SW_SHOW : SW_HIDE); IntReleaseWindowObject(Window); - return TRUE; + return( TRUE); } OldStyle = Window->Style; @@ -844,13 +892,30 @@ NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow) if(Window->Style & WS_VISIBLE) { /* Frame has been changed, let the window redraw itself */ - WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + co_WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING); } } IntReleaseWindowObject(Window); - return TRUE; + return( TRUE); } + +DWORD STDCALL +NtUserShowScrollBar(HWND hWnd, int wBar, DWORD bShow) +{ + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserShowScrollBar\n"); + UserEnterExclusive(); + + RETURN(co_UserShowScrollBar(hWnd, wBar, bShow)); + +CLEANUP: + DPRINT("Leave NtUserShowScrollBar, ret%i\n",_ret_); + UserLeave(); + END_CLEANUP; + +} /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/timer.c b/reactos/subsys/win32k/ntuser/timer.c index ebc8473aef4..340ad14b27a 100644 --- a/reactos/subsys/win32k/ntuser/timer.c +++ b/reactos/subsys/win32k/ntuser/timer.c @@ -204,7 +204,17 @@ NtUserSetTimer TIMERPROC lpTimerFunc ) { - return IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, FALSE); + DECLARE_RETURN(UINT_PTR); + + DPRINT("Enter NtUserSetTimer\n"); + UserEnterExclusive(); + + RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, FALSE)); + +CLEANUP: + DPRINT("Leave NtUserSetTimer, ret=%i\n", _ret_); + UserLeave(); + END_CLEANUP; } @@ -216,7 +226,17 @@ NtUserKillTimer UINT_PTR uIDEvent ) { - return IntKillTimer(hWnd, uIDEvent, FALSE); + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserKillTimer\n"); + UserEnterExclusive(); + + RETURN(IntKillTimer(hWnd, uIDEvent, FALSE)); + +CLEANUP: + DPRINT("Leave NtUserKillTimer, ret=%i\n", _ret_); + UserLeave(); + END_CLEANUP; } @@ -229,7 +249,17 @@ NtUserSetSystemTimer( TIMERPROC lpTimerFunc ) { - return IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, TRUE); + DECLARE_RETURN(UINT_PTR); + + DPRINT("Enter NtUserSetSystemTimer\n"); + UserEnterExclusive(); + + RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, TRUE)); + +CLEANUP: + DPRINT("Leave NtUserSetSystemTimer, ret=%i\n", _ret_); + UserLeave(); + END_CLEANUP; } @@ -240,7 +270,17 @@ NtUserKillSystemTimer( UINT_PTR uIDEvent ) { - return IntKillTimer(hWnd, uIDEvent, TRUE); + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserKillSystemTimer\n"); + UserEnterExclusive(); + + RETURN(IntKillTimer(hWnd, uIDEvent, TRUE)); + +CLEANUP: + DPRINT("Leave NtUserKillSystemTimer, ret=%i\n", _ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/vis.c b/reactos/subsys/win32k/ntuser/vis.c index 1916ea2e1b8..c6187c9aa36 100644 --- a/reactos/subsys/win32k/ntuser/vis.c +++ b/reactos/subsys/win32k/ntuser/vis.c @@ -156,7 +156,7 @@ VIS_ComputeVisibleRegion( } VOID FASTCALL -VIS_WindowLayoutChanged( +co_VIS_WindowLayoutChanged( PWINDOW_OBJECT Window, HRGN NewlyExposed) { @@ -172,7 +172,7 @@ VIS_WindowLayoutChanged( NtGdiOffsetRgn(Temp, Window->WindowRect.left - Parent->ClientRect.left, Window->WindowRect.top - Parent->ClientRect.top); - IntRedrawWindow(Parent, NULL, Temp, + co_UserRedrawWindow(Parent, NULL, Temp, RDW_FRAME | RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN); IntReleaseWindowObject(Parent); diff --git a/reactos/subsys/win32k/ntuser/windc.c b/reactos/subsys/win32k/ntuser/windc.c index f3c61b628ec..88267018aad 100644 --- a/reactos/subsys/win32k/ntuser/windc.c +++ b/reactos/subsys/win32k/ntuser/windc.c @@ -109,6 +109,12 @@ NtUserGetWindowDC(HWND hWnd) return (DWORD)NtUserGetDCEx(hWnd, 0, DCX_USESTYLE | DCX_WINDOW); } +DWORD FASTCALL +UserGetWindowDC(PWINDOW_OBJECT Wnd) +{ + return (DWORD)UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW); +} + HDC STDCALL NtUserGetDC(HWND hWnd) { @@ -365,23 +371,18 @@ noparent: } } -HDC STDCALL -NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) +HDC FASTCALL +UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags) { - PWINDOW_OBJECT Window, Parent; + PWINDOW_OBJECT Parent; ULONG DcxFlags; DCE* Dce; BOOL UpdateVisRgn = TRUE; BOOL UpdateClipOrigin = FALSE; - if (NULL == hWnd) + if (NULL == Window) { Flags &= ~DCX_USESTYLE; - Window = NULL; - } - else if (NULL == (Window = IntGetWindowObject(hWnd))) - { - return(0); } if (NULL == Window || NULL == Window->Dce) @@ -470,7 +471,7 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) { DceEmpty = Dce; } - else if (Dce->hwndCurrent == hWnd && + else if (Dce->hwndCurrent == (Window ? Window->Self : NULL) && ((Dce->DCXFlags & DCX_CACHECOMPAREMASK) == DcxFlags)) { #if 0 /* FIXME */ @@ -497,7 +498,7 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) else { Dce = Window->Dce; - if (NULL != Dce && Dce->hwndCurrent == hWnd) + if (NULL != Dce && Dce->hwndCurrent == (Window ? Window->Self : NULL)) { UpdateVisRgn = FALSE; /* updated automatically, via DCHook() */ } @@ -508,12 +509,10 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) if (NULL == Dce) { - if(NULL != Window) - IntReleaseWindowObject(Window); return(NULL); } - Dce->hwndCurrent = hWnd; + Dce->hwndCurrent = (Window ? Window->Self : NULL); Dce->DCXFlags = DcxFlags | (Flags & DCX_WINDOWPAINT) | DCX_DCEBUSY; if (0 == (Flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN)) && NULL != ClipRegion) @@ -596,14 +595,44 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) DceUpdateVisRgn(Dce, Window, Flags); } - if (NULL != Window) - { - IntReleaseWindowObject(Window); - } - return(Dce->hDC); } + + +HDC STDCALL +NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) +{ + PWINDOW_OBJECT Wnd=NULL; + DECLARE_RETURN(HDC); + HDC ret; + + DPRINT("Enter NtUserGetDCEx\n"); + UserEnterExclusive(); + + if (hWnd) + { + if (!(Wnd = IntGetWindowObject(hWnd))) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + RETURN(NULL); + } + } + + ret = UserGetDCEx(Wnd, ClipRegion, Flags); + + if (Wnd) IntReleaseWindowObject(Wnd); + + RETURN(ret); + +CLEANUP: + DPRINT("Leave NtUserGetDCEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody) { @@ -653,8 +682,9 @@ IntWindowFromDC(HDC hDc) return 0; } -INT STDCALL -NtUserReleaseDC(HWND hWnd, HDC hDc) + +INT FASTCALL +UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc) { DCE *dce; INT nRet = 0; @@ -663,7 +693,7 @@ NtUserReleaseDC(HWND hWnd, HDC hDc) dce = FirstDce; - DPRINT("%p %p\n", hWnd, hDc); + DPRINT("%p %p\n", Window, hDc); while (dce && (dce->hDC != hDc)) { @@ -680,6 +710,24 @@ NtUserReleaseDC(HWND hWnd, HDC hDc) return nRet; } + + +INT STDCALL +NtUserReleaseDC(HWND hWnd, HDC hDc) +{ + DECLARE_RETURN(INT); + + DPRINT("Enter NtUserReleaseDC\n"); + UserEnterExclusive(); + + RETURN(UserReleaseDC(NULL, hDc)); + +CLEANUP: + DPRINT("Leave NtUserReleaseDC, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + /*********************************************************************** * DceFreeDCE */ diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index f0790e5b4b4..16018dd5f5d 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -240,7 +240,7 @@ static void IntSendDestroyMsg(HWND Wnd) if (!Owner) { Parent = IntGetParent(Window); if (!Parent) - IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM) Wnd); + co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM) Wnd); else IntReleaseWindowObject(Parent); } else { @@ -256,7 +256,7 @@ static void IntSendDestroyMsg(HWND Wnd) * Send the WM_DESTROY to the window. */ - IntSendMessage(Wnd, WM_DESTROY, 0, 0); + co_IntSendMessage(Wnd, WM_DESTROY, 0, 0); /* * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow @@ -291,7 +291,7 @@ static void IntSendDestroyMsg(HWND Wnd) * * Destroy storage associated to a window. "Internals" p.358 */ -static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, +static LRESULT co_IntDestroyWindow(PWINDOW_OBJECT Window, PW32PROCESS ProcessData, PW32THREAD ThreadData, BOOLEAN SendMessages) @@ -343,7 +343,7 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, IntSendDestroyMsg(Child->Self); } else - IntDestroyWindow(Child, ProcessData, ThreadData, SendMessages); + co_IntDestroyWindow(Child, ProcessData, ThreadData, SendMessages); IntReleaseWindowObject(Child); } } @@ -356,11 +356,11 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, * Clear the update region to make sure no WM_PAINT messages will be * generated for this window while processing the WM_NCDESTROY. */ - IntRedrawWindow(Window, NULL, 0, + co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_NOCHILDREN); if(BelongsToThreadData) - IntSendMessage(Window->Self, WM_NCDESTROY, 0, 0); + co_IntSendMessage(Window->Self, WM_NCDESTROY, 0, 0); } MsqRemoveTimersWindow(ThreadData->MessageQueue, Window->Self); @@ -454,20 +454,20 @@ IntGetWindowBorderMeasures(PWINDOW_OBJECT WindowObject, UINT *cx, UINT *cy) { if(HAS_DLGFRAME(WindowObject->Style, WindowObject->ExStyle) && !(WindowObject->Style & WS_MINIMIZE)) { - *cx = NtUserGetSystemMetrics(SM_CXDLGFRAME); - *cy = NtUserGetSystemMetrics(SM_CYDLGFRAME); + *cx = UserGetSystemMetrics(SM_CXDLGFRAME); + *cy = UserGetSystemMetrics(SM_CYDLGFRAME); } else { if(HAS_THICKFRAME(WindowObject->Style, WindowObject->ExStyle)&& !(WindowObject->Style & WS_MINIMIZE)) { - *cx = NtUserGetSystemMetrics(SM_CXFRAME); - *cy = NtUserGetSystemMetrics(SM_CYFRAME); + *cx = UserGetSystemMetrics(SM_CXFRAME); + *cy = UserGetSystemMetrics(SM_CYFRAME); } else if(HAS_THINFRAME(WindowObject->Style, WindowObject->ExStyle)) { - *cx = NtUserGetSystemMetrics(SM_CXBORDER); - *cy = NtUserGetSystemMetrics(SM_CYBORDER); + *cx = UserGetSystemMetrics(SM_CXBORDER); + *cy = UserGetSystemMetrics(SM_CYBORDER); } else { @@ -484,7 +484,7 @@ IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi) pwi->rcClient = WindowObject->ClientRect; pwi->dwStyle = WindowObject->Style; pwi->dwExStyle = WindowObject->ExStyle; - pwi->dwWindowStatus = (NtUserGetForegroundWindow() == WindowObject->Self); /* WS_ACTIVECAPTION */ + pwi->dwWindowStatus = (UserGetForegroundWindow() == WindowObject->Self); /* WS_ACTIVECAPTION */ IntGetWindowBorderMeasures(WindowObject, &pwi->cxWindowBorders, &pwi->cyWindowBorders); pwi->atomWindowType = (WindowObject->Class ? WindowObject->Class->Atom : 0); pwi->wCreatorVersion = 0x400; /* FIXME - return a real version number */ @@ -566,7 +566,7 @@ IntSetMenu( VOID FASTCALL -DestroyThreadWindows(struct _ETHREAD *Thread) +co_DestroyThreadWindows(struct _ETHREAD *Thread) { PLIST_ENTRY Current; PW32PROCESS Win32Process; @@ -608,7 +608,7 @@ DestroyThreadWindows(struct _ETHREAD *Thread) for(pWnd = List; *pWnd; pWnd++) { - NtUserDestroyWindow((*pWnd)->Self); + co_UserDestroyWindow(*pWnd); IntReleaseWindowObject(*pWnd); } ExFreePool(List); @@ -702,7 +702,7 @@ IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu) } else { - SysMenu = NtUserCreateMenu(FALSE); + SysMenu = UserCreateMenu(FALSE); if (NULL == SysMenu) { return NULL; @@ -710,23 +710,23 @@ IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu) SysMenuObject = IntGetMenuObject(SysMenu); if (NULL == SysMenuObject) { - NtUserDestroyMenu(SysMenu); + UserDestroyMenu(SysMenu); return NULL; } SysMenuObject->MenuInfo.Flags |= MF_SYSMENU; SysMenuObject->MenuInfo.Wnd = WindowObject->Self; - NewMenu = IntLoadSysMenuTemplate(); + NewMenu = co_IntLoadSysMenuTemplate(); if(!NewMenu) { IntReleaseMenuObject(SysMenuObject); - NtUserDestroyMenu(SysMenu); + UserDestroyMenu(SysMenu); return NULL; } MenuObject = IntGetMenuObject(NewMenu); if(!MenuObject) { IntReleaseMenuObject(SysMenuObject); - NtUserDestroyMenu(SysMenu); + UserDestroyMenu(SysMenu); return NULL; } @@ -735,7 +735,7 @@ IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu) { NewMenuObject->MenuInfo.Flags |= MF_SYSMENU | MF_POPUP; IntReleaseMenuObject(NewMenuObject); - NtUserSetMenuDefaultItem(NewMenuObject->MenuInfo.Self, SC_CLOSE, FALSE); + UserSetMenuDefaultItem(NewMenuObject->MenuInfo.Self, SC_CLOSE, FALSE); ItemInfo.cbSize = sizeof(MENUITEMINFOW); ItemInfo.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU; @@ -958,7 +958,7 @@ IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) * Windows hides the window first, then shows it again * including the WM_SHOWWINDOW messages and all */ - WasVisible = WinPosShowWindow(hWnd, SW_HIDE); + WasVisible = co_WinPosShowWindow(hWnd, SW_HIDE); /* Validate that window and parent still exist */ if (!IntIsWindow(hWnd) || !IntIsWindow(hWndNewParent)) @@ -1013,7 +1013,7 @@ IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) * in the z-order and send the expected WM_WINDOWPOSCHANGING and * WM_WINDOWPOSCHANGED notification messages. */ - WinPosSetWindowPos(hWnd, (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST), + co_WinPosSetWindowPos(hWnd, (0 == (Wnd->ExStyle & WS_EX_TOPMOST) ? HWND_TOP : HWND_TOPMOST), 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | (WasVisible ? SWP_SHOWWINDOW : 0)); @@ -1389,8 +1389,8 @@ IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT WindowObject, RECT *rc, if(IncPos) { - Pos.x = Parent->TiledCounter * (NtUserGetSystemMetrics(SM_CXSIZE) + NtUserGetSystemMetrics(SM_CXFRAME)); - Pos.y = Parent->TiledCounter * (NtUserGetSystemMetrics(SM_CYSIZE) + NtUserGetSystemMetrics(SM_CYFRAME)); + Pos.x = Parent->TiledCounter * (UserGetSystemMetrics(SM_CXSIZE) + UserGetSystemMetrics(SM_CXFRAME)); + Pos.y = Parent->TiledCounter * (UserGetSystemMetrics(SM_CYSIZE) + UserGetSystemMetrics(SM_CYFRAME)); if(Pos.x > ((rc->right - rc->left) / 4) || Pos.y > ((rc->bottom - rc->top) / 4)) { @@ -1425,7 +1425,7 @@ IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT WindowObject, RECT *rc, * @implemented */ HWND STDCALL -IntCreateWindowEx(DWORD dwExStyle, +co_IntCreateWindowEx(DWORD dwExStyle, PUNICODE_STRING ClassName, PUNICODE_STRING WindowName, DWORD dwStyle, @@ -1479,7 +1479,7 @@ IntCreateWindowEx(DWORD dwExStyle, if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD) ParentWindowHandle = hWndParent; else - OwnerWindowHandle = NtUserGetAncestor(hWndParent, GA_ROOT); + OwnerWindowHandle = UserGetAncestor(hWndParent, GA_ROOT); } else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD) { @@ -1722,7 +1722,7 @@ IntCreateWindowEx(DWORD dwExStyle, Cs.dwExStyle = dwExStyle; CbtCreate.lpcs = &Cs; CbtCreate.hwndInsertAfter = HWND_TOP; - if (HOOK_CallHooks(WH_CBT, HCBT_CREATEWND, (WPARAM) Handle, (LPARAM) &CbtCreate)) + if (co_HOOK_CallHooks(WH_CBT, HCBT_CREATEWND, (WPARAM) Handle, (LPARAM) &CbtCreate)) { if (NULL != ParentWindow) { @@ -1837,7 +1837,7 @@ IntCreateWindowEx(DWORD dwExStyle, POINT MaxSize, MaxPos, MinTrack, MaxTrack; /* WinPosGetMinMaxInfo sends the WM_GETMINMAXINFO message */ - WinPosGetMinMaxInfo(WindowObject, &MaxSize, &MaxPos, &MinTrack, + co_WinPosGetMinMaxInfo(WindowObject, &MaxSize, &MaxPos, &MinTrack, &MaxTrack); if (MaxSize.x < nWidth) nWidth = MaxSize.x; if (MaxSize.y < nHeight) nHeight = MaxSize.y; @@ -1869,7 +1869,7 @@ IntCreateWindowEx(DWORD dwExStyle, DPRINT("[win32k.window] IntCreateWindowEx style %d, exstyle %d, parent %d\n", Cs.style, Cs.dwExStyle, Cs.hwndParent); DPRINT("IntCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight); DPRINT("IntCreateWindowEx(): About to send NCCREATE message.\n"); - Result = IntSendMessage(WindowObject->Self, WM_NCCREATE, 0, (LPARAM) &Cs); + Result = co_IntSendMessage(WindowObject->Self, WM_NCCREATE, 0, (LPARAM) &Cs); if (!Result) { /* FIXME: Cleanup. */ @@ -1886,7 +1886,7 @@ IntCreateWindowEx(DWORD dwExStyle, MaxPos.y = WindowObject->WindowRect.top; DPRINT("IntCreateWindowEx(): About to get non-client size.\n"); /* WinPosGetNonClientSize SENDS THE WM_NCCALCSIZE message */ - Result = WinPosGetNonClientSize(WindowObject->Self, + Result = co_WinPosGetNonClientSize(WindowObject->Self, &WindowObject->WindowRect, &WindowObject->ClientRect); IntGdiOffsetRect(&WindowObject->WindowRect, @@ -1942,7 +1942,7 @@ IntCreateWindowEx(DWORD dwExStyle, /* Send the WM_CREATE message. */ DPRINT("IntCreateWindowEx(): about to send CREATE message.\n"); - Result = IntSendMessage(WindowObject->Self, WM_CREATE, 0, (LPARAM) &Cs); + Result = co_IntSendMessage(WindowObject->Self, WM_CREATE, 0, (LPARAM) &Cs); if (Result == (LRESULT)-1) { /* FIXME: Cleanup. */ @@ -1972,7 +1972,7 @@ IntCreateWindowEx(DWORD dwExStyle, WindowObject->ClientRect.left, WindowObject->ClientRect.bottom - WindowObject->ClientRect.top); - IntSendMessage(WindowObject->Self, WM_SIZE, SIZE_RESTORED, + co_IntSendMessage(WindowObject->Self, WM_SIZE, SIZE_RESTORED, lParam); DPRINT("IntCreateWindow(): About to send WM_MOVE\n"); @@ -1987,7 +1987,7 @@ IntCreateWindowEx(DWORD dwExStyle, lParam = MAKE_LONG(WindowObject->ClientRect.left, WindowObject->ClientRect.top); } - IntSendMessage(WindowObject->Self, WM_MOVE, 0, lParam); + co_IntSendMessage(WindowObject->Self, WM_MOVE, 0, lParam); /* Call WNDOBJ change procs */ IntEngWindowChanged(WindowObject, WOC_RGN_CLIENT); @@ -2001,14 +2001,14 @@ IntCreateWindowEx(DWORD dwExStyle, SwFlag = (WindowObject->Style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE; - WinPosMinMaximize(WindowObject, SwFlag, &NewPos); + co_WinPosMinMaximize(WindowObject, SwFlag, &NewPos); SwFlag = - ((WindowObject->Style & WS_CHILD) || NtUserGetActiveWindow()) ? + ((WindowObject->Style & WS_CHILD) || UserGetActiveWindow()) ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED : SWP_NOZORDER | SWP_FRAMECHANGED; DPRINT("IntCreateWindow(): About to minimize/maximize\n"); DPRINT("%d,%d %dx%d\n", NewPos.left, NewPos.top, NewPos.right, NewPos.bottom); - WinPosSetWindowPos(WindowObject->Self, 0, NewPos.left, NewPos.top, + co_WinPosSetWindowPos(WindowObject->Self, 0, NewPos.left, NewPos.top, NewPos.right, NewPos.bottom, SwFlag); } @@ -2017,7 +2017,7 @@ IntCreateWindowEx(DWORD dwExStyle, (!(WindowObject->ExStyle & WS_EX_NOPARENTNOTIFY)) && ParentWindow) { DPRINT("IntCreateWindow(): About to notify parent\n"); - IntSendMessage(ParentWindow->Self, + co_IntSendMessage(ParentWindow->Self, WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, WindowObject->IDMenu), (LPARAM)WindowObject->Self); @@ -2025,7 +2025,7 @@ IntCreateWindowEx(DWORD dwExStyle, if ((!hWndParent) && (!HasOwner)) { DPRINT("Sending CREATED notify\n"); - IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Handle); + co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Handle); } else { DPRINT("Not sending CREATED notify, %x %d\n", ParentWindow, HasOwner); } @@ -2038,17 +2038,17 @@ IntCreateWindowEx(DWORD dwExStyle, /* Initialize and show the window's scrollbars */ if (WindowObject->Style & WS_VSCROLL) { - NtUserShowScrollBar(WindowObject->Self, SB_VERT, TRUE); + co_UserShowScrollBar(WindowObject->Self, SB_VERT, TRUE); } if (WindowObject->Style & WS_HSCROLL) { - NtUserShowScrollBar(WindowObject->Self, SB_HORZ, TRUE); + co_UserShowScrollBar(WindowObject->Self, SB_HORZ, TRUE); } if (dwStyle & WS_VISIBLE) { DPRINT("IntCreateWindow(): About to show window\n"); - WinPosShowWindow(WindowObject->Self, dwShowMode); + co_WinPosShowWindow(WindowObject->Self, dwShowMode); } DPRINT("IntCreateWindow(): = %X\n", Handle); @@ -2076,15 +2076,17 @@ NtUserCreateWindowEx(DWORD dwExStyle, UNICODE_STRING WindowName; UNICODE_STRING ClassName; HWND NewWindow; + DECLARE_RETURN(HWND); - DPRINT("NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight); + DPRINT("Enter NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight); + UserEnterExclusive(); /* Get the class name (string or atom) */ Status = MmCopyFromCaller(&ClassName, UnsafeClassName, sizeof(UNICODE_STRING)); if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return NULL; + RETURN( NULL); } if (! IS_ATOM(ClassName.Buffer)) { @@ -2092,7 +2094,7 @@ NtUserCreateWindowEx(DWORD dwExStyle, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - return NULL; + RETURN( NULL); } } @@ -2107,7 +2109,7 @@ NtUserCreateWindowEx(DWORD dwExStyle, RtlFreeUnicodeString(&ClassName); } SetLastNtError(Status); - return NULL; + RETURN( NULL); } } else @@ -2115,7 +2117,7 @@ NtUserCreateWindowEx(DWORD dwExStyle, RtlInitUnicodeString(&WindowName, NULL); } - NewWindow = IntCreateWindowEx(dwExStyle, &ClassName, &WindowName, dwStyle, x, y, nWidth, nHeight, + NewWindow = co_IntCreateWindowEx(dwExStyle, &ClassName, &WindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam, dwShowMode, bUnicodeWindow); RtlFreeUnicodeString(&WindowName); @@ -2124,7 +2126,12 @@ NtUserCreateWindowEx(DWORD dwExStyle, RtlFreeUnicodeString(&ClassName); } - return NewWindow; + RETURN( NewWindow); + +CLEANUP: + DPRINT("Leave NtUserCreateWindowEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -2146,16 +2153,10 @@ NtUserDeferWindowPos(HDWP WinPosInfo, } -/* - * @implemented - */ -BOOLEAN STDCALL -NtUserDestroyWindow(HWND Wnd) +BOOLEAN FASTCALL co_UserDestroyWindow(PWINDOW_OBJECT Window) { - PWINDOW_OBJECT Window; BOOLEAN isChild; - Window = IntGetWindowObject(Wnd); if (Window == NULL) { return FALSE; @@ -2164,7 +2165,6 @@ NtUserDestroyWindow(HWND Wnd) /* Check for owner thread and desktop window */ if ((Window->OwnerThread != PsGetCurrentThread()) || IntIsDesktopWindow(Window)) { - IntReleaseWindowObject(Window); SetLastWin32Error(ERROR_ACCESS_DENIED); return FALSE; } @@ -2172,11 +2172,11 @@ NtUserDestroyWindow(HWND Wnd) /* Look whether the focus is within the tree of windows we will * be destroying. */ - if (!WinPosShowWindow(Wnd, SW_HIDE)) + if (!co_WinPosShowWindow(Window->Self, SW_HIDE)) { - if (NtUserGetActiveWindow() == Wnd) + if (UserGetActiveWindow() == Window->Self) { - WinPosActivateOtherWindow(Window); + co_WinPosActivateOtherWindow(Window); } } IntLockMessageQueue(Window->MessageQueue); @@ -2190,7 +2190,7 @@ NtUserDestroyWindow(HWND Wnd) IntDereferenceMessageQueue(Window->MessageQueue); /* Call hooks */ #if 0 /* FIXME */ - if (HOOK_CallHooks(WH_CBT, HCBT_DESTROYWND, (WPARAM) hwnd, 0, TRUE)) + if (co_HOOK_CallHooks(WH_CBT, HCBT_DESTROYWND, (WPARAM) hwnd, 0, TRUE)) { return FALSE; } @@ -2209,12 +2209,12 @@ NtUserDestroyWindow(HWND Wnd) } else if (NULL != GetWindow(Wnd, GW_OWNER)) { - HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWDESTROYED, (WPARAM)hwnd, 0L, TRUE ); + co_HOOK_CallHooks( WH_SHELL, HSHELL_WINDOWDESTROYED, (WPARAM)hwnd, 0L, TRUE ); /* FIXME: clean up palette - see "Internals" p.352 */ } #endif - if (!IntIsWindow(Wnd)) + if (!IntIsWindow(Window->Self)) { return TRUE; } @@ -2249,8 +2249,8 @@ NtUserDestroyWindow(HWND Wnd) IntUnLockRelatives(Child); if (IntWndBelongsToThread(Child, PsGetWin32Thread())) { - IntReleaseWindowObject(Child); - NtUserDestroyWindow(*ChildHandle); + co_UserDestroyWindow(Child); + IntReleaseWindowObject(Child); GotOne = TRUE; continue; } @@ -2271,20 +2271,48 @@ NtUserDestroyWindow(HWND Wnd) } } - if (!IntIsWindow(Wnd)) + if (!IntIsWindow(Window->Self)) { - IntReleaseWindowObject(Window); return TRUE; } /* Destroy the window storage */ - IntDestroyWindow(Window, PsGetWin32Process(), PsGetWin32Thread(), TRUE); + co_IntDestroyWindow(Window, PsGetWin32Process(), PsGetWin32Thread(), TRUE); - IntReleaseWindowObject(Window); return TRUE; } + + +/* + * @implemented + */ +BOOLEAN STDCALL +NtUserDestroyWindow(HWND Wnd) +{ + PWINDOW_OBJECT Window; + DECLARE_RETURN(BOOLEAN); + + DPRINT("Enter NtUserDestroyWindow\n"); + UserEnterExclusive(); + + Window = IntGetWindowObject(Wnd); + if (Window == NULL) + { + RETURN(FALSE); + } + + RETURN(co_UserDestroyWindow(Window)); + +CLEANUP: + DPRINT("Leave NtUserDestroyWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + /* * @unimplemented */ @@ -2417,6 +2445,10 @@ NtUserFindWindowEx(HWND hwndParent, NTSTATUS Status; HWND Desktop, Ret = NULL; RTL_ATOM ClassAtom; + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserFindWindowEx\n"); + UserEnterShared(); Desktop = IntGetCurrentThreadDesktopWindow(); @@ -2432,7 +2464,7 @@ NtUserFindWindowEx(HWND hwndParent, if(!(Parent = IntGetWindowObject(hwndParent))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; + RETURN( NULL); } ChildAfter = NULL; @@ -2440,7 +2472,7 @@ NtUserFindWindowEx(HWND hwndParent, { IntReleaseWindowObject(Parent); SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; + RETURN( NULL); } /* copy the window name */ @@ -2601,7 +2633,12 @@ NtUserFindWindowEx(HWND hwndParent, IntReleaseWindowObject(ChildAfter); IntReleaseWindowObject(Parent); - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserFindWindowEx, ret %i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -2620,8 +2657,7 @@ NtUserFlashWindowEx(DWORD Unknown0) /* * @implemented */ -HWND STDCALL -NtUserGetAncestor(HWND hWnd, UINT Type) +HWND FASTCALL UserGetAncestor(HWND hWnd, UINT Type) { PWINDOW_OBJECT Wnd, WndAncestor, Parent; HWND hWndAncestor; @@ -2706,6 +2742,26 @@ NtUserGetAncestor(HWND hWnd, UINT Type) } + +/* + * @implemented + */ +HWND STDCALL +NtUserGetAncestor(HWND hWnd, UINT Type) +{ + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetAncestor\n"); + UserEnterExclusive(); + + RETURN(UserGetAncestor(hWnd, Type)); + +CLEANUP: + DPRINT("Leave NtUserGetAncestor, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + /*! * Returns client window rectangle relative to the upper-left corner of client area. * @@ -2721,11 +2777,15 @@ NtUserGetClientRect(HWND hWnd, LPRECT Rect) { PWINDOW_OBJECT WindowObject; RECT SafeRect; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetClientRect\n"); + UserEnterShared(); if(!(WindowObject = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } IntGetClientRect(WindowObject, &SafeRect); @@ -2733,9 +2793,14 @@ NtUserGetClientRect(HWND hWnd, LPRECT Rect) if(!NT_SUCCESS(MmCopyToCaller(Rect, &SafeRect, sizeof(RECT)))) { - return FALSE; + RETURN( FALSE); } - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetClientRect, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -2745,7 +2810,17 @@ NtUserGetClientRect(HWND hWnd, LPRECT Rect) HWND STDCALL NtUserGetDesktopWindow() { - return IntGetDesktopWindow(); + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetDesktopWindow\n"); + UserEnterShared(); + + RETURN( IntGetDesktopWindow()); + +CLEANUP: + DPRINT("Leave NtUserGetDesktopWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -2816,11 +2891,15 @@ NtUserGetParent(HWND hWnd) { PWINDOW_OBJECT Wnd, WndParent; HWND hWndParent = NULL; + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetParent\n"); + UserEnterExclusive(); if (!(Wnd = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; + RETURN( NULL); } WndParent = IntGetParent(Wnd); @@ -2832,9 +2911,75 @@ NtUserGetParent(HWND hWnd) IntReleaseWindowObject(Wnd); - return hWndParent; + RETURN( hWndParent); + +CLEANUP: + DPRINT("Leave NtUserGetParent, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } + + + +HWND FASTCALL +UserSetParent(HWND hWndChild, HWND hWndNewParent) +{ + PWINDOW_OBJECT Wnd = NULL, WndParent = NULL, WndOldParent; + HWND hWndOldParent = NULL; + + if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + return( NULL); + } + + if (hWndChild == IntGetDesktopWindow()) + { + SetLastWin32Error(ERROR_ACCESS_DENIED); + return( NULL); + } + + if (hWndNewParent) + { + if (!(WndParent = IntGetWindowObject(hWndNewParent))) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return( NULL); + } + } + else + { + if (!(WndParent = IntGetWindowObject(IntGetDesktopWindow()))) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return( NULL); + } + } + + if (!(Wnd = IntGetWindowObject(hWndChild))) + { + IntReleaseWindowObject(WndParent); + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return( NULL); + } + + WndOldParent = IntSetParent(Wnd, WndParent); + + if (WndOldParent) + { + hWndOldParent = WndOldParent->Self; + IntReleaseWindowObject(WndOldParent); + } + + IntReleaseWindowObject(Wnd); + IntReleaseWindowObject(WndParent); + + return( hWndOldParent); +} + + + /* * NtUserSetParent * @@ -2855,59 +3000,45 @@ NtUserGetParent(HWND hWnd) HWND STDCALL NtUserSetParent(HWND hWndChild, HWND hWndNewParent) { - PWINDOW_OBJECT Wnd = NULL, WndParent = NULL, WndOldParent; - HWND hWndOldParent = NULL; + DECLARE_RETURN(HWND); - if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; - } + DPRINT("Enter NtUserSetParent\n"); + UserEnterExclusive(); - if (hWndChild == IntGetDesktopWindow()) - { - SetLastWin32Error(ERROR_ACCESS_DENIED); - return NULL; - } - - if (hWndNewParent) - { - if (!(WndParent = IntGetWindowObject(hWndNewParent))) - { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; - } - } - else - { - if (!(WndParent = IntGetWindowObject(IntGetDesktopWindow()))) - { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; - } - } - - if (!(Wnd = IntGetWindowObject(hWndChild))) - { - IntReleaseWindowObject(WndParent); - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; - } - - WndOldParent = IntSetParent(Wnd, WndParent); - - if (WndOldParent) - { - hWndOldParent = WndOldParent->Self; - IntReleaseWindowObject(WndOldParent); - } - - IntReleaseWindowObject(Wnd); - IntReleaseWindowObject(WndParent); - - return hWndOldParent; + RETURN( UserSetParent(hWndChild, hWndNewParent)); + +CLEANUP: + DPRINT("Leave NtUserSetParent, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } + + + +HWND FASTCALL UserGetShellWindow() +{ + PWINSTATION_OBJECT WinStaObject; + HWND Ret; + + NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, + KernelMode, + 0, + &WinStaObject); + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return( (HWND)0); + } + + Ret = (HWND)WinStaObject->ShellWindow; + + ObDereferenceObject(WinStaObject); + return( Ret); +} + + /* * NtUserGetShellWindow * @@ -2920,24 +3051,17 @@ NtUserSetParent(HWND hWndChild, HWND hWndNewParent) HWND STDCALL NtUserGetShellWindow() { - PWINSTATION_OBJECT WinStaObject; - HWND Ret; + DECLARE_RETURN(HWND); - NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, - KernelMode, - 0, - &WinStaObject); + DPRINT("Enter NtUserGetShellWindow\n"); + UserEnterShared(); - if (!NT_SUCCESS(Status)) - { - SetLastNtError(Status); - return (HWND)0; - } - - Ret = (HWND)WinStaObject->ShellWindow; - - ObDereferenceObject(WinStaObject); - return Ret; + RETURN( UserGetShellWindow() ); + +CLEANUP: + DPRINT("Leave NtUserGetShellWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -2954,6 +3078,10 @@ BOOL STDCALL NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) { PWINSTATION_OBJECT WinStaObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetShellWindowEx\n"); + UserEnterExclusive(); NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, KernelMode, @@ -2963,7 +3091,7 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) if (!NT_SUCCESS(Status)) { SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } /* @@ -2972,7 +3100,7 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) if (WinStaObject->ShellWindow) { ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); } /* @@ -2985,29 +3113,34 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView) * -- Filip, 01/nov/2003 */ #if 0 - WinPosSetWindowPos(hwndListView, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); + co_WinPosSetWindowPos(hwndListView, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); #endif - if (NtUserGetWindowLong(hwndListView, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) + if (UserGetWindowLong(hwndListView, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) { ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); } } - if (NtUserGetWindowLong(hwndShell, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) + if (UserGetWindowLong(hwndShell, GWL_EXSTYLE, FALSE) & WS_EX_TOPMOST) { ObDereferenceObject(WinStaObject); - return FALSE; + RETURN( FALSE); } - WinPosSetWindowPos(hwndShell, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); + co_WinPosSetWindowPos(hwndShell, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); WinStaObject->ShellWindow = hwndShell; WinStaObject->ShellListView = hwndListView; ObDereferenceObject(WinStaObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserSetShellWindowEx, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -3043,12 +3176,16 @@ NtUserGetSystemMenu(HWND hWnd, BOOL bRevert) HMENU Result = 0; PWINDOW_OBJECT WindowObject; PMENU_OBJECT MenuObject; + DECLARE_RETURN(HMENU); + + DPRINT("Enter NtUserGetSystemMenu\n"); + UserEnterShared(); WindowObject = IntGetWindowObject((HWND)hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } MenuObject = IntGetSystemMenu(WindowObject, bRevert, FALSE); @@ -3059,7 +3196,12 @@ NtUserGetSystemMenu(HWND hWnd, BOOL bRevert) } IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserGetSystemMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -3075,12 +3217,16 @@ NtUserSetSystemMenu(HWND hWnd, HMENU hMenu) BOOL Result = FALSE; PWINDOW_OBJECT WindowObject; PMENU_OBJECT MenuObject; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetSystemMenu\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if (!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if (hMenu) @@ -3093,7 +3239,7 @@ NtUserSetSystemMenu(HWND hWnd, HMENU hMenu) { IntReleaseWindowObject(WindowObject); SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); - return FALSE; + RETURN( FALSE); } Result = IntSetSystemMenu(WindowObject, MenuObject); @@ -3103,30 +3249,24 @@ NtUserSetSystemMenu(HWND hWnd, HMENU hMenu) IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserSetSystemMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } -/* - * NtUserGetWindow - * - * The NtUserGetWindow function retrieves a handle to a window that has the - * specified relationship (Z order or owner) to the specified window. - * - * Status - * @implemented - */ -HWND STDCALL -NtUserGetWindow(HWND hWnd, UINT Relationship) + + +HWND FASTCALL +UserGetWindow(HWND hWnd, UINT Relationship) { - PWINDOW_OBJECT WindowObject, Parent; + PWINDOW_OBJECT Parent, WindowObject; HWND hWndResult = NULL; - if (!(WindowObject = IntGetWindowObject(hWnd))) - { - SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return NULL; - } + if (!(WindowObject = IntGetWindowObject(hWnd))) return NULL; switch (Relationship) { @@ -3188,6 +3328,37 @@ NtUserGetWindow(HWND hWnd, UINT Relationship) return hWndResult; } + + +/* + * NtUserGetWindow + * + * The NtUserGetWindow function retrieves a handle to a window that has the + * specified relationship (Z order or owner) to the specified window. + * + * Status + * @implemented + */ + +HWND STDCALL +NtUserGetWindow(HWND hWnd, UINT Relationship) +{ + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserGetWindow\n"); + UserEnterShared(); + + RETURN(UserGetWindow(hWnd, Relationship)); + +CLEANUP: + DPRINT("Leave NtUserGetWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + + /* * NtUserGetWindowLong * @@ -3199,8 +3370,8 @@ NtUserGetWindow(HWND hWnd, UINT Relationship) * @implemented */ -LONG STDCALL -NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) +LONG FASTCALL +UserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) { PWINDOW_OBJECT WindowObject, Parent; LONG Result = 0; @@ -3263,7 +3434,7 @@ NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) if(Parent) { if (Parent && Parent->Self == IntGetDesktopWindow()) - Result = (LONG) NtUserGetWindow(WindowObject->Self, GW_OWNER); + Result = (LONG) UserGetWindow(WindowObject->Self, GW_OWNER); else Result = (LONG) Parent->Self; IntReleaseWindowObject(Parent); @@ -3291,19 +3462,41 @@ NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) return Result; } + + + /* - * NtUserSetWindowLong + * NtUserGetWindowLong * - * The NtUserSetWindowLong function changes an attribute of the specified - * window. The function also sets the 32-bit (long) value at the specified - * offset into the extra window memory. + * The NtUserGetWindowLong function retrieves information about the specified + * window. The function also retrieves the 32-bit (long) value at the + * specified offset into the extra window memory. * * Status * @implemented */ LONG STDCALL -NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) +NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) +{ + DECLARE_RETURN(LONG); + + DPRINT("Enter NtUserGetWindowLong(%x,%d,%d)\n", hWnd, (INT)Index, Ansi); + UserEnterExclusive(); + + RETURN(UserGetWindowLong(hWnd, Index, Ansi)); + +CLEANUP: + DPRINT("Leave NtUserGetWindowLong, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + + + +LONG FASTCALL +UserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) { PWINDOW_OBJECT WindowObject, Parent; PWINSTATION_OBJECT WindowStation; @@ -3313,14 +3506,14 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) if (hWnd == IntGetDesktopWindow()) { SetLastWin32Error(STATUS_ACCESS_DENIED); - return 0; + return( 0); } WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + return( 0); } if ((INT)Index >= 0) @@ -3329,7 +3522,7 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) { SetLastWin32Error(ERROR_INVALID_PARAMETER); IntReleaseWindowObject(WindowObject); - return 0; + return( 0); } OldValue = *((LONG *)(WindowObject->ExtraData + Index)); *((LONG *)(WindowObject->ExtraData + Index)) = NewValue; @@ -3353,18 +3546,18 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) Style.styleNew &= ~WS_EX_TOPMOST; } - IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style); + co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_EXSTYLE, (LPARAM) &Style); WindowObject->ExStyle = (DWORD)Style.styleNew; - IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style); + co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_EXSTYLE, (LPARAM) &Style); break; case GWL_STYLE: OldValue = (LONG) WindowObject->Style; Style.styleOld = OldValue; Style.styleNew = NewValue; - IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style); + co_IntSendMessage(hWnd, WM_STYLECHANGING, GWL_STYLE, (LPARAM) &Style); WindowObject->Style = (DWORD)Style.styleNew; - IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style); + co_IntSendMessage(hWnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM) &Style); break; case GWL_WNDPROC: @@ -3395,7 +3588,7 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) if (Parent && (Parent->Self == IntGetDesktopWindow())) OldValue = (LONG) IntSetOwner(WindowObject->Self, (HWND) NewValue); else - OldValue = (LONG) NtUserSetParent(WindowObject->Self, (HWND) NewValue); + OldValue = (LONG) UserSetParent(WindowObject->Self, (HWND) NewValue); if(Parent) IntReleaseWindowObject(Parent); break; @@ -3420,7 +3613,36 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) IntReleaseWindowObject(WindowObject); - return OldValue; + return( OldValue); +} + + + +/* + * NtUserSetWindowLong + * + * The NtUserSetWindowLong function changes an attribute of the specified + * window. The function also sets the 32-bit (long) value at the specified + * offset into the extra window memory. + * + * Status + * @implemented + */ + +LONG STDCALL +NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) +{ + DECLARE_RETURN(LONG); + + DPRINT("Enter NtUserSetWindowLong\n"); + UserEnterExclusive(); + + RETURN( UserSetWindowLong(hWnd, Index, NewValue, Ansi)); + +CLEANUP: + DPRINT("Leave NtUserSetWindowLong, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -3437,18 +3659,22 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue) { PWINDOW_OBJECT WindowObject; WORD OldValue; + DECLARE_RETURN(WORD); + + DPRINT("Enter NtUserSetWindowWord\n"); + UserEnterExclusive(); switch (Index) { case GWL_ID: case GWL_HINSTANCE: case GWL_HWNDPARENT: - return NtUserSetWindowLong(hWnd, Index, (UINT)NewValue, TRUE); + RETURN( UserSetWindowLong(hWnd, Index, (UINT)NewValue, TRUE)); default: if (Index < 0) { SetLastWin32Error(ERROR_INVALID_INDEX); - return 0; + RETURN( 0); } } @@ -3456,14 +3682,14 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue) if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } if (Index > WindowObject->ExtraDataSize - sizeof(WORD)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); IntReleaseWindowObject(WindowObject); - return 0; + RETURN( 0); } OldValue = *((WORD *)(WindowObject->ExtraData + Index)); @@ -3471,7 +3697,12 @@ NtUserSetWindowWord(HWND hWnd, INT Index, WORD NewValue) IntReleaseWindowObject(WindowObject); - return OldValue; + RETURN( OldValue); + +CLEANUP: + DPRINT("Leave NtUserSetWindowWord, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -3486,12 +3717,16 @@ NtUserGetWindowPlacement(HWND hWnd, POINT Size; WINDOWPLACEMENT Safepl; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetWindowPlacement\n"); + UserEnterShared(); WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT)); @@ -3499,12 +3734,12 @@ NtUserGetWindowPlacement(HWND hWnd, { SetLastNtError(Status); IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } if(Safepl.length != sizeof(WINDOWPLACEMENT)) { IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } Safepl.flags = 0; @@ -3523,7 +3758,7 @@ NtUserGetWindowPlacement(HWND hWnd, else { IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } Status = MmCopyToCaller(lpwndpl, &Safepl, sizeof(WINDOWPLACEMENT)); @@ -3531,11 +3766,16 @@ NtUserGetWindowPlacement(HWND hWnd, { SetLastNtError(Status); IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } IntReleaseWindowObject(WindowObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetWindowPlacement, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3552,22 +3792,31 @@ NtUserGetWindowRect(HWND hWnd, LPRECT Rect) { PWINDOW_OBJECT Wnd; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetWindowRect\n"); + UserEnterShared(); if (!(Wnd = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN(FALSE); } Status = MmCopyToCaller(Rect, &Wnd->WindowRect, sizeof(RECT)); if (!NT_SUCCESS(Status)) { IntReleaseWindowObject(Wnd); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } IntReleaseWindowObject(Wnd); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserGetWindowRect, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3579,11 +3828,15 @@ NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid) { PWINDOW_OBJECT Wnd; DWORD tid, pid; + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserGetWindowThreadProcessId\n"); + UserEnterShared(); if (!(Wnd = IntGetWindowObject(hWnd))) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } tid = (DWORD)IntGetWndThreadId(Wnd); @@ -3591,7 +3844,12 @@ NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid) if (UnsafePid) MmCopyToCaller(UnsafePid, &pid, sizeof(DWORD)); - return tid; + RETURN( tid); + +CLEANUP: + DPRINT("Leave NtUserGetWindowThreadProcessId, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3644,11 +3902,15 @@ NtUserQueryWindow(HWND hWnd, DWORD Index) { PWINDOW_OBJECT Window = IntGetWindowObject(hWnd); DWORD Result; + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserQueryWindow\n"); + UserEnterShared(); if (Window == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } switch(Index) @@ -3672,7 +3934,13 @@ NtUserQueryWindow(HWND hWnd, DWORD Index) IntReleaseWindowObject(Window); - return Result; + RETURN( Result); + + +CLEANUP: + DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3699,24 +3967,33 @@ NtUserRegisterWindowMessage(PUNICODE_STRING MessageNameUnsafe) UNICODE_STRING SafeMessageName; NTSTATUS Status; UINT Ret; + DECLARE_RETURN(UINT); + + DPRINT("Enter NtUserRegisterWindowMessage\n"); + UserEnterExclusive(); if(MessageNameUnsafe == NULL) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + RETURN( 0); } Status = IntSafeCopyUnicodeStringTerminateNULL(&SafeMessageName, MessageNameUnsafe); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); - return 0; + RETURN( 0); } Ret = (UINT)IntAddAtom(SafeMessageName.Buffer); RtlFreeUnicodeString(&SafeMessageName); - return Ret; + RETURN( Ret); + +CLEANUP: + DPRINT("Leave NtUserRegisterWindowMessage, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3787,29 +4064,38 @@ NtUserSetMenu( { PWINDOW_OBJECT WindowObject; BOOL Changed; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetMenu\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject((HWND) Wnd); if (NULL == WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if (! IntSetMenu(WindowObject, Menu, &Changed)) { IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } IntReleaseWindowObject(WindowObject); if (Changed && Repaint) { - WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + co_WinPosSetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); } - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserSetMenu, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3837,29 +4123,33 @@ NtUserSetWindowPlacement(HWND hWnd, PWINDOW_OBJECT WindowObject; WINDOWPLACEMENT Safepl; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetWindowPlacement\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT)); if(!NT_SUCCESS(Status)) { SetLastNtError(Status); IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } if(Safepl.length != sizeof(WINDOWPLACEMENT)) { IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } if ((WindowObject->Style & (WS_MAXIMIZE | WS_MINIMIZE)) == 0) { - WinPosSetWindowPos(WindowObject->Self, NULL, + co_WinPosSetWindowPos(WindowObject->Self, NULL, Safepl.rcNormalPosition.left, Safepl.rcNormalPosition.top, Safepl.rcNormalPosition.right - Safepl.rcNormalPosition.left, Safepl.rcNormalPosition.bottom - Safepl.rcNormalPosition.top, @@ -3867,7 +4157,7 @@ NtUserSetWindowPlacement(HWND hWnd, } /* FIXME - change window status */ - WinPosShowWindow(WindowObject->Self, Safepl.showCmd); + co_WinPosShowWindow(WindowObject->Self, Safepl.showCmd); if (WindowObject->InternalPos == NULL) WindowObject->InternalPos = ExAllocatePoolWithTag(PagedPool, sizeof(INTERNALPOS), TAG_WININTLIST); @@ -3876,7 +4166,12 @@ NtUserSetWindowPlacement(HWND hWnd, WindowObject->InternalPos->MaxPos = Safepl.ptMaxPosition; IntReleaseWindowObject(WindowObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3893,7 +4188,17 @@ NtUserSetWindowPos( int cy, UINT uFlags) { - return WinPosSetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags); + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserSetWindowPos\n"); + UserEnterExclusive(); + + RETURN( co_WinPosSetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags)); + +CLEANUP: + DPRINT("Leave NtUserSetWindowPos, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -3991,12 +4296,16 @@ NtUserSetWindowRgn( BOOL bRedraw) { PWINDOW_OBJECT WindowObject; - + DECLARE_RETURN(INT); + + DPRINT("Enter NtUserSetWindowRgn\n"); + UserEnterExclusive(); + WindowObject = IntGetWindowObject(hWnd); if (WindowObject == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } /* FIXME - Verify if hRgn is a valid handle!!!! @@ -4013,11 +4322,16 @@ NtUserSetWindowRgn( if(bRedraw) { - IntRedrawWindow(WindowObject, NULL, NULL, RDW_INVALIDATE); + co_UserRedrawWindow(WindowObject, NULL, NULL, RDW_INVALIDATE); } IntReleaseWindowObject(WindowObject); - return (INT)hRgn; + RETURN( (INT)hRgn); + +CLEANUP: + DPRINT("Leave NtUserSystemParametersInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -4028,7 +4342,17 @@ BOOL STDCALL NtUserShowWindow(HWND hWnd, LONG nCmdShow) { - return WinPosShowWindow(hWnd, nCmdShow); + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserShowWindow\n"); + UserEnterExclusive(); + + RETURN( co_WinPosShowWindow(hWnd, nCmdShow)); + +CLEANUP: + DPRINT("Leave NtUserShowWindow, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } @@ -4084,6 +4408,10 @@ NtUserWindowFromPoint(LONG X, LONG Y) POINT pt; HWND Ret; PWINDOW_OBJECT DesktopWindow, Window = NULL; + DECLARE_RETURN(HWND); + + DPRINT("Enter NtUserWindowFromPoint\n"); + UserEnterExclusive(); if ((DesktopWindow = IntGetWindowObject(IntGetDesktopWindow()))) { @@ -4092,20 +4420,26 @@ NtUserWindowFromPoint(LONG X, LONG Y) pt.x = X; pt.y = Y; - Hit = WinPosWindowFromPoint(DesktopWindow, PsGetWin32Thread()->MessageQueue, &pt, &Window); + Hit = co_WinPosWindowFromPoint(DesktopWindow, PsGetWin32Thread()->MessageQueue, &pt, &Window); if(Window) { Ret = Window->Self; IntReleaseWindowObject(Window); IntReleaseWindowObject(DesktopWindow); - return Ret; + RETURN( Ret); } IntReleaseWindowObject(DesktopWindow); } - return NULL; + RETURN( NULL); + +CLEANUP: + DPRINT("Leave NtUserWindowFromPoint, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; + } @@ -4125,12 +4459,16 @@ NtUserDefSetText(HWND WindowHandle, PUNICODE_STRING WindowText) PWINDOW_OBJECT WindowObject, Parent, Owner; UNICODE_STRING SafeText; NTSTATUS Status; + DECLARE_RETURN(INT); + + DPRINT("Enter NtUserDefSetText\n"); + UserEnterExclusive(); WindowObject = IntGetWindowObject(WindowHandle); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } if(WindowText) @@ -4140,7 +4478,7 @@ NtUserDefSetText(HWND WindowHandle, PUNICODE_STRING WindowText) { SetLastNtError(Status); IntReleaseWindowObject(WindowObject); - return FALSE; + RETURN( FALSE); } } else @@ -4160,7 +4498,7 @@ NtUserDefSetText(HWND WindowHandle, PUNICODE_STRING WindowText) if ((!Owner) && (!Parent)) { - IntShellHookNotify(HSHELL_REDRAW, (LPARAM) WindowHandle); + co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) WindowHandle); } if (Owner) @@ -4174,7 +4512,12 @@ NtUserDefSetText(HWND WindowHandle, PUNICODE_STRING WindowText) } IntReleaseWindowObject(WindowObject); - return TRUE; + RETURN( TRUE); + +CLEANUP: + DPRINT("Leave NtUserDefSetText, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* @@ -4190,18 +4533,22 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount) PWINDOW_OBJECT WindowObject; NTSTATUS Status; INT Result; + DECLARE_RETURN(INT); + + DPRINT("Enter NtUserInternalGetWindowText\n"); + UserEnterShared(); if(lpString && (nMaxCount <= 1)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + RETURN( 0); } WindowObject = IntGetWindowObject(hWnd); if(!WindowObject) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return 0; + RETURN( 0); } /* FIXME - do this thread-safe! otherwise one could crash here! */ @@ -4220,7 +4567,7 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount) { SetLastNtError(Status); IntReleaseWindowObject(WindowObject); - return 0; + RETURN( 0); } Buffer += Copy; } @@ -4230,19 +4577,29 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount) { SetLastNtError(Status); IntReleaseWindowObject(WindowObject); - return 0; + RETURN( 0); } Result = Copy; } IntReleaseWindowObject(WindowObject); - return Result; + RETURN( Result); + +CLEANUP: + DPRINT("Leave NtUserInternalGetWindowText, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD STDCALL NtUserDereferenceWndProcHandle(WNDPROC wpHandle, WndProcHandle *Data) { + DECLARE_RETURN(DWORD); + + DPRINT("Enter NtUserDereferenceWndProcHandle\n"); + UserEnterShared(); + WndProcHandle Entry; if (((DWORD)wpHandle & 0xFFFF0000) == 0xFFFF0000) { @@ -4250,11 +4607,16 @@ NtUserDereferenceWndProcHandle(WNDPROC wpHandle, WndProcHandle *Data) Data->WindowProc = Entry.WindowProc; Data->IsUnicode = Entry.IsUnicode; Data->ProcessID = Entry.ProcessID; - return TRUE; + RETURN( TRUE); } else { - return FALSE; + RETURN( FALSE); } - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserDereferenceWndProcHandle, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } DWORD @@ -4345,7 +4707,7 @@ IntShowOwnedPopups( HWND owner, BOOL fShow ) while (win_array[count]) count++; while (--count >= 0) { - if (NtUserGetWindow( win_array[count], GW_OWNER ) != owner) continue; + if (UserGetWindow( win_array[count], GW_OWNER ) != owner) continue; if (!(pWnd = IntGetWindowObject( win_array[count] ))) continue; // if (pWnd == WND_OTHER_PROCESS) continue; @@ -4358,7 +4720,7 @@ IntShowOwnedPopups( HWND owner, BOOL fShow ) * WM_SHOWWINDOW messages with SW_PARENTOPENING, * regardless of the state of the owner */ - IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING); + co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING); continue; } } @@ -4371,7 +4733,7 @@ IntShowOwnedPopups( HWND owner, BOOL fShow ) * WM_SHOWWINDOW messages with SW_PARENTCLOSING, * regardless of the state of the owner */ - IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING); + co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING); continue; } } diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 52f1fd46f23..0bb42d29b21 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -67,8 +67,11 @@ IntGetClientOrigin(HWND hWnd, LPPOINT Point) return TRUE; } -BOOL STDCALL -NtUserGetClientOrigin(HWND hWnd, LPPOINT Point) + + + +BOOL FASTCALL +UserGetClientOrigin(HWND hWnd, LPPOINT Point) { BOOL Ret; POINT pt; @@ -98,13 +101,31 @@ NtUserGetClientOrigin(HWND hWnd, LPPOINT Point) return Ret; } + + +BOOL STDCALL +NtUserGetClientOrigin(HWND hWnd, LPPOINT Point) +{ + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetClientOrigin\n"); + UserEnterShared(); + + RETURN(UserGetClientOrigin(hWnd, Point)); + +CLEANUP: + DPRINT("Leave NtUserGetClientOrigin, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + /******************************************************************* * WinPosActivateOtherWindow * * Activates window other than pWnd. */ VOID FASTCALL -WinPosActivateOtherWindow(PWINDOW_OBJECT Window) +co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window) { PWINDOW_OBJECT Wnd, Old; HWND Fg; @@ -163,17 +184,17 @@ WinPosActivateOtherWindow(PWINDOW_OBJECT Window) } done: - Fg = NtUserGetForegroundWindow(); + Fg = UserGetForegroundWindow(); if (Wnd && (!Fg || Window->Self == Fg)) { - if (IntSetForegroundWindow(Wnd)) + if (co_IntSetForegroundWindow(Wnd)) { IntReleaseWindowObject(Wnd); return; } } - if (!IntSetActiveWindow(Wnd)) - IntSetActiveWindow(0); + if (!co_IntSetActiveWindow(Wnd)) + co_IntSetActiveWindow(0); if (Wnd) IntReleaseWindowObject(Wnd); } @@ -181,7 +202,7 @@ done: UINT FASTCALL -WinPosArrangeIconicWindows(PWINDOW_OBJECT parent) +co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent) { RECT rectParent; HWND hwndChild; @@ -192,8 +213,8 @@ WinPosArrangeIconicWindows(PWINDOW_OBJECT parent) x = rectParent.left; y = rectParent.bottom; - xspacing = NtUserGetSystemMetrics(SM_CXMINSPACING); - yspacing = NtUserGetSystemMetrics(SM_CYMINSPACING); + xspacing = UserGetSystemMetrics(SM_CXMINSPACING); + yspacing = UserGetSystemMetrics(SM_CYMINSPACING); DPRINT("X:%d Y:%d XS:%d YS:%d\n",x,y,xspacing,yspacing); @@ -201,10 +222,10 @@ WinPosArrangeIconicWindows(PWINDOW_OBJECT parent) { hwndChild = List[i]; - if((NtUserGetWindowLong( hwndChild, GWL_STYLE, FALSE) & WS_MINIMIZE) != 0 ) + if((UserGetWindowLong( hwndChild, GWL_STYLE, FALSE) & WS_MINIMIZE) != 0 ) { - WinPosSetWindowPos( hwndChild, 0, x + NtUserGetSystemMetrics(SM_CXBORDER), - y - yspacing - NtUserGetSystemMetrics(SM_CYBORDER) + co_WinPosSetWindowPos( hwndChild, 0, x + UserGetSystemMetrics(SM_CXBORDER), + y - yspacing - UserGetSystemMetrics(SM_CYBORDER) , 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE ); if (x <= rectParent.right - xspacing) x += xspacing; else @@ -259,7 +280,7 @@ WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT *pt, PRECT RestoreRect) WindowObject->InternalPos->MaxPos.x = WorkArea.left - XInc; WindowObject->InternalPos->MaxPos.y = WorkArea.top - YInc; WindowObject->InternalPos->IconPos.x = WorkArea.left; - WindowObject->InternalPos->IconPos.y = WorkArea.bottom - NtUserGetSystemMetrics(SM_CYMINIMIZED); + WindowObject->InternalPos->IconPos.y = WorkArea.bottom - UserGetSystemMetrics(SM_CYMINIMIZED); } if (WindowObject->Style & WS_MINIMIZE) { @@ -277,7 +298,7 @@ WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT *pt, PRECT RestoreRect) } UINT FASTCALL -WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) +co_WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) { POINT Size; PINTERNALPOS InternalPos; @@ -292,7 +313,7 @@ WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) { if (WindowObject->Style & WS_MINIMIZE) { - if (!IntSendMessage(WindowObject->Self, WM_QUERYOPEN, 0, 0)) + if (!co_IntSendMessage(WindowObject->Self, WM_QUERYOPEN, 0, 0)) { return(SWP_NOSIZE | SWP_NOMOVE); } @@ -311,20 +332,20 @@ WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) { WindowObject->Flags &= ~WINDOWOBJECT_RESTOREMAX; } - IntRedrawWindow(WindowObject, NULL, 0, RDW_VALIDATE | RDW_NOERASE | + co_UserRedrawWindow(WindowObject, NULL, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOINTERNALPAINT); WindowObject->Style |= WS_MINIMIZE; WinPosFindIconPos(WindowObject, &InternalPos->IconPos); IntGdiSetRect(NewPos, InternalPos->IconPos.x, InternalPos->IconPos.y, - NtUserGetSystemMetrics(SM_CXMINIMIZED), - NtUserGetSystemMetrics(SM_CYMINIMIZED)); + UserGetSystemMetrics(SM_CXMINIMIZED), + UserGetSystemMetrics(SM_CYMINIMIZED)); SwpFlags |= SWP_NOCOPYBITS; break; } case SW_MAXIMIZE: { - WinPosGetMinMaxInfo(WindowObject, &Size, &InternalPos->MaxPos, + co_WinPosGetMinMaxInfo(WindowObject, &Size, &InternalPos->MaxPos, NULL, NULL); DPRINT("Maximize: %d,%d %dx%d\n", InternalPos->MaxPos.x, InternalPos->MaxPos.y, Size.x, Size.y); @@ -345,7 +366,7 @@ WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) WindowObject->Style &= ~WS_MINIMIZE; if (WindowObject->Flags & WINDOWOBJECT_RESTOREMAX) { - WinPosGetMinMaxInfo(WindowObject, &Size, + co_WinPosGetMinMaxInfo(WindowObject, &Size, &InternalPos->MaxPos, NULL, NULL); WindowObject->Style |= WS_MAXIMIZE; IntGdiSetRect(NewPos, InternalPos->MaxPos.x, @@ -394,8 +415,8 @@ WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info) /* Get default values. */ Info->ptMaxSize.x = WorkArea.right - WorkArea.left; Info->ptMaxSize.y = WorkArea.bottom - WorkArea.top; - Info->ptMinTrackSize.x = NtUserGetSystemMetrics(SM_CXMINTRACK); - Info->ptMinTrackSize.y = NtUserGetSystemMetrics(SM_CYMINTRACK); + Info->ptMinTrackSize.x = UserGetSystemMetrics(SM_CXMINTRACK); + Info->ptMinTrackSize.y = UserGetSystemMetrics(SM_CYMINTRACK); Info->ptMaxTrackSize.x = Info->ptMaxSize.x; Info->ptMaxTrackSize.y = Info->ptMaxSize.y; @@ -415,14 +436,14 @@ WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info) } UINT FASTCALL -WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos, +co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos, POINT* MinTrack, POINT* MaxTrack) { MINMAXINFO MinMax; WinPosFillMinMaxInfoStruct(Window, &MinMax); - IntSendMessage(Window->Self, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax); + co_IntSendMessage(Window->Self, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax); MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x, MinMax.ptMinTrackSize.x); @@ -475,7 +496,7 @@ FixClientRect(PRECT ClientRect, PRECT WindowRect) } LONG STATIC FASTCALL -WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos, +co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos, RECT* WindowRect, RECT* ClientRect) { PWINDOW_OBJECT Parent; @@ -503,7 +524,7 @@ WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos, params.lppos = &winposCopy; winposCopy = *WinPos; - wvrFlags = IntSendMessage(Window->Self, WM_NCCALCSIZE, TRUE, (LPARAM) ¶ms); + wvrFlags = co_IntSendMessage(Window->Self, WM_NCCALCSIZE, TRUE, (LPARAM) ¶ms); /* If the application send back garbage, ignore it */ if (params.rgrc[0].left <= params.rgrc[0].right && @@ -550,7 +571,7 @@ WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos, } BOOL FASTCALL -WinPosDoWinPosChanging(PWINDOW_OBJECT WindowObject, +co_WinPosDoWinPosChanging(PWINDOW_OBJECT WindowObject, PWINDOWPOS WinPos, PRECT WindowRect, PRECT ClientRect) @@ -559,7 +580,7 @@ WinPosDoWinPosChanging(PWINDOW_OBJECT WindowObject, if (!(WinPos->flags & SWP_NOSENDCHANGING)) { - IntSendMessage(WindowObject->Self, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos); + co_IntSendMessage(WindowObject->Self, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos); } *WindowRect = WindowObject->WindowRect; @@ -606,8 +627,8 @@ HWND FASTCALL WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter) { HWND *List = NULL; - HWND Owner = NtUserGetWindow(hWnd, GW_OWNER); - LONG Style = NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE); + HWND Owner = UserGetWindow(hWnd, GW_OWNER); + LONG Style = UserGetWindowLong(hWnd, GWL_STYLE, FALSE); PWINDOW_OBJECT DesktopWindow, ChildObject; int i; @@ -663,10 +684,10 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter) { if (List[i] == hWnd) break; - if ((NtUserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) && - NtUserGetWindow(List[i], GW_OWNER) == hWnd) + if ((UserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) && + UserGetWindow(List[i], GW_OWNER) == hWnd) { - WinPosSetWindowPos(List[i], hWndInsertAfter, 0, 0, 0, 0, + co_WinPosSetWindowPos(List[i], hWndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOSENDCHANGING); hWndInsertAfter = List[i]; } @@ -743,7 +764,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window) WinPos->flags |= SWP_NOMOVE; } - if (WinPos->hwnd == NtUserGetForegroundWindow()) + if (WinPos->hwnd == UserGetForegroundWindow()) { WinPos->flags |= SWP_NOACTIVATE; /* Already active */ } @@ -791,7 +812,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window) && HWND_BOTTOM != WinPos->hwndInsertAfter) { PWINDOW_OBJECT Parent = IntGetParentObject(Window); - if (NtUserGetAncestor(WinPos->hwndInsertAfter, GA_PARENT) != + if (UserGetAncestor(WinPos->hwndInsertAfter, GA_PARENT) != (Parent ? Parent->Self : NULL)) { if(Parent) @@ -808,7 +829,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window) * itself. */ if ((WinPos->hwnd == WinPos->hwndInsertAfter) || - (WinPos->hwnd == NtUserGetWindow(WinPos->hwndInsertAfter, GW_HWNDNEXT))) + (WinPos->hwnd == UserGetWindow(WinPos->hwndInsertAfter, GW_HWNDNEXT))) { WinPos->flags |= SWP_NOZORDER; } @@ -821,7 +842,7 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window) /* x and y are always screen relative */ BOOLEAN FASTCALL -WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, +co_WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags) { PWINDOW_OBJECT Window; @@ -868,7 +889,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, WinPos.cy = cy; WinPos.flags = flags; - WinPosDoWinPosChanging(Window, &WinPos, &NewWindowRect, &NewClientRect); + co_WinPosDoWinPosChanging(Window, &WinPos, &NewWindowRect, &NewClientRect); /* Fix up the flags. */ if (!WinPosFixupFlags(&WinPos, Window)) @@ -888,7 +909,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, if ((WinPos.flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER && - NtUserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow()) + UserGetAncestor(WinPos.hwnd, GA_PARENT) == IntGetDesktopWindow()) { WinPos.hwndInsertAfter = WinPosDoOwnedPopups(WinPos.hwnd, WinPos.hwndInsertAfter); } @@ -918,10 +939,10 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, } } - WvrFlags = WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect); + WvrFlags = co_WinPosDoNCCALCSize(Window, &WinPos, &NewWindowRect, &NewClientRect); /* Relink windows. (also take into account shell window in hwndShellWindow) */ - if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != NtUserGetShellWindow()) + if (!(WinPos.flags & SWP_NOZORDER) && WinPos.hwnd != UserGetShellWindow()) { PWINDOW_OBJECT ParentWindow; PWINDOW_OBJECT Sibling; @@ -1022,7 +1043,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, if (!(WinPos.flags & SWP_SHOWWINDOW) && (WinPos.flags & SWP_HIDEWINDOW)) { /* Clear the update region */ - IntRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOFRAME | + co_UserRedrawWindow(Window, NULL, 0, RDW_VALIDATE | RDW_NOFRAME | RDW_NOERASE | RDW_NOINTERNALPAINT | RDW_ALLCHILDREN); Window->Style &= ~WS_VISIBLE; } @@ -1125,14 +1146,14 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, HRGN ClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); NtGdiCombineRgn(ClipRgn, CopyRgn, NULL, RGN_COPY); - Dc = NtUserGetDCEx(Wnd, ClipRgn, DCX_WINDOW | DCX_CACHE | + Dc = UserGetDCEx(Window, ClipRgn, DCX_WINDOW | DCX_CACHE | DCX_INTERSECTRGN | DCX_CLIPSIBLINGS); NtGdiBitBlt(Dc, CopyRect.left, CopyRect.top, CopyRect.right - CopyRect.left, CopyRect.bottom - CopyRect.top, Dc, CopyRect.left + (OldWindowRect.left - NewWindowRect.left), CopyRect.top + (OldWindowRect.top - NewWindowRect.top), SRCCOPY); - NtUserReleaseDC(Wnd, Dc); + UserReleaseDC(Window, Dc); IntValidateParent(Window, CopyRgn); } else if(VisRgn) @@ -1162,7 +1183,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, NtGdiOffsetRgn(DirtyRgn, Window->WindowRect.left - Window->ClientRect.left, Window->WindowRect.top - Window->ClientRect.top); - IntRedrawWindow(Window, NULL, DirtyRgn, + co_UserRedrawWindow(Window, NULL, DirtyRgn, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN); } NtGdiDeleteObject(DirtyRgn); @@ -1187,7 +1208,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, if (RgnType != ERROR && RgnType != NULLREGION) { - VIS_WindowLayoutChanged(Window, ExposedRgn); + co_VIS_WindowLayoutChanged(Window, ExposedRgn); } NtGdiDeleteObject(ExposedRgn); NtGdiDeleteObject(VisBefore); @@ -1202,17 +1223,17 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, { if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD) { - IntSendMessage(WinPos.hwnd, WM_CHILDACTIVATE, 0, 0); + co_IntSendMessage(WinPos.hwnd, WM_CHILDACTIVATE, 0, 0); } else { - IntSetForegroundWindow(Window); + co_IntSetForegroundWindow(Window); } } } if ((WinPos.flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE) - IntSendMessage(WinPos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM) &WinPos); + co_IntSendMessage(WinPos.hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM) &WinPos); IntReleaseWindowObject(Window); @@ -1220,12 +1241,12 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, } LRESULT FASTCALL -WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect) +co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect) { LRESULT Result; *ClientRect = *WindowRect; - Result = IntSendMessage(Wnd, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect); + Result = co_IntSendMessage(Wnd, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect); FixClientRect(ClientRect, WindowRect); @@ -1233,7 +1254,7 @@ WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect) } BOOLEAN FASTCALL -WinPosShowWindow(HWND Wnd, INT Cmd) +co_WinPosShowWindow(HWND Wnd, INT Cmd) { BOOLEAN WasVisible; PWINDOW_OBJECT Window; @@ -1265,7 +1286,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) return(FALSE); } Swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE; - if (Window->Self != NtUserGetActiveWindow()) + if (Window->Self != UserGetActiveWindow()) Swp |= SWP_NOACTIVATE | SWP_NOZORDER; break; } @@ -1281,7 +1302,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) Swp |= SWP_FRAMECHANGED | SWP_NOACTIVATE; if (!(Window->Style & WS_MINIMIZE)) { - Swp |= WinPosMinMaximize(Window, SW_MINIMIZE, &NewPos); + Swp |= co_WinPosMinMaximize(Window, SW_MINIMIZE, &NewPos); } else { @@ -1295,7 +1316,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) Swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; if (!(Window->Style & WS_MAXIMIZE)) { - Swp |= WinPosMinMaximize(Window, SW_MAXIMIZE, &NewPos); + Swp |= co_WinPosMinMaximize(Window, SW_MAXIMIZE, &NewPos); } else { @@ -1321,7 +1342,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) Swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED; if (Window->Style & (WS_MINIMIZE | WS_MAXIMIZE)) { - Swp |= WinPosMinMaximize(Window, SW_RESTORE, &NewPos); + Swp |= co_WinPosMinMaximize(Window, SW_RESTORE, &NewPos); } else { @@ -1333,14 +1354,14 @@ WinPosShowWindow(HWND Wnd, INT Cmd) ShowFlag = (Cmd != SW_HIDE); if (ShowFlag != WasVisible) { - IntSendMessage(Wnd, WM_SHOWWINDOW, ShowFlag, 0); + co_IntSendMessage(Wnd, WM_SHOWWINDOW, ShowFlag, 0); /* * FIXME: Need to check the window wasn't destroyed during the * window procedure. */ if (!(Window->Parent)) { - IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Wnd); + co_IntShellHookNotify(HSHELL_WINDOWCREATED, (LPARAM)Wnd); } } @@ -1351,7 +1372,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) Swp |= SWP_NOACTIVATE | SWP_NOZORDER; } - WinPosSetWindowPos(Window->Self, 0 != (Window->ExStyle & WS_EX_TOPMOST) + co_WinPosSetWindowPos(Window->Self, 0 != (Window->ExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_TOP, NewPos.left, NewPos.top, NewPos.right, NewPos.bottom, LOWORD(Swp)); @@ -1362,21 +1383,21 @@ WinPosShowWindow(HWND Wnd, INT Cmd) * asynchronously. */ - if (Window->Self == NtUserGetActiveWindow()) + if (Window->Self == UserGetActiveWindow()) { - WinPosActivateOtherWindow(Window); + co_WinPosActivateOtherWindow(Window); } /* Revert focus to parent */ if (Wnd == IntGetThreadFocusWindow() || IntIsChildWindow(Wnd, IntGetThreadFocusWindow())) { - NtUserSetFocus(Window->Parent); + UserSetFocus(Window->Parent); } if (!(Window->Parent)) { - IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM)Wnd); + co_IntShellHookNotify(HSHELL_WINDOWDESTROYED, (LPARAM)Wnd); } } @@ -1397,12 +1418,12 @@ WinPosShowWindow(HWND Wnd, INT Cmd) wParam = SIZE_MINIMIZED; } - IntSendMessage(Wnd, WM_SIZE, wParam, + co_IntSendMessage(Wnd, WM_SIZE, wParam, MAKELONG(Window->ClientRect.right - Window->ClientRect.left, Window->ClientRect.bottom - Window->ClientRect.top)); - IntSendMessage(Wnd, WM_MOVE, 0, + co_IntSendMessage(Wnd, WM_MOVE, 0, MAKELONG(Window->ClientRect.left, Window->ClientRect.top)); IntEngWindowChanged(Window, WOC_RGN_CLIENT); @@ -1421,7 +1442,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) } STATIC VOID FASTCALL -WinPosSearchChildren( +co_WinPosSearchChildren( PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *Point, PWINDOW_OBJECT* Window, USHORT *HitTest) { @@ -1472,7 +1493,7 @@ WinPosSearchChildren( if (OnlyHitTests && (Current->MessageQueue == OnlyHitTests)) { - *HitTest = IntSendMessage(Current->Self, WM_NCHITTEST, 0, + *HitTest = co_IntSendMessage(Current->Self, WM_NCHITTEST, 0, MAKELONG(Point->x, Point->y)); if ((*HitTest) == (USHORT)HTTRANSPARENT) continue; @@ -1485,7 +1506,7 @@ WinPosSearchChildren( Point->y >= Current->ClientRect.top && Point->y < Current->ClientRect.bottom) { - WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest); + co_WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest); } break; @@ -1495,7 +1516,7 @@ WinPosSearchChildren( } USHORT FASTCALL -WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, +co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint, PWINDOW_OBJECT* Window) { HWND DesktopWindowHandle; @@ -1528,7 +1549,7 @@ WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, HitTest = HTNOWHERE; - WinPosSearchChildren(ScopeWin, OnlyHitTests, &Point, Window, &HitTest); + co_WinPosSearchChildren(ScopeWin, OnlyHitTests, &Point, Window, &HitTest); return ((*Window) ? HitTest : HTNOWHERE); } @@ -1545,12 +1566,16 @@ NtUserGetMinMaxInfo( PWINDOW_OBJECT Window; MINMAXINFO SafeMinMax; NTSTATUS Status; + DECLARE_RETURN(BOOL); + + DPRINT("Enter NtUserGetMinMaxInfo\n"); + UserEnterExclusive(); Window = IntGetWindowObject(hwnd); if(!Window) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); - return FALSE; + RETURN( FALSE); } Size.x = Window->WindowRect.left; @@ -1561,7 +1586,7 @@ NtUserGetMinMaxInfo( { if(SendMessage) { - WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition, + co_WinPosGetMinMaxInfo(Window, &SafeMinMax.ptMaxSize, &SafeMinMax.ptMaxPosition, &SafeMinMax.ptMinTrackSize, &SafeMinMax.ptMaxTrackSize); } else @@ -1573,14 +1598,19 @@ NtUserGetMinMaxInfo( { IntReleaseWindowObject(Window); SetLastNtError(Status); - return FALSE; + RETURN( FALSE); } IntReleaseWindowObject(Window); - return TRUE; + RETURN( TRUE); } IntReleaseWindowObject(Window); - return FALSE; + RETURN( FALSE); + +CLEANUP: + DPRINT("Leave NtUserGetMinMaxInfo, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/winsta.c b/reactos/subsys/win32k/ntuser/winsta.c index e887493cd65..a62fa78f066 100644 --- a/reactos/subsys/win32k/ntuser/winsta.c +++ b/reactos/subsys/win32k/ntuser/winsta.c @@ -339,7 +339,7 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object) } BOOL FASTCALL -IntInitializeDesktopGraphics(VOID) +co_IntInitializeDesktopGraphics(VOID) { UNICODE_STRING DriverName; if (! IntCreatePrimarySurface()) @@ -355,10 +355,10 @@ IntInitializeDesktopGraphics(VOID) } DC_SetOwnership(ScreenDeviceContext, NULL); - NtUserAcquireOrReleaseInputOwnership(FALSE); + UserAcquireOrReleaseInputOwnership(FALSE); /* Setup the cursor */ - IntLoadDefaultCursors(); + co_IntLoadDefaultCursors(); return TRUE; } @@ -366,7 +366,7 @@ IntInitializeDesktopGraphics(VOID) VOID FASTCALL IntEndDesktopGraphics(VOID) { - NtUserAcquireOrReleaseInputOwnership(TRUE); + UserAcquireOrReleaseInputOwnership(TRUE); if (NULL != ScreenDeviceContext) { DC_SetOwnership(ScreenDeviceContext, PsGetCurrentProcess()); @@ -921,6 +921,27 @@ NtUserSetObjectInformation( return FALSE; } + + + +HWINSTA FASTCALL +UserGetProcessWindowStation(VOID) +{ + if(PsGetCurrentProcess() != CsrProcess) + { + return PsGetCurrentProcess()->Win32WindowStation; + } + else + { + /* FIXME - get the pointer to the window station by querying the parent of + the desktop of the calling thread (which is a window station), + then use ObFindHandleForObject() to find a suitable handle */ + DPRINT1("CSRSS called NtUserGetProcessWindowStation()!!! returned NULL!\n"); + return NULL; + } +} + + /* * NtUserGetProcessWindowStation * @@ -938,18 +959,7 @@ NtUserSetObjectInformation( HWINSTA STDCALL NtUserGetProcessWindowStation(VOID) { - if(PsGetCurrentProcess() != CsrProcess) - { - return PsGetCurrentProcess()->Win32WindowStation; - } - else - { - /* FIXME - get the pointer to the window station by querying the parent of - the desktop of the calling thread (which is a window station), - then use ObFindHandleForObject() to find a suitable handle */ - DPRINT1("CSRSS called NtUserGetProcessWindowStation()!!! returned NULL!\n"); - return NULL; - } + return UserGetProcessWindowStation(); } PWINSTATION_OBJECT FASTCALL diff --git a/reactos/subsys/win32k/objects/color.c b/reactos/subsys/win32k/objects/color.c index b1e26aa9509..6c4c2754f8b 100644 --- a/reactos/subsys/win32k/objects/color.c +++ b/reactos/subsys/win32k/objects/color.c @@ -83,7 +83,7 @@ BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPal, UINT StartIndex, UINT pal_entries; HDC hDC; PDC dc; - HWND hHwd; + PWINDOW_OBJECT Wnd; const PALETTEENTRY *pptr = PaletteColors; palPtr = (PPALGDI)PALETTE_LockPalette(hPal); @@ -109,8 +109,8 @@ BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPal, UINT StartIndex, PALETTE_UnlockPalette(palPtr); /* Immediately apply the new palette if current window uses it */ - hHwd = NtUserGetDesktopWindow(); - hDC = (HDC)NtUserGetWindowDC(hHwd); + Wnd = UserGetDesktopWindow(); + hDC = (HDC)UserGetWindowDC(Wnd); dc = DC_LockDc(hDC); if (NULL != dc) { @@ -122,7 +122,7 @@ BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPal, UINT StartIndex, else DC_UnlockDc(dc); } - NtUserReleaseDC(hHwd,hDC); + UserReleaseDC(Wnd,hDC); } return TRUE; } @@ -636,15 +636,36 @@ NtGdiUnrealizeObject(HGDIOBJ hgdiobj) BOOL STDCALL NtGdiUpdateColors(HDC hDC) { - HWND hWnd; + PWINDOW_OBJECT Wnd; + BOOL calledFromUser, ret; - hWnd = (HWND)NtUserCallOneParam((DWORD)hDC, ONEPARAM_ROUTINE_WINDOWFROMDC); - if (hWnd == NULL) + calledFromUser = UserIsEntered(); + + if (!calledFromUser){ + UserEnterExclusive(); + } + + Wnd = IntGetWindowObject(IntWindowFromDC(hDC)); + if (Wnd == NULL) { SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + + if (!calledFromUser){ + UserLeave(); + } + return FALSE; } - return NtUserRedrawWindow(hWnd, NULL, 0, RDW_INVALIDATE); + + ret = co_UserRedrawWindow(Wnd, NULL, 0, RDW_INVALIDATE); + + IntReleaseWindowObject(Wnd); //temp hack + + if (!calledFromUser){ + UserLeave(); + } + + return ret; } INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index 3516afc4e25..94cc3630db9 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -667,7 +667,8 @@ IntCreatePrimarySurface() SIZEL SurfSize; RECTL SurfaceRect; SURFOBJ *SurfObj; - + BOOL calledFromUser; + if (! IntPrepareDriverIfNeeded()) { return FALSE; @@ -688,6 +689,11 @@ IntCreatePrimarySurface() PrimarySurface.DriverFunctions.AssertMode(PrimarySurface.PDev, TRUE); + calledFromUser = UserIsEntered(); //fixme: possibly upgrade a shared lock + if (!calledFromUser){ + UserEnterExclusive(); + } + /* attach monitor */ IntAttachMonitor(&PrimarySurface, PrimarySurface.DisplayNumber); @@ -705,7 +711,11 @@ IntCreatePrimarySurface() GDIDEV(SurfObj)->Pointer.Pos.y = (SurfaceRect.bottom - SurfaceRect.top) / 2; EngUnlockSurface(SurfObj); - IntShowDesktop(IntGetActiveDesktop(), SurfSize.cx, SurfSize.cy); + co_IntShowDesktop(IntGetActiveDesktop(), SurfSize.cx, SurfSize.cy); + + if (!calledFromUser){ + UserLeave(); + } return TRUE; } @@ -713,11 +723,22 @@ IntCreatePrimarySurface() VOID FASTCALL IntDestroyPrimarySurface() { + BOOL calledFromUser; + DRIVER_UnreferenceDriver(L"DISPLAY"); + calledFromUser = UserIsEntered(); + if (!calledFromUser){ + UserEnterExclusive(); + } + /* detach monitor */ IntDetachMonitor(&PrimarySurface); + if (!calledFromUser){ + UserLeave(); + } + /* * FIXME: Hide a mouse pointer there. Also because we have to prevent * memory leaks with the Eng* mouse routines. @@ -746,7 +767,8 @@ IntGdiCreateDC(PUNICODE_STRING Driver, HDC hDC = NULL; HRGN hVisRgn; UNICODE_STRING StdDriver; - + BOOL calledFromUser; + RtlInitUnicodeString(&StdDriver, L"DISPLAY"); if (NULL == Driver || 0 == RtlCompareUnicodeString(Driver, &StdDriver, TRUE)) @@ -759,10 +781,26 @@ IntGdiCreateDC(PUNICODE_STRING Driver, return NULL; } } - else if (! IntGraphicsCheck(TRUE)) + else { - DPRINT1("Unable to initialize graphics, returning NULL dc\n"); - return NULL; + calledFromUser = UserIsEntered(); + if (!calledFromUser){ + UserEnterExclusive(); + } + + if (! co_IntGraphicsCheck(TRUE)) + { + if (!calledFromUser){ + UserLeave(); + } + DPRINT1("Unable to initialize graphics, returning NULL dc\n"); + return NULL; + } + + if (!calledFromUser){ + UserLeave(); + } + } } diff --git a/reactos/subsys/win32k/win32k.xml b/reactos/subsys/win32k/win32k.xml index 0af34a2d6e6..b340c517302 100644 --- a/reactos/subsys/win32k/win32k.xml +++ b/reactos/subsys/win32k/win32k.xml @@ -1,4 +1,4 @@ - + . include include @@ -87,6 +87,7 @@ misc.c monitor.c msgqueue.c + ntuser.c painting.c prop.c scrollbar.c