儲存庫 vbox 的更動 89202
- 時間撮記:
- 2021-5-20 下午02:32:08 (4 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/src-server/win/svcmain.cpp
r88821 r89202 625 625 static LRESULT CALLBACK WinMainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 626 626 { 627 LRESULT rc = 0; 627 LRESULT lResult = 0; 628 628 629 switch (msg) 629 630 { 630 631 case WM_QUERYENDSESSION: 631 632 { 633 LogRel(("WM_QUERYENDSESSION:%s%s%s%s (0x%08lx)\n", 634 lParam == 0 ? " shutdown" : "", 635 lParam & ENDSESSION_CRITICAL ? " critical" : "", 636 lParam & ENDSESSION_LOGOFF ? " logoff" : "", 637 lParam & ENDSESSION_CLOSEAPP ? " close" : "", 638 (unsigned long)lParam)); 632 639 if (g_pModule) 633 640 { … … 635 642 if (fActiveConnection) 636 643 { 644 lResult = FALSE; 645 LogRel(("VBoxSvc has active connections:" 646 " bActivity = %RTbool, lock count = %d\n", 647 g_pModule->bActivity, g_pModule->GetLockCount())); 648 637 649 /* place the VBoxSVC into system shutdown list */ 638 650 ShutdownBlockReasonCreateAPI(hwnd, L"Has active connections."); 639 651 /* decrease a latency of MonitorShutdown loop */ 640 652 ASMAtomicXchgU32(&dwTimeOut, 100); 641 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n", 653 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections." 654 " bActivity = %d. Lock count = %d\n", 642 655 g_pModule->bActivity, g_pModule->GetLockCount())); 643 656 } 644 rc = !fActiveConnection; 657 else 658 { 659 LogRel(("No active connections:" 660 " bActivity = %RTbool, lock count = %d\n", 661 g_pModule->bActivity, g_pModule->GetLockCount())); 662 lResult = TRUE; 663 } 645 664 } 646 665 else … … 650 669 case WM_ENDSESSION: 651 670 { 671 LogRel(("WM_ENDSESSION:%s%s%s%s%s (%s/0x%08lx)\n", 672 lParam == 0 ? " shutdown" : "", 673 lParam & ENDSESSION_CRITICAL ? " critical" : "", 674 lParam & ENDSESSION_LOGOFF ? " logoff" : "", 675 lParam & ENDSESSION_CLOSEAPP ? " close" : "", 676 wParam == FALSE ? " cancelled" : "", 677 wParam ? "TRUE" : "FALSE", 678 (unsigned long)lParam)); 679 652 680 /* Restore timeout of Monitor Shutdown if user canceled system shutdown */ 653 681 if (wParam == FALSE) 654 682 { 683 Log(("VBoxSVCWinMain: user canceled system shutdown.\n")); 655 684 ASMAtomicXchgU32(&dwTimeOut, dwNormalTimeout); 656 Log(("VBoxSVCWinMain: user canceled system shutdown.\n"));685 ShutdownBlockReasonDestroyAPI(hwnd); 657 686 } 658 687 break; 659 688 } 689 660 690 case WM_DESTROY: 661 691 { … … 664 694 break; 665 695 } 696 666 697 default: 667 698 { 668 rc = DefWindowProc(hwnd, msg, wParam, lParam); 669 } 670 } 671 return rc; 699 lResult = DefWindowProc(hwnd, msg, wParam, lParam); 700 break; 701 } 702 } 703 return lResult; 672 704 } 673 705 … … 694 726 if (atomWindowClass == 0) 695 727 { 696 Log (("Failed to register main window class\n"));728 LogRel(("Failed to register window class for session monitoring\n")); 697 729 rc = VERR_NOT_SUPPORTED; 698 730 } … … 700 732 { 701 733 /* Create the window. */ 702 g_hMainWindow = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, 703 MAIN_WND_CLASS, MAIN_WND_CLASS, 704 WS_POPUPWINDOW, 734 g_hMainWindow = CreateWindowEx(0, MAIN_WND_CLASS, MAIN_WND_CLASS, 0, 705 735 0, 0, 1, 1, NULL, NULL, g_hInstance, NULL); 706 736 if (g_hMainWindow == NULL) 707 737 { 708 Log (("Failed to create main window\n"));738 LogRel(("Failed to create window for session monitoring\n")); 709 739 rc = VERR_NOT_SUPPORTED; 710 740 } 711 else 712 { 713 SetWindowPos(g_hMainWindow, HWND_TOPMOST, -200, -200, 0, 0, 714 SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE); 715 716 } 717 } 718 return 0; 741 } 742 return rc; 719 743 } 720 744 … … 735 759 } 736 760 } 761 762 763 static const char * const ctrl_event_names[] = { 764 "CTRL_C_EVENT", 765 "CTRL_BREAK_EVENT", 766 "CTRL_CLOSE_EVENT", 767 /* reserved, not used */ 768 "<console control event 3>", 769 "<console control event 4>", 770 /* not sent to processes that load gdi32.dll or user32.dll */ 771 "CTRL_LOGOFF_EVENT", 772 "CTRL_SHUTDOWN_EVENT", 773 }; 774 775 /** @todo r=uwe placeholder */ 776 BOOL WINAPI 777 ConsoleCtrlHandler(DWORD dwCtrlType) RT_NOTHROW_DEF 778 { 779 const char *signame; 780 char namebuf[48]; 781 // int rc; 782 783 if (dwCtrlType < RT_ELEMENTS(ctrl_event_names)) 784 signame = ctrl_event_names[dwCtrlType]; 785 else 786 { 787 /* should not happen, but be prepared */ 788 RTStrPrintf(namebuf, sizeof(namebuf), 789 "<console control event %lu>", (unsigned long)dwCtrlType); 790 signame = namebuf; 791 } 792 LogRel(("Got %s\n", signame)); 793 794 if (RT_UNLIKELY(g_pModule == NULL)) 795 { 796 LogRel(("%s: g_pModule == NULL\n", __FUNCTION__)); 797 return TRUE; 798 } 799 800 /* decrease latency of the MonitorShutdown loop */ 801 ASMAtomicXchgU32(&dwTimeOut, 100); 802 803 bool fHasClients = g_pModule->HasActiveConnection(); 804 if (!fHasClients) 805 { 806 LogRel(("No clients, closing the shop.\n")); 807 return TRUE; 808 } 809 810 LogRel(("VBoxSvc has clients: bActivity = %RTbool, lock count = %d\n", 811 g_pModule->bActivity, g_pModule->GetLockCount())); 812 813 /** @todo r=uwe wait for clients to disconnect */ 814 return TRUE; 815 } 816 737 817 738 818 … … 995 1075 else 996 1076 { 1077 997 1078 g_pModule->StartMonitor(); 998 1079 #if _WIN32_WINNT >= 0x0400 … … 1005 1086 _ASSERTE(SUCCEEDED(hRes)); 1006 1087 1088 /* 1089 * Register windows console signal handler to react to Ctrl-C, 1090 * Ctrl-Break, Close; but more importantly - to get notified 1091 * about shutdown when we are running in the context of the 1092 * autostart service - we won't get WM_ENDSESSION in that 1093 * case. 1094 */ 1095 ::SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); 1096 1097 1007 1098 if (RT_SUCCESS(CreateMainWindow())) 1008 1099 Log(("SVCMain: Main window succesfully created\n"));
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器