Changeset 44164 in vbox
- Timestamp:
- Dec 19, 2012 1:06:25 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r44159 r44164 96 96 97 97 #ifndef TARGET_NT4 98 99 static bool vboxServiceVMInfoSession0Separation(void) 100 { 101 /** @todo Only do this once. Later. */ 102 OSVERSIONINFOEX OSInfoEx; 103 RT_ZERO(OSInfoEx); 104 OSInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 105 if ( !GetVersionEx((LPOSVERSIONINFO) &OSInfoEx) 106 || OSInfoEx.dwPlatformId != VER_PLATFORM_WIN32_NT) 107 { 108 /* Platform other than NT (e.g. Win9x) not supported. */ 109 return false; 110 } 111 112 if ( OSInfoEx.dwMajorVersion >= 6 113 && OSInfoEx.dwMinorVersion >= 0) 114 { 115 return true; 116 } 117 118 return false; 119 } 98 120 99 121 /** … … 459 481 uint32_t VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, 460 482 PVBOXSERVICEVMINFOPROC const paProcs, DWORD cProcs, 461 PULONG pu Session)483 PULONG puTerminalSession) 462 484 { 463 485 if (!pSession) … … 507 529 508 530 if (g_cVerbosity) 509 VBoxServiceVerbose(3, "Session %u has %u processes total\n", 510 pSessionData->Session, cNumProcs); 531 VBoxServiceVerbose(3, "Session has %u processes total\n", cNumProcs); 511 532 else 512 VBoxServiceVerbose(3, "Session %u has at least one process\n", 513 pSessionData->Session); 514 515 if (puSession) 516 *puSession = pSessionData->Session; 533 VBoxServiceVerbose(3, "Session has at least one process\n"); 534 535 if (puTerminalSession) 536 *puTerminalSession = pSessionData->Session; 517 537 518 538 LsaFreeReturnBuffer(pSessionData); … … 596 616 pSessionData->LogonId.HighPart, pSessionData->LogonId.LowPart, 597 617 pSessionData->LogonType); 618 619 if (vboxServiceVMInfoSession0Separation()) 620 { 621 /* Starting at Windows Vista user sessions begin with session 1, so 622 * ignore (stale) session 0 users. */ 623 if ( pSessionData->Session == 0 624 /* Also check the logon time. */ 625 || pSessionData->LogonTime.QuadPart == 0) 626 { 627 LsaFreeReturnBuffer(pSessionData); 628 return false; 629 } 630 } 598 631 599 632 /* … … 732 765 int VBoxServiceVMInfoWinWriteUsers(char **ppszUserList, uint32_t *pcUsersInList) 733 766 { 734 AssertPtrReturn(ppszUserList && *ppszUserList, VERR_INVALID_POINTER);767 AssertPtrReturn(ppszUserList, VERR_INVALID_POINTER); 735 768 AssertPtrReturn(pcUsersInList, VERR_INVALID_POINTER); 736 769 … … 739 772 740 773 #ifdef DEBUG 741 if (!s_uGuestPropClientID) 742 { 743 int rc2 = VbglR3GuestPropConnect(&s_uGuestPropClientID); 744 AssertRC(rc2); 745 } 774 int rc2 = VbglR3GuestPropConnect(&s_uGuestPropClientID); 775 AssertRC(rc2); 746 776 #endif 747 777 … … 804 834 805 835 /* Retrieve assigned processes of current session. */ 806 ULONG ulSession;807 uint32_t cSessionProcs = VBoxServiceVMInfoWinSessionHasProcesses(&paSessions[i], paProcs, cProcs, &ulSession);836 uint32_t cSessionProcs = VBoxServiceVMInfoWinSessionHasProcesses(&paSessions[i], paProcs, cProcs, 837 NULL /* Terminal session ID */); 808 838 /* Don't return here when current session does not have assigned processes 809 839 * anymore -- in that case we have to search through the unique users list below 810 840 * and see if got a stale user/session entry. */ 811 841 842 #ifdef DEBUG 843 char szDebugUserPath[255]; RTStrPrintf(szDebugUserPath, sizeof(szDebugUserPath), "/VirtualBox/GuestInfo/Debug/LSA/Session/%RU32", i); 844 VBoxServiceWritePropF(s_uGuestPropClientID, szDebugUserPath, 845 "%RU32: cSessionProcs=%RU32 (%RU32 total)", s_uIter, cSessionProcs, cProcs); 846 #endif 812 847 bool fFoundUser = false; 813 848 for (ULONG a = 0; a < cUniqueUsers; a++) … … 823 858 * Only respect the highest session for the current user. 824 859 */ 825 if ( ulSession> pCurUser->ulSession)860 if (i > pCurUser->ulSession) 826 861 { 827 862 VBoxServiceVerbose(4, "Updating user=%ls to %u processes (last session=%RU32)\n", 828 pCurUser->wszUser, cSessionProcs, ulSession);863 pCurUser->wszUser, cSessionProcs, i); 829 864 830 865 if (!cSessionProcs) … … 832 867 pCurUser->wszUser, 833 868 pCurUser->ulNumProcs, cSessionProcs, 834 pCurUser->ulSession, ulSession);869 pCurUser->ulSession, i); 835 870 836 871 pCurUser->ulNumProcs = cSessionProcs; 837 pCurUser->ulSession = ulSession;872 pCurUser->ulSession = i; 838 873 } 839 874 /* There can be multiple session objects using the same session ID for the 840 875 * current user -- so when we got the same session again just add the found 841 876 * processes to it. */ 842 else if ( pCurUser->ulSession == ulSession877 else if ( pCurUser->ulSession == i 843 878 && cSessionProcs) 844 879 { 845 880 VBoxServiceVerbose(4, "Adding %u processes to user=%ls (session=%RU32)\n", 846 cSessionProcs, pCurUser->wszUser, ulSession);881 cSessionProcs, pCurUser->wszUser, i); 847 882 848 883 pCurUser->ulNumProcs += cSessionProcs; … … 857 892 { 858 893 VBoxServiceVerbose(4, "Adding new user=%ls (session=%RU32) with %u processes\n", 859 UserInfo.wszUser, ulSession, cSessionProcs);894 UserInfo.wszUser, i, cSessionProcs); 860 895 861 896 memcpy(&pUserInfo[cUniqueUsers], &UserInfo, sizeof(VBOXSERVICEVMINFOUSER)); 862 897 pUserInfo[cUniqueUsers].ulNumProcs = cSessionProcs; 863 pUserInfo[cUniqueUsers].ulSession = ulSession;898 pUserInfo[cUniqueUsers].ulSession = i; 864 899 cUniqueUsers++; 865 900 Assert(cUniqueUsers <= cSessions); … … 885 920 s_uIter, pUserInfo[i].wszUser, pUserInfo[i].ulSession, pUserInfo[i].ulNumProcs); 886 921 #endif 887 if (pUserInfo[i].ulNumProcs) 922 bool fAddUser = true; 923 if ( pUserInfo[i].ulNumProcs 924 /* If we have session 0 separation, add the user regardless of the 925 * attached processes. */ 926 || vboxServiceVMInfoSession0Separation()) 927 fAddUser = true; 928 929 if (fAddUser) 888 930 { 889 931 VBoxServiceVerbose(3, "User %ls has %ld processes (session %u)\n",
Note:
See TracChangeset
for help on using the changeset viewer.