Changeset 44159 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- Dec 19, 2012 10:12:36 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r40445 r44159 41 41 #include "VBoxServiceUtils.h" 42 42 43 #ifdef DEBUG 44 static uint32_t s_uGuestPropClientID = 0; 45 static uint32_t s_uIter = 0; 46 #endif 43 47 44 48 /******************************************************************************* … … 728 732 int VBoxServiceVMInfoWinWriteUsers(char **ppszUserList, uint32_t *pcUsersInList) 729 733 { 734 AssertPtrReturn(ppszUserList && *ppszUserList, VERR_INVALID_POINTER); 735 AssertPtrReturn(pcUsersInList, VERR_INVALID_POINTER); 736 730 737 PLUID paSessions = NULL; 731 738 ULONG cSessions = 0; 739 740 #ifdef DEBUG 741 if (!s_uGuestPropClientID) 742 { 743 int rc2 = VbglR3GuestPropConnect(&s_uGuestPropClientID); 744 AssertRC(rc2); 745 } 746 #endif 732 747 733 748 /* This function can report stale or orphaned interactive logon sessions … … 796 811 797 812 bool fFoundUser = false; 798 for (ULONG i = 0; i < cUniqueUsers; i++)813 for (ULONG a = 0; a < cUniqueUsers; a++) 799 814 { 800 if ( !wcscmp(UserInfo.wszUser, pUserInfo[i].wszUser) 801 && !wcscmp(UserInfo.wszLogonDomain, pUserInfo[i].wszLogonDomain) 802 && !wcscmp(UserInfo.wszAuthenticationPackage, pUserInfo[i].wszAuthenticationPackage) 803 && cSessionProcs) 815 PVBOXSERVICEVMINFOUSER pCurUser = &pUserInfo[a]; 816 AssertPtr(pCurUser); 817 818 if ( !wcscmp(UserInfo.wszUser, pCurUser->wszUser) 819 && !wcscmp(UserInfo.wszLogonDomain, pCurUser->wszLogonDomain) 820 && !wcscmp(UserInfo.wszAuthenticationPackage, pCurUser->wszAuthenticationPackage)) 804 821 { 805 822 /* 806 823 * Only respect the highest session for the current user. 807 824 */ 808 if (ulSession > p UserInfo[i].ulSession)825 if (ulSession > pCurUser->ulSession) 809 826 { 810 VBoxServiceVerbose(4, "Updating user=%ls to %u processes (last session: %u)\n", 811 UserInfo.wszUser, cSessionProcs, ulSession); 812 813 pUserInfo[i].ulNumProcs = cSessionProcs; 814 pUserInfo[i].ulSession = ulSession; 827 VBoxServiceVerbose(4, "Updating user=%ls to %u processes (last session=%RU32)\n", 828 pCurUser->wszUser, cSessionProcs, ulSession); 815 829 816 830 if (!cSessionProcs) 817 VBoxServiceVerbose(3, "Stale session for user=%ls detected! Old processes: %u, new: %u\n", 818 pUserInfo[i].wszUser, pUserInfo[i].ulNumProcs, cSessionProcs); 831 VBoxServiceVerbose(3, "Stale session for user=%ls detected! Procs %RU32->%RU32, Session RU%32->RU32\n", 832 pCurUser->wszUser, 833 pCurUser->ulNumProcs, cSessionProcs, 834 pCurUser->ulSession, ulSession); 835 836 pCurUser->ulNumProcs = cSessionProcs; 837 pCurUser->ulSession = ulSession; 819 838 } 820 839 /* There can be multiple session objects using the same session ID for the 821 840 * current user -- so when we got the same session again just add the found 822 841 * processes to it. */ 823 else if (pUserInfo[i].ulSession == ulSession) 842 else if ( pCurUser->ulSession == ulSession 843 && cSessionProcs) 824 844 { 825 VBoxServiceVerbose(4, "Adding %u processes to user=%ls (session %u)\n", 826 cSessionProcs, UserInfo.wszUser, ulSession); 827 828 pUserInfo[i].ulNumProcs += cSessionProcs; 829 pUserInfo[i].ulSession = ulSession; 845 VBoxServiceVerbose(4, "Adding %u processes to user=%ls (session=%RU32)\n", 846 cSessionProcs, pCurUser->wszUser, ulSession); 847 848 pCurUser->ulNumProcs += cSessionProcs; 830 849 } 831 850 … … 837 856 if (!fFoundUser) 838 857 { 839 VBoxServiceVerbose(4, "Adding new user=%ls (session %u) with %u processes\n",858 VBoxServiceVerbose(4, "Adding new user=%ls (session=%RU32) with %u processes\n", 840 859 UserInfo.wszUser, ulSession, cSessionProcs); 841 860 … … 849 868 } 850 869 870 #ifdef DEBUG 871 VBoxServiceWritePropF(s_uGuestPropClientID, "/VirtualBox/GuestInfo/Debug/LSA", 872 "%RU32: cSessions=%RU32, cProcs=%RU32, cUniqueUsers=%RU32", 873 s_uIter, cSessions, cProcs, cUniqueUsers); 874 #endif 851 875 VBoxServiceVerbose(3, "Found %u unique logged-in user(s)\n", 852 876 cUniqueUsers); … … 855 879 for (ULONG i = 0; i < cUniqueUsers; i++) 856 880 { 881 #ifdef DEBUG 882 char szDebugUserPath[255]; RTStrPrintf(szDebugUserPath, sizeof(szDebugUserPath), "/VirtualBox/GuestInfo/Debug/LSA/User/%RU32", i); 883 VBoxServiceWritePropF(s_uGuestPropClientID, szDebugUserPath, 884 "%RU32: szName=%ls, sessionID=%RU32, cProcs=%RU32", 885 s_uIter, pUserInfo[i].wszUser, pUserInfo[i].ulSession, pUserInfo[i].ulNumProcs); 886 #endif 857 887 if (pUserInfo[i].ulNumProcs) 858 888 { … … 886 916 } 887 917 LsaFreeReturnBuffer(paSessions); 918 #ifdef DEBUG 919 s_uIter++; 920 VbglR3GuestPropDisconnect(s_uGuestPropClientID); 921 #endif 888 922 return rc; 889 923 }
Note:
See TracChangeset
for help on using the changeset viewer.