Changeset 59519 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- Jan 29, 2016 10:32:47 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r59133 r59519 609 609 static int rtProcWinUserLogon(PRTUTF16 pwszUser, PRTUTF16 pwszPassword, HANDLE *phToken) 610 610 { 611 AssertPtrReturn(pwszUser, VERR_INVALID_POINTER);611 AssertPtrReturn(pwszUser, VERR_INVALID_POINTER); 612 612 AssertPtrReturn(pwszPassword, VERR_INVALID_POINTER); 613 AssertPtrReturn(phToken, VERR_INVALID_POINTER); 613 614 614 615 /* … … 1330 1331 if (pSid) 1331 1332 { 1332 cwcDomain = fRc ? cwcDomain + 2 : _ 512K;1333 cwcDomain = fRc ? cwcDomain + 2 : _4K; 1333 1334 PRTUTF16 pwszDomain = (PRTUTF16)RTMemAllocZ(cwcDomain * sizeof(RTUTF16)); 1334 1335 if (pwszDomain) 1335 1336 { 1336 /* Note: Also supports FQDNs! */ 1337 if ( LookupAccountNameW(NULL /*lpSystemName*/, pwszUser, pSid, &cbSid, pwszDomain, &cwcDomain, &SidNameUse) 1338 && IsValidSid(pSid)) 1337 /* Note: Just pass in the UPN (User Principal Name), e.g. [email protected] */ 1338 if (LookupAccountNameW(NULL /*lpSystemName*/, pwszUser, pSid, &cbSid, pwszDomain, &cwcDomain, &SidNameUse)) 1339 1339 { 1340 /* Array of process names we want to look for. */ 1341 static const char * const s_papszProcNames[] = 1340 if (IsValidSid(pSid)) 1342 1341 { 1343 #ifdef VBOX /* The explorer entry is a fallback in case GA aren't installed. */ 1344 { "VBoxTray.exe" }, 1342 /* Array of process names we want to look for. */ 1343 static const char * const s_papszProcNames[] = 1344 { 1345 #ifdef VBOX /* The explorer entry is a fallback in case GA aren't installed. */ 1346 { "VBoxTray.exe" }, 1345 1347 #endif 1346 { "explorer.exe" }, 1347 NULL 1348 }; 1349 fFound = rtProcWinFindTokenByProcess(s_papszProcNames, pSid, &hTokenUserDesktop); 1348 { "explorer.exe" }, 1349 NULL 1350 }; 1351 fFound = rtProcWinFindTokenByProcess(s_papszProcNames, pSid, &hTokenUserDesktop); 1352 } 1353 else 1354 { 1355 dwErr = GetLastError(); 1356 rc = dwErr != NO_ERROR ? RTErrConvertFromWin32(dwErr) : VERR_INTERNAL_ERROR_4; 1357 } 1350 1358 } 1351 1359 else … … 1356 1364 RTMemFree(pwszDomain); 1357 1365 } 1366 else 1367 rc = VERR_NO_MEMORY; 1368 1358 1369 RTMemFree(pSid); 1359 1370 } 1371 else 1372 rc = VERR_NO_MEMORY; 1360 1373 } 1361 1374 /* else: !RTPROC_FLAGS_SERVICE: Nothing to do here right now. */ … … 1486 1499 if (hTokenUserDesktop != INVALID_HANDLE_VALUE) 1487 1500 CloseHandle(hTokenUserDesktop); 1488 CloseHandle(hTokenLogon); 1501 if (hTokenLogon != INVALID_HANDLE_VALUE) 1502 CloseHandle(hTokenLogon); 1489 1503 1490 1504 if (rc == VERR_UNRESOLVED_ERROR) … … 1618 1632 else 1619 1633 { 1620 RTENV hEnvToUse = NIL_RTENV;1621 HANDLE hToken ;1622 rc = rtProcWinUserLogon(pwszUser, pwszPassword, &hToken );1634 RTENV hEnvToUse = NIL_RTENV; 1635 HANDLE hTokenLogon = INVALID_HANDLE_VALUE; 1636 rc = rtProcWinUserLogon(pwszUser, pwszPassword, &hTokenLogon); 1623 1637 if (RT_SUCCESS(rc)) 1624 1638 { … … 1632 1646 ProfileInfo.dwFlags = PI_NOUI; /* Prevents the display of profile error messages. */ 1633 1647 1634 if (g_pfnLoadUserProfileW(hToken , &ProfileInfo))1648 if (g_pfnLoadUserProfileW(hTokenLogon, &ProfileInfo)) 1635 1649 { 1636 1650 /* 1637 1651 * Do what we need to do. Don't keep any temp environment object. 1638 1652 */ 1639 rc = rtProcWinCreateEnvFromToken(hToken , hEnv, fFlags, &hEnvToUse);1653 rc = rtProcWinCreateEnvFromToken(hTokenLogon, hEnv, fFlags, &hEnvToUse); 1640 1654 if (RT_SUCCESS(rc)) 1641 1655 { … … 1647 1661 } 1648 1662 1649 if (!g_pfnUnloadUserProfile(hToken , ProfileInfo.hProfile))1663 if (!g_pfnUnloadUserProfile(hTokenLogon, ProfileInfo.hProfile)) 1650 1664 AssertFailed(); 1651 1665 } 1652 1666 else 1653 1667 rc = RTErrConvertFromWin32(GetLastError()); 1654 CloseHandle(hToken); 1668 1669 if (hTokenLogon != INVALID_HANDLE_VALUE) 1670 CloseHandle(hTokenLogon); 1655 1671 } 1656 1672 }
Note:
See TracChangeset
for help on using the changeset viewer.