Changeset 35863 in vbox
- Timestamp:
- Feb 7, 2011 10:59:08 AM (14 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 8 edited
-
VBoxHelpers.cpp (modified) (3 diffs)
-
VBoxHelpers.h (modified) (1 diff)
-
VBoxHostVersion.cpp (modified) (1 diff)
-
VBoxIPC.cpp (modified) (1 diff)
-
VBoxRestore.cpp (modified) (1 diff)
-
VBoxSeamless.cpp (modified) (2 diffs)
-
VBoxTray.cpp (modified) (14 diffs)
-
VBoxTray.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.cpp
r34025 r35863 4 4 5 5 /* 6 * Copyright (C) 2006-201 0Oracle Corporation6 * Copyright (C) 2006-2011 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 20 20 #include <iprt/string.h> 21 #include <VBox/Log.h> 21 22 #include <VBox/VBoxGuestLib.h> 22 23 … … 27 28 28 29 30 int hlpReportStatus(VBoxGuestStatusCurrent statusCurrent) 31 { 32 int rc = VbglR3ReportAdditionsStatus(VBoxGuestStatusFacility_VBoxTray, 33 statusCurrent, 34 0 /* Flags */); 35 if (RT_FAILURE(rc)) 36 Log(("VBoxTray: Could not report VBoxTray status \"%ld\", rc=%Rrc\n", statusCurrent, rc)); 37 return rc; 38 } 29 39 30 40 /** -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHelpers.h
r34025 r35863 27 27 #endif /* !DEBUG_DISPLAY_CHANGE */ 28 28 29 extern int hlpReportStatus(VBoxGuestStatusCurrent statusCurrent); 29 30 extern void hlpReloadCursor(void); 30 31 extern void hlpResizeRect(RECTL *paRects, unsigned nRects, unsigned uPrimary, unsigned uResized, int iNewWidth, int iNewHeight); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxHostVersion.cpp
r34026 r35863 51 51 "install option from the Devices menu.", pszGuestVersion, pszHostVersion); 52 52 53 rc = hlpShowBalloonTip(g Instance, gToolWindow, ID_TRAYICON,53 rc = hlpShowBalloonTip(ghInstance, ghwndToolWindow, ID_TRAYICON, 54 54 szMsg, szTitle, 55 55 5000 /* Time to display in msec */, NIIF_INFO); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxIPC.cpp
r34382 r35863 130 130 if (RT_SUCCESS(rc)) 131 131 { 132 hlpShowBalloonTip(g Instance, gToolWindow, ID_TRAYICON,132 hlpShowBalloonTip(ghInstance, ghwndToolWindow, ID_TRAYICON, 133 133 msg.szContent, msg.szTitle, 134 134 msg.ulShowMS, msg.ulType); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxRestore.cpp
r33966 r35863 130 130 /* did we get the right event? */ 131 131 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_RESTORED) 132 PostMessage(g ToolWindow, WM_VBOXTRAY_VM_RESTORED, 0, 0);132 PostMessage(ghwndToolWindow, WM_VBOXTRAY_VM_RESTORED, 0, 0); 133 133 else 134 134 /** @todo Don't poll, but wait for connect/disconnect events */ 135 PostMessage(g ToolWindow, WM_VBOXTRAY_VRDP_CHECK, 0, 0);135 PostMessage(ghwndToolWindow, WM_VBOXTRAY_VRDP_CHECK, 0, 0); 136 136 } 137 137 else -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSeamless.cpp
r35304 r35863 341 341 Log(("VBoxTray: SystemParametersInfo SPI_SETSCREENSAVEACTIVE failed with %d\n", GetLastError())); 342 342 } 343 PostMessage(g ToolWindow, WM_VBOX_REMOVE_SEAMLESS_HOOK, 0, 0);343 PostMessage(ghwndToolWindow, WM_VBOX_REMOVE_SEAMLESS_HOOK, 0, 0); 344 344 break; 345 345 … … 355 355 if (!ret) 356 356 Log(("VBoxTray: SystemParametersInfo SPI_SETSCREENSAVEACTIVE failed with %d\n", GetLastError())); 357 PostMessage(g ToolWindow, WM_VBOX_INSTALL_SEAMLESS_HOOK, 0, 0);357 PostMessage(ghwndToolWindow, WM_VBOX_INSTALL_SEAMLESS_HOOK, 0, 0); 358 358 break; 359 359 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r34080 r35863 4 4 5 5 /* 6 * Copyright (C) 2006-201 0Oracle Corporation6 * Copyright (C) 2006-2011 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 43 43 * Global Variables * 44 44 *******************************************************************************/ 45 HANDLE g VBoxDriver;46 HANDLE g StopSem;45 HANDLE ghVBoxDriver; 46 HANDLE ghStopSem; 47 47 HANDLE ghSeamlessNotifyEvent = 0; 48 48 SERVICE_STATUS gVBoxServiceStatus; 49 49 SERVICE_STATUS_HANDLE gVBoxServiceStatusHandle; 50 HINSTANCE g Instance;51 HWND g ToolWindow;50 HINSTANCE ghInstance; 51 HWND ghwndToolWindow; 52 52 NOTIFYICONDATA gNotifyIconData; 53 53 DWORD gMajorVersion; … … 141 141 static int vboxTrayCreateTrayIcon(void) 142 142 { 143 HICON hIcon = LoadIcon(g Instance, MAKEINTRESOURCE(IDI_VIRTUALBOX));143 HICON hIcon = LoadIcon(ghInstance, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 144 144 if (hIcon == NULL) 145 145 { … … 152 152 RT_ZERO(gNotifyIconData); 153 153 gNotifyIconData.cbSize = NOTIFYICONDATA_V1_SIZE; // sizeof(NOTIFYICONDATA); 154 gNotifyIconData.hWnd = g ToolWindow;154 gNotifyIconData.hWnd = ghwndToolWindow; 155 155 gNotifyIconData.uID = ID_TRAYICON; 156 156 gNotifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; … … 289 289 } 290 290 291 int vboxTrayRegisterGlobalMessages(PVBOXGLOBALMESSAGE pTable)291 static int vboxTrayRegisterGlobalMessages(PVBOXGLOBALMESSAGE pTable) 292 292 { 293 293 int rc = VINF_SUCCESS; … … 312 312 } 313 313 314 bool vboxTrayHandleGlobalMessages(PVBOXGLOBALMESSAGE pTable, UINT uMsg,315 WPARAM wParam, LPARAM lParam)314 static bool vboxTrayHandleGlobalMessages(PVBOXGLOBALMESSAGE pTable, UINT uMsg, 315 WPARAM wParam, LPARAM lParam) 316 316 { 317 317 if (pTable == NULL) 318 318 return false; 319 while (pTable ->pszName)319 while (pTable && pTable->pszName) 320 320 { 321 321 if (pTable->uMsgID == uMsg) … … 332 332 } 333 333 334 void WINAPI VBoxServiceStart(void) 335 { 336 Log(("VBoxTray: Entering service main function\n")); 337 338 VBOXSERVICEENV svcEnv; 339 DWORD dwErr = NO_ERROR; 340 334 static int vboxTrayOpenBaseDriver() 335 { 341 336 /* Open VBox guest driver. */ 342 gVBoxDriver = CreateFile(VBOXGUEST_DEVICE_NAME, 337 DWORD dwErr = ERROR_SUCCESS; 338 ghVBoxDriver = CreateFile(VBOXGUEST_DEVICE_NAME, 343 339 GENERIC_READ | GENERIC_WRITE, 344 340 FILE_SHARE_READ | FILE_SHARE_WRITE, … … 347 343 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, 348 344 NULL); 349 if (g VBoxDriver == INVALID_HANDLE_VALUE)345 if (ghVBoxDriver == INVALID_HANDLE_VALUE) 350 346 { 351 347 dwErr = GetLastError(); 352 348 LogRel(("VBoxTray: Could not open VirtualBox Guest Additions driver! Please install / start it first! Error = %08X\n", dwErr)); 353 349 } 354 355 if (dwErr == NO_ERROR) 356 { 357 /* Create a custom window class. */ 358 WNDCLASS windowClass = {0}; 359 windowClass.style = CS_NOCLOSE; 360 windowClass.lpfnWndProc = (WNDPROC)VBoxToolWndProc; 361 windowClass.hInstance = gInstance; 362 windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); 363 windowClass.lpszClassName = "VBoxTrayToolWndClass"; 364 if (!RegisterClass(&windowClass)) 365 { 366 dwErr = GetLastError(); 367 Log(("VBoxTray: Registering invisible tool window failed, error = %08X\n", dwErr)); 368 } 369 } 370 371 if (dwErr == NO_ERROR) 372 { 373 /* Create our (invisible) tool window. */ 374 /* Note: The window name ("VBoxTrayToolWnd") and class ("VBoxTrayToolWndClass") is 350 return RTErrConvertFromWin32(dwErr); 351 } 352 353 static void vboxTrayCloseBaseDriver() 354 { 355 if (ghVBoxDriver) 356 { 357 CloseHandle(ghVBoxDriver); 358 ghVBoxDriver = NULL; 359 } 360 } 361 362 static void vboxTrayDestroyToolWindow() 363 { 364 if (ghwndToolWindow) 365 { 366 Log(("VBoxTray: Destroying tool window ...\n")); 367 368 /* Destroy the tool window. */ 369 DestroyWindow(ghwndToolWindow); 370 ghwndToolWindow = NULL; 371 372 UnregisterClass("VBoxTrayToolWndClass", ghInstance); 373 } 374 } 375 376 static int vboxTrayCreateToolWindow() 377 { 378 DWORD dwErr = ERROR_SUCCESS; 379 380 /* Create a custom window class. */ 381 WNDCLASS windowClass = {0}; 382 windowClass.style = CS_NOCLOSE; 383 windowClass.lpfnWndProc = (WNDPROC)VBoxToolWndProc; 384 windowClass.hInstance = ghInstance; 385 windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); 386 windowClass.lpszClassName = "VBoxTrayToolWndClass"; 387 if (!RegisterClass(&windowClass)) 388 { 389 dwErr = GetLastError(); 390 Log(("VBoxTray: Registering invisible tool window failed, error = %08X\n", dwErr)); 391 } 392 else 393 { 394 /* 395 * Create our (invisible) tool window. 396 * Note: The window name ("VBoxTrayToolWnd") and class ("VBoxTrayToolWndClass") is 375 397 * needed for posting globally registered messages to VBoxTray and must not be 376 * changed! Otherwise things get broken! */ 377 gToolWindow = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST, 378 "VBoxTrayToolWndClass", "VBoxTrayToolWnd", 379 WS_POPUPWINDOW, 380 -200, -200, 100, 100, NULL, NULL, gInstance, NULL); 381 if (!gToolWindow) 398 * changed! Otherwise things get broken! 399 * 400 */ 401 ghwndToolWindow = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT | WS_EX_TOPMOST, 402 "VBoxTrayToolWndClass", "VBoxTrayToolWnd", 403 WS_POPUPWINDOW, 404 -200, -200, 100, 100, NULL, NULL, ghInstance, NULL); 405 if (!ghwndToolWindow) 382 406 { 383 407 dwErr = GetLastError(); … … 386 410 else 387 411 { 412 /* Reload the cursor(s). */ 388 413 hlpReloadCursor(); 389 } 390 } 391 392 Log(("VBoxTray: Window Handle = %p, Status = %p\n", gToolWindow, dwErr)); 393 414 415 Log(("VBoxTray: Invisible tool window handle = %p\n", ghwndToolWindow)); 416 } 417 } 418 419 if (dwErr != ERROR_SUCCESS) 420 vboxTrayDestroyToolWindow(); 421 return RTErrConvertFromWin32(dwErr); 422 } 423 424 static int vboxTraySetupSeamless() 425 { 394 426 OSVERSIONINFO info; 395 gMajorVersion = 5; /* default XP*/427 gMajorVersion = 5; /* Default to Windows XP. */ 396 428 info.dwOSVersionInfoSize = sizeof(info); 397 429 if (GetVersionEx(&info)) … … 401 433 } 402 434 403 if (dwErr == NO_ERROR) 404 { 405 gStopSem = CreateEvent(NULL, TRUE, FALSE, NULL); 406 if (gStopSem == NULL) 407 { 408 Log(("VBoxTray: CreateEvent for stopping VBoxTray failed, error = %08X\n", GetLastError())); 409 return; 410 } 411 412 /* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore */ 413 SECURITY_ATTRIBUTES SecAttr; 414 char secDesc[SECURITY_DESCRIPTOR_MIN_LENGTH]; 415 BOOL ret; 416 417 SecAttr.nLength = sizeof(SecAttr); 418 SecAttr.bInheritHandle = FALSE; 419 SecAttr.lpSecurityDescriptor = &secDesc; 420 InitializeSecurityDescriptor(SecAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); 421 ret = SetSecurityDescriptorDacl(SecAttr.lpSecurityDescriptor, TRUE, 0, FALSE); 422 if (!ret) 423 Log(("VBoxTray: SetSecurityDescriptorDacl failed with error = %08X\n", GetLastError())); 424 425 /* For Vista and up we need to change the integrity of the security descriptor too */ 435 /* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore. */ 436 SECURITY_ATTRIBUTES SecAttr; 437 DWORD dwErr = ERROR_SUCCESS; 438 char secDesc[SECURITY_DESCRIPTOR_MIN_LENGTH]; 439 BOOL fRC; 440 441 SecAttr.nLength = sizeof(SecAttr); 442 SecAttr.bInheritHandle = FALSE; 443 SecAttr.lpSecurityDescriptor = &secDesc; 444 InitializeSecurityDescriptor(SecAttr.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION); 445 fRC = SetSecurityDescriptorDacl(SecAttr.lpSecurityDescriptor, TRUE, 0, FALSE); 446 if (!fRC) 447 { 448 dwErr = GetLastError(); 449 Log(("VBoxTray: SetSecurityDescriptorDacl failed with last error = %08X\n", dwErr)); 450 } 451 else 452 { 453 /* For Vista and up we need to change the integrity of the security descriptor, too. */ 426 454 if (gMajorVersion >= 6) 427 455 { 428 HMODULE hModule;429 430 456 BOOL (WINAPI * pfnConvertStringSecurityDescriptorToSecurityDescriptorA)(LPCSTR StringSecurityDescriptor, DWORD StringSDRevision, PSECURITY_DESCRIPTOR *SecurityDescriptor, PULONG SecurityDescriptorSize); 431 457 432 hModule = LoadLibrary("ADVAPI32.DLL"); 433 if (hModule) 458 HMODULE hModule = LoadLibrary("ADVAPI32.DLL"); 459 if (!hModule) 460 { 461 dwErr = GetLastError(); 462 Log(("VBoxTray: Loading module ADVAPI32.DLL failed with last error = %08X\n", dwErr)); 463 } 464 else 434 465 { 435 466 PSECURITY_DESCRIPTOR pSD; … … 443 474 if (pfnConvertStringSecurityDescriptorToSecurityDescriptorA) 444 475 { 445 ret= pfnConvertStringSecurityDescriptorToSecurityDescriptorA("S:(ML;;NW;;;LW)", /* this means "low integrity" */476 fRC = pfnConvertStringSecurityDescriptorToSecurityDescriptorA("S:(ML;;NW;;;LW)", /* this means "low integrity" */ 446 477 SDDL_REVISION_1, &pSD, NULL); 447 if (!ret) 448 Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with error = %08X\n", GetLastError())); 449 450 ret = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); 451 if (!ret) 452 Log(("VBoxTray: GetSecurityDescriptorSacl failed with error = %08X\n", GetLastError())); 453 454 ret = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); 455 if (!ret) 456 Log(("VBoxTray: SetSecurityDescriptorSacl failed with error = %08X\n", GetLastError())); 478 if (!fRC) 479 { 480 dwErr = GetLastError(); 481 Log(("VBoxTray: ConvertStringSecurityDescriptorToSecurityDescriptorA failed with last error = %08X\n", dwErr)); 482 } 483 else 484 { 485 fRC = GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted); 486 if (!fRC) 487 { 488 dwErr = GetLastError(); 489 Log(("VBoxTray: GetSecurityDescriptorSacl failed with last error = %08X\n", dwErr)); 490 } 491 else 492 { 493 fRC = SetSecurityDescriptorSacl(SecAttr.lpSecurityDescriptor, TRUE, pSacl, FALSE); 494 if (!fRC) 495 { 496 dwErr = GetLastError(); 497 Log(("VBoxTray: SetSecurityDescriptorSacl failed with last error = %08X\n", dwErr)); 498 } 499 } 500 } 457 501 } 458 502 } 459 503 } 460 504 461 if (gMajorVersion >= 5) /* Only for W2K and up ... */ 505 if ( dwErr == ERROR_SUCCESS 506 && gMajorVersion >= 5) /* Only for W2K and up ... */ 462 507 { 463 508 ghSeamlessNotifyEvent = CreateEvent(&SecAttr, FALSE, FALSE, VBOXHOOK_GLOBAL_EVENT_NAME); 464 509 if (ghSeamlessNotifyEvent == NULL) 465 510 { 466 Log(("VBoxTray: CreateEvent for Seamless failed, error = %08X\n", GetLastError())); 467 return; 468 } 469 } 470 } 471 472 /* 473 * Start services listed in the vboxServiceTable. 474 */ 475 svcEnv.hInstance = gInstance; 476 svcEnv.hDriver = gVBoxDriver; 477 478 /* initializes disp-if to default (XPDM) mode */ 479 dwErr = VBoxDispIfInit(&svcEnv.dispIf); 480 #ifdef VBOX_WITH_WDDM 481 /* 482 * For now the display mode will be adjusted to WDDM mode if needed 483 * on display service initialization when it detects the display driver type. 484 */ 485 #endif 486 487 if (dwErr == NO_ERROR) 488 { 489 int rc = vboxTrayStartServices(&svcEnv, vboxServiceTable); 490 if (RT_FAILURE (rc)) 491 { 492 dwErr = ERROR_GEN_FAILURE; 493 } 494 } 495 496 /* terminate service if something went wrong */ 497 if (dwErr != NO_ERROR) 498 { 499 vboxTrayStopServices(&svcEnv, vboxServiceTable); 500 return; 501 } 502 503 int rc = vboxTrayCreateTrayIcon(); 504 if ( RT_SUCCESS(rc) 505 && gMajorVersion >= 5) /* Only for W2K and up ... */ 506 { 507 /* We're ready to create the tooltip balloon. */ 508 /* Check in 10 seconds (@todo make seconds configurable) ... */ 509 SetTimer(gToolWindow, 510 TIMERID_VBOXTRAY_CHECK_HOSTVERSION, 511 10 * 1000, /* 10 seconds */ 512 NULL /* No timerproc */); 513 } 514 515 /* Do the Shared Folders auto-mounting stuff. */ 516 VBoxSharedFoldersAutoMount(); 517 518 /* Boost thread priority to make sure we wake up early for seamless window notifications (not sure if it actually makes any difference though) */ 519 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 520 521 /* 522 * Main execution loop 523 * Wait for the stop semaphore to be posted or a window event to arrive 524 */ 525 526 DWORD dwEventCount = 2; 527 HANDLE hWaitEvent[2] = {gStopSem, ghSeamlessNotifyEvent}; 528 529 if (0 == ghSeamlessNotifyEvent) /* If seamless mode is not active / supported, reduce event array count */ 530 dwEventCount = 1; 531 532 Log(("VBoxTray: Number of events to wait in main loop: %ld\n", dwEventCount)); 533 while (true) 534 { 535 DWORD waitResult = MsgWaitForMultipleObjectsEx(dwEventCount, hWaitEvent, 500, QS_ALLINPUT, 0); 536 waitResult = waitResult - WAIT_OBJECT_0; 537 538 /* Only enable for message debugging, lots of traffic! */ 539 //Log(("VBoxTray: Wait result = %ld\n", waitResult)); 540 541 if (waitResult == 0) 542 { 543 Log(("VBoxTray: Event 'Exit' triggered\n")); 544 /* exit */ 545 break; 546 } 547 else if ( (waitResult == 1) 548 && (ghSeamlessNotifyEvent!=0)) /* Only jump in, if seamless is active! */ 549 { 550 Log(("VBoxTray: Event 'Seamless' triggered\n")); 551 552 /* seamless window notification */ 553 VBoxSeamlessCheckWindows(); 511 dwErr = GetLastError(); 512 Log(("VBoxTray: CreateEvent for Seamless failed, last error = %08X\n", dwErr)); 513 } 514 } 515 } 516 return RTErrConvertFromWin32(dwErr); 517 } 518 519 static void vboxTrayShutdownSeamless(void) 520 { 521 if (ghSeamlessNotifyEvent) 522 { 523 CloseHandle(ghSeamlessNotifyEvent); 524 ghSeamlessNotifyEvent = NULL; 525 } 526 } 527 528 static int vboxTrayServiceMain(void) 529 { 530 int rc = VINF_SUCCESS; 531 Log(("VBoxTray: Entering vboxTrayServiceMain\n")); 532 533 ghStopSem = CreateEvent(NULL, TRUE, FALSE, NULL); 534 if (ghStopSem == NULL) 535 { 536 rc = RTErrConvertFromWin32(GetLastError()); 537 Log(("VBoxTray: CreateEvent for stopping VBoxTray failed, rc=%Rrc\n", rc)); 538 } 539 else 540 { 541 /* 542 * Start services listed in the vboxServiceTable. 543 */ 544 VBOXSERVICEENV svcEnv; 545 svcEnv.hInstance = ghInstance; 546 svcEnv.hDriver = ghVBoxDriver; 547 548 /* Initializes disp-if to default (XPDM) mode. */ 549 VBoxDispIfInit(&svcEnv.dispIf); /* Cannot fail atm. */ 550 #ifdef VBOX_WITH_WDDM 551 /* 552 * For now the display mode will be adjusted to WDDM mode if needed 553 * on display service initialization when it detects the display driver type. 554 */ 555 #endif 556 557 /* Finally start all the built-in services! */ 558 rc = vboxTrayStartServices(&svcEnv, vboxServiceTable); 559 if (RT_FAILURE(rc)) 560 { 561 /* Terminate service if something went wrong. */ 562 vboxTrayStopServices(&svcEnv, vboxServiceTable); 554 563 } 555 564 else 556 565 { 557 /* timeout or a window message, handle it */ 558 MSG msg; 559 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 560 { 561 Log(("VBoxTray: msg %p\n", msg.message)); 562 if (msg.message == WM_QUIT) 566 rc = vboxTrayCreateTrayIcon(); 567 if ( RT_SUCCESS(rc) 568 && gMajorVersion >= 5) /* Only for W2K and up ... */ 569 { 570 /* We're ready to create the tooltip balloon. 571 Check in 10 seconds (@todo make seconds configurable) ... */ 572 SetTimer(ghwndToolWindow, 573 TIMERID_VBOXTRAY_CHECK_HOSTVERSION, 574 10 * 1000, /* 10 seconds */ 575 NULL /* No timerproc */); 576 } 577 578 if (RT_SUCCESS(rc)) 579 { 580 /* Do the Shared Folders auto-mounting stuff. */ 581 rc = VBoxSharedFoldersAutoMount(); 582 if (RT_SUCCESS(rc)) 563 583 { 564 Log(("VBoxTray: WM_QUIT!\n")); 565 SetEvent(gStopSem); 566 continue; 584 /* Report the host that we're up and running! */ 585 rc = hlpReportStatus(VBoxGuestStatusCurrent_Active); 567 586 } 568 TranslateMessage(&msg); 569 DispatchMessage(&msg); 570 } 571 } 572 } 573 574 Log(("VBoxTray: Returned from main loop, exiting ...\n")); 587 } 588 589 if (RT_SUCCESS(rc)) 590 { 591 /* Boost thread priority to make sure we wake up early for seamless window notifications 592 * (not sure if it actually makes any difference though). */ 593 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 594 595 /* 596 * Main execution loop 597 * Wait for the stop semaphore to be posted or a window event to arrive 598 */ 599 600 DWORD dwEventCount = 2; 601 HANDLE hWaitEvent[2] = { ghStopSem, ghSeamlessNotifyEvent }; 602 603 if (0 == ghSeamlessNotifyEvent) /* If seamless mode is not active / supported, reduce event array count. */ 604 dwEventCount = 1; 605 606 Log(("VBoxTray: Number of events to wait in main loop: %ld\n", dwEventCount)); 607 while (true) 608 { 609 DWORD waitResult = MsgWaitForMultipleObjectsEx(dwEventCount, hWaitEvent, 500, QS_ALLINPUT, 0); 610 waitResult = waitResult - WAIT_OBJECT_0; 611 612 /* Only enable for message debugging, lots of traffic! */ 613 //Log(("VBoxTray: Wait result = %ld\n", waitResult)); 614 615 if (waitResult == 0) 616 { 617 Log(("VBoxTray: Event 'Exit' triggered\n")); 618 /* exit */ 619 break; 620 } 621 else if ( waitResult == 1 622 && ghSeamlessNotifyEvent != 0) /* Only jump in, if seamless is active! */ 623 { 624 Log(("VBoxTray: Event 'Seamless' triggered\n")); 625 626 /* seamless window notification */ 627 VBoxSeamlessCheckWindows(); 628 } 629 else 630 { 631 /* timeout or a window message, handle it */ 632 MSG msg; 633 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 634 { 635 Log(("VBoxTray: msg %p\n", msg.message)); 636 if (msg.message == WM_QUIT) 637 { 638 Log(("VBoxTray: WM_QUIT!\n")); 639 SetEvent(ghStopSem); 640 continue; 641 } 642 TranslateMessage(&msg); 643 DispatchMessage(&msg); 644 } 645 } 646 } 647 Log(("VBoxTray: Returned from main loop, exiting ...\n")); 648 } 649 Log(("VBoxTray: Waiting for services to stop ...\n")); 650 vboxTrayStopServices(&svcEnv, vboxServiceTable); 651 } /* Services started */ 652 CloseHandle(ghStopSem); 653 } /* Stop event created */ 575 654 576 655 vboxTrayRemoveTrayIcon(); 577 656 578 Log(("VBoxTray: Waiting for display change thread ...\n")); 579 580 vboxTrayStopServices(&svcEnv, vboxServiceTable); 581 582 Log(("VBoxTray: Destroying tool window ...\n")); 583 584 /* Destroy the tool window. */ 585 DestroyWindow(gToolWindow); 586 587 UnregisterClass("VBoxTrayToolWndClass", gInstance); 588 589 CloseHandle(gVBoxDriver); 590 CloseHandle(gStopSem); 591 CloseHandle(ghSeamlessNotifyEvent); 592 593 Log(("VBoxTray: Leaving service main function\n")); 594 595 return; 596 } 597 657 Log(("VBoxTray: Leaving vboxTrayServiceMain with rc=%Rrc\n", rc)); 658 return rc; 659 } 598 660 599 661 /** … … 613 675 } 614 676 677 LogRel(("VBoxTray: %s r%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr())); 678 615 679 int rc = RTR3Init(); 680 if (RT_SUCCESS(rc)) 681 { 682 rc = VbglR3Init(); 683 if (RT_SUCCESS(rc)) 684 rc = vboxTrayOpenBaseDriver(); 685 } 686 616 687 if (RT_FAILURE(rc)) 617 return rc; 618 619 rc = VbglR3Init(); 620 if (RT_FAILURE(rc)) 621 return rc; 622 623 LogRel(("VBoxTray: %s r%s started\n", RTBldCfgVersion(), RTBldCfgRevisionStr())); 624 625 gInstance = hInstance; 626 VBoxServiceStart(); 627 688 { 689 CloseHandle (hMutexAppRunning); 690 hMutexAppRunning = NULL; 691 return 1; 692 } 693 694 if (RT_SUCCESS(rc)) 695 { 696 /* Save instance handle. */ 697 ghInstance = hInstance; 698 699 rc = hlpReportStatus(VBoxGuestStatusCurrent_Init); 700 if (RT_SUCCESS(rc)) 701 { 702 rc = vboxTrayCreateToolWindow(); 703 if (RT_SUCCESS(rc)) 704 { 705 rc = vboxTraySetupSeamless(); 706 if (RT_SUCCESS(rc)) 707 { 708 Log(("VBoxTray: Init successful\n")); 709 rc = vboxTrayServiceMain(); 710 hlpReportStatus(VBoxGuestStatusCurrent_Terminating); 711 vboxTrayShutdownSeamless(); 712 } 713 vboxTrayDestroyToolWindow(); 714 } 715 rc = hlpReportStatus(VBoxGuestStatusCurrent_Inactive); 716 } 717 } 718 else 719 Log(("VBoxTray: Could not report VBoxTray status \"Init\", rc=%Rrc\n", rc)); 720 if (RT_FAILURE(rc)) 721 LogRel(("VBoxTray: Error while starting, rc=%Rrc\n", rc)); 628 722 LogRel(("VBoxTray: Ended\n")); 629 723 … … 661 755 case WM_DESTROY: 662 756 Log(("VBoxTray: Tool window destroyed\n")); 663 KillTimer(g ToolWindow, TIMERID_VBOXTRAY_CHECK_HOSTVERSION);757 KillTimer(ghwndToolWindow, TIMERID_VBOXTRAY_CHECK_HOSTVERSION); 664 758 return 0; 665 759 … … 671 765 { 672 766 /* After successful run we don't need to check again. */ 673 KillTimer(g ToolWindow, TIMERID_VBOXTRAY_CHECK_HOSTVERSION);767 KillTimer(ghwndToolWindow, TIMERID_VBOXTRAY_CHECK_HOSTVERSION); 674 768 } 675 769 return 0; -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r34080 r35863 102 102 } VBOXGLOBALMESSAGE, *PVBOXGLOBALMESSAGE; 103 103 104 extern HWND g ToolWindow;105 extern HINSTANCE g Instance;104 extern HWND ghwndToolWindow; 105 extern HINSTANCE ghInstance; 106 106 107 107 #endif /* !___VBOXTRAY_H */
Note:
See TracChangeset
for help on using the changeset viewer.

