-W32k/NtUser separation

-Introduce new WinSta lock to replace most others

svn path=/trunk/; revision=5380
This commit is contained in:
Gunnar Dalsnes 2003-08-02 16:32:18 +00:00
parent 0eec40929a
commit 59caa89d83
6 changed files with 103 additions and 45 deletions

View file

@ -0,0 +1,14 @@
#ifndef _WIN32K_PROP_H
#define _WIN32K_PROP_H
BOOL FASTCALL
W32kSetProp(struct _WINDOW_OBJECT* Wnd, ATOM Atom, HANDLE Data);
struct _PROPERTY* FASTCALL
W32kGetProp(struct _WINDOW_OBJECT* WindowObject, ATOM Atom);
#endif /* _WIN32K_PROP_H */
/* EOF */

View file

@ -1,12 +1,16 @@
#ifndef __WIN32K_WINDOW_H
#define __WIN32K_WINDOW_H
struct _PROPERTY;
struct _WINDOW_OBJECT;
#include <windows.h>
#include <ddk/ntddk.h>
#include <include/class.h>
#include <include/msgqueue.h>
#include <include/winsta.h>
#include <include/dce.h>
#include <include/prop.h>
typedef struct _PROPERTY
{

View file

@ -52,6 +52,10 @@ W32kGetCaptureWindow(VOID);
VOID STDCALL
W32kSetCaptureWindow(struct _WINDOW_OBJECT* Window);
inline VOID W32kAcquireWinStaLockShared();
inline VOID W32kAcquireWinStaLockExclusive();
inline VOID W32kReleaseWinStaLock();
#endif /* __WIN32K_WINSTA_H */
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: prop.c,v 1.2 2003/05/18 17:16:17 ea Exp $
/* $Id: prop.c,v 1.3 2003/08/02 16:32:18 gdalsnes Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -83,11 +83,11 @@ NtUserRemoveProp(HWND hWnd, ATOM Atom)
PPROPERTY Prop;
HANDLE Data;
WindowObject = W32kGetWindowObject(hWnd);
if (WindowObject == NULL)
{
return(NULL);
}
if (!(WindowObject = W32kGetWindowObject(hWnd)))
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return NULL;
}
Prop = W32kGetProp(WindowObject, Atom);
if (Prop == NULL)
@ -109,47 +109,65 @@ NtUserGetProp(HWND hWnd, ATOM Atom)
PPROPERTY Prop;
HANDLE Data = NULL;
WindowObject = W32kGetWindowObject(hWnd);
if (WindowObject == NULL)
{
return(FALSE);
}
W32kAcquireWinStaLockShared();
if (!(WindowObject = W32kGetWindowObject(hWnd)))
{
W32kReleaseWinStaLock();
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
Prop = W32kGetProp(WindowObject, Atom);
if (Prop != NULL)
{
Data = Prop->Data;
}
W32kReleaseWindowObject(WindowObject);
{
Data = Prop->Data;
}
W32kReleaseWinStaLock();
return(Data);
}
BOOL FASTCALL
W32kSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data)
{
PPROPERTY Prop;
Prop = W32kGetProp(Wnd, Atom);
if (Prop == NULL)
{
Prop = ExAllocatePool(PagedPool, sizeof(PROPERTY));
if (Prop == NULL) return FALSE;
Prop->Atom = Atom;
InsertTailList(&Wnd->PropListHead, &Prop->PropListEntry);
}
Prop->Data = Data;
return TRUE;
}
BOOL STDCALL
NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
{
PWINDOW_OBJECT WindowObject;
PPROPERTY Prop;
PWINDOW_OBJECT Wnd;
BOOL ret;
WindowObject = W32kGetWindowObject(hWnd);
if (WindowObject == NULL)
{
return(FALSE);
}
W32kAcquireWinStaLockExclusive();
Prop = W32kGetProp(WindowObject, Atom);
if (Prop == NULL)
{
Prop = ExAllocatePool(PagedPool, sizeof(PROPERTY));
if (Prop == NULL)
{
W32kReleaseWindowObject(WindowObject);
return(FALSE);
}
Prop->Atom = Atom;
InsertTailList(&WindowObject->PropListHead, &Prop->PropListEntry);
}
Prop->Data = Data;
W32kReleaseWindowObject(WindowObject);
return(TRUE);
if (!(Wnd = W32kGetWindowObject(hWnd)))
{
W32kReleaseWinStaLock();
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
ret = W32kSetProp(Wnd, Atom, Data);
W32kReleaseWinStaLock();
return ret;
}
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: winpos.c,v 1.18 2003/08/01 14:38:51 dwelch Exp $
/* $Id: winpos.c,v 1.19 2003/08/02 16:32:18 gdalsnes Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -117,8 +117,7 @@ WinPosCreateIconTitle(PWINDOW_OBJECT WindowObject)
BOOL STATIC FASTCALL
WinPosShowIconTitle(PWINDOW_OBJECT WindowObject, BOOL Show)
{
PINTERNALPOS InternalPos = NtUserGetProp(WindowObject->Self,
AtomInternalPos);
PINTERNALPOS InternalPos = W32kGetProp(WindowObject, AtomInternalPos);
PWINDOW_OBJECT IconWindow;
NTSTATUS Status;
@ -161,13 +160,12 @@ WinPosShowIconTitle(PWINDOW_OBJECT WindowObject, BOOL Show)
PINTERNALPOS STATIC STDCALL
WinPosInitInternalPos(PWINDOW_OBJECT WindowObject, POINT pt, PRECT RestoreRect)
{
PINTERNALPOS InternalPos = NtUserGetProp(WindowObject->Self,
AtomInternalPos);
PINTERNALPOS InternalPos = W32kGetProp(WindowObject, AtomInternalPos);
if (InternalPos == NULL)
{
InternalPos =
ExAllocatePool(NonPagedPool, sizeof(INTERNALPOS));
NtUserSetProp(WindowObject->Self, AtomInternalPos, InternalPos);
W32kSetProp(WindowObject, AtomInternalPos, InternalPos);
InternalPos->IconTitle = 0;
InternalPos->NormalRect = WindowObject->WindowRect;
InternalPos->IconPos.x = InternalPos->MaxPos.x = 0xFFFFFFFF;
@ -327,7 +325,7 @@ WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
MinMax.ptMaxSize.x += 2 * XInc;
MinMax.ptMaxSize.y += 2 * YInc;
Pos = NtUserGetProp(Window->Self, AtomInternalPos);
Pos = W32kGetProp(Window, AtomInternalPos);
if (Pos != NULL)
{
MinMax.ptMaxPosition = Pos->MaxPos;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: winsta.c,v 1.20 2003/07/27 21:35:50 dwelch Exp $
/* $Id: winsta.c,v 1.21 2003/08/02 16:32:18 gdalsnes Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -68,6 +68,25 @@ static HDC ScreenDeviceContext = NULL;
/* FUNCTIONS *****************************************************************/
inline VOID W32kAcquireWinStaLockShared()
{
ExAcquireResourceExclusiveLite(&(PsGetWin32Process()->WindowStation->Resource),
TRUE /*Wait*/
);
}
inline VOID W32kAcquireWinStaLockExclusive()
{
ExAcquireResourceSharedLite(&(PsGetWin32Process()->WindowStation->Resource),
TRUE /*Wait*/
);
}
inline VOID W32kReleaseWinStaLock()
{
ExReleaseResourceLite( &(PsGetWin32Process()->WindowStation->Resource) );
}
PDESKTOP_OBJECT FASTCALL
W32kGetActiveDesktop(VOID)
{
@ -340,6 +359,7 @@ NtUserCreateWindowStation(PUNICODE_STRING lpszWindowStationName,
return (HWINSTA)0;
}
ExInitializeResourceLite(&WinStaObject->Resource);
WinStaObject->HandleTable = ObmCreateHandleTable();
if (!WinStaObject->HandleTable)
{