mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 17:51:40 +00:00
[NtUser]
- Add object handle information and set station user support. svn path=/trunk/; revision=66164
This commit is contained in:
parent
2ff70a1a12
commit
9491749bfd
7 changed files with 162 additions and 17 deletions
|
@ -25,7 +25,7 @@ IntGetWinStaForCbAccess(VOID)
|
|||
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");
|
||||
|
|
|
@ -1516,7 +1516,8 @@ NtUserSetWindowsHookEx( HINSTANCE Mod,
|
|||
Status = IntValidateWindowStationHandle( PsGetCurrentProcess()->Win32WindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&WinStaObj);
|
||||
&WinStaObj,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -1407,7 +1407,8 @@ HMENU FASTCALL UserCreateMenu(PDESKTOP Desktop, BOOL PopupMenu)
|
|||
Status = IntValidateWindowStationHandle(CurrentProcess->Win32WindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&WinStaObject);
|
||||
&WinStaObject,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -113,7 +113,6 @@ UserInitialize(VOID)
|
|||
HBITMAP hPattern55AABitmap = NULL;
|
||||
NTSTATUS Status;
|
||||
|
||||
// Set W32PF_Flags |= (W32PF_READSCREENACCESSGRANTED | W32PF_IOWINSTA)
|
||||
// Create Event for Diconnect Desktop.
|
||||
|
||||
Status = UserCreateWinstaDirectory();
|
||||
|
|
|
@ -3399,7 +3399,8 @@ HWND FASTCALL UserGetShellWindow(VOID)
|
|||
NTSTATUS Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&WinStaObject);
|
||||
&WinStaObject,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -3448,7 +3449,8 @@ NtUserSetShellWindowEx(HWND hwndShell, HWND hwndListView)
|
|||
Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&WinStaObject);
|
||||
&WinStaObject,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -105,6 +105,8 @@ IntWinStaObjectDelete(
|
|||
|
||||
TRACE("Deleting window station (0x%p)\n", WinSta);
|
||||
|
||||
WinSta->Flags |= WSS_DYING;
|
||||
|
||||
UserEmptyClipboardData(WinSta);
|
||||
|
||||
RtlDestroyAtomTable(WinSta->AtomTable);
|
||||
|
@ -214,7 +216,8 @@ IntValidateWindowStationHandle(
|
|||
HWINSTA WindowStation,
|
||||
KPROCESSOR_MODE AccessMode,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
PWINSTATION_OBJECT *Object)
|
||||
PWINSTATION_OBJECT *Object,
|
||||
POBJECT_HANDLE_INFORMATION pObjectHandleInfo)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
|
@ -231,7 +234,7 @@ IntValidateWindowStationHandle(
|
|||
ExWindowStationObjectType,
|
||||
AccessMode,
|
||||
(PVOID*)Object,
|
||||
NULL);
|
||||
pObjectHandleInfo);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
SetLastNtError(Status);
|
||||
|
@ -291,6 +294,9 @@ co_IntInitializeDesktopGraphics(VOID)
|
|||
/* Setup the cursor */
|
||||
co_IntLoadDefaultCursors();
|
||||
|
||||
/* Setup the icons */
|
||||
//co_IntSetWndIcons();
|
||||
|
||||
/* Show the desktop */
|
||||
pdesk = IntGetActiveDesktop();
|
||||
ASSERT(pdesk);
|
||||
|
@ -318,6 +324,29 @@ IntGetScreenDC(VOID)
|
|||
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,11 +487,17 @@ NtUserCreateWindowStation(
|
|||
|
||||
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",
|
||||
WindowStation, &WindowStationObject->Name, WindowStation);
|
||||
|
@ -563,7 +598,8 @@ NtUserCloseWindowStation(
|
|||
hWinSta,
|
||||
KernelMode,
|
||||
0,
|
||||
&Object);
|
||||
&Object,
|
||||
0);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -852,6 +888,7 @@ UserSetProcessWindowStation(HWINSTA hWindowStation)
|
|||
PPROCESSINFO ppi;
|
||||
NTSTATUS Status;
|
||||
HWINSTA hwinstaOld;
|
||||
OBJECT_HANDLE_INFORMATION ObjectHandleInfo;
|
||||
PWINSTATION_OBJECT NewWinSta = NULL, OldWinSta;
|
||||
|
||||
ppi = PsGetCurrentProcessWin32Process();
|
||||
|
@ -862,7 +899,8 @@ UserSetProcessWindowStation(HWINSTA hWindowStation)
|
|||
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 @@ UserSetProcessWindowStation(HWINSTA hWindowStation)
|
|||
|
||||
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 @@ NtUserLockWindowStation(HWINSTA hWindowStation)
|
|||
hWindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&Object);
|
||||
&Object,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
TRACE("Validation of window station handle (%p) failed\n",
|
||||
|
@ -1003,7 +1061,8 @@ NtUserUnlockWindowStation(HWINSTA hWindowStation)
|
|||
hWindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&Object);
|
||||
&Object,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
TRACE("Validation of window station handle (%p) failed\n",
|
||||
|
@ -1212,7 +1271,8 @@ BuildDesktopNameList(
|
|||
Status = IntValidateWindowStationHandle(hWindowStation,
|
||||
KernelMode,
|
||||
0,
|
||||
&WindowStation);
|
||||
&WindowStation,
|
||||
0);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
|
@ -1376,4 +1436,75 @@ NtUserLockWorkStation(VOID)
|
|||
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 */
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -32,6 +36,11 @@ typedef struct _WINSTATION_OBJECT
|
|||
INT fClipboardChanged : 1;
|
||||
INT fInDelayedRendering : 1;
|
||||
|
||||
PWND spwndClipboardListener;
|
||||
LUID luidEndSession;
|
||||
LUID luidUser;
|
||||
PVOID psidUser;
|
||||
|
||||
} WINSTATION_OBJECT, *PWINSTATION_OBJECT;
|
||||
|
||||
extern WINSTATION_OBJECT *InputWindowStation;
|
||||
|
@ -95,10 +104,12 @@ IntValidateWindowStationHandle(
|
|||
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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue