Changeset 81147 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Oct 8, 2019 11:54:10 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/process-win.cpp
r80569 r81147 442 442 443 443 /** 444 * Get the token assigned to specifiedthread indicated by @a hThread.444 * Get the token assigned to the thread indicated by @a hThread. 445 445 * 446 446 * Only used when RTPROC_FLAGS_AS_IMPERSONATED_TOKEN is in effect and the … … 466 466 rc = rtProcWinDuplicateToken(hTokenThread, phToken); 467 467 CloseHandle(hTokenThread); 468 } 469 else 470 rc = RTErrConvertFromWin32(GetLastError()); 471 return rc; 472 } 473 474 475 /** 476 * Get the token assigned the process indicated by @a hProcess. 477 * 478 * Only used when pwszUser is NULL and RTPROC_FLAGS_AS_IMPERSONATED_TOKEN isn't 479 * set. 480 * 481 * @returns IPRT status code. 482 * @param hProcess The process handle (current process). 483 * @param phToken Where to return the a duplicate of the thread token 484 * handle on success. (The caller closes it.) 485 */ 486 static int rtProcWinGetProcessTokenHandle(HANDLE hProcess, PHANDLE phToken) 487 { 488 AssertPtr(phToken); 489 490 int rc; 491 HANDLE hTokenProcess; 492 if (OpenProcessToken(hProcess, 493 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY | TOKEN_DUPLICATE 494 | TOKEN_ASSIGN_PRIMARY | TOKEN_ADJUST_SESSIONID | TOKEN_READ | TOKEN_WRITE, 495 &hTokenProcess)) 496 { 497 rc = rtProcWinDuplicateToken(hTokenProcess, phToken); /* not sure if this is strictly necessary */ 498 CloseHandle(hTokenProcess); 468 499 } 469 500 else … … 1612 1643 HANDLE hTokenLogon = INVALID_HANDLE_VALUE; 1613 1644 int rc; 1614 if ( (fFlags & RTPROC_FLAGS_AS_IMPERSONATED_TOKEN) || pwszUser == NULL)1645 if (fFlags & RTPROC_FLAGS_AS_IMPERSONATED_TOKEN) 1615 1646 rc = rtProcWinGetThreadTokenHandle(GetCurrentThread(), &hTokenLogon); 1647 else if (pwszUser == NULL) 1648 rc = rtProcWinGetProcessTokenHandle(GetCurrentProcess(), &hTokenLogon); 1616 1649 else 1617 1650 rc = rtProcWinUserLogon(pwszUser, pwszPassword, &hTokenLogon);
Note:
See TracChangeset
for help on using the changeset viewer.