Changeset 76092 in vbox
- Timestamp:
- Dec 9, 2018 11:19:16 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 127333
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r76087 r76092 1188 1188 VBoxProxyStub_SDKS = VBOX_NTDLL 1189 1189 VBoxProxyStub_DEFPATH = $(VBoxCOM_0_OUTDIR)/# Hack to workaround drive letter in $(VBoxCOM_0_OUTDIR)/ for CFLAGS hack below. 1190 VBoxProxyStub_INCS = $(VBoxCOM_0_OUTDIR)/ \ 1191 $(VBOX_PATH_MAIN_SRC)/include/ 1190 VBoxProxyStub_INCS = $(VBoxCOM_0_OUTDIR)/ 1192 1191 VBoxProxyStub_SOURCES := \ 1193 1192 VirtualBox_p.c \ … … 1196 1195 $(PATH_SUB_CURRENT)/src-all/win/VBoxProxyStub.rc \ 1197 1196 $(PATH_SUB_CURRENT)/src-all/win/VBoxProxyStub.c 1198 # $(PATH_SUB_CURRENT)/src-all/win/RpcChannelHook.cpp1199 1197 src-all/win/VBoxProxyStub.rc_DEPS = $(VBoxCOM_0_OUTDIR)/VirtualBox.tlb 1200 1198 VBoxProxyStub_VirtualBox_p.c_CFLAGS.x86 = /Gz # Workaround for incorrect ObjectStublessClient* prototypes in SDK v7.1. … … 1204 1202 VBoxProxyStubLegacy_EXTENDS = VBoxProxyStub 1205 1203 VBoxProxyStubLegacy_DEFS = $(VBoxProxyStub_DEFS) VBOX_IN_PROXY_STUB_LEGACY 1206 VBoxProxyStubLegacy_INCS = $(VBoxCOM_0_OUTDIR)/legacy/ \ 1207 $(VBOX_PATH_MAIN_SRC)/include/ 1204 VBoxProxyStubLegacy_INCS = $(VBoxCOM_0_OUTDIR)/legacy/ 1208 1205 VBoxProxyStubLegacy_SOURCES = \ 1209 1206 $(VBoxCOM_0_OUTDIR)/legacy/VirtualBox_p.c \ … … 1212 1209 src-all/win/VBoxProxyStubLegacy.rc \ 1213 1210 src-all/win/VBoxProxyStub.c 1214 # src-all/win/RpcChannelHook.cpp1215 1211 src-all/win/VBoxProxyStubLegacy.rc_DEPS = $(VBoxCOM_0_OUTDIR)/legacy/VirtualBox.tlb 1216 1212 … … 1220 1216 VBoxProxyStub-x86_SDKS = VBOX_NTDLL 1221 1217 VBoxProxyStub-x86_DEFS = $(VBoxProxyStub_DEFS) VBOX_PROXY_STUB_32_ON_64 WIN32 1222 VBoxProxyStub-x86_INCS = $(VBoxCOM-x86_0_OUTDIR)/ \ 1223 $(VBOX_PATH_MAIN_SRC)/include/ 1218 VBoxProxyStub-x86_INCS = $(VBoxCOM-x86_0_OUTDIR)/ 1224 1219 VBoxProxyStub-x86_SOURCES = \ 1225 1220 $(VBoxCOM-x86_0_OUTDIR)/VirtualBox_p.c \ … … 1228 1223 src-all/win/VBoxProxyStub-x86.rc \ 1229 1224 src-all/win/VBoxProxyStub.def 1230 # src-all/win/RpcChannelHook.cpp1231 1225 src-all/win/VBoxProxyStub-x86.rc_DEPS = $(VBoxCOM-x86_0_OUTDIR)/VirtualBox-x86.tlb 1232 1226 endif -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r76091 r76092 25788 25788 <interface 25789 25789 name="IVBoxSVCRegistration" extends="$unknown" notdual="yes" 25790 uuid=" f22181fb-921b-4f2a-7801-0cc5ec28cdae"25790 uuid="9e106366-4521-44cc-df95-186e4d057c83" 25791 25791 wsmap="suppress" internal="yes" 25792 25792 reservedMethods="0" reservedAttributes="0" … … 25802 25802 <desc> Where to return the IUnknown interface. </desc> 25803 25803 </param> 25804 </method>25805 25806 <method name="notifyClientsFinished">25807 <desc>Notify service that their clients finished.</desc>25808 25804 </method> 25809 25805 -
trunk/src/VBox/Main/src-all/win/VBoxProxyStub.c
r76067 r76092 41 41 #include <iprt/uuid.h> 42 42 #include <iprt/utf16.h> 43 #include "RpcChannelHook.h"44 43 45 44 … … 172 171 RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 173 172 Log12(("VBoxProxyStub[%u]/DllMain: DLL_PROCESS_ATTACH\n", GetCurrentProcessId())); 174 175 #ifdef VBOX_WITH_SDS_CLIENT_WATCHER176 /*177 * Install RPC channel hook to intercept a moment just after VirtualBox object activation.178 * It's reports to VBoxSDS that a new VirtualBox API client started.179 */180 if (GetProcAddress(GetModuleHandle(NULL), "Is_VirtualBox_service_process_like_VBoxSDS_And_VBoxSDS") == NULL)181 SetupClientRpcChannelHook();182 #endif183 173 184 174 #ifdef VBOX_STRICT … … 1356 1346 VbpsRegisterClassId(pState, &CLSID_VirtualBoxSDS, "VirtualBoxSDS Class", pszSdsAppId, "VirtualBox.VirtualBoxSDS", ".1", 1357 1347 &LIBID_VirtualBox, "LocalServer32", pwszVBoxDir, pszSdsExe, NULL /*N/A*/); 1358 1359 # if 01360 VbpsRegisterClassName(pState, "VirtualBox.VirtualBoxClientList.1", "VirtualBoxClientList Class", &CLSID_VirtualBoxClientList, NULL);1361 VbpsRegisterClassName(pState, "VirtualBox.VirtualBoxClientList", "VirtualBoxClientList Class", &CLSID_VirtualBoxClientList, ".1");1362 VbpsRegisterClassId(pState, &CLSID_VirtualBoxClientList, "VirtualBoxClientList Class", pszSdsAppId, "VirtualBox.VirtualBoxClientList", ".1",1363 &LIBID_VirtualBox, "LocalServer32", pwszVBoxDir, pszSdsExe, NULL /*N/A*/);1364 # endif1365 1348 #endif 1366 1349 } -
trunk/src/VBox/Main/src-global/win/VBoxSDS.cpp
r76082 r76092 754 754 755 755 756 /** Special export that make VBoxProxyStub not register this process as one that757 * VBoxSDS should be watching.758 */759 extern "C" DECLEXPORT(void) VBOXCALL Is_VirtualBox_service_process_like_VBoxSDS_And_VBoxSDS(void)760 {761 /* never called, just need to be here */762 }763 764 765 756 /** 766 757 * Main function for the VBoxSDS process. -
trunk/src/VBox/Main/src-server/win/svcmain.cpp
r76091 r76092 28 28 #include "VBox/com/com.h" 29 29 #include "VBox/com/VirtualBox.h" 30 #include "VBox/com/array.h"31 30 32 31 #include "VirtualBoxImpl.h" … … 43 42 #include <iprt/message.h> 44 43 #include <iprt/asm.h> 45 46 //#ifdef VBOX_WITH_SDS47 //# include <TlHelp32.h>48 //#endif49 44 50 45 … … 98 93 volatile uint32_t dwTimeOut = dwNormalTimeout; /* time for EXE to be idle before shutting down. Can be decreased at system shutdown phase. */ 99 94 100 101 #if 0 //def VBOX_WITH_SDS102 103 BOOL CALLBACK CloseWindowProc(_In_ HWND hWnd, _In_ LPARAM /* lParam */)104 {105 _ASSERTE(hWnd);106 DWORD_PTR dwResult;107 // Close topmost windows in the thread108 LRESULT lResult = SendMessageTimeout(hWnd, WM_CLOSE, NULL, NULL,109 SMTO_ABORTIFHUNG | SMTO_BLOCK, 0, &dwResult);110 if (lResult != 0)111 {112 LogRel(("EnumThreadWndProc: Close message sent to window %x successfully \n", hWnd));113 }114 else115 {116 LogRel(("EnumThreadWndProc: Cannot send event to window %x. result: %d, last error: %x\n",117 hWnd, dwResult, GetLastError()));118 }119 return TRUE;120 }121 122 void SendCloseToAllThreads(DWORD dwTargetPid)123 {124 HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);125 if (hSnapshot == NULL)126 {127 LogRel(("SendCloseToAllThreads: cannot get threads snapshot. error: 0x%x \n",128 GetLastError()));129 return;130 }131 132 THREADENTRY32 threadEntry;133 ZeroMemory(&threadEntry, sizeof(threadEntry));134 threadEntry.dwSize = sizeof(threadEntry);135 136 if (Thread32First(hSnapshot, &threadEntry))137 {138 do139 {140 LogRel(("SendCloseToAllThreads: process: %d thread: %x \n",141 threadEntry.th32OwnerProcessID, threadEntry.th32ThreadID));142 if (threadEntry.th32OwnerProcessID == dwTargetPid)143 {144 BOOL bRes = EnumThreadWindows(threadEntry.th32ThreadID, CloseWindowProc, NULL);145 if (!bRes)146 {147 LogRel(("SendCloseToAllThreads: EnumThreadWindows() failed to enumerate threads. error: %x \n",148 GetLastError()));149 }150 else151 {152 LogRel(("SendCloseToAllThreads: about to close window in thread %x of process d\n",153 threadEntry.th32ThreadID, dwTargetPid));154 }155 }156 } while (Thread32Next(hSnapshot, &threadEntry));157 }158 CloseHandle(hSnapshot);159 }160 161 static int CloseActiveClients()162 {163 ComPtr<IVirtualBoxClientList> ptrClientList;164 /**165 * Connect to VBoxSDS.166 * here we close all API client processes: our own and customers167 */168 LogRelFunc(("Forcibly close API clients during system shutdown on Windows 7:\n"));169 HRESULT hrc = CoCreateInstance(CLSID_VirtualBoxClientList, NULL, CLSCTX_LOCAL_SERVER, IID_IVirtualBoxClientList,170 (void **)ptrClientList.asOutParam());171 if (SUCCEEDED(hrc))172 {173 com::SafeArray<LONG> aCllients;174 hrc = ptrClientList->get_Clients(aCllients.__asOutParam());175 RTCList<LONG> clientsList = aCllients.toList();176 LogRel(("==========Client list begin ========\n"));177 for (size_t i = 0; i < clientsList.size(); i++)178 {179 LogRel(("About to close client pid: %d\n", clientsList[i]));180 SendCloseToAllThreads(clientsList[i]);181 }182 LogRel(("==========Client list end ========\n"));183 }184 else185 {186 LogFunc(("Error to connect to VBoxSDS: hr=%Rhrf\n", hrc));187 }188 return 0;189 }190 191 // These are copies of functions defined in VersionHelpers.h192 bool IsWindowsVersionOrGreaterWrap(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)193 {194 OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };195 DWORDLONG const dwlConditionMask = VerSetConditionMask(196 VerSetConditionMask(197 VerSetConditionMask(198 0, VER_MAJORVERSION, VER_GREATER_EQUAL),199 VER_MINORVERSION, VER_GREATER_EQUAL),200 VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);201 202 osvi.dwMajorVersion = wMajorVersion;203 osvi.dwMinorVersion = wMinorVersion;204 osvi.wServicePackMajor = wServicePackMajor;205 206 return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;207 }208 209 #if !defined _WIN32_WINNT_WIN8210 211 #define _WIN32_WINNT_WIN8 0x0602212 213 #endif // #if !defined _WIN32_WINNT_WIN8214 215 bool IsWindows8OrGreaterWrap()216 {217 return IsWindowsVersionOrGreaterWrap(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);218 }219 220 #endif // !VBOX_WITH_SDS221 95 222 96 … … 367 241 HRESULT VirtualBoxClassFactory::i_registerWithSds(IUnknown **ppOtherVirtualBox); 368 242 void VirtualBoxClassFactory::i_deregisterWithSds(void); 369 void VirtualBoxClassFactory::i_finishVBoxSvc();370 243 371 244 friend VBoxSVCRegistration; … … 438 311 return m_pFactory->i_getVirtualBox(ppResult); 439 312 return E_FAIL; 440 }441 442 // IVBoxSVCRegistration: called from443 STDMETHOD(NotifyClientsFinished)()444 {445 LogRelFunc(("All clients gone - shutdown sequence initiated\n"));446 if (m_pFactory)447 m_pFactory->i_finishVBoxSvc();448 449 // This is not enough to finish VBoxSvc such as reference to crashed client still is in action450 // So I forcebly shutdown VBoxSvc451 LONG cLocks = g_pModule->Unlock();452 LogRelFunc(("Unlock -> %d\n", cLocks));453 while (cLocks > 0)454 cLocks = g_pModule->Unlock();455 456 LogRelFunc(("returns\n"));457 return S_OK;458 313 } 459 314 }; … … 507 362 NOREF(hrc); 508 363 } 509 } 510 i_finishVBoxSvc(); 364 m_ptrVirtualBoxSDS.setNull(); 365 g_fRegisteredWithVBoxSDS = false; 366 } 367 if (m_pVBoxSVC) 368 { 369 m_pVBoxSVC->m_pFactory = NULL; 370 m_pVBoxSVC->Release(); 371 m_pVBoxSVC = NULL; 372 } 511 373 } 512 374 … … 534 396 Log(("VirtualBoxClassFactory::GetVirtualBox: E_FAIL\n")); 535 397 return E_FAIL; 536 }537 538 539 void VirtualBoxClassFactory::i_finishVBoxSvc()540 {541 LogRelFunc(("Finish work of VBoxSVC and VBoxSDS\n"));542 if (m_ptrVirtualBoxSDS.isNotNull())543 {544 m_ptrVirtualBoxSDS.setNull();545 g_fRegisteredWithVBoxSDS = false;546 }547 if (m_pVBoxSVC)548 {549 m_pVBoxSVC->m_pFactory = NULL;550 m_pVBoxSVC->Release();551 m_pVBoxSVC = NULL;552 }553 398 } 554 399 … … 794 639 Log(("VBoxSVCWinMain: WM_QUERYENDSESSION: VBoxSvc has active connections. bActivity = %d. Loc count = %d\n", 795 640 g_pModule->bActivity, g_pModule->GetLockCount())); 796 797 #if 0 //def VBOX_WITH_SDS798 // On Windows 7 our clients doesn't receive right sequence of Session End events799 // So we send them all WM_QUIT to forcible close them.800 // Windows 10 sends end session events correctly801 // Note: the IsWindows8Point1() and IsWindows10OrGreater() doesnt work in802 // application without manifest so I use old compatible functions for detection of Win 7803 if(!IsWindows8OrGreaterWrap())804 CloseActiveClients();805 #endif806 641 } 807 642 rc = !fActiveConnection;
Note:
See TracChangeset
for help on using the changeset viewer.