Changeset 38087 in vbox
- Timestamp:
- Jul 21, 2011 9:01:44 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73034
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
r33895 r38087 256 256 bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs) 257 257 { 258 AssertPtr(pSession);259 260 if (!cProcs) /* To be on the safe side. */258 if (!pSession) 259 { 260 VBoxServiceVerbose(1, "VMInfo/Users: Session became invalid while enumerating!\n"); 261 261 return false; 262 AssertPtr(paProcs);262 } 263 263 264 264 PSECURITY_LOGON_SESSION_DATA pSessionData = NULL; … … 266 266 if (rcNt != STATUS_SUCCESS) 267 267 { 268 VBoxServiceError(" Could not get logon session data! rcNt=%#x", rcNt);268 VBoxServiceError("VMInfo/Users: Could not get logon session data! rcNt=%#x", rcNt); 269 269 return false; 270 270 } 271 AssertPtrReturn(pSessionData, false);272 271 273 272 /* … … 276 275 * session <-> process LUIDs. 277 276 */ 277 uint32_t cNumProcs = 0; 278 278 for (DWORD i = 0; i < cProcs; i++) 279 279 { … … 284 284 && paProcs[i].luid.LowPart == pSessionData->LogonId.LowPart) 285 285 { 286 VBoxServiceVerbose(3, "Users: Session %ld:%ld has active processes\n", 287 pSessionData->LogonId.HighPart, pSessionData->LogonId.LowPart); 288 LsaFreeReturnBuffer(pSessionData); 289 return true; 290 } 291 } 286 cNumProcs++; 287 if (g_cVerbosity < 4) /* We want a bit more info on high verbosity. */ 288 break; 289 } 290 } 291 292 VBoxServiceVerbose(3, "VMInfo/Users: Session %u has %u processes\n", 293 pSessionData->Session, cNumProcs); 294 292 295 LsaFreeReturnBuffer(pSessionData); 293 return false;296 return cNumProcs ? true : false; 294 297 } 295 298 … … 324 327 * 325 328 * @returns true if logged in, false if not (or error). 326 * @param a_pUserInfoWhere to return the user information.327 * @param a_pSessionThe session to check.328 */ 329 bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession)330 { 331 AssertPtr( a_pUserInfo);332 if (! a_pSession)329 * @param pUserInfo Where to return the user information. 330 * @param pSession The session to check. 331 */ 332 bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER pUserInfo, PLUID pSession) 333 { 334 AssertPtr(pUserInfo); 335 if (!pSession) 333 336 return false; 334 337 335 338 PSECURITY_LOGON_SESSION_DATA pSessionData = NULL; 336 NTSTATUS rcNt = LsaGetLogonSessionData( a_pSession, &pSessionData);339 NTSTATUS rcNt = LsaGetLogonSessionData(pSession, &pSessionData); 337 340 if (rcNt != STATUS_SUCCESS) 338 341 { … … 373 376 * Copy out relevant data. 374 377 */ 375 VBoxServiceVMInfoWinSafeCopy( a_pUserInfo->wszUser, sizeof(a_pUserInfo->wszUser),378 VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszUser, sizeof(pUserInfo->wszUser), 376 379 &pSessionData->UserName, "User name"); 377 VBoxServiceVMInfoWinSafeCopy( a_pUserInfo->wszAuthenticationPackage, sizeof(a_pUserInfo->wszAuthenticationPackage),380 VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszAuthenticationPackage, sizeof(pUserInfo->wszAuthenticationPackage), 378 381 &pSessionData->AuthenticationPackage, "Authentication pkg name"); 379 VBoxServiceVMInfoWinSafeCopy( a_pUserInfo->wszLogonDomain, sizeof(a_pUserInfo->wszLogonDomain),382 VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszLogonDomain, sizeof(pUserInfo->wszLogonDomain), 380 383 &pSessionData->LogonDomain, "Logon domain name"); 381 384 … … 401 404 */ 402 405 if (dwErr != ERROR_NONE_MAPPED) 403 VBoxServiceError("VMInfo/Users: Failed looking up account info for user '%ls': %ld!\n",404 a_pUserInfo->wszUser, dwErr);406 VBoxServiceError("VMInfo/Users: Failed looking up account info for user=%ls, error=$ld!\n", 407 pUserInfo->wszUser, dwErr); 405 408 } 406 409 else … … 409 412 { 410 413 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, Session=%ld, LUID=%ld,%ld, AuthPkg=%ls, Domain=%ls\n", 411 a_pUserInfo->wszUser, pSessionData->Session, pSessionData->LogonId.HighPart,412 pSessionData->LogonId.LowPart, a_pUserInfo->wszAuthenticationPackage,413 a_pUserInfo->wszLogonDomain);414 pUserInfo->wszUser, pSessionData->Session, pSessionData->LogonId.HighPart, 415 pSessionData->LogonId.LowPart, pUserInfo->wszAuthenticationPackage, 416 pUserInfo->wszLogonDomain); 414 417 415 418 /* Detect RDP sessions as well. */ … … 425 428 if (cbRet) 426 429 iState = *pBuffer; 427 VBoxServiceVerbose(3, "VMInfo/Users: 428 a_pUserInfo->wszUser, iState);430 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, WTSConnectState=%d\n", 431 pUserInfo->wszUser, iState); 429 432 if ( iState == WTSActive /* User logged on to WinStation. */ 430 433 || iState == WTSShadow /* Shadowing another WinStation. */ … … 433 436 /** @todo On Vista and W2K, always "old" user name are still 434 437 * there. Filter out the old one! */ 435 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls is logged in via TCS/RDP. State=%d\n",436 a_pUserInfo->wszUser, iState);438 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls using TCS/RDP, state=%d\n", 439 pUserInfo->wszUser, iState); 437 440 fFoundUser = true; 438 441 } … … 442 445 else 443 446 { 444 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, WTSConnectState returned %ld\n", 445 a_pUserInfo->wszUser, GetLastError()); 446 447 /* 448 * Terminal services don't run (for example in W2K, 449 * nothing to worry about ...). ... or is on the Vista 450 * fast user switching page! 451 */ 447 DWORD dwLastErr = GetLastError(); 448 switch (dwLastErr) 449 { 450 /* 451 * Terminal services don't run (for example in W2K, 452 * nothing to worry about ...). ... or is on the Vista 453 * fast user switching page! 454 */ 455 case ERROR_CTX_WINSTATION_NOT_FOUND: 456 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, no WinSta found\n", 457 pUserInfo->wszUser); 458 break; 459 460 default: 461 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, error=%ld\n", 462 pUserInfo->wszUser, dwLastErr); 463 break; 464 } 465 452 466 fFoundUser = true; 453 467 } 454 468 } 455 469 } 470 471 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls %s logged in\n", 472 pUserInfo->wszUser, fFoundUser ? "is" : "is not"); 456 473 } 457 474 … … 493 510 return RTErrConvertFromWin32(rcWin); 494 511 } 495 VBoxServiceVerbose(3, "VMInfo/Users: Found %ld users\n", cSession);512 VBoxServiceVerbose(3, "VMInfo/Users: Found %ld sessions\n", cSession); 496 513 497 514 PVBOXSERVICEVMINFOPROC paProcs; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
r37256 r38087 262 262 && RT_SUCCESS(rc)) 263 263 { 264 VBoxServiceVerbose(4, "VMInfo : Found logged in user \"%s\"\n", ut_user->ut_user);265 264 VBoxServiceVerbose(4, "VMInfo/Users: Found logged in user \"%s\"\n", 265 ut_user->ut_user); 266 266 if (cUsersInList > cListSize) 267 267 { … … 322 322 cUsersInList = 0; 323 323 324 VBoxServiceVerbose(4, "VMInfo : cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",324 VBoxServiceVerbose(4, "VMInfo/Users: cUsersInList: %u, pszUserList: %s, rc=%Rrc\n", 325 325 cUsersInList, pszUserList ? pszUserList : "<NULL>", rc); 326 326 … … 764 764 if (idNewSession != g_idVMInfoSession) 765 765 { 766 VBoxServiceVerbose(3, "VMInfo: The VM session ID changed, flushing all properties .\n");766 VBoxServiceVerbose(3, "VMInfo: The VM session ID changed, flushing all properties\n"); 767 767 vboxserviceVMInfoWriteFixedProperties(); 768 768 VBoxServicePropCacheFlush(&g_VMInfoPropCache);
Note:
See TracChangeset
for help on using the changeset viewer.