-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);
BOOL FASTCALL IntSetupCurIconHandles(PWINSTATION_OBJECT WinStaObject);
PCURICON_OBJECT FASTCALL IntGetCurIconObject(HANDLE Handle);
PCURICON_OBJECT FASTCALL IntCreateCurIconHandle(PWINSTATION_OBJECT WinStaObject);
VOID FASTCALL IntCleanupCurIcons(struct _EPROCESS *Process, PW32PROCESS Win32Process);

View file

@ -50,10 +50,9 @@ typedef struct tagDCE
#define DCEOBJ_UnlockDCE(pDCE) GDIOBJ_UnlockObjByPtr(pDCE)
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);
VOID FASTCALL DCE_FreeWindowDCE(HWND);
HRGN STDCALL DceGetVisRgn(HWND hWnd, ULONG Flags, HWND hWndChild, ULONG CFlags);
INT FASTCALL DCE_ExcludeRgn(HDC, HWND, HRGN);
BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL);
HWND FASTCALL IntWindowFromDC(HDC hDc);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -72,7 +72,11 @@ CleanupAcceleratorImpl(VOID)
static
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)
{
@ -355,7 +359,7 @@ found:
mesg = 1;
else if (IntGetCaptureWindow())
mesg = 2;
else if (!IntIsWindowVisible(Window->hSelf)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
else if (!IntIsWindowVisible(Window)) /* FIXME: WINE IsWindowEnabled == IntIsWindowVisible? */
mesg = 3;
else
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -49,24 +49,16 @@
/* From kbdxx.c -- Key changes with numlock */
#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 *****************************************************************/
/* Initialization -- Right now, just zero the key state and init the lock */
NTSTATUS FASTCALL InitKeyboardImpl(VOID)
{
ExInitializeFastMutex(&QueueStateLock);
RtlZeroMemory(&QueueKeyStateTable,0x100);
RtlZeroMemory(&gQueueKeyStateTable,0x100);
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 (down)
QueueKeyStateTable[vk] ^= KS_LOCK_BIT;
gQueueKeyStateTable[vk] ^= KS_LOCK_BIT;
}
if (ext && vk == VK_LSHIFT)
@ -104,46 +96,46 @@ static VOID STDCALL SetKeyState(DWORD key, DWORD vk, DWORD ext, BOOL down)
vk = VK_RMENU;
if (down)
QueueKeyStateTable[vk] |= KS_DOWN_BIT;
gQueueKeyStateTable[vk] |= KS_DOWN_BIT;
else
QueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
gQueueKeyStateTable[vk] &= ~KS_DOWN_MASK;
if (vk == VK_LSHIFT || vk == VK_RSHIFT)
{
if ((QueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
(QueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
if ((gQueueKeyStateTable[VK_LSHIFT] & KS_DOWN_BIT) ||
(gQueueKeyStateTable[VK_RSHIFT] & KS_DOWN_BIT))
{
QueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
gQueueKeyStateTable[VK_SHIFT] |= KS_DOWN_BIT;
}
else
{
QueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
gQueueKeyStateTable[VK_SHIFT] &= ~KS_DOWN_MASK;
}
}
if (vk == VK_LCONTROL || vk == VK_RCONTROL)
{
if ((QueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
(QueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
if ((gQueueKeyStateTable[VK_LCONTROL] & KS_DOWN_BIT) ||
(gQueueKeyStateTable[VK_RCONTROL] & KS_DOWN_BIT))
{
QueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
gQueueKeyStateTable[VK_CONTROL] |= KS_DOWN_BIT;
}
else
{
QueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
gQueueKeyStateTable[VK_CONTROL] &= ~KS_DOWN_MASK;
}
}
if (vk == VK_LMENU || vk == VK_RMENU)
{
if ((QueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
(QueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
if ((gQueueKeyStateTable[VK_LMENU] & KS_DOWN_BIT) ||
(gQueueKeyStateTable[VK_RMENU] & KS_DOWN_BIT))
{
QueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
gQueueKeyStateTable[VK_MENU] |= KS_DOWN_BIT;
}
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;
IntLockQueueState;
if( key < 0x100 )
{
ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
(QueueKeyStateTable[key] & KS_LOCK_BIT);
ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
(gQueueKeyStateTable[key] & KS_LOCK_BIT);
}
IntUnLockQueueState;
return ret;
}
@ -386,13 +377,12 @@ DWORD FASTCALL UserGetAsyncKeyState(DWORD key)
{
DWORD ret = 0;
IntLockQueueState;
if( key < 0x100 )
{
ret = ((DWORD)(QueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
(QueueKeyStateTable[key] & KS_LOCK_BIT);
ret = ((DWORD)(gQueueKeyStateTable[key] & KS_DOWN_BIT) << 8 ) |
(gQueueKeyStateTable[key] & KS_LOCK_BIT);
}
IntUnLockQueueState;
return ret;
}
@ -434,7 +424,6 @@ int STDCALL ToUnicodeEx( UINT wVirtKey,
}
else
{
IntLockQueueState;
ToUnicodeResult = ToUnicodeInner( wVirtKey,
wScanCode,
lpKeyState,
@ -443,7 +432,6 @@ int STDCALL ToUnicodeEx( UINT wVirtKey,
wFlags,
PsGetWin32Thread() ?
PsGetWin32Thread()->KeyboardLayout : 0 );
IntUnLockQueueState;
}
return ToUnicodeResult;
@ -458,7 +446,7 @@ int STDCALL ToUnicode( UINT wVirtKey,
{
return ToUnicodeEx( wVirtKey,
wScanCode,
QueueKeyStateTable,
gQueueKeyStateTable,
pwszBuff,
cchBuff,
wFlags,
@ -735,14 +723,12 @@ IntTranslateKbdMessage(LPMSG lpMsg,
ScanCode = (lpMsg->lParam >> 16) & 0xff;
IntLockQueueState;
/* All messages have to contain the cursor point. */
IntGetCursorLocation(PsGetWin32Thread()->Desktop->WindowStation,
&NewMsg.pt);
UState = ToUnicodeInner(lpMsg->wParam, HIWORD(lpMsg->lParam) & 0xff,
QueueKeyStateTable, wp, 2, 0,
gQueueKeyStateTable, wp, 2, 0,
keyLayout );
if (UState == 1)
@ -797,7 +783,6 @@ IntTranslateKbdMessage(LPMSG lpMsg,
Result = TRUE;
}
IntUnLockQueueState;
return Result;
}
@ -807,33 +792,47 @@ NtUserGetKeyboardState(
LPBYTE lpKeyState)
{
BOOL Result = TRUE;
IntLockQueueState;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserGetKeyboardState\n");
UserEnterShared();
if (lpKeyState)
{
if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, QueueKeyStateTable, 256)))
if(!NT_SUCCESS(MmCopyToCaller(lpKeyState, gQueueKeyStateTable, 256)))
Result = FALSE;
}
IntUnLockQueueState;
return Result;
RETURN(Result);
CLEANUP:
DPRINT("Leave NtUserGetKeyboardState, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
DWORD
STDCALL
NtUserSetKeyboardState(
LPBYTE lpKeyState)
NtUserSetKeyboardState(LPBYTE lpKeyState)
{
BOOL Result = TRUE;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserSetKeyboardState\n");
UserEnterExclusive();
IntLockQueueState;
if (lpKeyState)
{
if(! NT_SUCCESS(MmCopyFromCaller(QueueKeyStateTable, lpKeyState, 256)))
if(! NT_SUCCESS(MmCopyFromCaller(gQueueKeyStateTable, lpKeyState, 256)))
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 )
@ -950,13 +949,23 @@ UINT
STDCALL
NtUserMapVirtualKeyEx( UINT Code, UINT Type, DWORD keyboardId, HKL dwhkl )
{
PKBDTABLES keyLayout = PsGetWin32Thread() ?
PsGetWin32Thread()->KeyboardLayout : 0;
PKBDTABLES keyLayout;
DECLARE_RETURN(UINT);
DPRINT("Enter NtUserMapVirtualKeyEx\n");
UserEnterExclusive();
keyLayout = PsGetWin32Thread() ? PsGetWin32Thread()->KeyboardLayout : 0;
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];
PWCHAR OutPwszBuff = 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,
@ -981,13 +994,13 @@ NtUserToUnicodeEx(
sizeof(KeyStateBuf))) )
{
DPRINT1( "Couldn't copy key state from caller.\n" );
return 0;
RETURN(0);
}
OutPwszBuff = ExAllocatePoolWithTag(NonPagedPool,sizeof(WCHAR) * cchBuff, TAG_STRING);
if( !OutPwszBuff )
{
DPRINT1( "ExAllocatePool(%d) failed\n", sizeof(WCHAR) * cchBuff);
return 0;
RETURN(0);
}
RtlZeroMemory( OutPwszBuff, sizeof( WCHAR ) * cchBuff );
@ -1002,7 +1015,12 @@ NtUserToUnicodeEx(
MmCopyToCaller(pwszBuff,OutPwszBuff,sizeof(WCHAR)*cchBuff);
ExFreePool(OutPwszBuff);
return ret;
RETURN(ret);
CLEANUP:
DPRINT("Leave NtUserSetKeyboardState, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
}
static int W32kSimpleToupper( int ch )
@ -1022,12 +1040,17 @@ NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize )
UINT VkCode = 0;
UINT ScanCode = (lParam >> 16) & 0xff;
BOOL ExtKey = lParam & (1<<24) ? TRUE : FALSE;
PKBDTABLES keyLayout =
PsGetWin32Thread() ?
PKBDTABLES keyLayout;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserGetKeyNameText\n");
UserEnterShared();
keyLayout = PsGetWin32Thread() ?
PsGetWin32Thread()->KeyboardLayout : 0;
if( !keyLayout || nSize < 1 )
return 0;
RETURN(0);
if( lParam & (1<<25) )
{
@ -1083,10 +1106,15 @@ NtUserGetKeyNameText( LONG lParam, LPWSTR lpString, int nSize )
ret = 1;
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;
}
IntLockQueueState;
/* arty -- handle numpad -- On real windows, the actual key produced
* 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
* key
@ -1152,7 +1178,6 @@ W32kKeyProcessMessage(LPMSG Msg,
/* ignore shift codes */
if( ScanCode == 0x2A || ScanCode == 0x36 )
{
IntUnLockQueueState;
return;
}
VscVkTable = KeyboardLayout->pVSCtoVK_E0;
@ -1206,7 +1231,7 @@ W32kKeyProcessMessage(LPMSG Msg,
}
/* 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 )
Msg->message = WM_KEYDOWN;
@ -1214,7 +1239,6 @@ W32kKeyProcessMessage(LPMSG Msg,
Msg->message = WM_KEYUP;
}
IntUnLockQueueState;
}
DWORD
@ -1310,7 +1334,17 @@ STDCALL
NtUserGetKeyboardType(
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 Unknown2)
{
/* FAXME: currently, this routine doesnt seem to need any locking */
PKBDTABLES KeyLayout;
PVK_TO_WCHAR_TABLE vtwTbl;
PVK_TO_WCHARS10 vkPtr;

View file

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

View file

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

View file

@ -413,7 +413,10 @@ NtUserCallTwoParam(
{
DWORD Ret;
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));
if(!NT_SUCCESS(Status))
{
@ -424,7 +427,10 @@ NtUserCallTwoParam(
}
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:
{
@ -480,7 +486,12 @@ NtUserCallTwoParam(
RETURN( 0);
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:
{

View file

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

View file

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

View file

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

View file

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

View file

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