Author: jimtabor
Date: Wed Feb 4 21:59:15 2015
New Revision: 66164
URL:
http://svn.reactos.org/svn/reactos?rev=66164&view=rev
Log:
[NtUser]
- Add object handle information and set station user support.
Modified:
trunk/reactos/win32ss/user/ntuser/clipboard.c
trunk/reactos/win32ss/user/ntuser/hook.c
trunk/reactos/win32ss/user/ntuser/menu.c
trunk/reactos/win32ss/user/ntuser/ntuser.c
trunk/reactos/win32ss/user/ntuser/window.c
trunk/reactos/win32ss/user/ntuser/winsta.c
trunk/reactos/win32ss/user/ntuser/winsta.h
Modified: trunk/reactos/win32ss/user/ntuser/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/clipbo…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -25,7 +25,7 @@
NTSTATUS Status;
hWinSta = UserGetProcessWindowStation();
- Status = IntValidateWindowStationHandle(hWinSta, KernelMode, WINSTA_ACCESSCLIPBOARD,
&pWinStaObj);
+ Status = IntValidateWindowStationHandle(hWinSta, KernelMode, WINSTA_ACCESSCLIPBOARD,
&pWinStaObj, 0);
if (!NT_SUCCESS(Status))
{
ERR("Cannot open winsta\n");
Modified: trunk/reactos/win32ss/user/ntuser/hook.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/hook.c…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -1516,7 +1516,8 @@
Status = IntValidateWindowStationHandle(
PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
- &WinStaObj);
+ &WinStaObj,
+ 0);
if (!NT_SUCCESS(Status))
{
Modified: trunk/reactos/win32ss/user/ntuser/menu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/menu.c…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/menu.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/menu.c [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -1407,7 +1407,8 @@
Status = IntValidateWindowStationHandle(CurrentProcess->Win32WindowStation,
KernelMode,
0,
- &WinStaObject);
+ &WinStaObject,
+ 0);
if (!NT_SUCCESS(Status))
{
Modified: trunk/reactos/win32ss/user/ntuser/ntuser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/ntuser…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/ntuser.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/ntuser.c [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -113,7 +113,6 @@
HBITMAP hPattern55AABitmap = NULL;
NTSTATUS Status;
-// Set W32PF_Flags |= (W32PF_READSCREENACCESSGRANTED | W32PF_IOWINSTA)
// Create Event for Diconnect Desktop.
Status = UserCreateWinstaDirectory();
Modified: trunk/reactos/win32ss/user/ntuser/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -3399,7 +3399,8 @@
NTSTATUS Status =
IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
- &WinStaObject);
+ &WinStaObject,
+ 0);
if (!NT_SUCCESS(Status))
{
@@ -3448,7 +3449,8 @@
Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
KernelMode,
0,
- &WinStaObject);
+ &WinStaObject,
+ 0);
if (!NT_SUCCESS(Status))
{
Modified: trunk/reactos/win32ss/user/ntuser/winsta.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winsta…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/winsta.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/winsta.c [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -104,6 +104,8 @@
PWINSTATION_OBJECT WinSta = (PWINSTATION_OBJECT)DeleteParameters->Object;
TRACE("Deleting window station (0x%p)\n", WinSta);
+
+ WinSta->Flags |= WSS_DYING;
UserEmptyClipboardData(WinSta);
@@ -214,7 +216,8 @@
HWINSTA WindowStation,
KPROCESSOR_MODE AccessMode,
ACCESS_MASK DesiredAccess,
- PWINSTATION_OBJECT *Object)
+ PWINSTATION_OBJECT *Object,
+ POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
{
NTSTATUS Status;
@@ -231,7 +234,7 @@
ExWindowStationObjectType,
AccessMode,
(PVOID*)Object,
- NULL);
+ pObjectHandleInfo);
if (!NT_SUCCESS(Status))
SetLastNtError(Status);
@@ -291,6 +294,9 @@
/* Setup the cursor */
co_IntLoadDefaultCursors();
+ /* Setup the icons */
+ //co_IntSetWndIcons();
+
/* Show the desktop */
pdesk = IntGetActiveDesktop();
ASSERT(pdesk);
@@ -317,6 +323,29 @@
{
return ScreenDeviceContext;
}
+
+BOOL FASTCALL
+CheckWinstaAttributeAccess(ACCESS_MASK DesiredAccess)
+{
+ PPROCESSINFO ppi = PsGetCurrentProcessWin32Process();
+ if ( gpidLogon != PsGetCurrentProcessId() )
+ {
+ if (!(ppi->W32PF_flags & W32PF_IOWINSTA))
+ {
+ ERR("Requires Interactive Window Station\n");
+ EngSetLastError(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION);
+ return FALSE;
+ }
+ if (!RtlAreAllAccessesGranted(ppi->amwinsta, DesiredAccess))
+ {
+ ERR("Access Denied\n");
+ EngSetLastError(ERROR_ACCESS_DENIED);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -458,10 +487,16 @@
if (InputWindowStation == NULL)
{
- TRACE("Initializeing input window station\n");
+ ERR("Initializeing input window station\n");
InputWindowStation = WindowStationObject;
+ WindowStationObject->Flags &= ~WSS_NOIO;
+
InitCursorImpl();
+ }
+ else
+ {
+ WindowStationObject->Flags |= WSS_NOIO;
}
TRACE("NtUserCreateWindowStation created object %p with name %wZ handle
%p\n",
@@ -563,7 +598,8 @@
hWinSta,
KernelMode,
0,
- &Object);
+ &Object,
+ 0);
if (!NT_SUCCESS(Status))
{
@@ -852,6 +888,7 @@
PPROCESSINFO ppi;
NTSTATUS Status;
HWINSTA hwinstaOld;
+ OBJECT_HANDLE_INFORMATION ObjectHandleInfo;
PWINSTATION_OBJECT NewWinSta = NULL, OldWinSta;
ppi = PsGetCurrentProcessWin32Process();
@@ -862,7 +899,8 @@
Status = IntValidateWindowStationHandle( hWindowStation,
KernelMode,
0,
- &NewWinSta);
+ &NewWinSta,
+ &ObjectHandleInfo);
if (!NT_SUCCESS(Status))
{
TRACE("Validation of window station handle (%p) failed\n",
@@ -895,7 +933,26 @@
ppi->prpwinsta = NewWinSta;
ppi->hwinsta = hWindowStation;
-
+ ppi->amwinsta = ObjectHandleInfo.GrantedAccess;
+ ERR("WS : Granted Access %p\n",ppi->amwinsta);
+
+ if (RtlAreAllAccessesGranted(ppi->amwinsta, WINSTA_READSCREEN))
+ {
+ ppi->W32PF_flags |= W32PF_READSCREENACCESSGRANTED;
+ }
+ else
+ {
+ ppi->W32PF_flags &= ~W32PF_READSCREENACCESSGRANTED;
+ }
+
+ if (NewWinSta && !(NewWinSta->Flags & WSS_NOIO) )
+ {
+ ppi->W32PF_flags |= W32PF_IOWINSTA;
+ }
+ else // Might be closed if the handle is null.
+ {
+ ppi->W32PF_flags &= ~W32PF_IOWINSTA;
+ }
return TRUE;
}
@@ -958,7 +1015,8 @@
hWindowStation,
KernelMode,
0,
- &Object);
+ &Object,
+ 0);
if (!NT_SUCCESS(Status))
{
TRACE("Validation of window station handle (%p) failed\n",
@@ -1003,7 +1061,8 @@
hWindowStation,
KernelMode,
0,
- &Object);
+ &Object,
+ 0);
if (!NT_SUCCESS(Status))
{
TRACE("Validation of window station handle (%p) failed\n",
@@ -1212,7 +1271,8 @@
Status = IntValidateWindowStationHandle(hWindowStation,
KernelMode,
0,
- &WindowStation);
+ &WindowStation,
+ 0);
if (! NT_SUCCESS(Status))
{
return Status;
@@ -1376,4 +1436,75 @@
return ret;
}
+BOOL APIENTRY
+NEW_NtUserSetWindowStationUser(
+ HWINSTA hWindowStation,
+ PLUID pluid,
+ PSID psid,
+ DWORD size)
+{
+ NTSTATUS Status;
+ PWINSTATION_OBJECT WindowStation = NULL;
+ BOOL Ret = FALSE;
+
+ UserEnterExclusive();
+
+ if (gpidLogon != PsGetCurrentProcessId())
+ {
+ EngSetLastError(ERROR_ACCESS_DENIED);
+ goto Leave;
+ }
+
+ Status = IntValidateWindowStationHandle(hWindowStation,
+ KernelMode,
+ 0,
+ &WindowStation,
+ 0);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Leave;
+ }
+
+ if (WindowStation->psidUser)
+ {
+ ExFreePoolWithTag(WindowStation->psidUser, USERTAG_SECURITY);
+ }
+
+ WindowStation->psidUser = ExAllocatePoolWithTag(PagedPool, size,
USERTAG_SECURITY);
+ if (WindowStation->psidUser == NULL)
+ {
+ EngSetLastError(ERROR_OUTOFMEMORY);
+ goto Leave;
+ }
+
+ _SEH2_TRY
+ {
+ ProbeForRead( psid, size, 1);
+ ProbeForRead( pluid, sizeof(LUID), 1);
+
+ RtlCopyMemory(WindowStation->psidUser, psid, size);
+ WindowStation->luidUser = *pluid;
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = _SEH2_GetExceptionCode();
+ }
+ _SEH2_END;
+
+ if (!NT_SUCCESS(Status))
+ {
+ ExFreePoolWithTag(WindowStation->psidUser, 0);
+ WindowStation->psidUser = 0;
+ goto Leave;
+ }
+
+ Ret = TRUE;
+
+Leave:
+ if (WindowStation) ObDereferenceObject(WindowStation);
+ UserLeave();
+ return Ret;
+}
+
+
/* EOF */
Modified: trunk/reactos/win32ss/user/ntuser/winsta.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/winsta…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/winsta.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/winsta.h [iso-8859-1] Wed Feb 4 21:59:15 2015
@@ -4,8 +4,12 @@
#define SESSION_DIR L"\\Sessions"
/* Window Station Status Flags */
-#define WSS_LOCKED (1)
-#define WSS_NOINTERACTIVE (2)
+#define WSS_LOCKED (1)
+#define WSS_NOINTERACTIVE (2)
+#define WSS_NOIO (4)
+#define WSS_SHUTDOWN (8)
+#define WSS_DYING (16)
+#define WSS_REALSHUTDOWN (32)
typedef struct _WINSTATION_OBJECT
{
@@ -31,6 +35,11 @@
INT iClipSequenceNumber;
INT fClipboardChanged : 1;
INT fInDelayedRendering : 1;
+
+ PWND spwndClipboardListener;
+ LUID luidEndSession;
+ LUID luidUser;
+ PVOID psidUser;
} WINSTATION_OBJECT, *PWINSTATION_OBJECT;
@@ -95,10 +104,12 @@
HWINSTA WindowStation,
KPROCESSOR_MODE AccessMode,
ACCESS_MASK DesiredAccess,
- PWINSTATION_OBJECT *Object);
+ PWINSTATION_OBJECT *Object,
+ POBJECT_HANDLE_INFORMATION pObjectHandleInfo);
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation);
BOOL FASTCALL co_IntInitializeDesktopGraphics(VOID);
VOID FASTCALL IntEndDesktopGraphics(VOID);
+BOOL FASTCALL CheckWinstaAttributeAccess(ACCESS_MASK);
/* EOF */