Author: gadamopoulos Date: Thu Jan 1 11:43:40 2015 New Revision: 65929
URL: http://svn.reactos.org/svn/reactos?rev=65929&view=rev Log: [WINLOGON] - Implement calling SetWindowStationUser See http://msdn.microsoft.com/en-us/library/windows/desktop/aa380571%28v=vs.85%2... and http://msdn.microsoft.com/en-us/library/windows/desktop/aa446670%28v=vs.85%2...
Modified: trunk/reactos/base/system/winlogon/sas.c
Modified: trunk/reactos/base/system/winlogon/sas.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/sas.c?... ============================================================================== --- trunk/reactos/base/system/winlogon/sas.c [iso-8859-1] (original) +++ trunk/reactos/base/system/winlogon/sas.c [iso-8859-1] Thu Jan 1 11:43:40 2015 @@ -929,6 +929,87 @@ } }
+DWORD WINAPI SetWindowStationUser(HWINSTA hWinSta, LUID* pluid, PSID psid, DWORD sidSize); + +static +BOOL AllowWinstaAccess(PWLSESSION Session) +{ + BOOL bSuccess = FALSE; + DWORD dwIndex; + DWORD dwLength = 0; + PTOKEN_GROUPS ptg = NULL; + PSID psid; + TOKEN_STATISTICS Stats; + DWORD cbStats; + DWORD ret; + + // Get required buffer size and allocate the TOKEN_GROUPS buffer. + + if (!GetTokenInformation(Session->UserToken, + TokenGroups, + ptg, + 0, + &dwLength)) + { + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + return FALSE; + + ptg = (PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLength); + if (ptg == NULL) + return FALSE; + } + + // Get the token group information from the access token. + if (!GetTokenInformation(Session->UserToken, + TokenGroups, + ptg, + dwLength, + &dwLength)) + { + goto Cleanup; + } + + // Loop through the groups to find the logon SID. + + for (dwIndex = 0; dwIndex < ptg->GroupCount; dwIndex++) + { + if ((ptg->Groups[dwIndex].Attributes & SE_GROUP_LOGON_ID) + == SE_GROUP_LOGON_ID) + { + psid = ptg->Groups[dwIndex].Sid; + break; + } + } + + dwLength = GetLengthSid(psid); + + if (!GetTokenInformation(Session->UserToken, + TokenStatistics, + &Stats, + sizeof(TOKEN_STATISTICS), + &cbStats)) + { + WARN("Couldn't get Authentication id from user token!\n"); + goto Cleanup; + } + + ret = SetWindowStationUser(Session->InteractiveWindowStation, + &Stats.AuthenticationId, + psid, + dwLength); + TRACE("SetWindowStationUser returned 0x%x\n", ret); + + bSuccess = TRUE; + +Cleanup: + + // Free the buffer for the token groups. + if (ptg != NULL) + HeapFree(GetProcessHeap(), 0, (LPVOID)ptg); + + return bSuccess; +} + static VOID DispatchSAS( @@ -968,6 +1049,8 @@ &Session->UserToken, &Session->MprNotifyInfo, (PVOID*)&Session->Profile); + + AllowWinstaAccess(Session); break;
case STATE_LOGGED_OFF_SAS: