Changeset 39106 in vbox
- Timestamp:
- Oct 25, 2011 9:45:40 AM (13 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
-
VBoxServiceVMInfo-win.cpp (modified) (7 diffs)
-
VBoxServiceVMInfo.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r38946 r39106 72 72 * Prototypes 73 73 *******************************************************************************/ 74 boolVBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs);74 uint32_t VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs); 75 75 bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession); 76 76 int VBoxServiceVMInfoWinProcessesEnumerate(PVBOXSERVICEVMINFOPROC *ppProc, DWORD *pdwCount); … … 251 251 * Determines whether the specified session has processes on the system. 252 252 * 253 * @returns true if it has, false if it doesn't.253 * @returns Number of processes found for a specified session. 254 254 * @param pSession The session. 255 255 * @param paProcs The process snapshot. 256 256 * @param cProcs The number of processes in the snaphot. 257 257 */ 258 boolVBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs)258 uint32_t VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs) 259 259 { 260 260 if (!pSession) 261 261 { 262 262 VBoxServiceVerbose(1, "VMInfo/Users: Session became invalid while enumerating!\n"); 263 return false;263 return 0; 264 264 } 265 265 … … 269 269 { 270 270 VBoxServiceError("VMInfo/Users: Could not get logon session data! rcNt=%#x", rcNt); 271 return false;271 return 0; 272 272 } 273 273 … … 292 292 } 293 293 294 VBoxServiceVerbose(3, "VMInfo/Users: Session %u has %u processes\n", 295 pSessionData->Session, cNumProcs); 294 if (g_cVerbosity >= 4) 295 VBoxServiceVerbose(3, "VMInfo/Users: Session %u has %u processes\n", 296 pSessionData->Session, cNumProcs); 297 else 298 VBoxServiceVerbose(3, "VMInfo/Users: Session %u has at least one process\n", 299 pSessionData->Session); 296 300 297 301 LsaFreeReturnBuffer(pSessionData); 298 return cNumProcs ? true : false;302 return cNumProcs; 299 303 } 300 304 … … 560 564 if (VBoxServiceVMInfoWinIsLoggedIn(&UserInfo, &paSessions[i])) 561 565 { 562 VBoxServiceVMInfoWinSessionHasProcesses(&paSessions[i], paProcs, cProcs); 566 uint32_t cSessionProcs = VBoxServiceVMInfoWinSessionHasProcesses(&paSessions[i], paProcs, cProcs); 567 if (!cSessionProcs) 568 continue; 563 569 564 570 bool fFoundUser = false; … … 573 579 * we detected a stale session. */ 574 580 if ( pUserInfo[i].ulNumProcs > 0 575 && !c Procs)581 && !cSessionProcs) 576 582 { 577 583 VBoxServiceVerbose(3, "VMInfo/Users: Stale session for user=%ls detected! Old processes: %u, new: %u\n", 578 pUserInfo[i].wszUser, pUserInfo[i].ulNumProcs, c Procs);584 pUserInfo[i].wszUser, pUserInfo[i].ulNumProcs, cSessionProcs); 579 585 } 580 586 581 587 VBoxServiceVerbose(4, "VMInfo/Users: Updating user=%ls to %u processes\n", 582 UserInfo.wszUser, c Procs);583 584 pUserInfo[i].ulNumProcs = c Procs;588 UserInfo.wszUser, cSessionProcs); 589 590 pUserInfo[i].ulNumProcs = cSessionProcs; 585 591 fFoundUser = true; 586 592 break; … … 591 597 { 592 598 VBoxServiceVerbose(4, "VMInfo/Users: Adding new user=%ls with %u processes\n", 593 UserInfo.wszUser, cProcs); 594 595 memcpy(&pUserInfo[cUniqueUsers++], &UserInfo, sizeof(VBOXSERVICEVMINFOUSER)); 599 UserInfo.wszUser, cSessionProcs); 600 601 memcpy(&pUserInfo[cUniqueUsers], &UserInfo, sizeof(VBOXSERVICEVMINFOUSER)); 602 pUserInfo[cUniqueUsers++].ulNumProcs = cSessionProcs; 596 603 Assert(cUniqueUsers <= cSessions); 597 604 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r38224 r39106 83 83 84 84 85 #ifdef RT_OS_WINDOWS 86 static BOOL WINAPI VBoxServiceVMInfoConsoleControlHandler(DWORD dwCtrlType) 87 { 88 int rc = VINF_SUCCESS; 89 bool fEventHandled = FALSE; 90 switch (dwCtrlType) 91 { 92 case CTRL_LOGOFF_EVENT: 93 VBoxServiceVerbose(2, "VMInfo: Received logged-off event\n"); 94 /* Trigger a re-enumeration of all logged-in users by unblocking 95 * the multi event semaphore of the VMInfo thread. */ 96 if (g_hVMInfoEvent) 97 rc = RTSemEventMultiSignal(g_hVMInfoEvent); 98 fEventHandled = TRUE; 99 break; 100 default: 101 break; 102 /** @todo Add other events here. */ 103 } 104 105 if (RT_FAILURE(rc)) 106 VBoxServiceError("VMInfo: Event %ld handled with error rc=%Rrc\n", 107 dwCtrlType, rc); 108 return fEventHandled; 109 } 110 #endif /* RT_OS_WINDOWS */ 111 112 85 113 /** @copydoc VBOXSERVICE::pfnPreInit */ 86 114 static DECLCALLBACK(int) VBoxServiceVMInfoPreInit(void) … … 154 182 VBoxServicePropCacheUpdateEntry(&g_VMInfoPropCache, "/VirtualBox/GuestInfo/Net/Count", 155 183 VBOXSERVICEPROPCACHEFLAG_TEMPORARY | VBOXSERVICEPROPCACHEFLAG_ALWAYS_UPDATE, NULL /* Delete on exit */); 184 185 #ifdef RT_OS_WINDOWS 186 # ifndef RT_OS_NT4 187 /* Install console control handler. */ 188 if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)VBoxServiceVMInfoConsoleControlHandler, TRUE /* Add handler */)) 189 { 190 VBoxServiceError("VMInfo: Unable to add console control handler, error=%ld\n", GetLastError()); 191 /* Just skip this error, not critical. */ 192 } 193 # endif /* !RT_OS_NT4 */ 194 #endif /* RT_OS_WINDOWS */ 156 195 } 157 196 return rc; … … 812 851 break; 813 852 } 853 else if (RT_LIKELY(RT_SUCCESS(rc2))) 854 { 855 /* Reset event semaphore if it got triggered. */ 856 rc2 = RTSemEventMultiReset(g_hVMInfoEvent); 857 if (RT_FAILURE(rc2)) 858 rc2 = VBoxServiceError("VMInfo: RTSemEventMultiReset failed; rc2=%Rrc\n", rc2); 859 } 814 860 } 815 861 … … 833 879 { 834 880 int rc; 881 882 #ifdef RT_OS_WINDOWS 883 # ifndef RT_OS_NT4 884 /* Install console control handler. */ 885 if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)NULL, FALSE /* Remove handler */)) 886 { 887 VBoxServiceError("VMInfo: Unable to remove console control handler, error=%ld\n", GetLastError()); 888 /* Just skip this error, not critical. */ 889 } 890 # endif /* !RT_OS_NT4 */ 891 #endif 835 892 836 893 if (g_hVMInfoEvent != NIL_RTSEMEVENTMULTI)
Note:
See TracChangeset
for help on using the changeset viewer.

