-refcount reworking (simplification & improvement)

-make functions deal with pointers, not handles
-misc formatting

svn path=/trunk/; revision=17802
This commit is contained in:
Gunnar Dalsnes 2005-09-11 14:48:32 +00:00
parent 9e486c444b
commit fdafc67fbe
16 changed files with 603 additions and 719 deletions

View file

@ -287,7 +287,7 @@ EngDeleteWnd(
}
/* Get window object */
Window = IntGetWindowObject(WndObjInt->Hwnd);
Window = UserGetWindowObject(WndObjInt->Hwnd);
if (Window == NULL)
{
DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n");
@ -297,7 +297,6 @@ EngDeleteWnd(
{
/* Remove object from window */
RemoveEntryList(&WndObjInt->ListEntry);
IntReleaseWindowObject(Window);
}
if (!calledFromUser){

View file

@ -2,15 +2,57 @@
#define _WIN32K_USERFUNCS_H
#define ASSERT_REFS_CO(obj) \
PMENU_OBJECT FASTCALL UserGetMenuObject(HMENU hMenu);
#if 0
#define ObmDereferenceObject(_obj_) \
{ \
LONG ref = USER_BODY_TO_HEADER(obj)->RefCount;\
DPRINT1("obj 0x%x dereffed to %i refs\n",_obj_, USER_BODY_TO_HEADER(_obj_)->RefCount-1); \
ObmDereferenceObject2(_obj_); \
}
#endif
#define ASSERT_REFS_CO(_obj_) \
{ \
LONG ref = USER_BODY_TO_HEADER(_obj_)->RefCount;\
if (!(ref >= 1)){ \
DPRINT1("obj 0x%x, refs %i\n", obj, ref); \
DPRINT1("ASSERT: obj 0x%x, refs %i\n", _obj_, ref); \
ASSERT(FALSE); \
} \
}
#if 0
#define ASSERT_REFS_CO(_obj_) \
{ \
PSINGLE_LIST_ENTRY e; \
BOOL gotit=FALSE; \
LONG ref = USER_BODY_TO_HEADER(_obj_)->RefCount;\
if (!(ref >= 1)){ \
DPRINT1("obj 0x%x, refs %i\n", _obj_, ref); \
ASSERT(FALSE); \
} \
\
e = PsGetWin32Thread()->ReferencesList.Next; \
while (e) \
{ \
PUSER_REFERENCE_ENTRY ref = CONTAINING_RECORD(e, USER_REFERENCE_ENTRY, Entry); \
if (ref->obj == _obj_){ gotit=TRUE; break; } \
e = e->Next; \
} \
ASSERT(gotit); \
}
#endif
#define DUMP_REFS(obj) DPRINT1("obj 0x%x, refs %i\n",obj, USER_BODY_TO_HEADER(obj)->RefCount)
@ -19,11 +61,6 @@
VOID FASTCALL ObmReferenceObject(PVOID obj);
BOOL FASTCALL ObmDereferenceObject(PVOID obj);
#define IntReferenceWindowObject(o) ObmReferenceObject(o)
#define UserDerefObject(o) ObmReferenceObject(o)
VOID FASTCALL IntReleaseWindowObject(PWINDOW_OBJECT Window);
PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd);
PVOID FASTCALL
ObmCreateObject(PUSER_HANDLE_TABLE ht, HANDLE* h,USER_OBJECT_TYPE type , ULONG size);
@ -31,8 +68,8 @@ ObmCreateObject(PUSER_HANDLE_TABLE ht, HANDLE* h,USER_OBJECT_TYPE type , ULONG s
BOOL FASTCALL
ObmDeleteObject(HANDLE h, USER_OBJECT_TYPE type );
//#define UserRefObjectCo(o) ObmReferenceObject(o)
//#define UserDerefObjectCo(o) ObmDereferenceObject(o)
#define UserRefObject(o) ObmReferenceObject(o)
#define UserDerefObject(o) ObmDereferenceObject(o)
BOOL FASTCALL ObmCreateHandleTable();

View file

@ -157,7 +157,7 @@ BOOL FASTCALL
IntIsWindowVisible (PWINDOW_OBJECT Window);
BOOL FASTCALL
IntIsChildWindow (HWND Parent, HWND Child);
IntIsChildWindow (PWINDOW_OBJECT Parent, PWINDOW_OBJECT Child);
VOID FASTCALL
IntUnlinkWindow(PWINDOW_OBJECT Wnd);
@ -174,8 +174,6 @@ IntGetParent(PWINDOW_OBJECT Wnd);
PWINDOW_OBJECT FASTCALL
IntGetOwner(PWINDOW_OBJECT Wnd);
PWINDOW_OBJECT FASTCALL
IntGetParentObject(PWINDOW_OBJECT Wnd);
INT FASTCALL
IntGetWindowRgn(PWINDOW_OBJECT Window, HRGN hRgn);

View file

@ -559,8 +559,6 @@ CLEANUP:
void FASTCALL
co_IntSetClassLong(PWINDOW_OBJECT Window, ULONG Offset, LONG dwNewLong, BOOL Ansi)
{
PWINDOW_OBJECT Parent, Owner;
ASSERT_REFS_CO(Window);
if ((int)Offset >= 0)
@ -591,25 +589,11 @@ co_IntSetClassLong(PWINDOW_OBJECT Window, ULONG Offset, LONG dwNewLong, BOOL Ans
break;
case GCL_HICON:
Window->Class->hIcon = (HICON)dwNewLong;
Owner = IntGetOwner(Window);
Parent = IntGetParent(Window);
if ((!Owner) && (!Parent))
if (!IntGetOwner(Window) && !IntGetParent(Window))
{
co_IntShellHookNotify(HSHELL_REDRAW, (LPARAM) Window->hSelf);
}
if (Parent)
{
IntReleaseWindowObject(Parent);
}
if (Owner)
{
IntReleaseWindowObject(Owner);
}
break;
case GCL_HICONSM:
Window->Class->hIconSm = (HICON)dwNewLong;

View file

@ -463,7 +463,6 @@ HWND FASTCALL IntGetDesktopWindow(VOID)
PWINDOW_OBJECT FASTCALL UserGetDesktopWindow(VOID)
{
PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
PWINDOW_OBJECT DeskWnd;
if (!pdo)
{
@ -471,11 +470,7 @@ PWINDOW_OBJECT FASTCALL UserGetDesktopWindow(VOID)
return NULL;
}
//temp hack
DeskWnd = IntGetWindowObject(pdo->DesktopWindow);
if (DeskWnd)
IntReleaseWindowObject(DeskWnd);
return DeskWnd;
return UserGetWindowObject(pdo->DesktopWindow);
}
@ -1190,14 +1185,11 @@ NtUserPaintDesktop(HDC hDC)
IntGdiGetClipBox(hDC, &Rect);
hWndDesktop = IntGetDesktopWindow();
if (!(WndDesktop = IntGetWindowObject(hWndDesktop)))
if (!(WndDesktop = UserGetWindowObject(hWndDesktop)))
return FALSE;
DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE); //fixme: verify retval
//temp hack
IntReleaseWindowObject(WndDesktop);
/*
* Paint desktop background
@ -1207,7 +1199,7 @@ NtUserPaintDesktop(HDC hDC)
{
PWINDOW_OBJECT DeskWin;
if((DeskWin = IntGetWindowObject(hWndDesktop)))
if((DeskWin = UserGetWindowObject(hWndDesktop)))
{
SIZE sz;
int x, y;
@ -1215,7 +1207,7 @@ NtUserPaintDesktop(HDC hDC)
sz.cx = DeskWin->WindowRect.right - DeskWin->WindowRect.left;
sz.cy = DeskWin->WindowRect.bottom - DeskWin->WindowRect.top;
IntReleaseWindowObject(DeskWin);
x = (sz.cx / 2) - (WinSta->cxWallpaper / 2);
y = (sz.cy / 2) - (WinSta->cyWallpaper / 2);

View file

@ -61,10 +61,13 @@ co_IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd)
VOID FASTCALL
co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
{
PWINDOW_OBJECT Window, Owner, Parent;
if (hWnd && (Window = IntGetWindowObject(hWnd)))
PWINDOW_OBJECT Window;
if ((Window = UserGetWindowObject(hWnd)))
{
UserRefObjectCo(Window);
/* Send palette messages */
if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0))
{
@ -76,22 +79,12 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
co_WinPosSetWindowPos(Window, HWND_TOP, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
Owner = IntGetOwner(Window);
if (!Owner)
if (!IntGetOwner(Window) && !IntGetParent(Window))
{
Parent = IntGetParent(Window);
if (!Parent)
co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd);
else
IntReleaseWindowObject(Parent);
}
else
{
IntReleaseWindowObject(Owner);
co_IntShellHookNotify(HSHELL_WINDOWACTIVATED, (LPARAM) hWnd);
}
IntReleaseWindowObject(Window);
UserDerefObjectCo(Window);
/* FIXME: IntIsWindow */
@ -130,17 +123,15 @@ IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner)
for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
{
OwnerWnd = IntGetWindowObject(Child->hOwner);
OwnerWnd = UserGetWindowObject(Child->hOwner);
if(!OwnerWnd)
continue;
if(OwnerWnd == Owner)
{
Ret = Child->hSelf;
IntReleaseWindowObject(OwnerWnd);
return Ret;
}
IntReleaseWindowObject(OwnerWnd);
}
return NULL;
@ -215,9 +206,9 @@ co_IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWin
}
BOOL FASTCALL
co_IntSetForegroundWindow(PWINDOW_OBJECT Window)
co_IntSetForegroundWindow(PWINDOW_OBJECT Window)//FIXME: can Window be NULL??
{
ASSERT_REFS_CO(Window);
/*if (Window)*/ ASSERT_REFS_CO(Window);
return co_IntSetForegroundAndFocusWindow(Window, Window, FALSE);
}
@ -234,18 +225,18 @@ co_IntMouseActivateWindow(PWINDOW_OBJECT Window)
{
BOOL Ret;
PWINDOW_OBJECT TopWnd;
PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
PWINDOW_OBJECT DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
if(DesktopWindow)
{
Top = IntFindChildWindowToOwner(DesktopWindow, Window);
if((TopWnd = IntGetWindowObject(Top)))
if((TopWnd = UserGetWindowObject(Top)))
{
UserRefObjectCo(TopWnd);
Ret = co_IntMouseActivateWindow(TopWnd);
IntReleaseWindowObject(TopWnd);
IntReleaseWindowObject(DesktopWindow);
UserDerefObjectCo(TopWnd);
return Ret;
}
IntReleaseWindowObject(DesktopWindow);
}
return FALSE;
}
@ -253,23 +244,6 @@ co_IntMouseActivateWindow(PWINDOW_OBJECT Window)
TopWindow = UserGetAncestor(Window, GA_ROOT);
if (!TopWindow) return FALSE;
// if (TopWindow != Window)
// {
// Top = UserGetAncestor(Window, GA_ROOT);
// if (Top != Window->hSelf)
// {
// TopWindow = IntGetWindowObject(Top);
// if (TopWindow == NULL)
// {
// SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
// return FALSE;
// }
// }
// else
// {
// TopWindow = Window;
// }
/* TMN: Check return valud from this function? */
UserRefObjectCo(TopWindow);
@ -278,10 +252,6 @@ co_IntMouseActivateWindow(PWINDOW_OBJECT Window)
UserDerefObjectCo(TopWindow);
// if (TopWindow != Window)
// {
// IntReleaseWindowObject(TopWindow);
// }
return TRUE;
}

View file

@ -318,7 +318,6 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
{
NTSTATUS Status;
NTUSERDISPATCHMESSAGEINFO MsgInfo;
PWINDOW_OBJECT WindowObject;
LRESULT Result = TRUE;
DECLARE_RETURN(LRESULT);
@ -352,19 +351,19 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
}
else
{
PWINDOW_OBJECT Window;
/* Get the window object. */
WindowObject = IntGetWindowObject(MsgInfo.Msg.hwnd);
if (NULL == WindowObject)
Window = UserGetWindowObject(MsgInfo.Msg.hwnd);
if (NULL == Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
MsgInfo.HandledByKernel = TRUE;
Result = 0;
}
else
{
if (WindowObject->OwnerThread != PsGetCurrentThread())
if (Window->OwnerThread != PsGetCurrentThread())
{
IntReleaseWindowObject(WindowObject);
DPRINT1("Window doesn't belong to the calling thread!\n");
MsgInfo.HandledByKernel = TRUE;
Result = 0;
@ -375,30 +374,29 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
MsgInfo.HandledByKernel = FALSE;
Result = 0;
if (0xFFFF0000 != ((DWORD) WindowObject->WndProcW & 0xFFFF0000))
if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000))
{
if (0xFFFF0000 != ((DWORD) WindowObject->WndProcA & 0xFFFF0000))
if (0xFFFF0000 != ((DWORD) Window->WndProcA & 0xFFFF0000))
{
/* Both Unicode and Ansi winprocs are real, use whatever
usermode prefers */
MsgInfo.Proc = (MsgInfo.Ansi ? WindowObject->WndProcA
: WindowObject->WndProcW);
MsgInfo.Proc = (MsgInfo.Ansi ? Window->WndProcA
: Window->WndProcW);
}
else
{
/* Real Unicode winproc */
MsgInfo.Ansi = FALSE;
MsgInfo.Proc = WindowObject->WndProcW;
MsgInfo.Proc = Window->WndProcW;
}
}
else
{
/* Must have real Ansi winproc */
MsgInfo.Ansi = TRUE;
MsgInfo.Proc = WindowObject->WndProcA;
MsgInfo.Proc = Window->WndProcA;
}
}
IntReleaseWindowObject(WindowObject);
}
}
Status = MmCopyToCaller(UnsafeMsgInfo, &MsgInfo, sizeof(NTUSERDISPATCHMESSAGEINFO));
@ -511,13 +509,15 @@ co_IntActivateWindowMouse(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, PWINDOW_OB
ULONG Result;
PWINDOW_OBJECT Parent;
ASSERT_REFS_CO(MsgWindow);
if(*HitTest == (USHORT)HTTRANSPARENT)
{
/* eat the message, search again! */
return TRUE;
}
Parent = IntGetParent(MsgWindow);
Parent = IntGetParent(MsgWindow);//fixme: deref retval?
/* fixme: abort if no parent ? */
Result = co_IntSendMessage(MsgWindow->hSelf,
WM_MOUSEACTIVATE,
@ -548,12 +548,14 @@ co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *
{
PWINDOW_OBJECT Window;
if(!(Window = IntGetWindowObject(Msg->hwnd)))
if(!(Window = UserGetWindowObject(Msg->hwnd)))
{
/* let's just eat the message?! */
return TRUE;
}
UserRefObjectCo(Window);
if(ThreadQueue == Window->MessageQueue &&
ThreadQueue->CaptureWindow != Window->hSelf)
{
@ -566,10 +568,12 @@ co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *
PWINDOW_OBJECT DesktopWindow;
HWND hDesktop = IntGetDesktopWindow();
if((DesktopWindow = IntGetWindowObject(hDesktop)))
if((DesktopWindow = UserGetWindowObject(hDesktop)))
{
PWINDOW_OBJECT Wnd;
UserRefObjectCo(DesktopWindow);
co_WinPosWindowFromPoint(DesktopWindow, Window->MessageQueue, &Msg->pt, &Wnd);
if(Wnd)
{
@ -585,15 +589,15 @@ co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *
}
/* eat the message */
IntReleaseWindowObject(Wnd);
IntReleaseWindowObject(Window);
IntReleaseWindowObject(DesktopWindow);
UserDerefObject(Wnd);
UserDerefObjectCo(DesktopWindow);
UserDerefObjectCo(Window);
return TRUE;
}
IntReleaseWindowObject(Wnd);
UserDerefObject(Wnd);
}
IntReleaseWindowObject(DesktopWindow);
UserDerefObjectCo(DesktopWindow);
}
}
}
@ -641,7 +645,7 @@ co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *
}
}
IntReleaseWindowObject(Window);
UserDerefObjectCo(Window);
return FALSE;
}
@ -651,7 +655,7 @@ co_IntTranslateMouseMessage(PUSER_MESSAGE_QUEUE ThreadQueue, LPMSG Msg, USHORT *
*/
BOOL FASTCALL
co_IntPeekMessage(PUSER_MESSAGE Msg,
HWND Wnd,
HWND hWnd,
UINT MsgFilterMin,
UINT MsgFilterMax,
UINT RemoveMsg)
@ -703,7 +707,7 @@ CheckMessages:
Present = co_MsqFindMessage(ThreadQueue,
FALSE,
RemoveMessages,
Wnd,
hWnd,
MsgFilterMin,
MsgFilterMax,
&Message);
@ -721,7 +725,7 @@ CheckMessages:
Present = co_MsqFindMessage(ThreadQueue,
TRUE,
RemoveMessages,
Wnd,
hWnd,
MsgFilterMin,
MsgFilterMax,
&Message);
@ -740,14 +744,14 @@ CheckMessages:
;
/* Check for paint messages. */
if (IntGetPaintMessage(Wnd, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages))
if (IntGetPaintMessage(hWnd, MsgFilterMin, MsgFilterMax, PsGetWin32Thread(), &Msg->Msg, RemoveMessages))
{
Msg->FreeLParam = FALSE;
return TRUE;
}
/* Check for WM_(SYS)TIMER messages */
Present = MsqGetTimerMessage(ThreadQueue, Wnd, MsgFilterMin, MsgFilterMax,
Present = MsqGetTimerMessage(ThreadQueue, hWnd, MsgFilterMin, MsgFilterMax,
&Msg->Msg, RemoveMessages);
if (Present)
{
@ -763,19 +767,22 @@ MessageFound:
{
PWINDOW_OBJECT MsgWindow = NULL;
if(Msg->Msg.hwnd && (MsgWindow = IntGetWindowObject(Msg->Msg.hwnd)) &&
if(Msg->Msg.hwnd && (MsgWindow = UserGetWindowObject(Msg->Msg.hwnd)) &&
Msg->Msg.message >= WM_MOUSEFIRST && Msg->Msg.message <= WM_MOUSELAST)
{
USHORT HitTest;
UserRefObjectCo(MsgWindow);
if(co_IntTranslateMouseMessage(ThreadQueue, &Msg->Msg, &HitTest, TRUE))
/* FIXME - check message filter again, if the message doesn't match anymore,
search again */
{
IntReleaseWindowObject(MsgWindow);
UserDerefObjectCo(MsgWindow);
/* eat the message, search again */
goto CheckMessages;
}
if(ThreadQueue->CaptureWindow == NULL)
{
co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
@ -783,21 +790,23 @@ MessageFound:
IS_BTN_MESSAGE(Msg->Msg.message, DOWN) &&
co_IntActivateWindowMouse(ThreadQueue, &Msg->Msg, MsgWindow, &HitTest))
{
IntReleaseWindowObject(MsgWindow);
UserDerefObjectCo(MsgWindow);
/* eat the message, search again */
goto CheckMessages;
}
}
UserDerefObjectCo(MsgWindow);
}
else
{
co_IntSendHitTestMessages(ThreadQueue, &Msg->Msg);
}
if(MsgWindow)
{
IntReleaseWindowObject(MsgWindow);
}
// if(MsgWindow)
// {
// UserDerefObject(MsgWindow);
// }
return TRUE;
}
@ -820,7 +829,7 @@ MessageFound:
BOOL STDCALL
NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
HWND Wnd,
HWND hWnd,
UINT MsgFilterMin,
UINT MsgFilterMax,
UINT RemoveMsg)
@ -839,16 +848,11 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
UserEnterExclusive();
/* Validate input */
if (NULL != Wnd)
if (hWnd && hWnd != INVALID_HANDLE_VALUE)
{
Window = IntGetWindowObject(Wnd);
if (NULL == Window)
if (!(Window = UserGetWindowObject(hWnd)))
{
Wnd = NULL;
}
else
{
IntReleaseWindowObject(Window);
RETURN(-1);
}
}
@ -858,7 +862,7 @@ NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
MsgFilterMax = 0;
}
Present = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, RemoveMsg);
Present = co_IntPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, RemoveMsg);
if (Present)
{
Info.Msg = Msg.Msg;
@ -945,7 +949,7 @@ co_IntWaitMessage(HWND Wnd,
BOOL STDCALL
NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
HWND Wnd,
HWND hWnd,
UINT MsgFilterMin,
UINT MsgFilterMax)
/*
@ -962,7 +966,7 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
BOOL GotMessage;
NTUSERGETMESSAGEINFO Info;
NTSTATUS Status;
PWINDOW_OBJECT Window;
PWINDOW_OBJECT Window = NULL;
PMSGMEMORY MsgMemoryEntry;
PVOID UserMem;
UINT Size;
@ -973,14 +977,13 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
UserEnterExclusive();
/* Validate input */
if (NULL != Wnd)
if (hWnd && !(Window = UserGetWindowObject(hWnd)))
{
Window = IntGetWindowObject(Wnd);
if(!Window)
Wnd = NULL;
else
IntReleaseWindowObject(Window);
RETURN(-1);
}
// if (Window) UserRefObjectCo(Window);
if (MsgFilterMax < MsgFilterMin)
{
MsgFilterMin = 0;
@ -989,7 +992,7 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
do
{
GotMessage = co_IntPeekMessage(&Msg, Wnd, MsgFilterMin, MsgFilterMax, PM_REMOVE);
GotMessage = co_IntPeekMessage(&Msg, hWnd, MsgFilterMin, MsgFilterMax, PM_REMOVE);
if (GotMessage)
{
Info.Msg = Msg.Msg;
@ -1038,7 +1041,7 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
RETURN( (BOOL) -1);
}
}
else if (! co_IntWaitMessage(Wnd, MsgFilterMin, MsgFilterMax))
else if (! co_IntWaitMessage(hWnd, MsgFilterMin, MsgFilterMax))
{
RETURN( (BOOL) -1);
}
@ -1048,6 +1051,8 @@ NtUserGetMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
RETURN( WM_QUIT != Info.Msg.message);
CLEANUP:
// if (Window) UserDerefObjectCo(Window);
DPRINT("Leave NtUserGetMessage\n");
UserLeave();
END_CLEANUP;
@ -1169,7 +1174,6 @@ UserPostMessage(HWND Wnd,
WPARAM wParam,
LPARAM lParam)
{
PWINDOW_OBJECT Window;
MSG UserModeMsg, KernelModeMsg;
LARGE_INTEGER LargeTickCount;
NTSTATUS Status;
@ -1185,9 +1189,9 @@ UserPostMessage(HWND Wnd,
PWINDOW_OBJECT DesktopWindow;
ULONG i;
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
List = IntWinListChildren(DesktopWindow);
IntReleaseWindowObject(DesktopWindow);
if (List != NULL)
{
for (i = 0; List[i]; i++)
@ -1197,15 +1201,15 @@ UserPostMessage(HWND Wnd,
}
else
{
Window = IntGetWindowObject(Wnd);
PWINDOW_OBJECT Window;
Window = UserGetWindowObject(Wnd);
if (NULL == Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
if(Window->Status & WINDOWSTATUS_DESTROYING)
{
IntReleaseWindowObject(Window);
DPRINT1("Attempted to post message to window 0x%x that is being destroyed!\n", Wnd);
/* FIXME - last error code? */
return FALSE;
@ -1229,7 +1233,6 @@ UserPostMessage(HWND Wnd,
MsqPostMessage(Window->MessageQueue, &KernelModeMsg,
NULL != MsgMemoryEntry && 0 != KernelModeMsg.lParam,
QS_POSTMESSAGE);
IntReleaseWindowObject(Window);
}
return TRUE;
@ -1336,7 +1339,8 @@ co_IntSendMessage(HWND hWnd,
return 0;
}
static LRESULT FASTCALL
static
LRESULT FASTCALL
co_IntSendMessageTimeoutSingle(HWND hWnd,
UINT Msg,
WPARAM wParam,
@ -1347,19 +1351,20 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
{
ULONG_PTR Result;
NTSTATUS Status;
PWINDOW_OBJECT Window;
PWINDOW_OBJECT Window = NULL;
PMSGMEMORY MsgMemoryEntry;
INT lParamBufferSize;
LPARAM lParamPacked;
PW32THREAD Win32Thread;
DECLARE_RETURN(LRESULT);
/* FIXME: Call hooks. */
Window = IntGetWindowObject(hWnd);
if (!Window)
if (!(Window = UserGetWindowObject(hWnd)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
RETURN( FALSE);
}
UserRefObjectCo(Window);
Win32Thread = PsGetWin32Thread();
@ -1369,8 +1374,7 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
if (Win32Thread->IsExiting)
{
/* Never send messages to exiting threads */
IntReleaseWindowObject(Window);
return FALSE;
RETURN( FALSE);
}
/* See if this message type is present in the table */
@ -1386,9 +1390,8 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
if (! NT_SUCCESS(PackParam(&lParamPacked, Msg, wParam, lParam)))
{
IntReleaseWindowObject(Window);
DPRINT1("Failed to pack message parameters\n");
return FALSE;
RETURN( FALSE);
}
if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000))
{
@ -1408,46 +1411,47 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam)))
{
IntReleaseWindowObject(Window);
DPRINT1("Failed to unpack message parameters\n");
return TRUE;
RETURN( TRUE);
}
IntReleaseWindowObject(Window);
return TRUE;
RETURN( TRUE);
}
if(uFlags & SMTO_ABORTIFHUNG && MsqIsHung(Window->MessageQueue))
{
IntReleaseWindowObject(Window);
/* FIXME - Set a LastError? */
return FALSE;
RETURN( FALSE);
}
if(Window->Status & WINDOWSTATUS_DESTROYING)
{
IntReleaseWindowObject(Window);
/* FIXME - last error? */
DPRINT1("Attempted to send message to window 0x%x that is being destroyed!\n", hWnd);
return FALSE;
RETURN( FALSE);
}
Status = co_MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam,
uTimeout, (uFlags & SMTO_BLOCK), FALSE, uResult);
IntReleaseWindowObject(Window);
if (STATUS_TIMEOUT == Status)
{
/* MSDN says GetLastError() should return 0 after timeout */
SetLastWin32Error(0);
return FALSE;
RETURN( FALSE);
}
else if (! NT_SUCCESS(Status))
{
SetLastNtError(Status);
return FALSE;
RETURN( FALSE);
}
return TRUE;
RETURN( TRUE);
CLEANUP:
if (Window) UserDerefObjectCo(Window);
END_CLEANUP;
}
LRESULT FASTCALL
@ -1468,14 +1472,14 @@ co_IntSendMessageTimeout(HWND hWnd,
return co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, uFlags, uTimeout, uResult);
}
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
if (NULL == DesktopWindow)
{
SetLastWin32Error(ERROR_INTERNAL_ERROR);
return 0;
}
Children = IntWinListChildren(DesktopWindow);
IntReleaseWindowObject(DesktopWindow);
if (NULL == Children)
{
return 0;
@ -1509,10 +1513,8 @@ co_IntPostOrSendMessage(HWND hWnd,
return 0;
}
Window = IntGetWindowObject(hWnd);
if(!Window)
if(!(Window = UserGetWindowObject(hWnd)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return 0;
}
@ -1528,13 +1530,11 @@ co_IntPostOrSendMessage(HWND hWnd,
}
}
IntReleaseWindowObject(Window);
return (LRESULT)Result;
}
LRESULT FASTCALL
co_IntDoSendMessage(HWND Wnd,
co_IntDoSendMessage(HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam,
@ -1552,15 +1552,14 @@ co_IntDoSendMessage(HWND Wnd,
RtlZeroMemory(&Info, sizeof(NTUSERSENDMESSAGEINFO));
/* FIXME: Call hooks. */
if (HWND_BROADCAST != Wnd)
if (HWND_BROADCAST != hWnd)
{
Window = IntGetWindowObject(Wnd);
Window = UserGetWindowObject(hWnd);
if (NULL == Window)
{
/* Tell usermode to not touch this one */
Info.HandledByKernel = TRUE;
MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO));
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return 0;
}
}
@ -1568,7 +1567,7 @@ co_IntDoSendMessage(HWND Wnd,
/* FIXME: Check for an exiting window. */
/* See if the current thread can handle the message */
if (HWND_BROADCAST != Wnd && NULL != PsGetWin32Thread() &&
if (HWND_BROADCAST != hWnd && NULL != PsGetWin32Thread() &&
Window->MessageQueue == PsGetWin32Thread()->MessageQueue)
{
/* Gather the information usermode needs to call the window proc directly */
@ -1599,17 +1598,16 @@ co_IntDoSendMessage(HWND Wnd,
Info.Ansi = TRUE;
Info.Proc = Window->WndProcA;
}
IntReleaseWindowObject(Window);
}
else
{
/* Must be handled by other thread */
if (HWND_BROADCAST != Wnd)
{
IntReleaseWindowObject(Window);
}
// if (HWND_BROADCAST != hWnd)
// {
// UserDerefObject(Window);
// }
Info.HandledByKernel = TRUE;
UserModeMsg.hwnd = Wnd;
UserModeMsg.hwnd = hWnd;
UserModeMsg.message = Msg;
UserModeMsg.wParam = wParam;
UserModeMsg.lParam = lParam;

View file

@ -182,35 +182,30 @@ NtUserCallOneParam(
{
case ONEPARAM_ROUTINE_GETMENU:
{
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
DWORD Result;
WindowObject = IntGetWindowObject((HWND)Param);
if(!WindowObject)
if(!(Window = UserGetWindowObject((HWND)Param)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
Result = (DWORD)WindowObject->IDMenu;
Result = (DWORD)Window->IDMenu;
IntReleaseWindowObject(WindowObject);
RETURN( Result);
}
case ONEPARAM_ROUTINE_ISWINDOWUNICODE:
{
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
DWORD Result;
WindowObject = IntGetWindowObject((HWND)Param);
if(!WindowObject)
Window = UserGetWindowObject((HWND)Param);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
Result = WindowObject->Unicode;
IntReleaseWindowObject(WindowObject);
Result = Window->Unicode;
RETURN( Result);
}
@ -219,32 +214,30 @@ NtUserCallOneParam(
case ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID:
{
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
DWORD Result;
WindowObject = IntGetWindowObject((HWND)Param);
if(!WindowObject)
Window = UserGetWindowObject((HWND)Param);
if(!Window)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
Result = WindowObject->ContextHelpId;
Result = Window->ContextHelpId;
IntReleaseWindowObject(WindowObject);
RETURN( Result);
}
case ONEPARAM_ROUTINE_SWAPMOUSEBUTTON:
{
PWINSTATION_OBJECT WinStaObject;
PWINSTATION_OBJECT WinSta;
NTSTATUS Status;
DWORD Result;
Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
&WinStaObject);
&WinSta);
if (!NT_SUCCESS(Status))
RETURN( (DWORD)FALSE);
@ -252,7 +245,7 @@ NtUserCallOneParam(
Result = (DWORD)IntSwapMouseButton(WinStaObject, (BOOL)Param); */
Result = 0;
ObDereferenceObject(WinStaObject);
ObDereferenceObject(WinSta);
RETURN( Result);
}
@ -267,17 +260,15 @@ NtUserCallOneParam(
case ONEPARAM_ROUTINE_GETWINDOWINSTANCE:
{
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
DWORD Result;
if(!(WindowObject = IntGetWindowObject((HWND)Param)))
if(!(Window = UserGetWindowObject((HWND)Param)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
Result = (DWORD)WindowObject->Instance;
IntReleaseWindowObject(WindowObject);
Result = (DWORD)Window->Instance;
RETURN( Result);
}
@ -286,7 +277,7 @@ NtUserCallOneParam(
case ONEPARAM_ROUTINE_GETCURSORPOSITION:
{
PWINSTATION_OBJECT WinStaObject;
PWINSTATION_OBJECT WinSta;
NTSTATUS Status;
POINT Pos;
@ -295,41 +286,38 @@ NtUserCallOneParam(
Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
&WinStaObject);
&WinSta);
if (!NT_SUCCESS(Status))
RETURN( (DWORD)FALSE);
/* FIXME - check if process has WINSTA_READATTRIBUTES */
IntGetCursorLocation(WinStaObject, &Pos);
IntGetCursorLocation(WinSta, &Pos);
Status = MmCopyToCaller((PPOINT)Param, &Pos, sizeof(POINT));
if(!NT_SUCCESS(Status))
{
ObDereferenceObject(WinStaObject);
ObDereferenceObject(WinSta);
SetLastNtError(Status);
RETURN( FALSE);
}
ObDereferenceObject(WinStaObject);
ObDereferenceObject(WinSta);
RETURN( (DWORD)TRUE);
}
case ONEPARAM_ROUTINE_ISWINDOWINDESTROY:
{
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
DWORD Result;
WindowObject = IntGetWindowObject((HWND)Param);
if(!WindowObject)
if(!(Window = UserGetWindowObject((HWND)Param)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
Result = (DWORD)IntIsWindowInDestroy(WindowObject);
Result = (DWORD)IntIsWindowInDestroy(Window);
IntReleaseWindowObject(WindowObject);
RETURN( Result);
}
@ -389,7 +377,7 @@ NtUserCallTwoParam(
DWORD Routine)
{
NTSTATUS Status;
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
DECLARE_RETURN(DWORD);
DPRINT("Enter NtUserCallTwoParam\n");
@ -496,26 +484,26 @@ NtUserCallTwoParam(
case TWOPARAM_ROUTINE_ROS_SHOWWINDOW:
{
#define WIN_NEEDS_SHOW_OWNEDPOPUP (0x00000040)
PWINDOW_OBJECT Window = IntGetWindowObject((HWND)Param1);
PWINDOW_OBJECT Window;
DPRINT1("ROS_SHOWWINDOW\n");
if (Window == 0)
if (!(Window = UserGetWindowObject((HWND)Param1)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
if (Param2)
{
if (!(Window->Flags & WIN_NEEDS_SHOW_OWNEDPOPUP))
{
IntReleaseWindowObject(Window);
RETURN( TRUE);
}
Window->Flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
}
else
Window->Flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
DPRINT1("ROS_SHOWWINDOW ---> 0x%x\n",Window->Flags);
IntReleaseWindowObject(Window);
RETURN( TRUE);
}
case TWOPARAM_ROUTINE_SWITCHTOTHISWINDOW:
@ -538,16 +526,14 @@ NtUserCallTwoParam(
}
case TWOPARAM_ROUTINE_SETWNDCONTEXTHLPID:
WindowObject = IntGetWindowObject((HWND)Param1);
if(!WindowObject)
if(!(Window = UserGetWindowObject((HWND)Param1)))
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
RETURN( (DWORD)FALSE);
}
WindowObject->ContextHelpId = Param2;
Window->ContextHelpId = Param2;
IntReleaseWindowObject(WindowObject);
RETURN( (DWORD)TRUE);
case TWOPARAM_ROUTINE_SETCARETPOS:
@ -558,9 +544,8 @@ NtUserCallTwoParam(
WINDOWINFO wi;
DWORD Ret;
if(!(WindowObject = IntGetWindowObject((HWND)Param1)))
if(!(Window = UserGetWindowObject((HWND)Param1)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
@ -572,31 +557,27 @@ NtUserCallTwoParam(
Status = MmCopyFromCaller(&wi.cbSize, (PVOID)Param2, sizeof(wi.cbSize));
if(!NT_SUCCESS(Status))
{
IntReleaseWindowObject(WindowObject);
SetLastNtError(Status);
RETURN( FALSE);
}
if(wi.cbSize != sizeof(WINDOWINFO))
{
IntReleaseWindowObject(WindowObject);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
RETURN( FALSE);
}
#endif
if((Ret = (DWORD)IntGetWindowInfo(WindowObject, &wi)))
if((Ret = (DWORD)IntGetWindowInfo(Window, &wi)))
{
Status = MmCopyToCaller((PVOID)Param2, &wi, sizeof(WINDOWINFO));
if(!NT_SUCCESS(Status))
{
IntReleaseWindowObject(WindowObject);
SetLastNtError(Status);
RETURN( FALSE);
}
}
IntReleaseWindowObject(WindowObject);
RETURN( Ret);
}
@ -728,12 +709,11 @@ NtUserCallHwndLock(
DPRINT("Enter NtUserCallHwndLock\n");
UserEnterExclusive();
Window = IntGetWindowObject(hWnd);
if (Window == 0)
if (!(Window = UserGetWindowObject(hWnd)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( FALSE);
}
UserRefObjectCo(Window);
/* FIXME: Routine can be 0x53 - 0x5E */
switch (Routine)
@ -744,19 +724,21 @@ NtUserCallHwndLock(
case HWNDLOCK_ROUTINE_DRAWMENUBAR:
{
PMENU_OBJECT MenuObject;
PMENU_OBJECT Menu;
DPRINT("HWNDLOCK_ROUTINE_DRAWMENUBAR\n");
Ret = FALSE;
if (!((Window->Style & (WS_CHILD | WS_POPUP)) != WS_CHILD))
break;
MenuObject = IntGetMenuObject((HMENU) Window->IDMenu);
if(MenuObject == NULL)
if(!(Menu = UserGetMenuObject((HMENU) Window->IDMenu)))
break;
MenuObject->MenuInfo.WndOwner = hWnd;
MenuObject->MenuInfo.Height = 0;
IntReleaseMenuObject(MenuObject);
Menu->MenuInfo.WndOwner = hWnd;
Menu->MenuInfo.Height = 0;
co_WinPosSetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
Ret = TRUE;
break;
}
@ -774,7 +756,7 @@ NtUserCallHwndLock(
break;
}
IntReleaseWindowObject(Window);
UserDerefObjectCo(Window);
RETURN( Ret);

View file

@ -254,14 +254,23 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Fi
{
USHORT Msg = Message->Msg.message;
PWINDOW_OBJECT Window = NULL;
HWND CaptureWin;
HWND hCaptureWin;
ASSERT_REFS_CO(ScopeWin);
CaptureWin = IntGetCaptureWindow();
if (CaptureWin == NULL)
/*
co_WinPosWindowFromPoint can return a Window, and in that case
that window has a ref that we need to deref. Thats why we add "dummy"
refs in all other cases.
*/
hCaptureWin = IntGetCaptureWindow();
if (hCaptureWin == NULL)
{
if(Msg == WM_MOUSEWHEEL)
{
Window = IntGetWindowObject(IntGetFocusWindow());
Window = UserGetWindowObject(IntGetFocusWindow());
if (Window) UserRefObject(Window);
}
else
{
@ -269,7 +278,12 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Fi
if(Window == NULL)
{
Window = ScopeWin;
IntReferenceWindowObject(Window);
if (Window) UserRefObject(Window);
}
else
{
/* this is the one case where we dont add a ref, since the returned
window is already referenced */
}
}
}
@ -277,9 +291,12 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Fi
{
/* FIXME - window messages should go to the right window if no buttons are
pressed */
Window = IntGetWindowObject(CaptureWin);
Window = UserGetWindowObject(hCaptureWin);
if (Window) UserRefObject(Window);
}
if (Window == NULL)
{
if(!FromGlobalQueue)
@ -348,7 +365,7 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Fi
IntUnLockHardwareMessageQueue(Window->MessageQueue);
*Freed = FALSE;
IntReleaseWindowObject(Window);
UserDerefObject(Window);
return(FALSE);
}
@ -391,7 +408,7 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Fi
IntUnLockHardwareMessageQueue(Window->MessageQueue);
}
IntReleaseWindowObject(Window);
UserDerefObject(Window);
*Freed = FALSE;
return(FALSE);
}
@ -430,7 +447,7 @@ co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT Fi
}
}
IntReleaseWindowObject(Window);
UserDerefObject(Window);
*Freed = FALSE;
return(TRUE);
}
@ -444,14 +461,15 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
POINT ScreenPoint;
BOOL Accept, Freed;
PLIST_ENTRY CurrentEntry;
PWINDOW_OBJECT DesktopWindow;
PWINDOW_OBJECT DesktopWindow = NULL;
PVOID WaitObjects[2];
NTSTATUS WaitStatus;
DECLARE_RETURN(BOOL);
if( !IntGetScreenDC() ||
PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() )
{
return FALSE;
RETURN(FALSE);
}
WaitObjects[1] = MessageQueue->NewMessages;
@ -472,8 +490,10 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
}
while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
if (DesktopWindow) UserRefObjectCo(DesktopWindow);//can DesktopWindow be NULL?
/* Process messages in the message queue itself. */
IntLockHardwareMessageQueue(MessageQueue);
CurrentEntry = MessageQueue->HardwareMessagesListHead.Flink;
@ -485,6 +505,9 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
if (Current->Msg.message >= WM_MOUSEFIRST &&
Current->Msg.message <= WM_MOUSELAST)
{
Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
Current, Remove, &Freed,
DesktopWindow, &ScreenPoint, FALSE);
@ -497,8 +520,8 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
IntUnLockHardwareMessageQueue(MessageQueue);
IntUnLockSystemHardwareMessageQueueLock(FALSE);
*Message = Current;
IntReleaseWindowObject(DesktopWindow);
return(TRUE);
RETURN(TRUE);
}
}
@ -623,8 +646,8 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
}
IntUnLockSystemHardwareMessageQueueLock(FALSE);
*Message = Current;
IntReleaseWindowObject(DesktopWindow);
return(TRUE);
RETURN(TRUE);
}
/* If the contents of the queue changed then restart processing. */
if (HardwareMessageQueueStamp != ActiveStamp)
@ -634,7 +657,7 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
}
}
}
IntReleaseWindowObject(DesktopWindow);
/* Check if the system message queue is now empty. */
IntLockSystemMessageQueue(OldIrql);
if (SystemMessageQueueCount == 0 && IsListEmpty(&HardwareMessageQueueHead))
@ -644,7 +667,12 @@ co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
IntUnLockSystemMessageQueue(OldIrql);
IntUnLockSystemHardwareMessageQueueLock(FALSE);
return(FALSE);
RETURN(FALSE);
CLEANUP:
if (DesktopWindow) UserDerefObjectCo(DesktopWindow);
END_CLEANUP;
}
VOID FASTCALL

View file

@ -55,6 +55,8 @@ inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht)
{
PUSER_HANDLE_ENTRY entry;
// DPRINT1("handles used %i\n",usedHandles);
if (ht->freelist)
{
entry = ht->freelist;

View file

@ -164,11 +164,13 @@ co_IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags)
{
for (phWnd = List; *phWnd; ++phWnd)
{
Window = IntGetWindowObject(*phWnd);
Window = UserGetWindowObject(*phWnd);
if (Window && (Window->Style & WS_VISIBLE))
{
UserRefObjectCo(Window);
co_IntPaintWindows(Window, Flags);
IntReleaseWindowObject(Window);
UserDerefObjectCo(Window);
}
}
ExFreePool(List);
@ -344,11 +346,11 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
{
for (phWnd = List; *phWnd; ++phWnd)
{
Child = IntGetWindowObject(*phWnd);
if(!Child)
if(!(Child = UserGetWindowObject(*phWnd)))
{
continue;
}
if (Child->Style & WS_VISIBLE)
{
/*
@ -362,7 +364,7 @@ IntInvalidateWindows(PWINDOW_OBJECT Window, HRGN hRgn, ULONG Flags)
IntInvalidateWindows(Child, hRgnTemp, Flags);
NtGdiDeleteObject(hRgnTemp);
}
IntReleaseWindowObject(Child);
}
ExFreePool(List);
}
@ -539,14 +541,12 @@ IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
PWINDOW_OBJECT Child;
HWND hFoundWnd = NULL;
Window = IntGetWindowObject(hWnd);
if (Window == NULL)
if (!(Window = UserGetWindowObject(hWnd)))
return NULL;
if (IntIsWindowDirty(Window) &&
IntWndBelongsToThread(Window, Thread))
{
IntReleaseWindowObject(Window);
return hWnd;
}
@ -578,8 +578,6 @@ IntFindWindowToRepaint(HWND hWnd, PW32THREAD Thread)
}
}
IntReleaseWindowObject(Window);
return hFoundWnd;
}
@ -613,17 +611,13 @@ IntGetPaintMessage(HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax,
return FALSE;
}
Window = IntGetWindowObject(Message->hwnd);
if (Window != NULL)
{
Message->message = WM_PAINT;
Message->wParam = Message->lParam = 0;
IntReleaseWindowObject(Window);
if (!(Window = UserGetWindowObject(Message->hwnd)))
return FALSE;
return TRUE;
}
Message->message = WM_PAINT;
Message->wParam = Message->lParam = 0;
return FALSE;
return TRUE;
}
static
@ -643,8 +637,9 @@ co_IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags)
WndCaret = UserGetWindowObject(hWndCaret);
//fix: check for WndCaret can be null
if (WndCaret == Window ||
((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window->hSelf, hWndCaret)))
((flags & SW_SCROLLCHILDREN) && IntIsChildWindow(Window, WndCaret)))
{
POINT pt, FromOffset, ToOffset, Offset;
RECT rcCaret;
@ -683,7 +678,7 @@ co_IntFixCaret(PWINDOW_OBJECT Window, LPRECT lprc, UINT flags)
HDC STDCALL
NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
{
PWINDOW_OBJECT Window;
PWINDOW_OBJECT Window = NULL;
PAINTSTRUCT Ps;
PROSRGNDATA Rgn;
NTSTATUS Status;
@ -692,12 +687,13 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
DPRINT("Enter NtUserBeginPaint\n");
UserEnterExclusive();
if (!(Window = IntGetWindowObject(hWnd)))
if (!(Window = UserGetWindowObject(hWnd)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN( NULL);
}
UserRefObjectCo(Window);
co_UserHideCaret(Window);
if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT)
@ -728,7 +724,6 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
if (!Ps.hdc)
{
IntReleaseWindowObject(Window);
RETURN( NULL);
}
@ -757,6 +752,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
{
if (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT)
MsqDecPaintCountQueue(Window->MessageQueue);
IntGetClientRect(Window, &Ps.rcPaint);
}
Window->Flags &= ~WINDOWOBJECT_NEED_INTERNALPAINT;
@ -771,8 +767,6 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
Ps.fErase = FALSE;
}
IntReleaseWindowObject(Window);
Status = MmCopyToCaller(UnsafePs, &Ps, sizeof(PAINTSTRUCT));
if (! NT_SUCCESS(Status))
{
@ -783,6 +777,8 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* UnsafePs)
RETURN( Ps.hdc);
CLEANUP:
if (Window) UserDerefObjectCo(Window);
DPRINT("Leave NtUserBeginPaint, ret=%i\n",_ret_);
UserLeave();
END_CLEANUP;
@ -805,15 +801,16 @@ NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT* lPs)
DPRINT("Enter NtUserEndPaint\n");
UserEnterExclusive();
if (!(Window = IntGetWindowObject(hWnd)))
if (!(Window = UserGetWindowObject(hWnd)))
{
RETURN(FALSE);
}
UserReleaseDC(Window, lPs->hdc);
co_UserShowCaret(Window);
IntReleaseWindowObject(Window); //temp hack
UserRefObjectCo(Window);
co_UserShowCaret(Window);
UserDerefObjectCo(Window);
RETURN(TRUE);

View file

@ -58,7 +58,7 @@ static ULONG HintIndex = 0;
UINT_PTR FASTCALL
IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL SystemTimer)
{
PWINDOW_OBJECT WindowObject;
PWINDOW_OBJECT Window;
UINT_PTR Ret = 0;
DPRINT("IntSetTimer wnd %x id %p elapse %u timerproc %p systemtimer %s\n",
@ -85,22 +85,19 @@ IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL S
}
else
{
WindowObject = IntGetWindowObject(Wnd);
if (! WindowObject)
if (!(Window = UserGetWindowObject(Wnd)))
{
DPRINT1("Invalid window handle\n");
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return 0;
}
if (WindowObject->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
if (Window->OwnerThread->ThreadsProcess != PsGetCurrentProcess())
{
IntReleaseWindowObject(WindowObject);
DPRINT1("Trying to set timer for window in another process (shatter attack?)\n");
SetLastWin32Error(ERROR_ACCESS_DENIED);
return 0;
}
IntReleaseWindowObject(WindowObject);
Ret = IDEvent;
}

View file

@ -293,11 +293,10 @@ DceUpdateVisRgn(DCE *Dce, PWINDOW_OBJECT Window, ULONG Flags)
}
else if (Window == NULL)
{
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
if (NULL != DesktopWindow)
{
hRgnVisible = UnsafeIntCreateRectRgnIndirect(&DesktopWindow->WindowRect);
IntReleaseWindowObject(DesktopWindow);
}
else
{
@ -571,30 +570,20 @@ UserGetDCEx(PWINDOW_OBJECT Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
HDC STDCALL
NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags)
NtUserGetDCEx(HWND hWnd OPTIONAL, HANDLE ClipRegion, ULONG Flags)
{
PWINDOW_OBJECT Wnd=NULL;
DECLARE_RETURN(HDC);
HDC ret;
DPRINT("Enter NtUserGetDCEx\n");
UserEnterExclusive();
if (hWnd)
if (hWnd && !(Wnd = UserGetWindowObject(hWnd)))
{
if (!(Wnd = IntGetWindowObject(hWnd)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
RETURN(NULL);
}
RETURN(NULL);
}
ret = UserGetDCEx(Wnd, ClipRegion, Flags);
if (Wnd)
IntReleaseWindowObject(Wnd);
RETURN(ret);
RETURN( UserGetDCEx(Wnd, ClipRegion, Flags));
CLEANUP:
DPRINT("Leave NtUserGetDCEx, ret=%i\n",_ret_);
@ -815,7 +804,7 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
}
else
{
CurrentWindow = IntGetWindowObject(pDCE->hwndCurrent);
CurrentWindow = UserGetWindowObject(pDCE->hwndCurrent);
if (NULL == CurrentWindow)
{
pDCE = pDCE->next;
@ -826,14 +815,14 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
dc = DC_LockDc(pDCE->hDC);
if (dc == NULL)
{
if (Window->hSelf != pDCE->hwndCurrent)
{
IntReleaseWindowObject(CurrentWindow);
}
// if (Window->hSelf != pDCE->hwndCurrent)
// {
// UserDerefObject(CurrentWindow);
// }
pDCE = pDCE->next;
continue;
}
if (Window == CurrentWindow || IntIsChildWindow(Window->hSelf, CurrentWindow->hSelf))
if (Window == CurrentWindow || IntIsChildWindow(Window, CurrentWindow))
{
if (pDCE->DCXFlags & DCX_WINDOW)
{
@ -865,7 +854,7 @@ DceResetActiveDCEs(PWINDOW_OBJECT Window)
if (Window->hSelf != pDCE->hwndCurrent)
{
// IntEngWindowChanged(CurrentWindow, WOC_RGN_CLIENT);
IntReleaseWindowObject(CurrentWindow);
// UserDerefObject(CurrentWindow);
}
}

File diff suppressed because it is too large Load diff

View file

@ -126,7 +126,8 @@ CLEANUP:
*
* Check if we can activate the specified window.
*/
static BOOL FASTCALL can_activate_window( PWINDOW_OBJECT Wnd )
static
BOOL FASTCALL can_activate_window( PWINDOW_OBJECT Wnd OPTIONAL)
{
LONG style;
@ -144,65 +145,54 @@ static BOOL FASTCALL can_activate_window( PWINDOW_OBJECT Wnd )
* Activates window other than pWnd.
*/
VOID FASTCALL
co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window OPTIONAL)
co_WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
{
PWINDOW_OBJECT Wnd;
PWINDOW_OBJECT WndTo = NULL;
HWND Fg;
if (Window)
ASSERT_REFS_CO(Window);
ASSERT_REFS_CO(Window);
if (!Window || IntIsDesktopWindow(Window))
if (IntIsDesktopWindow(Window))
{
IntSetFocusMessageQueue(NULL);
return;
}
/* If this is popup window, try to activate the owner first. */
if ((Window->Style & WS_POPUP) && (Wnd = IntGetOwner(Window)))
if ((Window->Style & WS_POPUP) && (WndTo = IntGetOwner(Window)))
{
Wnd = UserGetAncestor( Wnd, GA_ROOT );
if (can_activate_window(Wnd)) goto done;
WndTo = UserGetAncestor( WndTo, GA_ROOT );
if (can_activate_window(WndTo)) goto done;
}
/* Pick a next top-level window. */
/* FIXME: Search for non-tooltip windows first. */
Wnd = Window;
while (Wnd != NULL)
WndTo = Window;
for (;;)
{
if (Wnd->NextSibling == NULL)
{
Wnd = NULL;
break;
}
Wnd = Wnd->NextSibling;
if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
(Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
break;
if (!(WndTo = WndTo->NextSibling)) break;
if (can_activate_window( WndTo )) break;
}
done:
if (Wnd)
UserRefObjectCo(Wnd);
if (WndTo) UserRefObjectCo(WndTo);
Fg = UserGetForegroundWindow();
if (Wnd && (!Fg || Window->hSelf == Fg))
if ((!Fg || Window->hSelf == Fg) && WndTo)//fixme: ok if WndTo is NULL??
{
if (co_IntSetForegroundWindow(Wnd))
/* fixme: wine can pass WndTo=NULL to co_IntSetForegroundWindow. hmm */
if (co_IntSetForegroundWindow(WndTo))
{
UserDerefObjectCo(Wnd);
UserDerefObjectCo(WndTo);
return;
}
}
if (!co_IntSetActiveWindow(Wnd))
if (!co_IntSetActiveWindow(WndTo)) /* ok for WndTo to be NULL here */
co_IntSetActiveWindow(0);
if (Wnd)
UserDerefObjectCo(Wnd);
if (WndTo) UserDerefObjectCo(WndTo);
}
@ -419,6 +409,7 @@ co_WinPosMinMaximize(PWINDOW_OBJECT Window, UINT ShowFlag, RECT* NewPos)
return(SwpFlags);
}
static
VOID FASTCALL
WinPosFillMinMaxInfoStruct(PWINDOW_OBJECT Window, MINMAXINFO *Info)
{
@ -480,7 +471,8 @@ co_WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
return 0; //FIXME: what does it return?
}
STATIC VOID FASTCALL
static
VOID FASTCALL
FixClientRect(PRECT ClientRect, PRECT WindowRect)
{
if (ClientRect->left < WindowRect->left)
@ -517,7 +509,8 @@ FixClientRect(PRECT ClientRect, PRECT WindowRect)
}
}
LONG STATIC FASTCALL
static
LONG FASTCALL
co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
RECT* WindowRect, RECT* ClientRect)
{
@ -592,6 +585,7 @@ co_WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
return wvrFlags;
}
static
BOOL FASTCALL
co_WinPosDoWinPosChanging(PWINDOW_OBJECT Window,
PWINDOWPOS WinPos,
@ -646,6 +640,7 @@ co_WinPosDoWinPosChanging(PWINDOW_OBJECT Window,
* Fix Z order taking into account owned popups -
* basically we need to maintain them above the window that owns them
*/
static
HWND FASTCALL
WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
{
@ -662,9 +657,9 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
if (hWndInsertAfter != HWND_TOPMOST)
{
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
List = IntWinListChildren(DesktopWindow);
IntReleaseWindowObject(DesktopWindow);
if (List != NULL)
{
for (i = 0; List[i]; i++)
@ -673,15 +668,13 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
break;
if (HWND_TOP == hWndInsertAfter)
{
ChildObject = IntGetWindowObject(List[i]);
ChildObject = UserGetWindowObject(List[i]);
if (NULL != ChildObject)
{
if (0 == (ChildObject->ExStyle & WS_EX_TOPMOST))
{
IntReleaseWindowObject(ChildObject);
break;
}
IntReleaseWindowObject(ChildObject);
}
}
if (List[i] != hWnd)
@ -700,9 +693,8 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
if (!List)
{
DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
List = IntWinListChildren(DesktopWindow);
IntReleaseWindowObject(DesktopWindow);
}
if (List != NULL)
{
@ -741,7 +733,8 @@ WinPosDoOwnedPopups(HWND hWnd, HWND hWndInsertAfter)
* Update WindowRect and ClientRect of Window and all of its children
* We keep both WindowRect and ClientRect in screen coordinates internally
*/
VOID STATIC FASTCALL
static
VOID FASTCALL
WinPosInternalMoveWindow(PWINDOW_OBJECT Window, INT MoveX, INT MoveY)
{
PWINDOW_OBJECT Child;
@ -767,7 +760,7 @@ WinPosInternalMoveWindow(PWINDOW_OBJECT Window, INT MoveX, INT MoveY)
*
* Fix redundant flags and values in the WINDOWPOS structure.
*/
static
BOOL FASTCALL
WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
{
@ -999,14 +992,14 @@ co_WinPosSetWindowPos(
}
if (NULL != InsertAfterWindow)
{
IntReferenceWindowObject(InsertAfterWindow);
UserRefObject(InsertAfterWindow);
}
}
else if (WinPos.hwndInsertAfter == HWND_BOTTOM)
{
if(ParentWindow->LastChild)
{
IntReferenceWindowObject(ParentWindow->LastChild);
UserRefObject(ParentWindow->LastChild);
InsertAfterWindow = ParentWindow->LastChild;
}
else
@ -1022,7 +1015,7 @@ co_WinPosSetWindowPos(
IntLinkWindow(Window, ParentWindow, InsertAfterWindow);
}
if (InsertAfterWindow != NULL)
IntReleaseWindowObject(InsertAfterWindow);
UserDerefObject(InsertAfterWindow);
if ((HWND_TOPMOST == WinPos.hwndInsertAfter)
|| (0 != (Window->ExStyle & WS_EX_TOPMOST)
&& NULL != Window->PrevSibling
@ -1395,6 +1388,8 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
if (Cmd == SW_HIDE)
{
PWINDOW_OBJECT ThreadFocusWindow;
/* FIXME: This will cause the window to be activated irrespective
* of whether it is owned by the same thread. Has to be done
* asynchronously.
@ -1405,9 +1400,13 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
co_WinPosActivateOtherWindow(Window);
}
//temphack
ThreadFocusWindow = UserGetWindowObject(IntGetThreadFocusWindow());
/* Revert focus to parent */
if (Window->hSelf == IntGetThreadFocusWindow() ||
IntIsChildWindow(Window->hSelf, IntGetThreadFocusWindow()))
if (ThreadFocusWindow && (Window == ThreadFocusWindow ||
IntIsChildWindow(Window, ThreadFocusWindow)))
{
//faxme: as long as we have ref on Window, we also, indirectly, have ref on parent...
co_UserSetFocus(Window->Parent);
@ -1457,10 +1456,43 @@ co_WinPosShowWindow(PWINDOW_OBJECT Window, INT Cmd)
return(WasVisible);
}
STATIC VOID FASTCALL
#if 0
/* find child of 'parent' that contains the given point (in parent-relative coords) */
PWINDOW_OBJECT child_window_from_point(PWINDOW_OBJECT parent, int x, int y )
{
PWINDOW_OBJECT Wnd;// = parent->FirstChild;
// LIST_FOR_EACH_ENTRY( Wnd, &parent->children, struct window, entry )
for (Wnd = parent->FirstChild; Wnd; Wnd = Wnd->NextSibling)
{
if (!IntPtInWindow( Wnd, x, y )) continue; /* skip it */
/* if window is minimized or disabled, return at once */
if (Wnd->Style & (WS_MINIMIZE|WS_DISABLED)) return Wnd;
/* if point is not in client area, return at once */
if (x < Wnd->ClientRect.left || x >= Wnd->ClientRect.right ||
y < Wnd->ClientRect.top || y >= Wnd->ClientRect.bottom)
return Wnd;
return child_window_from_point( Wnd, x - Wnd->ClientRect.left, y - Wnd->ClientRect.top );
}
return parent; /* not found any child */
}
#endif
static
VOID FASTCALL
co_WinPosSearchChildren(
PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *Point,
PWINDOW_OBJECT* Window, USHORT *HitTest)
PWINDOW_OBJECT ScopeWin,
PUSER_MESSAGE_QUEUE OnlyHitTests,
POINT *Point,
PWINDOW_OBJECT* Window,
USHORT *HitTest
)
{
PWINDOW_OBJECT Current;
HWND *List, *phWnd;
@ -1471,50 +1503,52 @@ co_WinPosSearchChildren(
{
for (phWnd = List; *phWnd; ++phWnd)
{
if (!(Current = IntGetWindowObject(*phWnd)))
if (!(Current = UserGetWindowObject(*phWnd)))
continue;
if (!(Current->Style & WS_VISIBLE))
{
IntReleaseWindowObject(Current);
continue;
}
if ((Current->Style & (WS_POPUP | WS_CHILD | WS_DISABLED)) ==
(WS_CHILD | WS_DISABLED))
{
IntReleaseWindowObject(Current);
continue;
}
if (!IntPtInWindow(Current, Point->x, Point->y))
{
IntReleaseWindowObject(Current);
continue;
}
if (*Window)
IntReleaseWindowObject(*Window);
*Window = Current;
if (Current->Style & WS_MINIMIZE)
{
*HitTest = HTCAPTION;
UserRefObject(Current);
break;
}
if (Current->Style & WS_DISABLED)
{
*HitTest = HTERROR;
UserRefObject(Current);
break;
}
UserRefObjectCo(Current);
if (OnlyHitTests && (Current->MessageQueue == OnlyHitTests))
{
*HitTest = co_IntSendMessage(Current->hSelf, WM_NCHITTEST, 0,
MAKELONG(Point->x, Point->y));
if ((*HitTest) == (USHORT)HTTRANSPARENT)
{
UserDerefObjectCo(Current);
continue;
}
}
else
*HitTest = HTCLIENT;
@ -1526,6 +1560,9 @@ co_WinPosSearchChildren(
{
co_WinPosSearchChildren(Current, OnlyHitTests, Point, Window, HitTest);
}
UserRefObject(Current);
UserDerefObjectCo(Current);
break;
}
@ -1533,6 +1570,7 @@ co_WinPosSearchChildren(
}
}
/* wine: WINPOS_WindowFromPoint */
USHORT FASTCALL
co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTests, POINT *WinPoint,
PWINDOW_OBJECT* Window)
@ -1560,11 +1598,10 @@ co_WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, PUSER_MESSAGE_QUEUE OnlyHitTes
/* Translate the point to the space of the scope window. */
DesktopWindowHandle = IntGetDesktopWindow();
if((DesktopWindowHandle != ScopeWin->hSelf) &&
(DesktopWindow = IntGetWindowObject(DesktopWindowHandle)))
(DesktopWindow = UserGetWindowObject(DesktopWindowHandle)))
{
Point.x += ScopeWin->ClientRect.left - DesktopWindow->ClientRect.left;
Point.y += ScopeWin->ClientRect.top - DesktopWindow->ClientRect.top;
IntReleaseWindowObject(DesktopWindow);
}
HitTest = HTNOWHERE;
@ -1626,8 +1663,7 @@ NtUserGetMinMaxInfo(
RETURN( FALSE);
CLEANUP:
if (Window)
UserDerefObjectCo(Window);
if (Window) UserDerefObjectCo(Window);
DPRINT("Leave NtUserGetMinMaxInfo, ret=%i\n",_ret_);
UserLeave();

View file

@ -645,7 +645,7 @@ NtGdiUpdateColors(HDC hDC)
UserEnterExclusive();
}
Wnd = IntGetWindowObject(IntWindowFromDC(hDC));
Wnd = UserGetWindowObject(IntWindowFromDC(hDC));
if (Wnd == NULL)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
@ -657,9 +657,9 @@ NtGdiUpdateColors(HDC hDC)
return FALSE;
}
UserRefObjectCo(Wnd);
ret = co_UserRedrawWindow(Wnd, NULL, 0, RDW_INVALIDATE);
IntReleaseWindowObject(Wnd); //temp hack
UserDerefObjectCo(Wnd);
if (!calledFromUser){
UserLeave();