-remove hotkey lock

-remove dc list lock
-simplify/rework refcounting
-remove keyboard queue state lock
-convert some functions into taking pointerargs, not handles

svn path=/trunk/; revision=17743
This commit is contained in:
Gunnar Dalsnes 2005-09-08 16:18:51 +00:00
parent 57b5d08a65
commit b4f5c9b4b5
24 changed files with 411 additions and 550 deletions

View file

@ -50,7 +50,6 @@ typedef struct _SYSTEM_CURSORINFO
HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange); HCURSOR FASTCALL IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, BOOL ForceChange);
BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject); BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject);
PCURICON_OBJECT FASTCALL IntGetCurIconObject(HANDLE Handle);
PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject); PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject);
VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process); VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process);

View file

@ -50,10 +50,9 @@ typedef struct tagDCE
#define DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(pDCE) #define DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(pDCE)
BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody); BOOL INTERNAL_CALL DCE_Cleanup(PVOID ObjectBody);
PDCE FASTCALL DceAllocDCE(HWND hWnd, DCE_TYPE Type); PDCE FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
PDCE FASTCALL DCE_FreeDCE(PDCE dce); PDCE FASTCALL DCE_FreeDCE(PDCE dce);
VOID FASTCALL DCE_FreeWindowDCE(HWND); VOID FASTCALL DCE_FreeWindowDCE(HWND);
HRGN STDCALL DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags);
INT FASTCALL DCE_ExcludeRgn(HDC, HWND, HRGN); INT FASTCALL DCE_ExcludeRgn(HDC, HWND, HRGN);
BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL); BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL);
HWND FASTCALL IntWindowFromDC(HDC hDc); HWND FASTCALL IntWindowFromDC(HDC hDc);

View file

@ -34,12 +34,6 @@ UnregisterWindowHotKeys(PWINDOW_OBJECT Window);
VOID VOID
UnregisterThreadHotKeys(struct _ETHREAD *Thread); UnregisterThreadHotKeys(struct _ETHREAD *Thread);
#define IntLockHotKeys(WinStaObject) \
ExAcquireFastMutex(&WinStaObject->HotKeyListLock)
#define IntUnLockHotKeys(WinStaObject) \
ExReleaseFastMutex(&WinStaObject->HotKeyListLock)
#endif /* _WIN32K_HOTKEY_H */ #endif /* _WIN32K_HOTKEY_H */
/* EOF */ /* EOF */

View file

@ -67,7 +67,7 @@ HWND FASTCALL UserGetActiveWindow();
HWND FASTCALL UserGetForegroundWindow(VOID); HWND FASTCALL UserGetForegroundWindow(VOID);
HWND FASTCALL UserSetFocus(HWND hWnd); HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window);
/*************** WINDC.C ***************/ /*************** WINDC.C ***************/

View file

@ -154,7 +154,7 @@ HWND FASTCALL
IntGetActiveWindow (VOID); IntGetActiveWindow (VOID);
BOOL FASTCALL BOOL FASTCALL
IntIsWindowVisible (HWND hWnd); IntIsWindowVisible (PWINDOW_OBJECT Window);
BOOL FASTCALL BOOL FASTCALL
IntIsChildWindow (HWND Parent, HWND Child); IntIsChildWindow (HWND Parent, HWND Child);
@ -178,10 +178,10 @@ PWINDOW_OBJECT FASTCALL
IntGetParentObject(PWINDOW_OBJECT Wnd); IntGetParentObject(PWINDOW_OBJECT Wnd);
INT FASTCALL INT FASTCALL
IntGetWindowRgn(HWND hWnd, HRGN hRgn); IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn);
INT FASTCALL INT FASTCALL
IntGetWindowRgnBox(HWND hWnd, RECT *Rect); IntGetWindowRgnBox(PWINDOW_OBJECT Window, RECT *Rect);
BOOL FASTCALL BOOL FASTCALL
IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi); IntGetWindowInfo(PWINDOW_OBJECT WindowObject, PWINDOWINFO pwi);
@ -200,7 +200,7 @@ DWORD IntRemoveProcessWndProcHandles(HANDLE ProcessID);
DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode); DWORD IntAddWndProcHandle(WNDPROC WindowProc, BOOL IsUnicode);
BOOL FASTCALL BOOL FASTCALL
IntShowOwnedPopups( HWND owner, BOOL fShow ); IntShowOwnedPopups( PWINDOW_OBJECT owner, BOOL fShow );
#endif /* _WIN32K_WINDOW_H */ #endif /* _WIN32K_WINDOW_H */

View file

@ -19,7 +19,7 @@ FASTCALL co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent);
BOOL FASTCALL BOOL FASTCALL
IntGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point); IntGetClientOrigin(PWINDOW_OBJECT Window, LPPOINT Point);
LRESULT FASTCALL LRESULT FASTCALL
co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect); co_WinPosGetNonClientSize(PWINDOW_OBJECT Window, RECT* WindowRect, RECT* ClientRect);
UINT FASTCALL UINT FASTCALL
co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos, co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
POINT* MinTrack, POINT* MaxTrack); POINT* MinTrack, POINT* MaxTrack);

View file

@ -42,7 +42,6 @@ typedef struct _WINSTATION_OBJECT
struct _DESKTOP_OBJECT* ActiveDesktop; struct _DESKTOP_OBJECT* ActiveDesktop;
/* FIXME: Clipboard */ /* FIXME: Clipboard */
LIST_ENTRY HotKeyListHead; LIST_ENTRY HotKeyListHead;
FAST_MUTEX HotKeyListLock;
} WINSTATION_OBJECT, *PWINSTATION_OBJECT; } WINSTATION_OBJECT, *PWINSTATION_OBJECT;
extern WINSTATION_OBJECT *InputWindowStation; extern WINSTATION_OBJECT *InputWindowStation;

View file

@ -72,7 +72,11 @@ CleanupAcceleratorImpl(VOID)
static static
PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel) PACCELERATOR_TABLE FASTCALL UserGetAccelObject(HACCEL hAccel)
{ {
PACCELERATOR_TABLE Accel= UserGetObject(&gHandleTable, hAccel, otAccel); PACCELERATOR_TABLE Accel;
if (!hAccel) return NULL;
Accel= UserGetObject(&gHandleTable, hAccel, otAccel);
if (Accel) if (Accel)
{ {
@ -355,7 +359,7 @@ found:
mesg = 1; mesg = 1;
else if (IntGetCaptureWindow()) else if (IntGetCaptureWindow())
mesg = 2; mesg = 2;
else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */ else if (!IntIsWindowVisible(Window)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
mesg = 3; mesg = 3;
else else
{ {

View file

@ -221,23 +221,20 @@ NtUserCreateCaret(
int nWidth, int nWidth,
int nHeight) int nHeight)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT Window;
PUSER_MESSAGE_QUEUE ThreadQueue; PUSER_MESSAGE_QUEUE ThreadQueue;
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserCreateCaret\n"); DPRINT("Enter NtUserCreateCaret\n");
UserEnterExclusive(); UserEnterExclusive();
WindowObject = IntGetWindowObject(hWnd); if(!(Window = UserGetWindowObject(hWnd)))
if(!WindowObject)
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE);
RETURN(FALSE); RETURN(FALSE);
} }
if(WindowObject->OwnerThread != PsGetCurrentThread()) if(Window->OwnerThread != PsGetCurrentThread())
{ {
IntReleaseWindowObject(WindowObject);
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
RETURN(FALSE); RETURN(FALSE);
} }
@ -265,8 +262,6 @@ NtUserCreateCaret(
ThreadQueue->CaretInfo->Visible = 0; ThreadQueue->CaretInfo->Visible = 0;
ThreadQueue->CaretInfo->Showing = 0; ThreadQueue->CaretInfo->Showing = 0;
IntReleaseWindowObject(WindowObject);
RETURN(TRUE); RETURN(TRUE);
CLEANUP: CLEANUP:
@ -282,7 +277,7 @@ NtUserGetCaretBlinkTime(VOID)
DECLARE_RETURN(UINT); DECLARE_RETURN(UINT);
DPRINT("Enter NtUserGetCaretBlinkTime\n"); DPRINT("Enter NtUserGetCaretBlinkTime\n");
UserEnterExclusive(); UserEnterShared();
RETURN(IntGetCaretBlinkTime()); RETURN(IntGetCaretBlinkTime());
@ -322,11 +317,11 @@ CLEANUP:
} }
BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject) BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT Window)
{ {
PUSER_MESSAGE_QUEUE ThreadQueue; PUSER_MESSAGE_QUEUE ThreadQueue;
if(WindowObject->OwnerThread != PsGetCurrentThread()) if(Window->OwnerThread != PsGetCurrentThread())
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
@ -334,7 +329,7 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject)
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(ThreadQueue->CaretInfo->hWnd != WindowObject->hSelf) if(ThreadQueue->CaretInfo->hWnd != Window->hSelf)
{ {
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
@ -342,7 +337,7 @@ BOOL FASTCALL co_UserHideCaret(PWINDOW_OBJECT WindowObject)
if(ThreadQueue->CaretInfo->Visible) if(ThreadQueue->CaretInfo->Visible)
{ {
IntKillTimer(WindowObject->hSelf, IDCARETTIMER, TRUE); IntKillTimer(Window->hSelf, IDCARETTIMER, TRUE);
co_IntHideCaret(ThreadQueue->CaretInfo); co_IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Visible = 0; ThreadQueue->CaretInfo->Visible = 0;
@ -358,22 +353,21 @@ STDCALL
NtUserHideCaret( NtUserHideCaret(
HWND hWnd) HWND hWnd)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT Window;
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
BOOL ret; BOOL ret;
DPRINT("Enter NtUserHideCaret\n"); DPRINT("Enter NtUserHideCaret\n");
UserEnterExclusive(); UserEnterExclusive();
WindowObject = IntGetWindowObject(hWnd); if(!(Window = UserGetWindowObject(hWnd)))
if(!WindowObject)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE); RETURN(FALSE);
} }
ret = co_UserHideCaret(WindowObject); UserRefObjectCo(Window);
IntReleaseWindowObject(WindowObject); ret = co_UserHideCaret(Window);
UserDerefObjectCo(Window);
RETURN(ret); RETURN(ret);
@ -421,22 +415,22 @@ STDCALL
NtUserShowCaret( NtUserShowCaret(
HWND hWnd) HWND hWnd)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT Window;
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
BOOL ret; BOOL ret;
DPRINT("Enter NtUserShowCaret\n"); DPRINT("Enter NtUserShowCaret\n");
UserEnterExclusive(); UserEnterExclusive();
WindowObject = IntGetWindowObject(hWnd); if(!(Window = UserGetWindowObject(hWnd)))
if(!WindowObject)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE); RETURN(FALSE);
} }
ret = co_UserShowCaret(WindowObject); UserRefObjectCo(Window);
IntReleaseWindowObject(WindowObject); ret = co_UserShowCaret(Window);
UserDerefObjectCo(Window);
RETURN(ret); RETURN(ret);
CLEANUP: CLEANUP:

View file

@ -235,21 +235,18 @@ NtUserGetClassName (
LPWSTR lpClassName, LPWSTR lpClassName,
ULONG nMaxCount) ULONG nMaxCount)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT Window;
LONG Length;
DECLARE_RETURN(DWORD); DECLARE_RETURN(DWORD);
UserEnterShared(); UserEnterShared();
DPRINT("Enter NtUserGetClassName\n");
WindowObject = IntGetWindowObject(hWnd); if (!(Window = UserGetWindowObject(hWnd)))
if (WindowObject == NULL)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(0); RETURN(0);
} }
Length = IntGetClassName(WindowObject, lpClassName, nMaxCount);
IntReleaseWindowObject(WindowObject); RETURN( IntGetClassName(Window, lpClassName, nMaxCount));
RETURN(Length);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_); DPRINT("Leave NtUserGetClassName, ret=%i\n",_ret_);

View file

@ -72,35 +72,48 @@ IntGetCursorLocation(PWINSTATION_OBJECT WinStaObject, POINT *loc)
} }
#if 0
static
/* temp hack */ PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCursor)
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HANDLE hWnd)
{ {
PCURICON_OBJECT Window = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hWnd, otCursor); PCURICON_OBJECT Cursor;
if (!Window)
if (!hCursor) return NULL;
Cursor = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hCursor, otCursor);
if (!Cursor)
{ {
SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE); SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
return NULL; return NULL;
} }
ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0); ASSERT(USER_BODY_TO_HEADER(Cursor)->RefCount >= 0);
return Window; return Cursor;
} }
#endif
PCURICON_OBJECT FASTCALL static
IntGetCurIconObject(HANDLE Handle) PCURICON_OBJECT FASTCALL IntGetCurIconObject(HCURSOR hCursor)
{ {
PCURICON_OBJECT ci = UserGetCurIconObject(Handle); PCURICON_OBJECT Cursor;
if (ci)
if (!hCursor) return NULL;
Cursor = (PCURICON_OBJECT)UserGetObject(&gHandleTable, hCursor, otCursor);
if (!Cursor)
{ {
ASSERT(USER_BODY_TO_HEADER(ci)->RefCount >= 0); SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE);
return NULL;
USER_BODY_TO_HEADER(ci)->RefCount++;
} }
return ci;
ASSERT(USER_BODY_TO_HEADER(Cursor)->RefCount >= 0);
USER_BODY_TO_HEADER(Cursor)->RefCount++;
return Cursor;
} }
#define COLORCURSORS_ALLOWED FALSE #define COLORCURSORS_ALLOWED FALSE
HCURSOR FASTCALL HCURSOR FASTCALL
IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor, IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,

View file

@ -316,25 +316,28 @@ co_IntSetActiveWindow(PWINDOW_OBJECT Window OPTIONAL)
return hWndPrev; return hWndPrev;
} }
static
HWND FASTCALL HWND FASTCALL
co_IntSetFocusWindow(HWND hWnd) co_IntSetFocusWindow(PWINDOW_OBJECT Window)
{ {
HWND hWndPrev = 0; HWND hWndPrev = 0;
PUSER_MESSAGE_QUEUE ThreadQueue; PUSER_MESSAGE_QUEUE ThreadQueue;
ASSERT_REFS_CO(Window);
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
ASSERT(ThreadQueue != 0); ASSERT(ThreadQueue != 0);
hWndPrev = ThreadQueue->FocusWindow; hWndPrev = ThreadQueue->FocusWindow;
if (hWndPrev == hWnd) if (hWndPrev == Window->hSelf)
{ {
return hWndPrev; return hWndPrev;
} }
ThreadQueue->FocusWindow = hWnd; ThreadQueue->FocusWindow = Window->hSelf;
co_IntSendKillFocusMessages(hWndPrev, hWnd); co_IntSendKillFocusMessages(hWndPrev, Window->hSelf);
co_IntSendSetFocusMessages(hWndPrev, hWnd); co_IntSendSetFocusMessages(hWndPrev, Window->hSelf);
return hWndPrev; return hWndPrev;
} }
@ -513,18 +516,14 @@ CLEANUP:
HWND FASTCALL UserSetFocus(HWND hWnd) HWND FASTCALL co_UserSetFocus(PWINDOW_OBJECT Window OPTIONAL)
{ {
if (hWnd) if (Window)
{ {
PWINDOW_OBJECT Window;
PUSER_MESSAGE_QUEUE ThreadQueue; PUSER_MESSAGE_QUEUE ThreadQueue;
HWND hWndPrev, hWndTop; HWND hWndPrev, hWndTop;
if (!(Window = UserGetWindowObject(hWnd))) ASSERT_REFS_CO(Window);
{
return( 0);
}
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue; ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
@ -539,15 +538,17 @@ HWND FASTCALL UserSetFocus(HWND hWnd)
return( 0); return( 0);
} }
hWndTop = UserGetAncestor(hWnd, GA_ROOT); hWndTop = UserGetAncestor(Window->hSelf, GA_ROOT);
if (hWndTop != UserGetActiveWindow()) if (hWndTop != UserGetActiveWindow())
{ {
PWINDOW_OBJECT WndTops = IntGetWindowObject(hWndTop); PWINDOW_OBJECT WndTops = UserGetWindowObject(hWndTop);
UserRefObjectCo(WndTops);
co_IntSetActiveWindow(WndTops); co_IntSetActiveWindow(WndTops);
IntReleaseWindowObject(WndTops);//temp hack UserDerefObjectCo(WndTops);
} }
hWndPrev = co_IntSetFocusWindow(hWnd); hWndPrev = co_IntSetFocusWindow(Window);
return( hWndPrev); return( hWndPrev);
} }
@ -565,12 +566,23 @@ HWND FASTCALL UserSetFocus(HWND hWnd)
HWND STDCALL HWND STDCALL
NtUserSetFocus(HWND hWnd) NtUserSetFocus(HWND hWnd)
{ {
PWINDOW_OBJECT Window;
DECLARE_RETURN(HWND); DECLARE_RETURN(HWND);
HWND ret;
DPRINT("Enter NtUserSetFocus(%x)\n", hWnd); DPRINT("Enter NtUserSetFocus(%x)\n", hWnd);
UserEnterExclusive(); UserEnterExclusive();
RETURN(UserSetFocus(hWnd)); if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(NULL);
}
UserRefObjectCo(Window);
ret = co_UserSetFocus(Window);
UserDerefObjectCo(Window);
RETURN(ret);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_); DPRINT("Leave NtUserSetFocus, ret=%i\n",_ret_);

View file

@ -42,7 +42,6 @@ NTSTATUS FASTCALL
InitHotKeys(PWINSTATION_OBJECT WinStaObject) InitHotKeys(PWINSTATION_OBJECT WinStaObject)
{ {
InitializeListHead(&WinStaObject->HotKeyListHead); InitializeListHead(&WinStaObject->HotKeyListHead);
ExInitializeFastMutex(&WinStaObject->HotKeyListLock);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -72,8 +71,6 @@ GetHotKey (PWINSTATION_OBJECT WinStaObject,
return FALSE; return FALSE;
} }
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink; Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead) while (Entry != &WinStaObject->HotKeyListHead)
{ {
@ -92,7 +89,6 @@ GetHotKey (PWINSTATION_OBJECT WinStaObject,
if (id != NULL) if (id != NULL)
*id = HotKeyItem->id; *id = HotKeyItem->id;
IntUnLockHotKeys(WinStaObject);
return TRUE; return TRUE;
} }
@ -100,8 +96,6 @@ GetHotKey (PWINSTATION_OBJECT WinStaObject,
Entry = Entry->Flink; Entry = Entry->Flink;
} }
IntUnLockHotKeys(WinStaObject);
return FALSE; return FALSE;
} }
@ -119,8 +113,6 @@ UnregisterWindowHotKeys(PWINDOW_OBJECT Window)
if(!WinStaObject) if(!WinStaObject)
return; return;
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink; Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead) while (Entry != &WinStaObject->HotKeyListHead)
{ {
@ -135,7 +127,6 @@ UnregisterWindowHotKeys(PWINDOW_OBJECT Window)
} }
} }
IntUnLockHotKeys(WinStaObject);
} }
@ -152,8 +143,6 @@ UnregisterThreadHotKeys(struct _ETHREAD *Thread)
if(!WinStaObject) if(!WinStaObject)
return; return;
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink; Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead) while (Entry != &WinStaObject->HotKeyListHead)
{ {
@ -168,7 +157,6 @@ UnregisterThreadHotKeys(struct _ETHREAD *Thread)
} }
} }
IntUnLockHotKeys(WinStaObject);
} }
@ -220,14 +208,11 @@ NtUserRegisterHotKey(HWND hWnd,
} }
else else
{ {
Window = IntGetWindowObject(hWnd); if(!(Window = UserGetWindowObject(hWnd)))
if(!Window)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
HotKeyThread = Window->OwnerThread; HotKeyThread = Window->OwnerThread;
IntReleaseWindowObject(Window);
} }
@ -239,19 +224,15 @@ NtUserRegisterHotKey(HWND hWnd,
RETURN( FALSE); RETURN( FALSE);
} }
IntLockHotKeys(WinStaObject);
/* Check for existing hotkey */ /* Check for existing hotkey */
if (IsHotKey (WinStaObject, fsModifiers, vk)) if (IsHotKey (WinStaObject, fsModifiers, vk))
{ {
IntUnLockHotKeys(WinStaObject);
RETURN( FALSE); RETURN( FALSE);
} }
HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY); HotKeyItem = ExAllocatePoolWithTag (PagedPool, sizeof(HOT_KEY_ITEM), TAG_HOTKEY);
if (HotKeyItem == NULL) if (HotKeyItem == NULL)
{ {
IntUnLockHotKeys(WinStaObject);
RETURN( FALSE); RETURN( FALSE);
} }
@ -264,8 +245,6 @@ NtUserRegisterHotKey(HWND hWnd,
InsertHeadList (&WinStaObject->HotKeyListHead, InsertHeadList (&WinStaObject->HotKeyListHead,
&HotKeyItem->ListEntry); &HotKeyItem->ListEntry);
IntUnLockHotKeys(WinStaObject);
RETURN( TRUE); RETURN( TRUE);
CLEANUP: CLEANUP:
@ -288,10 +267,8 @@ NtUserUnregisterHotKey(HWND hWnd,
DPRINT("Enter NtUserUnregisterHotKey\n"); DPRINT("Enter NtUserUnregisterHotKey\n");
UserEnterExclusive(); UserEnterExclusive();
Window = IntGetWindowObject(hWnd); if(!(Window = UserGetWindowObject(hWnd)))
if(!Window)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
@ -300,12 +277,9 @@ NtUserUnregisterHotKey(HWND hWnd,
if(!WinStaObject) if(!WinStaObject)
{ {
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
IntLockHotKeys(WinStaObject);
Entry = WinStaObject->HotKeyListHead.Flink; Entry = WinStaObject->HotKeyListHead.Flink;
while (Entry != &WinStaObject->HotKeyListHead) while (Entry != &WinStaObject->HotKeyListHead)
{ {
@ -317,18 +291,13 @@ NtUserUnregisterHotKey(HWND hWnd,
{ {
RemoveEntryList (&HotKeyItem->ListEntry); RemoveEntryList (&HotKeyItem->ListEntry);
ExFreePool (HotKeyItem); ExFreePool (HotKeyItem);
IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
RETURN( TRUE); RETURN( TRUE);
} }
Entry = Entry->Flink; Entry = Entry->Flink;
} }
IntUnLockHotKeys(WinStaObject);
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
CLEANUP: CLEANUP:

View file

@ -35,7 +35,7 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
extern BYTE QueueKeyStateTable[]; extern BYTE gQueueKeyStateTable[];
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
@ -377,7 +377,7 @@ IntKeyboardSendWinKeyMsg()
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
MSG Mesg; MSG Mesg;
if (!(Window = IntGetWindowObject(InputWindowStation->ShellWindow))) if (!(Window = UserGetWindowObject(InputWindowStation->ShellWindow)))
{ {
DPRINT1("Couldn't find window to send Windows key message!\n"); DPRINT1("Couldn't find window to send Windows key message!\n");
return; return;
@ -390,8 +390,6 @@ IntKeyboardSendWinKeyMsg()
/* The QS_HOTKEY is just a guess */ /* The QS_HOTKEY is just a guess */
MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY); MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
ObmDereferenceObject(Window);
} }
STATIC VOID STDCALL STATIC VOID STDCALL
@ -1026,42 +1024,42 @@ IntMouseInput(MOUSEINPUT *mi)
Msg.message = 0; Msg.message = 0;
if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN) if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN)
{ {
QueueKeyStateTable[VK_LBUTTON] |= 0xc0; gQueueKeyStateTable[VK_LBUTTON] |= 0xc0;
Msg.message = SwapBtnMsg[0][SwapButtons]; Msg.message = SwapBtnMsg[0][SwapButtons];
CurInfo->ButtonsDown |= SwapBtn[SwapButtons]; CurInfo->ButtonsDown |= SwapBtn[SwapButtons];
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
else if(mi->dwFlags & MOUSEEVENTF_LEFTUP) else if(mi->dwFlags & MOUSEEVENTF_LEFTUP)
{ {
QueueKeyStateTable[VK_LBUTTON] &= ~0x80; gQueueKeyStateTable[VK_LBUTTON] &= ~0x80;
Msg.message = SwapBtnMsg[1][SwapButtons]; Msg.message = SwapBtnMsg[1][SwapButtons];
CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons]; CurInfo->ButtonsDown &= ~SwapBtn[SwapButtons];
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN) if(mi->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
{ {
QueueKeyStateTable[VK_MBUTTON] |= 0xc0; gQueueKeyStateTable[VK_MBUTTON] |= 0xc0;
Msg.message = WM_MBUTTONDOWN; Msg.message = WM_MBUTTONDOWN;
CurInfo->ButtonsDown |= MK_MBUTTON; CurInfo->ButtonsDown |= MK_MBUTTON;
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP) else if(mi->dwFlags & MOUSEEVENTF_MIDDLEUP)
{ {
QueueKeyStateTable[VK_MBUTTON] &= ~0x80; gQueueKeyStateTable[VK_MBUTTON] &= ~0x80;
Msg.message = WM_MBUTTONUP; Msg.message = WM_MBUTTONUP;
CurInfo->ButtonsDown &= ~MK_MBUTTON; CurInfo->ButtonsDown &= ~MK_MBUTTON;
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN) if(mi->dwFlags & MOUSEEVENTF_RIGHTDOWN)
{ {
QueueKeyStateTable[VK_RBUTTON] |= 0xc0; gQueueKeyStateTable[VK_RBUTTON] |= 0xc0;
Msg.message = SwapBtnMsg[0][!SwapButtons]; Msg.message = SwapBtnMsg[0][!SwapButtons];
CurInfo->ButtonsDown |= SwapBtn[!SwapButtons]; CurInfo->ButtonsDown |= SwapBtn[!SwapButtons];
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP) else if(mi->dwFlags & MOUSEEVENTF_RIGHTUP)
{ {
QueueKeyStateTable[VK_RBUTTON] &= ~0x80; gQueueKeyStateTable[VK_RBUTTON] &= ~0x80;
Msg.message = SwapBtnMsg[1][!SwapButtons]; Msg.message = SwapBtnMsg[1][!SwapButtons];
CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons]; CurInfo->ButtonsDown &= ~SwapBtn[!SwapButtons];
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
@ -1079,14 +1077,14 @@ IntMouseInput(MOUSEINPUT *mi)
Msg.message = WM_XBUTTONDOWN; Msg.message = WM_XBUTTONDOWN;
if(mi->mouseData & XBUTTON1) if(mi->mouseData & XBUTTON1)
{ {
QueueKeyStateTable[VK_XBUTTON1] |= 0xc0; gQueueKeyStateTable[VK_XBUTTON1] |= 0xc0;
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1); Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
CurInfo->ButtonsDown |= XBUTTON1; CurInfo->ButtonsDown |= XBUTTON1;
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
if(mi->mouseData & XBUTTON2) if(mi->mouseData & XBUTTON2)
{ {
QueueKeyStateTable[VK_XBUTTON2] |= 0xc0; gQueueKeyStateTable[VK_XBUTTON2] |= 0xc0;
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2); Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
CurInfo->ButtonsDown |= XBUTTON2; CurInfo->ButtonsDown |= XBUTTON2;
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
@ -1097,14 +1095,14 @@ IntMouseInput(MOUSEINPUT *mi)
Msg.message = WM_XBUTTONUP; Msg.message = WM_XBUTTONUP;
if(mi->mouseData & XBUTTON1) if(mi->mouseData & XBUTTON1)
{ {
QueueKeyStateTable[VK_XBUTTON1] &= ~0x80; gQueueKeyStateTable[VK_XBUTTON1] &= ~0x80;
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1); Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON1);
CurInfo->ButtonsDown &= ~XBUTTON1; CurInfo->ButtonsDown &= ~XBUTTON1;
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);
} }
if(mi->mouseData & XBUTTON2) if(mi->mouseData & XBUTTON2)
{ {
QueueKeyStateTable[VK_XBUTTON2] &= ~0x80; gQueueKeyStateTable[VK_XBUTTON2] &= ~0x80;
Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2); Msg.wParam = MAKEWPARAM(CurInfo->ButtonsDown, XBUTTON2);
CurInfo->ButtonsDown &= ~XBUTTON2; CurInfo->ButtonsDown &= ~XBUTTON2;
MsqInsertSystemMessage(&Msg); MsqInsertSystemMessage(&Msg);

View file

@ -49,24 +49,16 @@
/* From kbdxx.c -- Key changes with numlock */ /* From kbdxx.c -- Key changes with numlock */
#define KNUMP 0x400 #define KNUMP 0x400
/* Lock the keyboard state to prevent unusual concurrent access */
FAST_MUTEX QueueStateLock;
BYTE QueueKeyStateTable[256]; BYTE gQueueKeyStateTable[256];
#define IntLockQueueState \
ExAcquireFastMutex(&QueueStateLock)
#define IntUnLockQueueState \
ExReleaseFastMutex(&QueueStateLock)
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/* Initialization -- Right now, just zero the key state and init the lock */ /* Initialization -- Right now, just zero the key state and init the lock */
NTSTATUS FASTCALL InitKeyboardImpl(VOID) NTSTATUS FASTCALL InitKeyboardImpl(VOID)
{ {
ExInitializeFastMutex(&QueueStateLock); RtlZeroMemory(&gQueueKeyStateTable,0x100);
RtlZeroMemory(&QueueKeyStateTable,0x100);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -93,7 +85,7 @@ static VOID STDCALL SetKeyState(DWORD key, DWORD vk, DWORD ext, BOOL down)
if (vk == VK_CAPITAL || vk == VK_NUMLOCK) if (vk == VK_CAPITAL || vk == VK_NUMLOCK)
{ {
if (down) if (down)
QueueKeyStateTable[vk] ^= KS_LOCK_BIT; gQueueKeyStateTable[vk] ^= KS_LOCK_BIT;
} }
if (ext && vk == VK_LSHIFT) if (ext && vk == VK_LSHIFT)
@ -104,46 +96,46 @@ static VOID STDCALL SetKeyState(DWORD key, DWORD vk, DWORD ext, BOOL down)
vk = VK_RMENU; vk = VK_RMENU;
if (down) if (down)
QueueKeyStateTable[vk] |= KS_DOWN_BIT; gQueueKeyStateTable[vk] |= KS_DOWN_BIT;
else else
QueueKeyStateTable[vk] &= ~KS_DOWN_MASK; gQueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
if (vk == VK_LSHIFT || vk == VK_RSHIFT) if (vk == VK_LSHIFT || vk == VK_RSHIFT)
{ {
if ((QueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) || if ((gQueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
(QueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT)) (gQueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
{ {
QueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT; gQueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
} }
else else
{ {
QueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK; gQueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
} }
} }
if (vk == VK_LCONTROL || vk == VK_RCONTROL) if (vk == VK_LCONTROL || vk == VK_RCONTROL)
{ {
if ((QueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) || if ((gQueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
(QueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT)) (gQueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
{ {
QueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT; gQueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
} }
else else
{ {
QueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK; gQueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
} }
} }
if (vk == VK_LMENU || vk == VK_RMENU) if (vk == VK_LMENU || vk == VK_RMENU)
{ {
if ((QueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) || if ((gQueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
(QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT)) (gQueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
{ {
QueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT; gQueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
} }
else else
{ {
QueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK; gQueueKeyStateTable[VK_MENU] &= ~KS_DOWN_MASK;
} }
} }
} }
@ -351,13 +343,12 @@ DWORD FASTCALL UserGetKeyState(DWORD key)
{ {
DWORD ret = 0; DWORD ret = 0;
IntLockQueueState;
if( key < 0x100 ) if( key < 0x100 )
{ {
ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) | ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
(QueueKeyStateTable[key] & KS_LOCK_BIT); (gQueueKeyStateTable[key] & KS_LOCK_BIT);
} }
IntUnLockQueueState;
return ret; return ret;
} }
@ -386,13 +377,12 @@ DWORD FASTCALL UserGetAsyncKeyState(DWORD key)
{ {
DWORD ret = 0; DWORD ret = 0;
IntLockQueueState;
if( key < 0x100 ) if( key < 0x100 )
{ {
ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) | ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
(QueueKeyStateTable[key] & KS_LOCK_BIT); (gQueueKeyStateTable[key] & KS_LOCK_BIT);
} }
IntUnLockQueueState;
return ret; return ret;
} }
@ -434,7 +424,6 @@ int STDCALL ToUnicodeEx( UINT wVirtKey,
} }
else else
{ {
IntLockQueueState;
ToUnicodeResult = ToUnicodeInner( wVirtKey, ToUnicodeResult = ToUnicodeInner( wVirtKey,
wScanCode, wScanCode,
lpKeyState, lpKeyState,
@ -443,7 +432,6 @@ int STDCALL ToUnicodeEx( UINT wVirtKey,
wFlags, wFlags,
PsGetWin32Thread() ? PsGetWin32Thread() ?
PsGetWin32Thread()->KeyboardLayout : 0 ); PsGetWin32Thread()->KeyboardLayout : 0 );
IntUnLockQueueState;
} }
return ToUnicodeResult; return ToUnicodeResult;
@ -458,7 +446,7 @@ int STDCALL ToUnicode( UINT wVirtKey,
{ {
return ToUnicodeEx( wVirtKey, return ToUnicodeEx( wVirtKey,
wScanCode, wScanCode,
QueueKeyStateTable, gQueueKeyStateTable,
pwszBuff, pwszBuff,
cchBuff, cchBuff,
wFlags, wFlags,
@ -735,14 +723,12 @@ IntTranslateKbdMessage(LPMSG lpMsg,
ScanCode = (lpMsg->lParam >> 16) & 0xff; ScanCode = (lpMsg->lParam >> 16) & 0xff;
IntLockQueueState;
/* All messages have to contain the cursor point. */ /* All messages have to contain the cursor point. */
IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation, IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation,
&NewMsg.pt); &NewMsg.pt);
UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff, UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff,
QueueKeyStateTable, wp, 2, 0, gQueueKeyStateTable, wp, 2, 0,
keyLayout ); keyLayout );
if (UState == 1) if (UState == 1)
@ -797,7 +783,6 @@ IntTranslateKbdMessage(LPMSG lpMsg,
Result = TRUE; Result = TRUE;
} }
IntUnLockQueueState;
return Result; return Result;
} }
@ -807,33 +792,47 @@ NtUserGetKeyboardState(
LPBYTE lpKeyState) LPBYTE lpKeyState)
{ {
BOOL Result = TRUE; BOOL Result = TRUE;
DECLARE_RETURN(DWORD);
IntLockQueueState;
DPRINT("Enter NtUserGetKeyboardState\n");
UserEnterShared();
if (lpKeyState) if (lpKeyState)
{ {
if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, QueueKeyStateTable, 256))) if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, gQueueKeyStateTable, 256)))
Result = FALSE; Result = FALSE;
} }
IntUnLockQueueState;
return Result; RETURN(Result);
CLEANUP:
DPRINT("Leave NtUserGetKeyboardState, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
DWORD DWORD
STDCALL STDCALL
NtUserSetKeyboardState( NtUserSetKeyboardState(LPBYTE lpKeyState)
LPBYTE lpKeyState)
{ {
BOOL Result = TRUE; BOOL Result = TRUE;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserSetKeyboardState\n");
UserEnterExclusive();
IntLockQueueState;
if (lpKeyState) if (lpKeyState)
{ {
if(! NT_SUCCESS(MmCopyFromCaller(QueueKeyStateTable, lpKeyState, 256))) if(! NT_SUCCESS(MmCopyFromCaller(gQueueKeyStateTable, lpKeyState, 256)))
Result = FALSE; Result = FALSE;
} }
IntUnLockQueueState;
RETURN(Result);
return Result; CLEANUP:
DPRINT("Leave NtUserSetKeyboardState, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
static UINT VkToScan( UINT Code, BOOL ExtCode, PKBDTABLES pkKT ) static UINT VkToScan( UINT Code, BOOL ExtCode, PKBDTABLES pkKT )
@ -950,13 +949,23 @@ UINT
STDCALL STDCALL
NtUserMapVirtualKeyEx( UINT Code, UINT Type, DWORD keyboardId, HKL dwhkl ) NtUserMapVirtualKeyEx( UINT Code, UINT Type, DWORD keyboardId, HKL dwhkl )
{ {
PKBDTABLES keyLayout = PsGetWin32Thread() ? PKBDTABLES keyLayout;
PsGetWin32Thread()->KeyboardLayout : 0; DECLARE_RETURN(UINT);
DPRINT("Enter NtUserMapVirtualKeyEx\n");
UserEnterExclusive();
keyLayout = PsGetWin32Thread() ? PsGetWin32Thread()->KeyboardLayout : 0;
if( !keyLayout ) if( !keyLayout )
return 0; RETURN(0);
return IntMapVirtualKeyEx( Code, Type, keyLayout ); RETURN(IntMapVirtualKeyEx( Code, Type, keyLayout ));
CLEANUP:
DPRINT("Leave NtUserMapVirtualKeyEx, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
@ -974,6 +983,10 @@ NtUserToUnicodeEx(
BYTE KeyStateBuf[0x100]; BYTE KeyStateBuf[0x100];
PWCHAR OutPwszBuff = 0; PWCHAR OutPwszBuff = 0;
int ret = 0; int ret = 0;
DECLARE_RETURN(int);
DPRINT("Enter NtUserSetKeyboardState\n");
UserEnterShared();//faxme: this syscall doesnt seem to need any locking...
if( !NT_SUCCESS(MmCopyFromCaller(KeyStateBuf, if( !NT_SUCCESS(MmCopyFromCaller(KeyStateBuf,
@ -981,13 +994,13 @@ NtUserToUnicodeEx(
sizeof(KeyStateBuf))) ) sizeof(KeyStateBuf))) )
{ {
DPRINT1( "Couldn't copy key state from caller.\n" ); DPRINT1( "Couldn't copy key state from caller.\n" );
return 0; RETURN(0);
} }
OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING); OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING);
if( !OutPwszBuff ) if( !OutPwszBuff )
{ {
DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff); DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff);
return 0; RETURN(0);
} }
RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff ); RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff );
@ -1002,7 +1015,12 @@ NtUserToUnicodeEx(
MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff); MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff);
ExFreePool(OutPwszBuff); ExFreePool(OutPwszBuff);
return ret; RETURN(ret);
CLEANUP:
DPRINT("Leave NtUserSetKeyboardState, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
static int W32kSimpleToupper( int ch ) static int W32kSimpleToupper( int ch )
@ -1022,12 +1040,17 @@ NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize )
UINT VkCode = 0; UINT VkCode = 0;
UINT ScanCode = (lParam >> 16) & 0xff; UINT ScanCode = (lParam >> 16) & 0xff;
BOOL ExtKey = lParam & (1<<24) ? TRUE : FALSE; BOOL ExtKey = lParam & (1<<24) ? TRUE : FALSE;
PKBDTABLES keyLayout = PKBDTABLES keyLayout;
PsGetWin32Thread() ? DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserGetKeyNameText\n");
UserEnterShared();
keyLayout = PsGetWin32Thread() ?
PsGetWin32Thread()->KeyboardLayout : 0; PsGetWin32Thread()->KeyboardLayout : 0;
if( !keyLayout || nSize < 1 ) if( !keyLayout || nSize < 1 )
return 0; RETURN(0);
if( lParam & (1<<25) ) if( lParam & (1<<25) )
{ {
@ -1083,10 +1106,15 @@ NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize )
ret = 1; ret = 1;
if( !NT_SUCCESS(MmCopyToCaller( lpString, UCName, 2 * sizeof(WCHAR) )) ) if( !NT_SUCCESS(MmCopyToCaller( lpString, UCName, 2 * sizeof(WCHAR) )) )
return 0; RETURN(0);
} }
return ret; RETURN(ret);
CLEANUP:
DPRINT("Leave NtUserGetKeyNameText, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
/* /*
@ -1125,11 +1153,9 @@ W32kKeyProcessMessage(LPMSG Msg,
return; return;
} }
IntLockQueueState;
/* arty -- handle numpad -- On real windows, the actual key produced /* arty -- handle numpad -- On real windows, the actual key produced
* by the messaging layer is different based on the state of numlock. */ * by the messaging layer is different based on the state of numlock. */
ModifierBits = ModBits(KeyboardLayout,QueueKeyStateTable); ModifierBits = ModBits(KeyboardLayout,gQueueKeyStateTable);
/* Get the raw scan code, so we can look up whether the key is a numpad /* Get the raw scan code, so we can look up whether the key is a numpad
* key * key
@ -1152,7 +1178,6 @@ W32kKeyProcessMessage(LPMSG Msg,
/* ignore shift codes */ /* ignore shift codes */
if( ScanCode == 0x2A || ScanCode == 0x36 ) if( ScanCode == 0x2A || ScanCode == 0x36 )
{ {
IntUnLockQueueState;
return; return;
} }
VscVkTable = KeyboardLayout->pVSCtoVK_E0; VscVkTable = KeyboardLayout->pVSCtoVK_E0;
@ -1206,7 +1231,7 @@ W32kKeyProcessMessage(LPMSG Msg,
} }
/* We need to unset SYSKEYDOWN if the ALT key is an ALT+Gr */ /* We need to unset SYSKEYDOWN if the ALT key is an ALT+Gr */
if( QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT ) if( gQueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT )
{ {
if( Msg->message == WM_SYSKEYDOWN ) if( Msg->message == WM_SYSKEYDOWN )
Msg->message = WM_KEYDOWN; Msg->message = WM_KEYDOWN;
@ -1214,7 +1239,6 @@ W32kKeyProcessMessage(LPMSG Msg,
Msg->message = WM_KEYUP; Msg->message = WM_KEYUP;
} }
IntUnLockQueueState;
} }
DWORD DWORD
@ -1310,7 +1334,17 @@ STDCALL
NtUserGetKeyboardType( NtUserGetKeyboardType(
DWORD TypeFlag) DWORD TypeFlag)
{ {
return UserGetKeyboardType(TypeFlag); DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserGetKeyboardType\n");
UserEnterShared();
RETURN( UserGetKeyboardType(TypeFlag));
CLEANUP:
DPRINT("Leave NtUserGetKeyboardType, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
@ -1325,6 +1359,8 @@ NtUserVkKeyScanEx(
DWORD KeyboardLayout, DWORD KeyboardLayout,
DWORD Unknown2) DWORD Unknown2)
{ {
/* FAXME: currently, this routine doesnt seem to need any locking */
PKBDTABLES KeyLayout; PKBDTABLES KeyLayout;
PVK_TO_WCHAR_TABLE vtwTbl; PVK_TO_WCHAR_TABLE vtwTbl;
PVK_TO_WCHARS10 vkPtr; PVK_TO_WCHARS10 vkPtr;

View file

@ -206,11 +206,10 @@ IntFreeMenuItem(PMENU_OBJECT Menu, PMENU_ITEM MenuItem,
if(bRecurse && MenuItem->hSubMenu) if(bRecurse && MenuItem->hSubMenu)
{ {
PMENU_OBJECT SubMenu; PMENU_OBJECT SubMenu;
SubMenu = IntGetMenuObject(MenuItem->hSubMenu ); SubMenu = UserGetMenuObject(MenuItem->hSubMenu );
if(SubMenu) if(SubMenu)
{ {
IntDestroyMenuObject(SubMenu, bRecurse, TRUE); IntDestroyMenuObject(SubMenu, bRecurse, TRUE);
IntReleaseMenuObject(SubMenu);
} }
} }
@ -485,9 +484,8 @@ IntIsMenu(HMENU hMenu)
{ {
PMENU_OBJECT Menu; PMENU_OBJECT Menu;
if((Menu = IntGetMenuObject(hMenu))) if((Menu = UserGetMenuObject(hMenu)))
{ {
IntReleaseMenuObject(Menu);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -781,12 +779,11 @@ IntSetMenuItemInfo(PMENU_OBJECT MenuObject, PMENU_ITEM MenuItem, PROSMENUITEMINF
/* Make sure the submenu is marked as a popup menu */ /* Make sure the submenu is marked as a popup menu */
if (MenuItem->hSubMenu) if (MenuItem->hSubMenu)
{ {
SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu); SubMenuObject = UserGetMenuObject(MenuItem->hSubMenu);
if (SubMenuObject != NULL) if (SubMenuObject != NULL)
{ {
SubMenuObject->MenuInfo.Flags |= MF_POPUP; SubMenuObject->MenuInfo.Flags |= MF_POPUP;
MenuItem->fType |= MF_POPUP; MenuItem->fType |= MF_POPUP;
IntReleaseMenuObject(SubMenuObject);
} }
else else
{ {
@ -1184,7 +1181,7 @@ IntGetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT fByPos, UINT gmdiFlags,
MenuItem->hSubMenu) MenuItem->hSubMenu)
{ {
SubMenuObject = IntGetMenuObject(MenuItem->hSubMenu); SubMenuObject = UserGetMenuObject(MenuItem->hSubMenu);
if(!SubMenuObject || (SubMenuObject == MenuObject)) if(!SubMenuObject || (SubMenuObject == MenuObject))
break; break;
@ -1192,8 +1189,6 @@ IntGetMenuDefaultItem(PMENU_OBJECT MenuObject, UINT fByPos, UINT gmdiFlags,
sres = IntGetMenuDefaultItem(SubMenuObject, fByPos, gmdiFlags, gismc); sres = IntGetMenuDefaultItem(SubMenuObject, fByPos, gmdiFlags, gismc);
(*gismc)--; (*gismc)--;
IntReleaseMenuObject(SubMenuObject);
if(sres > (UINT)-1) if(sres > (UINT)-1)
res = sres; res = sres;
} }
@ -1311,30 +1306,26 @@ NtUserBuildMenuItemList(
DWORD Reserved) DWORD Reserved)
{ {
DWORD res = -1; DWORD res = -1;
PMENU_OBJECT MenuObject; PMENU_OBJECT Menu;
DECLARE_RETURN(DWORD); DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserBuildMenuItemList\n"); DPRINT("Enter NtUserBuildMenuItemList\n");
UserEnterExclusive(); UserEnterExclusive();
MenuObject = IntGetMenuObject(hMenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
RETURN( (DWORD)-1); RETURN( (DWORD)-1);
} }
if(Buffer) if(Buffer)
{ {
res = IntBuildMenuItemList(MenuObject, Buffer, nBufSize); res = IntBuildMenuItemList(Menu, Buffer, nBufSize);
} }
else else
{ {
res = MenuObject->MenuInfo.MenuItemCount; res = Menu->MenuInfo.MenuItemCount;
} }
IntReleaseMenuObject(MenuObject);
RETURN( res); RETURN( res);
CLEANUP: CLEANUP:
@ -1349,28 +1340,22 @@ CLEANUP:
*/ */
DWORD STDCALL DWORD STDCALL
NtUserCheckMenuItem( NtUserCheckMenuItem(
HMENU hmenu, HMENU hMenu,
UINT uIDCheckItem, UINT uIDCheckItem,
UINT uCheck) UINT uCheck)
{ {
DWORD res = 0; PMENU_OBJECT Menu;
PMENU_OBJECT MenuObject;
DECLARE_RETURN(DWORD); DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserCheckMenuItem\n"); DPRINT("Enter NtUserCheckMenuItem\n");
UserEnterExclusive(); UserEnterExclusive();
MenuObject = IntGetMenuObject(hmenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
RETURN( (DWORD)-1); RETURN( (DWORD)-1);
} }
res = IntCheckMenuItem(MenuObject, uIDCheckItem, uCheck); RETURN( IntCheckMenuItem(Menu, uIDCheckItem, uCheck));
IntReleaseMenuObject(MenuObject);
RETURN( res);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserCheckMenuItem, ret=%i\n",_ret_); DPRINT("Leave NtUserCheckMenuItem, ret=%i\n",_ret_);
@ -1432,24 +1417,18 @@ NtUserDeleteMenu(
UINT uPosition, UINT uPosition,
UINT uFlags) UINT uFlags)
{ {
BOOL res; PMENU_OBJECT Menu;
PMENU_OBJECT MenuObject;
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserDeleteMenu\n"); DPRINT("Enter NtUserDeleteMenu\n");
UserEnterExclusive(); UserEnterExclusive();
MenuObject = IntGetMenuObject(hMenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
res = IntRemoveMenuItem(MenuObject, uPosition, uFlags, TRUE); RETURN( IntRemoveMenuItem(Menu, uPosition, uFlags, TRUE));
IntReleaseMenuObject(MenuObject);
RETURN( res);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserDeleteMenu, ret=%i\n",_ret_); DPRINT("Leave NtUserDeleteMenu, ret=%i\n",_ret_);
@ -1464,25 +1443,20 @@ CLEANUP:
*/ */
BOOL FASTCALL UserDestroyMenu(HMENU hMenu) BOOL FASTCALL UserDestroyMenu(HMENU hMenu)
{ {
BOOL Ret; PMENU_OBJECT Menu;
PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
return FALSE; return FALSE;
} }
if(MenuObject->Process != PsGetCurrentProcess())
if(Menu->Process != PsGetCurrentProcess())
{ {
IntReleaseMenuObject(MenuObject);
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
} }
Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE); return IntDestroyMenuObject(Menu, FALSE, TRUE);
IntReleaseMenuObject(MenuObject);
return Ret;
} }
/* /*
@ -1492,29 +1466,24 @@ BOOL STDCALL
NtUserDestroyMenu( NtUserDestroyMenu(
HMENU hMenu) HMENU hMenu)
{ {
BOOL Ret; PMENU_OBJECT Menu;
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserDestroyMenu\n"); DPRINT("Enter NtUserDestroyMenu\n");
UserEnterExclusive(); UserEnterExclusive();
PMENU_OBJECT MenuObject = IntGetMenuObject(hMenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
if(MenuObject->Process != PsGetCurrentProcess())
if(Menu->Process != PsGetCurrentProcess())
{ {
IntReleaseMenuObject(MenuObject);
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
RETURN( FALSE); RETURN( FALSE);
} }
Ret = IntDestroyMenuObject(MenuObject, FALSE, TRUE); RETURN( IntDestroyMenuObject(Menu, FALSE, TRUE));
IntReleaseMenuObject(MenuObject);
RETURN( Ret);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserDestroyMenu, ret=%i\n",_ret_); DPRINT("Leave NtUserDestroyMenu, ret=%i\n",_ret_);
@ -1532,25 +1501,18 @@ NtUserEnableMenuItem(
UINT uIDEnableItem, UINT uIDEnableItem,
UINT uEnable) UINT uEnable)
{ {
UINT res = (UINT)-1; PMENU_OBJECT Menu;
PMENU_OBJECT MenuObject;
DECLARE_RETURN(UINT); DECLARE_RETURN(UINT);
DPRINT("Enter NtUserEnableMenuItem\n"); DPRINT("Enter NtUserEnableMenuItem\n");
UserEnterExclusive(); UserEnterExclusive();
MenuObject = IntGetMenuObject(hMenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); RETURN(-1);
RETURN( res);
} }
res = IntEnableMenuItem(MenuObject, uIDEnableItem, uEnable); RETURN( IntEnableMenuItem(Menu, uIDEnableItem, uEnable));
IntReleaseMenuObject(MenuObject);
RETURN( res);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserEnableMenuItem, ret=%i\n",_ret_); DPRINT("Leave NtUserEnableMenuItem, ret=%i\n",_ret_);
@ -1569,8 +1531,7 @@ NtUserInsertMenuItem(
BOOL fByPosition, BOOL fByPosition,
LPCMENUITEMINFOW UnsafeItemInfo) LPCMENUITEMINFOW UnsafeItemInfo)
{ {
DWORD Res = 0; PMENU_OBJECT Menu;
PMENU_OBJECT MenuObject;
NTSTATUS Status; NTSTATUS Status;
ROSMENUITEMINFO ItemInfo; ROSMENUITEMINFO ItemInfo;
DECLARE_RETURN(DWORD); DECLARE_RETURN(DWORD);
@ -1578,32 +1539,24 @@ NtUserInsertMenuItem(
DPRINT("Enter NtUserInsertMenuItem\n"); DPRINT("Enter NtUserInsertMenuItem\n");
UserEnterExclusive(); UserEnterExclusive();
MenuObject = IntGetMenuObject(hMenu); if(!(Menu = UserGetMenuObject(hMenu)))
if(!MenuObject)
{ {
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE); RETURN(0);
RETURN( 0);
} }
Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW)); Status = MmCopyFromCaller(&ItemInfo, UnsafeItemInfo, sizeof(MENUITEMINFOW));
if (! NT_SUCCESS(Status)) if (! NT_SUCCESS(Status))
{ {
IntReleaseMenuObject(MenuObject);
SetLastNtError(Status); SetLastNtError(Status);
RETURN( FALSE); RETURN( FALSE);
} }
if (ItemInfo.cbSize != sizeof(MENUITEMINFOW)) if (ItemInfo.cbSize != sizeof(MENUITEMINFOW))
{ {
IntReleaseMenuObject(MenuObject);
SetLastWin32Error(ERROR_INVALID_PARAMETER); SetLastWin32Error(ERROR_INVALID_PARAMETER);
RETURN( FALSE); RETURN( FALSE);
} }
Res = IntInsertMenuItem(MenuObject, uItem, fByPosition, &ItemInfo); RETURN( IntInsertMenuItem(Menu, uItem, fByPosition, &ItemInfo));
IntReleaseMenuObject(MenuObject);
RETURN( Res);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserInsertMenuItem, ret=%i\n",_ret_); DPRINT("Leave NtUserInsertMenuItem, ret=%i\n",_ret_);
@ -1769,39 +1722,34 @@ CLEANUP:
*/ */
BOOL STDCALL BOOL STDCALL
NtUserHiliteMenuItem( NtUserHiliteMenuItem(
HWND hwnd, HWND hWnd,
HMENU hmenu, HMENU hMenu,
UINT uItemHilite, UINT uItemHilite,
UINT uHilite) UINT uHilite)
{ {
BOOL res = FALSE; PMENU_OBJECT Menu;
PMENU_OBJECT MenuObject; PWINDOW_OBJECT Window;
PWINDOW_OBJECT WindowObject;
DECLARE_RETURN(BOOLEAN); DECLARE_RETURN(BOOLEAN);
DPRINT("Enter NtUserHiliteMenuItem\n"); DPRINT("Enter NtUserHiliteMenuItem\n");
UserEnterExclusive(); UserEnterExclusive();
WindowObject = IntGetWindowObject(hwnd); if(!(Window = UserGetWindowObject(hWnd)))
if(!WindowObject)
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); RETURN(FALSE);
RETURN( res);
} }
MenuObject = IntGetMenuObject(hmenu);
if(!MenuObject) if(!(Menu = UserGetMenuObject(hMenu)))
{ {
IntReleaseWindowObject(WindowObject); RETURN(FALSE);
SetLastWin32Error(ERROR_INVALID_MENU_HANDLE);
RETURN( res);
} }
if(WindowObject->IDMenu == (UINT)hmenu)
if(Window->IDMenu == (UINT)hMenu)
{ {
res = IntHiliteMenuItem(WindowObject, MenuObject, uItemHilite, uHilite); RETURN( IntHiliteMenuItem(Window, Menu, uItemHilite, uHilite));
} }
IntReleaseMenuObject(MenuObject);
IntReleaseWindowObject(WindowObject); RETURN(FALSE);
RETURN( res);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserHiliteMenuItem, ret=%i\n",_ret_); DPRINT("Leave NtUserHiliteMenuItem, ret=%i\n",_ret_);

View file

@ -227,7 +227,7 @@ NtUserGetSystemMetrics(ULONG Index)
DECLARE_RETURN(ULONG); DECLARE_RETURN(ULONG);
DPRINT("Enter NtUserGetSystemMetrics\n"); DPRINT("Enter NtUserGetSystemMetrics\n");
UserEnterExclusive(); UserEnterShared();
RETURN(UserGetSystemMetrics(Index)); RETURN(UserGetSystemMetrics(Index));

View file

@ -413,7 +413,10 @@ NtUserCallTwoParam(
{ {
DWORD Ret; DWORD Ret;
RECT rcRect; RECT rcRect;
Ret = (DWORD)IntGetWindowRgnBox((HWND)Param1, &rcRect); PWINDOW_OBJECT Window = UserGetWindowObject((HWND)Param1);
if (!Window) RETURN(ERROR);
Ret = (DWORD)IntGetWindowRgnBox(Window, &rcRect);
Status = MmCopyToCaller((PVOID)Param2, &rcRect, sizeof(RECT)); Status = MmCopyToCaller((PVOID)Param2, &rcRect, sizeof(RECT));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
@ -424,7 +427,10 @@ NtUserCallTwoParam(
} }
case TWOPARAM_ROUTINE_GETWINDOWRGN: case TWOPARAM_ROUTINE_GETWINDOWRGN:
{ {
RETURN( (DWORD)IntGetWindowRgn((HWND)Param1, (HRGN)Param2)); PWINDOW_OBJECT Window = UserGetWindowObject((HWND)Param1);
if (!Window) RETURN(ERROR);
RETURN( (DWORD)IntGetWindowRgn(Window, (HRGN)Param2));
} }
case TWOPARAM_ROUTINE_SETMENUBARHEIGHT: case TWOPARAM_ROUTINE_SETMENUBARHEIGHT:
{ {
@ -480,7 +486,12 @@ NtUserCallTwoParam(
RETURN( 0); RETURN( 0);
case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS: case TWOPARAM_ROUTINE_SHOWOWNEDPOPUPS:
RETURN( (DWORD)IntShowOwnedPopups((HWND) Param1, (BOOL) Param2)); {
PWINDOW_OBJECT Window = UserGetWindowObject((HWND)Param1);
if (!Window) RETURN(0);
RETURN( (DWORD)IntShowOwnedPopups(Window, (BOOL) Param2));
}
case TWOPARAM_ROUTINE_ROS_SHOWWINDOW: case TWOPARAM_ROUTINE_ROS_SHOWWINDOW:
{ {

View file

@ -41,8 +41,7 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
/* list of monitors */ /* list of monitors */
static PMONITOR_OBJECT MonitorList = NULL; static PMONITOR_OBJECT gMonitorList = NULL;
static FAST_MUTEX MonitorListLock; /* R/W lock for monitor list */
/* INITALIZATION FUNCTIONS ****************************************************/ /* INITALIZATION FUNCTIONS ****************************************************/
@ -50,7 +49,6 @@ NTSTATUS
InitMonitorImpl() InitMonitorImpl()
{ {
DPRINT("Initializing monitor implementation...\n"); DPRINT("Initializing monitor implementation...\n");
ExInitializeFastMutex(&MonitorListLock);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -121,24 +119,11 @@ IntDestroyMonitorObject(IN PMONITOR_OBJECT pMonitor)
ObmDereferenceObject(pMonitor); ObmDereferenceObject(pMonitor);
} }
/* IntGetMonitorObject
*
* Returns the MONITOR_OBJECT for the given monitor handle.
*
* Arguments
*
* hMonitor
* Monitor handle for which to get the MONITOR_OBJECT
*
* Return value
* Returns a pointer to a MONITOR_OBJECT on success and increase the
* refcount of the monitor object; NULL on failure
*/
static
PMONITOR_OBJECT
IntGetMonitorObject(IN HMONITOR hMonitor)
{
static
PMONITOR_OBJECT FASTCALL
UserGetMonitorObject(IN HMONITOR hMonitor)
{
PMONITOR_OBJECT Monitor = (PMONITOR_OBJECT)UserGetObject(&gHandleTable, hMonitor, otMonitor); PMONITOR_OBJECT Monitor = (PMONITOR_OBJECT)UserGetObject(&gHandleTable, hMonitor, otMonitor);
if (!Monitor) if (!Monitor)
{ {
@ -148,22 +133,9 @@ IntGetMonitorObject(IN HMONITOR hMonitor)
ASSERT(USER_BODY_TO_HEADER(Monitor)->RefCount >= 0); ASSERT(USER_BODY_TO_HEADER(Monitor)->RefCount >= 0);
USER_BODY_TO_HEADER(Monitor)->RefCount++;
return Monitor; return Monitor;
} }
/* IntReleaseMonitorObject
*
* Releases the given MONITOR_OBJECT.
*
* Arguments
*
* pMonitor
* MONITOR_OBJECT to be released
*/
#define IntReleaseMonitorObject(MonitorObj) \
ObmDereferenceObject(MonitorObj);
/* IntAttachMonitor /* IntAttachMonitor
* *
@ -202,25 +174,23 @@ IntAttachMonitor(IN GDIDEVICE *pGdiDevice,
} }
Monitor->GdiDevice = pGdiDevice; Monitor->GdiDevice = pGdiDevice;
ExAcquireFastMutex(&MonitorListLock); if (gMonitorList == NULL)
if (MonitorList == NULL)
{ {
DPRINT("Primary monitor is beeing attached\n"); DPRINT("Primary monitor is beeing attached\n");
Monitor->IsPrimary = TRUE; Monitor->IsPrimary = TRUE;
MonitorList = Monitor; gMonitorList = Monitor;
} }
else else
{ {
PMONITOR_OBJECT p; PMONITOR_OBJECT p;
DPRINT("Additional monitor is beeing attached\n"); DPRINT("Additional monitor is beeing attached\n");
for (p = MonitorList; p->Next != NULL; p = p->Next) for (p = gMonitorList; p->Next != NULL; p = p->Next)
; ;
{ {
p->Next = Monitor; p->Next = Monitor;
} }
Monitor->Prev = p; Monitor->Prev = p;
} }
ExReleaseFastMutex(&MonitorListLock);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -241,8 +211,7 @@ IntDetachMonitor(IN GDIDEVICE *pGdiDevice)
{ {
PMONITOR_OBJECT Monitor; PMONITOR_OBJECT Monitor;
ExAcquireFastMutex(&MonitorListLock); for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next)
for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
{ {
if (Monitor->GdiDevice == pGdiDevice) if (Monitor->GdiDevice == pGdiDevice)
break; break;
@ -251,7 +220,6 @@ IntDetachMonitor(IN GDIDEVICE *pGdiDevice)
if (Monitor == NULL) if (Monitor == NULL)
{ {
/* no monitor for given device found */ /* no monitor for given device found */
ExReleaseFastMutex(&MonitorListLock);
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
@ -264,9 +232,9 @@ IntDetachMonitor(IN GDIDEVICE *pGdiDevice)
ExReleaseFastMutex(&NewPrimaryMonitor->Lock); ExReleaseFastMutex(&NewPrimaryMonitor->Lock);
} }
if (MonitorList == Monitor) if (gMonitorList == Monitor)
{ {
MonitorList = Monitor->Next; gMonitorList = Monitor->Next;
if (Monitor->Next != NULL) if (Monitor->Next != NULL)
Monitor->Next->Prev = NULL; Monitor->Next->Prev = NULL;
} }
@ -276,7 +244,6 @@ IntDetachMonitor(IN GDIDEVICE *pGdiDevice)
if (Monitor->Next != NULL) if (Monitor->Next != NULL)
Monitor->Next->Prev = Monitor->Prev; Monitor->Next->Prev = Monitor->Prev;
} }
ExReleaseFastMutex(&MonitorListLock);
IntDestroyMonitorObject(Monitor); IntDestroyMonitorObject(Monitor);
@ -296,14 +263,12 @@ IntGetPrimaryMonitor()
{ {
PMONITOR_OBJECT Monitor; PMONITOR_OBJECT Monitor;
ExAcquireFastMutex(&MonitorListLock); for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next)
for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
{ {
/* FIXME: I guess locking the monitor is not neccessary to read 1 int */ /* FIXME: I guess locking the monitor is not neccessary to read 1 int */
if (Monitor->IsPrimary) if (Monitor->IsPrimary)
break; break;
} }
ExReleaseFastMutex(&MonitorListLock);
return Monitor; return Monitor;
} }
@ -352,8 +317,7 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECT pRect,
LONG iNearestDistanceX = 0x7fffffff, iNearestDistanceY = 0x7fffffff; LONG iNearestDistanceX = 0x7fffffff, iNearestDistanceY = 0x7fffffff;
/* find monitors which intersect the rectangle */ /* find monitors which intersect the rectangle */
ExAcquireFastMutex(&MonitorListLock); for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next)
for (Monitor = MonitorList; Monitor != NULL; Monitor = Monitor->Next)
{ {
RECT MonitorRect, IntersectionRect; RECT MonitorRect, IntersectionRect;
@ -419,7 +383,6 @@ IntGetMonitorsFromRect(OPTIONAL IN LPCRECT pRect,
} }
iCount++; iCount++;
} }
ExReleaseFastMutex(&MonitorListLock);
if (iCount == 0 && flags == MONITOR_DEFAULTTONEAREST) if (iCount == 0 && flags == MONITOR_DEFAULTTONEAREST)
{ {
@ -646,31 +609,32 @@ NtUserGetMonitorInfo(
PMONITOR_OBJECT Monitor; PMONITOR_OBJECT Monitor;
MONITORINFOEXW MonitorInfo; MONITORINFOEXW MonitorInfo;
NTSTATUS Status; NTSTATUS Status;
DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserGetMonitorInfo\n");
UserEnterShared();
/* get monitor object */ /* get monitor object */
if ((Monitor = IntGetMonitorObject(hMonitor)) == NULL) if (!(Monitor = UserGetMonitorObject(hMonitor)))
{ {
DPRINT("Couldnt find monitor 0x%lx\n", hMonitor); DPRINT("Couldnt find monitor 0x%lx\n", hMonitor);
SetLastNtError(STATUS_INVALID_HANDLE); RETURN(FALSE);
return FALSE;
} }
/* get size of pMonitorInfo */ /* get size of pMonitorInfo */
Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfo->cbSize, sizeof (MonitorInfo.cbSize)); Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfo->cbSize, sizeof (MonitorInfo.cbSize));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
IntReleaseMonitorObject(Monitor);
SetLastNtError(Status); SetLastNtError(Status);
return FALSE; RETURN(FALSE);
} }
if ((MonitorInfo.cbSize != sizeof (MONITORINFO)) && if ((MonitorInfo.cbSize != sizeof (MONITORINFO)) &&
(MonitorInfo.cbSize != sizeof (MONITORINFOEXW))) (MonitorInfo.cbSize != sizeof (MONITORINFOEXW)))
{ {
SetLastNtError(STATUS_INVALID_PARAMETER); SetLastNtError(STATUS_INVALID_PARAMETER);
return FALSE; RETURN(FALSE);
} }
ExAcquireFastMutex(&Monitor->Lock);
/* fill monitor info */ /* fill monitor info */
MonitorInfo.rcMonitor.left = 0; /* FIXME: get origin */ MonitorInfo.rcMonitor.left = 0; /* FIXME: get origin */
MonitorInfo.rcMonitor.top = 0; /* FIXME: get origin */ MonitorInfo.rcMonitor.top = 0; /* FIXME: get origin */
@ -678,6 +642,7 @@ NtUserGetMonitorInfo(
MonitorInfo.rcMonitor.bottom = MonitorInfo.rcMonitor.top + Monitor->GdiDevice->GDIInfo.ulVertRes; MonitorInfo.rcMonitor.bottom = MonitorInfo.rcMonitor.top + Monitor->GdiDevice->GDIInfo.ulVertRes;
MonitorInfo.rcWork = MonitorInfo.rcMonitor; /* FIXME: use DEVMODE panning to calculate work area? */ MonitorInfo.rcWork = MonitorInfo.rcMonitor; /* FIXME: use DEVMODE panning to calculate work area? */
MonitorInfo.dwFlags = 0; MonitorInfo.dwFlags = 0;
if (Monitor->IsPrimary) if (Monitor->IsPrimary)
MonitorInfo.dwFlags |= MONITORINFOF_PRIMARY; MonitorInfo.dwFlags |= MONITORINFOF_PRIMARY;
@ -692,8 +657,6 @@ NtUserGetMonitorInfo(
memcpy(MonitorInfo.szDevice, Monitor->DeviceName.Buffer, len); memcpy(MonitorInfo.szDevice, Monitor->DeviceName.Buffer, len);
memcpy(MonitorInfo.szDevice + (len / sizeof (WCHAR)), &nul, sizeof (WCHAR)); memcpy(MonitorInfo.szDevice + (len / sizeof (WCHAR)), &nul, sizeof (WCHAR));
} }
ExReleaseFastMutex(&Monitor->Lock);
IntReleaseMonitorObject(Monitor);
/* output data */ /* output data */
Status = MmCopyToCaller(pMonitorInfo, &MonitorInfo, MonitorInfo.cbSize); Status = MmCopyToCaller(pMonitorInfo, &MonitorInfo, MonitorInfo.cbSize);
@ -701,12 +664,17 @@ NtUserGetMonitorInfo(
{ {
DPRINT("GetMonitorInfo: MmCopyToCaller failed\n"); DPRINT("GetMonitorInfo: MmCopyToCaller failed\n");
SetLastNtError(Status); SetLastNtError(Status);
return FALSE; RETURN(FALSE);
} }
DPRINT("GetMonitorInfo: success\n"); DPRINT("GetMonitorInfo: success\n");
return TRUE; RETURN(TRUE);
CLEANUP:
DPRINT("Leave NtUserGetMonitorInfo, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }
/* NtUserMonitorFromPoint /* NtUserMonitorFromPoint
@ -885,12 +853,14 @@ NtUserMonitorFromWindow(
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
HMONITOR hMonitor = NULL; HMONITOR hMonitor = NULL;
RECT Rect; RECT Rect;
DECLARE_RETURN(HMONITOR);
Window = IntGetWindowObject(hWnd);
if (Window == NULL) DPRINT("Enter NtUserMonitorFromWindow\n");
UserEnterShared();
if (!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); RETURN(NULL);
return (HMONITOR)NULL;
} }
Rect.left = Rect.right = Window->WindowRect.left; Rect.left = Rect.right = Window->WindowRect.left;
@ -898,7 +868,10 @@ NtUserMonitorFromWindow(
IntGetMonitorsFromRect(&Rect, &hMonitor, NULL, 1, dwFlags); IntGetMonitorsFromRect(&Rect, &hMonitor, NULL, 1, dwFlags);
IntReleaseWindowObject(Window); RETURN(hMonitor);
return hMonitor; CLEANUP:
DPRINT("Leave NtUserMonitorFromWindow, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
} }

View file

@ -258,7 +258,7 @@ ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type )
return TRUE; return TRUE;
} }
// DPRINT1("info: something not destroyed bcause refs still left, inuse %i\n",usedHandles); // DPRINT1("info: something not destroyed bcause refs still left, inuse %i\n",usedHandles);
return FALSE; return FALSE;
} }
@ -283,7 +283,7 @@ BOOL FASTCALL ObmDereferenceObject(PVOID obj)
if (hdr->RefCount == 0 && hdr->destroyed) if (hdr->RefCount == 0 && hdr->destroyed)
{ {
// DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles); // DPRINT1("info: something destroyed bcaise of deref, in use=%i\n",usedHandles);
UserFreeHandle(&gHandleTable, hdr->hSelf); UserFreeHandle(&gHandleTable, hdr->hSelf);

View file

@ -466,7 +466,7 @@ co_IntCreateScrollBars(PWINDOW_OBJECT Window)
RtlZeroMemory(Window->Scroll, Size); RtlZeroMemory(Window->Scroll, Size);
Result = co_WinPosGetNonClientSize(Window->hSelf, Result = co_WinPosGetNonClientSize(Window,
&Window->WindowRect, &Window->WindowRect,
&Window->ClientRect); &Window->ClientRect);
@ -597,7 +597,7 @@ NtUserGetScrollInfo(HWND hWnd, int fnBar, LPSCROLLINFO lpsi)
DECLARE_RETURN(BOOL); DECLARE_RETURN(BOOL);
DPRINT("Enter NtUserGetScrollInfo\n"); DPRINT("Enter NtUserGetScrollInfo\n");
UserEnterShared(); UserEnterExclusive();
Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT)); Status = MmCopyFromCaller(&psi.cbSize, &(lpsi->cbSize), sizeof(UINT));
if(!NT_SUCCESS(Status) || if(!NT_SUCCESS(Status) ||

View file

@ -40,22 +40,9 @@
/* NOTE - I think we should store this per window station (including gdi objects) */ /* NOTE - I think we should store this per window station (including gdi objects) */
static FAST_MUTEX DceListLock;
static PDCE FirstDce = NULL; static PDCE FirstDce = NULL;
static HDC defaultDCstate; static HDC defaultDCstate;
#if 0
#define DCE_LockList() \
ExAcquireFastMutex(&DceListLock)
#define DCE_UnlockList() \
ExReleaseFastMutex(&DceListLock)
#else
#define DCE_LockList()
#define DCE_UnlockList()
#endif
#define DCX_CACHECOMPAREMASK (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | \ #define DCX_CACHECOMPAREMASK (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | \
DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP) DCX_CACHE | DCX_WINDOW | DCX_PARENTCLIP)
@ -64,29 +51,20 @@ static HDC defaultDCstate;
VOID FASTCALL VOID FASTCALL
DceInit(VOID) DceInit(VOID)
{ {
ExInitializeFastMutex(&DceListLock);
} }
HRGN STDCALL static
DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags) HRGN FASTCALL
DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, HWND hWndChild, ULONG CFlags)
{ {
PWINDOW_OBJECT Window;
HRGN VisRgn; HRGN VisRgn;
Window = IntGetWindowObject(hWnd);
if (NULL == Window)
{
return NULL;
}
VisRgn = VIS_ComputeVisibleRegion(Window, VisRgn = VIS_ComputeVisibleRegion(Window,
0 == (Flags & DCX_WINDOW), 0 == (Flags & DCX_WINDOW),
0 != (Flags & DCX_CLIPCHILDREN), 0 != (Flags & DCX_CLIPCHILDREN),
0 != (Flags & DCX_CLIPSIBLINGS)); 0 != (Flags & DCX_CLIPSIBLINGS));
IntReleaseWindowObject(Window);
return VisRgn; return VisRgn;
} }
@ -122,7 +100,7 @@ NtUserGetDC(HWND hWnd)
} }
PDCE FASTCALL PDCE FASTCALL
DceAllocDCE(HWND hWnd, DCE_TYPE Type) DceAllocDCE(PWINDOW_OBJECT Window OPTIONAL, DCE_TYPE Type)
{ {
HDCE DceHandle; HDCE DceHandle;
DCE* Dce; DCE* Dce;
@ -146,30 +124,26 @@ DceAllocDCE(HWND hWnd, DCE_TYPE Type)
} }
GDIOBJ_SetOwnership(Dce->Self, NULL); GDIOBJ_SetOwnership(Dce->Self, NULL);
DC_SetOwnership(Dce->hDC, NULL); DC_SetOwnership(Dce->hDC, NULL);
Dce->hwndCurrent = hWnd; Dce->hwndCurrent = (Window ? Window->hSelf : NULL);
Dce->hClipRgn = NULL; Dce->hClipRgn = NULL;
DCE_LockList();
Dce->next = FirstDce; Dce->next = FirstDce;
FirstDce = Dce; FirstDce = Dce;
DCE_UnlockList();
if (Type != DCE_CACHE_DC) if (Type != DCE_CACHE_DC)
{ {
Dce->DCXFlags = DCX_DCEBUSY; Dce->DCXFlags = DCX_DCEBUSY;
if (hWnd != NULL)
if (Window)
{ {
PWINDOW_OBJECT WindowObject; if (Window->Style & WS_CLIPCHILDREN)
WindowObject = IntGetWindowObject(hWnd);
if (WindowObject->Style & WS_CLIPCHILDREN)
{ {
Dce->DCXFlags |= DCX_CLIPCHILDREN; Dce->DCXFlags |= DCX_CLIPCHILDREN;
} }
if (WindowObject->Style & WS_CLIPSIBLINGS) if (Window->Style & WS_CLIPSIBLINGS)
{ {
Dce->DCXFlags |= DCX_CLIPSIBLINGS; Dce->DCXFlags |= DCX_CLIPSIBLINGS;
} }
IntReleaseWindowObject(WindowObject);
} }
} }
else else
@ -181,14 +155,14 @@ DceAllocDCE(HWND hWnd, DCE_TYPE Type)
} }
VOID STATIC STDCALL VOID STATIC STDCALL
DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags, DceSetDrawable(PWINDOW_OBJECT Window OPTIONAL, HDC hDC, ULONG Flags,
BOOL SetClipOrigin) BOOL SetClipOrigin)
{ {
DC *dc = DC_LockDc(hDC); DC *dc = DC_LockDc(hDC);
if(!dc) if(!dc)
return; return;
if (WindowObject == NULL) if (Window == NULL)
{ {
dc->w.DCOrgX = 0; dc->w.DCOrgX = 0;
dc->w.DCOrgY = 0; dc->w.DCOrgY = 0;
@ -197,13 +171,13 @@ DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags,
{ {
if (Flags & DCX_WINDOW) if (Flags & DCX_WINDOW)
{ {
dc->w.DCOrgX = WindowObject->WindowRect.left; dc->w.DCOrgX = Window->WindowRect.left;
dc->w.DCOrgY = WindowObject->WindowRect.top; dc->w.DCOrgY = Window->WindowRect.top;
} }
else else
{ {
dc->w.DCOrgX = WindowObject->ClientRect.left; dc->w.DCOrgX = Window->ClientRect.left;
dc->w.DCOrgY = WindowObject->ClientRect.top; dc->w.DCOrgY = Window->ClientRect.top;
} }
} }
DC_UnlockDc(dc); DC_UnlockDc(dc);
@ -294,7 +268,7 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
{ {
DcxFlags = Flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW); DcxFlags = Flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW);
} }
hRgnVisible = DceGetVisRgn(Parent->hSelf, DcxFlags, Window->hSelf, Flags); hRgnVisible = DceGetVisRgn(Parent, DcxFlags, Window->hSelf, Flags);
if (hRgnVisible == NULL) if (hRgnVisible == NULL)
{ {
hRgnVisible = NtGdiCreateRectRgn(0, 0, 0, 0); hRgnVisible = NtGdiCreateRectRgn(0, 0, 0, 0);
@ -332,7 +306,7 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
} }
else else
{ {
hRgnVisible = DceGetVisRgn(Window->hSelf, Flags, 0, 0); hRgnVisible = DceGetVisRgn(Window, Flags, 0, 0);
} }
noparent: noparent:
@ -457,8 +431,6 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
DCE* DceEmpty = NULL; DCE* DceEmpty = NULL;
DCE* DceUnused = NULL; DCE* DceUnused = NULL;
DCE_LockList();
for (Dce = FirstDce; Dce != NULL; Dce = Dce->next) for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
{ {
if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE) if ((Dce->DCXFlags & (DCX_CACHE | DCX_DCEBUSY)) == DCX_CACHE)
@ -481,7 +453,6 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
} }
} }
DCE_UnlockList();
if (Dce == NULL) if (Dce == NULL)
{ {
@ -639,8 +610,6 @@ DCE_Cleanup(PVOID ObjectBody)
PDCE PrevInList; PDCE PrevInList;
PDCE pDce = (PDCE)ObjectBody; PDCE pDce = (PDCE)ObjectBody;
DCE_LockList();
if (pDce == FirstDce) if (pDce == FirstDce)
{ {
FirstDce = pDce->next; FirstDce = pDce->next;
@ -659,8 +628,6 @@ DCE_Cleanup(PVOID ObjectBody)
assert(NULL != PrevInList); assert(NULL != PrevInList);
} }
DCE_UnlockList();
return NULL != PrevInList; return NULL != PrevInList;
} }
@ -669,16 +636,14 @@ IntWindowFromDC(HDC hDc)
{ {
DCE *Dce; DCE *Dce;
DCE_LockList();
for (Dce = FirstDce; Dce != NULL; Dce = Dce->next) for (Dce = FirstDce; Dce != NULL; Dce = Dce->next)
{ {
if(Dce->hDC == hDc) if(Dce->hDC == hDc)
{ {
DCE_UnlockList();
return Dce->hwndCurrent; return Dce->hwndCurrent;
} }
} }
DCE_UnlockList();
return 0; return 0;
} }
@ -689,8 +654,6 @@ UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc)
DCE *dce; DCE *dce;
INT nRet = 0; INT nRet = 0;
DCE_LockList();
dce = FirstDce; dce = FirstDce;
DPRINT("%p %p\n", Window, hDc); DPRINT("%p %p\n", Window, hDc);
@ -705,8 +668,6 @@ UserReleaseDC(PWINDOW_OBJECT Window, HDC hDc)
nRet = DceReleaseDC(dce); nRet = DceReleaseDC(dce);
} }
DCE_UnlockList();
return nRet; return nRet;
} }
@ -777,8 +738,6 @@ DceFreeWindowDCE(PWINDOW_OBJECT Window)
{ {
DCE *pDCE; DCE *pDCE;
DCE_LockList();
pDCE = FirstDce; pDCE = FirstDce;
while (pDCE) while (pDCE)
{ {
@ -820,18 +779,15 @@ DceFreeWindowDCE(PWINDOW_OBJECT Window)
} }
pDCE = pDCE->next; pDCE = pDCE->next;
} }
DCE_UnlockList();
} }
void FASTCALL void FASTCALL
DceEmptyCache() DceEmptyCache()
{ {
DCE_LockList();
while (FirstDce != NULL) while (FirstDce != NULL)
{ {
DceFreeDCE(FirstDce, TRUE); DceFreeDCE(FirstDce, TRUE);
} }
DCE_UnlockList();
} }
VOID FASTCALL VOID FASTCALL
@ -848,8 +804,6 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
return; return;
} }
DCE_LockList();
pDCE = FirstDce; pDCE = FirstDce;
while (pDCE) while (pDCE)
{ {
@ -918,7 +872,6 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
pDCE = pDCE->next; pDCE = pDCE->next;
} }
DCE_UnlockList();
} }

View file

@ -77,7 +77,8 @@ CleanupWindowImpl(VOID)
VOID FASTCALL IntReleaseWindowObject(PWINDOW_OBJECT Window) VOID FASTCALL IntReleaseWindowObject(PWINDOW_OBJECT Window)
{ {
ASSERT(Window); /*
ASSERT(Window);
ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 1); ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 1);
@ -86,12 +87,19 @@ VOID FASTCALL IntReleaseWindowObject(PWINDOW_OBJECT Window)
if (USER_BODY_TO_HEADER(Window)->RefCount == 0 && USER_BODY_TO_HEADER(Window)->destroyed) if (USER_BODY_TO_HEADER(Window)->RefCount == 0 && USER_BODY_TO_HEADER(Window)->destroyed)
{ {
} }
*/
ObmDereferenceObject(Window);
} }
PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd) PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd)
{ {
PWINDOW_OBJECT Window = UserGetWindowObject(hWnd); PWINDOW_OBJECT Window;
if (!hWnd) return NULL;
Window = UserGetWindowObject(hWnd);
if (Window) if (Window)
{ {
ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0); ASSERT(USER_BODY_TO_HEADER(Window)->RefCount >= 0);
@ -104,7 +112,11 @@ PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd)
/* temp hack */ /* temp hack */
PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd) PWINDOW_OBJECT FASTCALL UserGetWindowObject(HWND hWnd)
{ {
PWINDOW_OBJECT Window = (PWINDOW_OBJECT)UserGetObject(&gHandleTable, hWnd, otWindow); PWINDOW_OBJECT Window;
if (!hWnd) return NULL;
Window = (PWINDOW_OBJECT)UserGetObject(&gHandleTable, hWnd, otWindow);
if (!Window) if (!Window)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
@ -810,14 +822,9 @@ IntIsChildWindow(HWND Parent, HWND Child)
} }
BOOL FASTCALL BOOL FASTCALL
IntIsWindowVisible(HWND hWnd) IntIsWindowVisible(PWINDOW_OBJECT BaseWindow)
{ {
PWINDOW_OBJECT BaseWindow, Window, Old; PWINDOW_OBJECT Window;
if(!(BaseWindow = IntGetWindowObject(hWnd)))
{
return FALSE;
}
Window = BaseWindow; Window = BaseWindow;
while(Window) while(Window)
@ -828,30 +835,17 @@ IntIsWindowVisible(HWND hWnd)
} }
if(!(Window->Style & WS_VISIBLE)) if(!(Window->Style & WS_VISIBLE))
{ {
if(Window != BaseWindow)
IntReleaseWindowObject(Window);
IntReleaseWindowObject(BaseWindow);
return FALSE; return FALSE;
} }
Old = Window;
Window = IntGetParentObject(Window); Window = Window->Parent;
if(Old != BaseWindow)
IntReleaseWindowObject(Old);
} }
if(Window) if(Window && Window->Style & WS_VISIBLE)
{ {
if(Window->Style & WS_VISIBLE) return TRUE;
{
if(Window != BaseWindow)
IntReleaseWindowObject(Window);
IntReleaseWindowObject(BaseWindow);
return TRUE;
}
if(Window != BaseWindow)
IntReleaseWindowObject(Window);
} }
IntReleaseWindowObject(BaseWindow);
return FALSE; return FALSE;
} }
@ -1668,7 +1662,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
/* Allocate a DCE for this window. */ /* Allocate a DCE for this window. */
if (dwStyle & CS_OWNDC) if (dwStyle & CS_OWNDC)
{ {
Window->Dce = DceAllocDCE(Window->hSelf, DCE_WINDOW_DC); Window->Dce = DceAllocDCE(Window, DCE_WINDOW_DC);
} }
/* FIXME: Handle "CS_CLASSDC" */ /* FIXME: Handle "CS_CLASSDC" */
@ -1854,7 +1848,7 @@ co_IntCreateWindowEx(DWORD dwExStyle,
MaxPos.y = Window->WindowRect.top; MaxPos.y = Window->WindowRect.top;
DPRINT("IntCreateWindowEx(): About to get non-client size.\n"); DPRINT("IntCreateWindowEx(): About to get non-client size.\n");
/* WinPosGetNonClientSize SENDS THE WM_NCCALCSIZE message */ /* WinPosGetNonClientSize SENDS THE WM_NCCALCSIZE message */
Result = co_WinPosGetNonClientSize(Window->hSelf, Result = co_WinPosGetNonClientSize(Window,
&Window->WindowRect, &Window->WindowRect,
&Window->ClientRect); &Window->ClientRect);
IntGdiOffsetRect(&Window->WindowRect, IntGdiOffsetRect(&Window->WindowRect,
@ -3675,9 +3669,8 @@ NtUserGetWindowPlacement(HWND hWnd,
DPRINT("Enter NtUserGetWindowPlacement\n"); DPRINT("Enter NtUserGetWindowPlacement\n");
UserEnterShared(); UserEnterShared();
if (!(Window = IntGetWindowObject(hWnd))) if (!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
@ -3685,12 +3678,10 @@ NtUserGetWindowPlacement(HWND hWnd,
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
if(Safepl.length != sizeof(WINDOWPLACEMENT)) if(Safepl.length != sizeof(WINDOWPLACEMENT))
{ {
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
@ -3709,7 +3700,6 @@ NtUserGetWindowPlacement(HWND hWnd,
} }
else else
{ {
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
@ -3717,11 +3707,9 @@ NtUserGetWindowPlacement(HWND hWnd,
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
IntReleaseWindowObject(Window);
RETURN( TRUE); RETURN( TRUE);
CLEANUP: CLEANUP:
@ -3749,20 +3737,17 @@ NtUserGetWindowRect(HWND hWnd, LPRECT Rect)
DPRINT("Enter NtUserGetWindowRect\n"); DPRINT("Enter NtUserGetWindowRect\n");
UserEnterShared(); UserEnterShared();
if (!(Wnd = IntGetWindowObject(hWnd))) if (!(Wnd = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(FALSE); RETURN(FALSE);
} }
Status = MmCopyToCaller(Rect, &Wnd->WindowRect, sizeof(RECT)); Status = MmCopyToCaller(Rect, &Wnd->WindowRect, sizeof(RECT));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
IntReleaseWindowObject(Wnd);
SetLastNtError(Status); SetLastNtError(Status);
RETURN( FALSE); RETURN( FALSE);
} }
IntReleaseWindowObject(Wnd);
RETURN( TRUE); RETURN( TRUE);
CLEANUP: CLEANUP:
@ -3785,9 +3770,8 @@ NtUserGetWindowThreadProcessId(HWND hWnd, LPDWORD UnsafePid)
DPRINT("Enter NtUserGetWindowThreadProcessId\n"); DPRINT("Enter NtUserGetWindowThreadProcessId\n");
UserEnterShared(); UserEnterShared();
if (!(Wnd = IntGetWindowObject(hWnd))) if (!(Wnd = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( 0); RETURN( 0);
} }
@ -3853,16 +3837,15 @@ NtUserMoveWindow(
DWORD STDCALL DWORD STDCALL
NtUserQueryWindow(HWND hWnd, DWORD Index) NtUserQueryWindow(HWND hWnd, DWORD Index)
{ {
PWINDOW_OBJECT Window = IntGetWindowObject(hWnd); PWINDOW_OBJECT Window;
DWORD Result; DWORD Result;
DECLARE_RETURN(UINT); DECLARE_RETURN(UINT);
DPRINT("Enter NtUserQueryWindow\n"); DPRINT("Enter NtUserQueryWindow\n");
UserEnterShared(); UserEnterShared();
if (Window == NULL) if (!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( 0); RETURN( 0);
} }
@ -3885,11 +3868,8 @@ NtUserQueryWindow(HWND hWnd, DWORD Index)
break; break;
} }
IntReleaseWindowObject(Window);
RETURN( Result); RETURN( Result);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_); DPRINT("Leave NtUserQueryWindow, ret=%i\n",_ret_);
UserLeave(); UserLeave();
@ -4079,24 +4059,23 @@ NtUserSetWindowPlacement(HWND hWnd,
DPRINT("Enter NtUserSetWindowPlacement\n"); DPRINT("Enter NtUserSetWindowPlacement\n");
UserEnterExclusive(); UserEnterExclusive();
if (!(Window = IntGetWindowObject(hWnd))) if (!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT)); Status = MmCopyFromCaller(&Safepl, lpwndpl, sizeof(WINDOWPLACEMENT));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
if(Safepl.length != sizeof(WINDOWPLACEMENT)) if(Safepl.length != sizeof(WINDOWPLACEMENT))
{ {
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
UserRefObjectCo(Window);
if ((Window->Style & (WS_MAXIMIZE | WS_MINIMIZE)) == 0) if ((Window->Style & (WS_MAXIMIZE | WS_MINIMIZE)) == 0)
{ {
co_WinPosSetWindowPos(Window, NULL, co_WinPosSetWindowPos(Window, NULL,
@ -4115,8 +4094,8 @@ NtUserSetWindowPlacement(HWND hWnd,
Window->InternalPos->IconPos = Safepl.ptMinPosition; Window->InternalPos->IconPos = Safepl.ptMinPosition;
Window->InternalPos->MaxPos = Safepl.ptMaxPosition; Window->InternalPos->MaxPos = Safepl.ptMaxPosition;
IntReleaseWindowObject(Window); UserDerefObjectCo(Window);
RETURN( TRUE); RETURN(TRUE);
CLEANUP: CLEANUP:
DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_); DPRINT("Leave NtUserSetWindowPlacement, ret=%i\n",_ret_);
@ -4164,21 +4143,18 @@ CLEANUP:
INT FASTCALL INT FASTCALL
IntGetWindowRgn(HWND hWnd, HRGN hRgn) IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn)
{ {
INT Ret; INT Ret;
PWINDOW_OBJECT Window;
HRGN VisRgn; HRGN VisRgn;
ROSRGNDATA *pRgn; ROSRGNDATA *pRgn;
if(!(Window = IntGetWindowObject(hWnd))) if(!Window)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return ERROR; return ERROR;
} }
if(!hRgn) if(!hRgn)
{ {
IntReleaseWindowObject(Window);
return ERROR; return ERROR;
} }
@ -4201,26 +4177,22 @@ IntGetWindowRgn(HWND hWnd, HRGN hRgn)
NtGdiDeleteObject(VisRgn); NtGdiDeleteObject(VisRgn);
IntReleaseWindowObject(Window);
return Ret; return Ret;
} }
INT FASTCALL INT FASTCALL
IntGetWindowRgnBox(HWND hWnd, RECT *Rect) IntGetWindowRgnBox(PWINDOW_OBJECT Window, RECT *Rect)
{ {
INT Ret; INT Ret;
PWINDOW_OBJECT Window;
HRGN VisRgn; HRGN VisRgn;
ROSRGNDATA *pRgn; ROSRGNDATA *pRgn;
if(!(Window = IntGetWindowObject(hWnd))) if(!Window)
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return ERROR; return ERROR;
} }
if(!Rect) if(!Rect)
{ {
IntReleaseWindowObject(Window);
return ERROR; return ERROR;
} }
@ -4242,7 +4214,6 @@ IntGetWindowRgnBox(HWND hWnd, RECT *Rect)
NtGdiDeleteObject(VisRgn); NtGdiDeleteObject(VisRgn);
IntReleaseWindowObject(Window);
return Ret; return Ret;
} }
@ -4262,9 +4233,8 @@ NtUserSetWindowRgn(
DPRINT("Enter NtUserSetWindowRgn\n"); DPRINT("Enter NtUserSetWindowRgn\n");
UserEnterExclusive(); UserEnterExclusive();
if (!(Window = IntGetWindowObject(hWnd))) if (!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( 0); RETURN( 0);
} }
@ -4282,10 +4252,11 @@ NtUserSetWindowRgn(
if(bRedraw) if(bRedraw)
{ {
UserRefObjectCo(Window);
co_UserRedrawWindow(Window, NULL, NULL, RDW_INVALIDATE); co_UserRedrawWindow(Window, NULL, NULL, RDW_INVALIDATE);
UserDerefObjectCo(Window);
} }
IntReleaseWindowObject(Window);
RETURN( (INT)hRgn); RETURN( (INT)hRgn);
CLEANUP: CLEANUP:
@ -4434,9 +4405,8 @@ NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText)
DPRINT("Enter NtUserDefSetText\n"); DPRINT("Enter NtUserDefSetText\n");
UserEnterExclusive(); UserEnterExclusive();
if(!(Window = IntGetWindowObject(hWnd))) if(!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE); RETURN( FALSE);
} }
@ -4446,7 +4416,6 @@ NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText)
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
IntReleaseWindowObject(Window);
RETURN( FALSE); RETURN( FALSE);
} }
} }
@ -4480,7 +4449,6 @@ NtUserDefSetText(HWND hWnd, PUNICODE_STRING WindowText)
IntReleaseWindowObject(Parent); IntReleaseWindowObject(Parent);
} }
IntReleaseWindowObject(Window);
RETURN( TRUE); RETURN( TRUE);
CLEANUP: CLEANUP:
@ -4513,9 +4481,8 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount)
RETURN( 0); RETURN( 0);
} }
if(!(Window = IntGetWindowObject(hWnd))) if(!(Window = UserGetWindowObject(hWnd)))
{ {
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( 0); RETURN( 0);
} }
@ -4534,7 +4501,6 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount)
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
IntReleaseWindowObject(Window);
RETURN( 0); RETURN( 0);
} }
Buffer += Copy; Buffer += Copy;
@ -4544,14 +4510,12 @@ NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount)
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
IntReleaseWindowObject(Window);
RETURN( 0); RETURN( 0);
} }
Result = Copy; Result = Copy;
} }
IntReleaseWindowObject(Window);
RETURN( Result); RETURN( Result);
CLEANUP: CLEANUP:
@ -4657,20 +4621,15 @@ IntRemoveProcessWndProcHandles(HANDLE ProcessID)
BOOL BOOL
FASTCALL FASTCALL
IntShowOwnedPopups( HWND owner, BOOL fShow ) IntShowOwnedPopups(PWINDOW_OBJECT OwnerWnd, BOOL fShow )
{ {
int count = 0; int count = 0;
PWINDOW_OBJECT Window, pWnd; PWINDOW_OBJECT pWnd;
HWND *win_array; HWND *win_array;
if(!(Window = IntGetWindowObject(owner))) ASSERT(OwnerWnd);
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
win_array = IntWinListChildren( Window); win_array = IntWinListChildren(OwnerWnd);//faxme: use desktop?
IntReleaseWindowObject(Window);
if (!win_array) if (!win_array)
return TRUE; return TRUE;
@ -4679,9 +4638,9 @@ IntShowOwnedPopups( HWND owner, BOOL fShow )
count++; count++;
while (--count >= 0) while (--count >= 0)
{ {
if (UserGetWindow( win_array[count], GW_OWNER ) != owner) if (UserGetWindow( win_array[count], GW_OWNER ) != OwnerWnd->hSelf)
continue; continue;
if (!(pWnd = IntGetWindowObject( win_array[count] ))) if (!(pWnd = UserGetWindowObject( win_array[count] )))
continue; continue;
// if (pWnd == WND_OTHER_PROCESS) continue; // if (pWnd == WND_OTHER_PROCESS) continue;
@ -4689,7 +4648,6 @@ IntShowOwnedPopups( HWND owner, BOOL fShow )
{ {
if (pWnd->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP) if (pWnd->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
{ {
IntReleaseWindowObject( pWnd );
/* In Windows, ShowOwnedPopups(TRUE) generates /* In Windows, ShowOwnedPopups(TRUE) generates
* WM_SHOWWINDOW messages with SW_PARENTOPENING, * WM_SHOWWINDOW messages with SW_PARENTOPENING,
* regardless of the state of the owner * regardless of the state of the owner
@ -4702,7 +4660,6 @@ IntShowOwnedPopups( HWND owner, BOOL fShow )
{ {
if (pWnd->Style & WS_VISIBLE) if (pWnd->Style & WS_VISIBLE)
{ {
IntReleaseWindowObject( pWnd );
/* In Windows, ShowOwnedPopups(FALSE) generates /* In Windows, ShowOwnedPopups(FALSE) generates
* WM_SHOWWINDOW messages with SW_PARENTCLOSING, * WM_SHOWWINDOW messages with SW_PARENTCLOSING,
* regardless of the state of the owner * regardless of the state of the owner
@ -4711,7 +4668,7 @@ IntShowOwnedPopups( HWND owner, BOOL fShow )
continue; continue;
} }
} }
IntReleaseWindowObject( pWnd );
} }
ExFreePool( win_array ); ExFreePool( win_array );
return TRUE; return TRUE;

View file

@ -205,7 +205,6 @@ FASTCALL
co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent) co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent)
{ {
RECT rectParent; RECT rectParent;
HWND hwndChild;
INT i, x, y, xspacing, yspacing; INT i, x, y, xspacing, yspacing;
HWND *List = IntWinListChildren(parent); HWND *List = IntWinListChildren(parent);
@ -224,12 +223,10 @@ co_WinPosArrangeIconicWindows(PWINDOW_OBJECT parent)
{ {
PWINDOW_OBJECT WndChild; PWINDOW_OBJECT WndChild;
hwndChild = List[i];
if (!(WndChild = UserGetWindowObject(List[i]))) if (!(WndChild = UserGetWindowObject(List[i])))
continue; continue;
if((UserGetWindowLong( hwndChild, GWL_STYLE, FALSE) & WS_MINIMIZE) != 0 ) if((WndChild->Style & WS_MINIMIZE) != 0 )
{ {
UserRefObjectCo(WndChild); UserRefObjectCo(WndChild);
@ -454,6 +451,8 @@ co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
{ {
MINMAXINFO MinMax; MINMAXINFO MinMax;
ASSERT_REFS_CO(Window);
WinPosFillMinMaxInfoStruct(Window, &MinMax); WinPosFillMinMaxInfoStruct(Window, &MinMax);
co_IntSendMessage(Window->hSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax); co_IntSendMessage(Window->hSelf, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
@ -519,6 +518,8 @@ co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
PWINDOW_OBJECT Parent; PWINDOW_OBJECT Parent;
UINT wvrFlags = 0; UINT wvrFlags = 0;
ASSERT_REFS_CO(Window);
/* Send WM_NCCALCSIZE message to get new client area */ /* Send WM_NCCALCSIZE message to get new client area */
if ((WinPos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE) if ((WinPos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE)
{ {
@ -593,6 +594,8 @@ co_WinPosDoWinPosChanging(PWINDOW_OBJECT Window,
{ {
INT X, Y; INT X, Y;
ASSERT_REFS_CO(Window);
if (!(WinPos->flags & SWP_NOSENDCHANGING)) if (!(WinPos->flags & SWP_NOSENDCHANGING))
{ {
co_IntSendMessage(Window->hSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos); co_IntSendMessage(Window->hSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM) WinPos);
@ -707,7 +710,7 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
if (!(Wnd = UserGetWindowObject(List[i]))) if (!(Wnd = UserGetWindowObject(List[i])))
continue; continue;
if ((UserGetWindowLong(List[i], GWL_STYLE, FALSE) & WS_POPUP) && if ((Wnd->Style & WS_POPUP) &&
UserGetWindow(List[i], GW_OWNER) == hWnd) UserGetWindow(List[i], GW_OWNER) == hWnd)
{ {
UserRefObjectCo(Wnd); UserRefObjectCo(Wnd);
@ -968,7 +971,7 @@ co_WinPosSetWindowPos(
PWINDOW_OBJECT Sibling; PWINDOW_OBJECT Sibling;
PWINDOW_OBJECT InsertAfterWindow; PWINDOW_OBJECT InsertAfterWindow;
if ((ParentWindow = IntGetParentObject(Window))) if ((ParentWindow = Window->Parent))
{ {
if (HWND_TOPMOST == WinPos.hwndInsertAfter) if (HWND_TOPMOST == WinPos.hwndInsertAfter)
{ {
@ -1024,7 +1027,6 @@ co_WinPosSetWindowPos(
Window->ExStyle &= ~ WS_EX_TOPMOST; Window->ExStyle &= ~ WS_EX_TOPMOST;
} }
IntReleaseWindowObject(ParentWindow);
} }
} }
@ -1255,12 +1257,14 @@ co_WinPosSetWindowPos(
} }
LRESULT FASTCALL LRESULT FASTCALL
co_WinPosGetNonClientSize(HWND Wnd, RECT* WindowRect, RECT* ClientRect) co_WinPosGetNonClientSize(PWINDOW_OBJECT Window, RECT* WindowRect, RECT* ClientRect)
{ {
LRESULT Result; LRESULT Result;
ASSERT_REFS_CO(Window);
*ClientRect = *WindowRect; *ClientRect = *WindowRect;
Result = co_IntSendMessage(Wnd, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect); Result = co_IntSendMessage(Window->hSelf, WM_NCCALCSIZE, FALSE, (LPARAM) ClientRect);
FixClientRect(ClientRect, WindowRect); FixClientRect(ClientRect, WindowRect);
@ -1395,7 +1399,8 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
if (Window->hSelf == IntGetThreadFocusWindow() || if (Window->hSelf == IntGetThreadFocusWindow() ||
IntIsChildWindow(Window->hSelf, IntGetThreadFocusWindow())) IntIsChildWindow(Window->hSelf, IntGetThreadFocusWindow()))
{ {
UserSetFocus(Window->Parent->hSelf); //faxme: as long as we have ref on Window, we also, indirectly, have ref on parent...
co_UserSetFocus(Window->Parent);
} }
if (!(Window->Parent)) if (!(Window->Parent))