Changeset 69729 in vbox
- Timestamp:
- Nov 17, 2017 7:55:33 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119120
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/log.h
r69107 r69729 636 636 /** Main group, IVBoxSVCAvailabilityChangedEvent. */ 637 637 LOG_GROUP_MAIN_VBOXSVCAVAILABILITYCHANGEDEVENT, 638 /** Main group, IVBoxSVC. */ 639 LOG_GROUP_MAIN_VBOXSVC, 638 640 /** Main group, IVetoEvent. */ 639 641 LOG_GROUP_MAIN_VETOEVENT, -
trunk/src/VBox/Main/Makefile.kmk
r69683 r69729 278 278 PROGRAMS += VBoxSDS 279 279 VBoxSDS_TEMPLATE = VBOXMAINEXE 280 VBoxSDS_DEFS = \280 VBoxSDS_DEFS = $(if $(VBOX_WITH_SDS_PLAN_B),VBOX_WITH_SDS_PLAN_B,) 281 281 VBoxSDS_DEFS.win += VBOX_COM_OUTOFPROC_MODULE 282 282 VBoxSDS_DEFS.win += _WIN32_WINNT=0x0510 … … 367 367 $(if $(VBOX_WITH_NAT_SERVICE),VBOX_WITH_NAT_SERVICE,) \ 368 368 $(if $(VBOX_WITH_CROGL),VBOX_WITH_CROGL,) \ 369 $(if $(VBOX_WITH_CRHGSMI),VBOX_WITH_CRHGSMI,) 369 $(if $(VBOX_WITH_CRHGSMI),VBOX_WITH_CRHGSMI,) \ 370 $(if-expr defined(VBOX_WITH_SDS) && defined(VBOX_WITH_SDS_PLAN_B),VBOX_WITH_SDS_PLAN_B,) 370 371 ifdef VBOX_WITH_USB 371 372 VBoxSVC_DEFS += \ … … 763 764 $(if $(VBOX_WITH_PCI_PASSTHROUGH),VBOX_WITH_PCI_PASSTHROUGH,) \ 764 765 $(if $(VBOX_WITH_VRDEAUTH_IN_VBOXSVC),VBOX_WITH_VRDEAUTH_IN_VBOXSVC,) \ 765 $(if $(VBOX_WITH_SDS),VBOX_WITH_SDS,) 766 $(if $(VBOX_WITH_SDS),VBOX_WITH_SDS,) \ 767 $(if-expr defined(VBOX_WITH_SDS) && defined(VBOX_WITH_SDS_PLAN_B),VBOX_WITH_SDS_PLAN_B,) 766 768 ifdef VBOX_WITH_CRHGSMI 767 769 VBoxC_DEFS += VBOX_WITH_CRHGSMI … … 1194 1196 VBoxProxyStub_TEMPLATE = VBOXMAINCOMP 1195 1197 VBoxProxyStub_DEFS = REGISTER_PROXY_DLL PROXY_CLSID_IS="$(VBOX_MIDL_PROXY_CLSID_IS)" \ 1196 $(if $(VBOX_WITH_SDS),VBOX_WITH_SDS,) 1198 $(if $(VBOX_WITH_SDS),VBOX_WITH_SDS,) \ 1199 $(if-expr defined(VBOX_WITH_SDS) && defined(VBOX_WITH_SDS_PLAN_B),VBOX_WITH_SDS_PLAN_B,) 1197 1200 VBoxProxyStub_DEFS.win.x86 = WIN32 1198 1201 VBoxProxyStub_SDKS = VBOX_NTDLL -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r69379 r69729 24373 24373 24374 24374 <if target="midl"> 24375 24376 <!-- VBOX_SDS_PLAN_B start --> 24377 <!-- 24378 // IVBoxSVC 24379 ////////////////////////////////////////////////////////////////////////// 24380 --> 24381 <interface 24382 name="IVBoxSVC" extends="$unknown" 24383 uuid="8876e618-8936-4b2c-3015-aaebe6d479b9" 24384 wsmap="suppress" 24385 reservedMethods="2" reservedAttributes="4" 24386 > 24387 <desc> 24388 Implemented by the VirtualBox class factory and registered with VBoxSDS 24389 so it can retrieve IVirtualBox on behalf of other VBoxSVCs. 24390 </desc> 24391 24392 <method name="getVirtualBox" > 24393 <desc> Gets an IUnknown interface to the VirtualBox object in the VBoxSVC process. </desc> 24394 <param name="result" type="$unknown" dir="return" > 24395 <desc> Where to return the IUnknown interface. </desc> 24396 </param> 24397 </method> 24398 24399 </interface> 24400 <!-- VBOX_SDS_PLAN_B end --> 24401 24375 24402 <!-- 24376 24403 // IVirtualBoxSDS … … 24407 24434 </method> 24408 24435 24436 <!-- VBOX_SDS_PLAN_B start --> 24437 <method name="registerVBoxSVC"> 24438 <desc>Registers a VBoxSVC instance with the SDS.</desc> 24439 <param name="vboxSVC" type="IVBoxSVC" dir="in"> 24440 <desc>Interface implemented by the VirtualBox class factory.</desc> 24441 </param> 24442 <param name="pid" type="long" dir="in"> 24443 <desc>The process ID of the VBoxSVC instance.</desc> 24444 </param> 24445 <param name="existingVirtualBox" type="$unknown" dir="return"> 24446 <desc>If there is already an VBoxSVC for this user, the an IUnknown 24447 interface to its VirtualBox object is returned here, otherwise it 24448 is set to NULL.</desc> 24449 </param> 24450 </method> 24451 24452 <method name="deregisterVBoxSVC"> 24453 <desc>Registers a VBoxSVC instance with the SDS.</desc> 24454 <param name="vboxSVC" type="IVBoxSVC" dir="in"> 24455 <desc>Same as specified during registration.</desc> 24456 </param> 24457 <param name="pid" type="long" dir="in"> 24458 <desc>The process ID of the VBoxSVC instance (same as during registration).</desc> 24459 </param> 24460 </method> 24461 <!-- VBOX_SDS_PLAN_B end --> 24462 24409 24463 </interface> 24464 24410 24465 </if> 24411 24466 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r69500 r69729 59 59 } 60 60 61 62 #if defined(VBOX_WITH_SDS_PLAN_B) && !defined(VBOX_WITH_XPCOM) 63 class VirtualBoxClassFactory; /* See ../src-server/win/svcmain.cpp */ 64 #endif 65 66 61 67 class ATL_NO_VTABLE VirtualBox : 62 68 public VirtualBoxWrap … … 74 80 friend class CallbackEvent; 75 81 82 #ifndef VBOX_WITH_XPCOM 83 # ifdef VBOX_WITH_SDS_PLAN_B 84 DECLARE_CLASSFACTORY_EX(VirtualBoxClassFactory) 85 # else 76 86 DECLARE_CLASSFACTORY_SINGLETON(VirtualBox) 87 # endif 88 #endif 77 89 78 90 // Do not use any ATL registry support. -
trunk/src/VBox/Main/include/VirtualBoxSDSImpl.h
r69500 r69729 110 110 HRESULT getVirtualBox(ComPtr<IVirtualBox> &aVirtualBox, ComPtr<IToken> &aToken); 111 111 112 /* SDS plan B interfaces: */ 113 HRESULT registerVBoxSVC(const ComPtr<IVBoxSVC> &aVBoxSVC, LONG aPid, ComPtr<IUnknown> &aExistingVirtualBox); 114 HRESULT deregisterVBoxSVC(const ComPtr<IVBoxSVC> &aVBoxSVC, LONG aPid); 115 112 116 // Wrapped IVirtualBoxSDS methods 113 117 -
trunk/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
r69500 r69729 67 67 ///////////////////////////////////////////////////////////////////////////// 68 68 69 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) 69 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) && !defined(VBOX_WITH_SDS_PLAN_B) 70 70 71 71 HRESULT CreateVirtualBoxThroughSDS(ComPtr<IVirtualBox> &aVirtualBox, ComPtr<IToken> &aToken) … … 238 238 } 239 239 240 #endif 240 #endif /* RT_OS_WINDOWS && VBOX_WITH_SDS && !VBOX_WITH_SDS_PLAN_B */ 241 241 242 242 /** … … 250 250 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) 251 251 // setup COM Security to enable impersonation 252 // This works for console Virtual 252 // This works for console VirtualBox clients, GUI has own security settings 253 253 // For GUI Virtual Box it will be second call so can return TOO_LATE error 254 254 HRESULT hrGUICoInitializeSecurity = CoInitializeSecurity(NULL, … … 289 289 mData.m_SemEvWatcher = NIL_RTSEMEVENT; 290 290 291 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) 291 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) && !defined(VBOX_WITH_SDS_PLAN_B) 292 292 rc = CreateVirtualBoxThroughSDS(mData.m_pVirtualBox, mData.m_pToken); 293 293 #else … … 383 383 IUnknown *pUnknown = NULL; 384 384 385 # if def VBOX_WITH_SDS385 # if defined(VBOX_WITH_SDS) && !defined(VBOX_WITH_SDS_PLAN_B) 386 386 // Check the VBOXSDS service running account name is SYSTEM 387 387 wchar_t wszBuffer[256]; … … 746 746 ComPtr<IVirtualBox> pVirtualBox; 747 747 ComPtr<IToken> pToken; 748 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) 748 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_SDS) && !defined(VBOX_WITH_SDS_PLAN_B) 749 749 rc = CreateVirtualBoxThroughSDS(pVirtualBox, pToken); 750 750 #else -
trunk/src/VBox/Main/src-server/win/svcmain.cpp
r69500 r69729 138 138 139 139 140 #ifdef VBOX_WITH_SDS_PLAN_B 141 142 /** 143 * Custom class factory for the VirtualBox singleton. 144 * 145 * The implementation of CreateInstance is found in win/svcmain.cpp. 146 */ 147 class VirtualBoxClassFactory : public ATL::CComClassFactory 148 { 149 private: 150 /** Tri state: 0=uninitialized or initializing; 1=success; -1=failure. 151 * This will be updated after both m_hrcCreate and m_pObj have been set. */ 152 volatile int32_t m_iState; 153 /** The result of the instantiation attempt. */ 154 HRESULT m_hrcCreate; 155 /** The IUnknown of the VirtualBox object/interface we're working with. */ 156 IUnknown *m_pObj; 157 158 public: 159 VirtualBoxClassFactory() : m_iState(0), m_hrcCreate(S_OK), m_pObj(NULL) { } 160 virtual ~VirtualBoxClassFactory() 161 { 162 if (m_pObj) 163 { 164 m_pObj->Release(); 165 m_pObj = NULL; 166 } 167 /** @todo Need to check if this is okay wrt COM termination. */ 168 i_deregisterWithSds(); 169 } 170 171 // IClassFactory 172 STDMETHOD(CreateInstance)(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj); 173 174 // IVBoxSVC 175 STDMETHOD(GetVirtualBox)(IUnknown **ppOtherObj); 176 177 private: 178 HRESULT VirtualBoxClassFactory::i_registerWithSds(IUnknown **ppOtherVirtualBox); 179 void VirtualBoxClassFactory::i_deregisterWithSds(void); 180 }; 181 182 183 HRESULT VirtualBoxClassFactory::i_registerWithSds(IUnknown **ppOtherVirtualBox) 184 { 185 *ppOtherVirtualBox = NULL; 186 return S_OK; 187 } 188 189 190 void VirtualBoxClassFactory::i_deregisterWithSds(void) 191 { 192 Log(("VirtualBoxClassFactory::i_deregisterWithSds\n")); 193 } 194 195 196 STDMETHODIMP VirtualBoxClassFactory::GetVirtualBox(IUnknown **ppUnkVirtualBox) 197 { 198 IUnknown *pObj = m_pObj; 199 if (pObj) 200 { 201 /** @todo Do we need to do something regarding server locking? Hopefully COM 202 * deals with that........... */ 203 pObj->AddRef(); 204 *ppUnkVirtualBox = pObj; 205 Log(("VirtualBoxClassFactory::GetVirtualBox: S_OK - %p\n", pObj)); 206 return S_OK; 207 } 208 *ppUnkVirtualBox = NULL; 209 Log(("VirtualBoxClassFactory::GetVirtualBox: E_FAIL\n")); 210 return E_FAIL; 211 } 212 213 214 /** 215 * Custom class factory impl for the VirtualBox singleton. 216 * 217 * This will consult with VBoxSDS on whether this VBoxSVC instance should 218 * provide the actual VirtualBox instance or just forward the instance from 219 * some other SVC instance. 220 * 221 * @param pUnkOuter This must be NULL. 222 * @param riid Reference to the interface ID to provide. 223 * @param ppvObj Where to return the pointer to the riid instance. 224 * 225 * @return COM status code. 226 */ 227 STDMETHODIMP VirtualBoxClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj) 228 { 229 HRESULT hrc = E_POINTER; 230 if (ppvObj != NULL) 231 { 232 *ppvObj = NULL; 233 // no aggregation for singletons 234 AssertReturn(pUnkOuter == NULL, CLASS_E_NOAGGREGATION); 235 236 /* 237 * We must make sure there is only one instance around. 238 * So, we check without locking and then again after locking. 239 */ 240 if (ASMAtomicReadS32(&m_iState) == 0) 241 { 242 Lock(); 243 __try 244 { 245 if (ASMAtomicReadS32(&m_iState) == 0) 246 { 247 /* 248 * lock the module to indicate activity 249 * (necessary for the monitor shutdown thread to correctly 250 * terminate the module in case when CreateInstance() fails) 251 */ 252 ATL::_pAtlModule->Lock(); 253 __try 254 { 255 /* 256 * Now we need to connect to VBoxSDS to register ourselves. 257 */ 258 IUnknown *pOtherVirtualBox = NULL; 259 m_hrcCreate = hrc = i_registerWithSds(&pOtherVirtualBox); 260 if (SUCCEEDED(hrc) && pOtherVirtualBox) 261 m_pObj = pOtherVirtualBox; 262 else if (SUCCEEDED(hrc)) 263 { 264 ATL::_pAtlModule->Lock(); 265 ATL::CComObjectCached<VirtualBox> *p; 266 m_hrcCreate = hrc = ATL::CComObjectCached<VirtualBox>::CreateInstance(&p); 267 if (SUCCEEDED(hrc)) 268 { 269 m_hrcCreate = hrc = p->QueryInterface(IID_IUnknown, (void **)&m_pObj); 270 if (FAILED(hrc)) 271 { 272 delete p; 273 i_deregisterWithSds(); 274 m_pObj = NULL; 275 } 276 } 277 } 278 ASMAtomicWriteS32(&m_iState, SUCCEEDED(hrc) ? 1 : -1); 279 } 280 __finally 281 { 282 ATL::_pAtlModule->Unlock(); 283 } 284 } 285 } 286 __finally 287 { 288 if (ASMAtomicReadS32(&m_iState) == 0) 289 { 290 ASMAtomicWriteS32(&m_iState, -1); 291 if (SUCCEEDED(m_hrcCreate)) 292 m_hrcCreate = E_FAIL; 293 } 294 Unlock(); 295 } 296 } 297 298 /* 299 * Query the requested interface from the IUnknown one we're keeping around. 300 */ 301 if (m_hrcCreate == S_OK) 302 hrc = m_pObj->QueryInterface(riid, ppvObj); 303 else 304 hrc = m_hrcCreate; 305 } 306 return hrc; 307 } 308 309 #endif /* VBOX_WITH_SDS_PLAN_B */ 310 311 140 312 BEGIN_OBJECT_MAP(ObjectMap) 141 313 OBJECT_ENTRY(CLSID_VirtualBox, VirtualBox) … … 146 318 HINSTANCE g_hInstance = NULL; 147 319 #define MAIN_WND_CLASS L"VirtualBox Interface" 320 148 321 149 322 /*
Note:
See TracChangeset
for help on using the changeset viewer.