VirtualBox

source: vbox/trunk/src/VBox/Main/glue/initterm.cpp@ 59418

最後變更 在這個檔案從59418是 59418,由 vboxsync 提交於 9 年 前

Main,Installer/win: VBoxProxyStubLegacy for 32-bit windows as well - less ifdefs and no difference in W7+ behaviour between x86 and AMD64.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 20.4 KB
 
1/* $Id: initterm.cpp 59418 2016-01-20 13:39:26Z vboxsync $ */
2
3/** @file
4 * MS COM / XPCOM Abstraction Layer - Initialization and Termination.
5 */
6
7/*
8 * Copyright (C) 2006-2014 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#if !defined(VBOX_WITH_XPCOM)
20
21# include <iprt/nt/nt-and-windows.h>
22# include <objbase.h>
23
24#else /* !defined(VBOX_WITH_XPCOM) */
25
26# include <stdlib.h>
27
28# include <nsIComponentRegistrar.h>
29# include <nsIServiceManager.h>
30# include <nsCOMPtr.h>
31# include <nsEventQueueUtils.h>
32# include <nsEmbedString.h>
33
34# include <nsILocalFile.h>
35# include <nsIDirectoryService.h>
36# include <nsDirectoryServiceDefs.h>
37
38#endif /* !defined(VBOX_WITH_XPCOM) */
39
40#include "VBox/com/com.h"
41#include "VBox/com/assert.h"
42#include "VBox/com/NativeEventQueue.h"
43#include "VBox/com/AutoLock.h"
44
45#include "../include/Logging.h"
46
47#include <iprt/asm.h>
48#include <iprt/env.h>
49#include <iprt/ldr.h>
50#include <iprt/param.h>
51#include <iprt/path.h>
52#include <iprt/string.h>
53#include <iprt/thread.h>
54
55#include <VBox/err.h>
56
57namespace com
58{
59
60#if defined(VBOX_WITH_XPCOM)
61
62class DirectoryServiceProvider : public nsIDirectoryServiceProvider
63{
64public:
65
66 NS_DECL_ISUPPORTS
67
68 DirectoryServiceProvider()
69 : mCompRegLocation(NULL), mXPTIDatLocation(NULL)
70 , mComponentDirLocation(NULL), mCurrProcDirLocation(NULL)
71 {}
72
73 virtual ~DirectoryServiceProvider();
74
75 HRESULT init(const char *aCompRegLocation,
76 const char *aXPTIDatLocation,
77 const char *aComponentDirLocation,
78 const char *aCurrProcDirLocation);
79
80 NS_DECL_NSIDIRECTORYSERVICEPROVIDER
81
82private:
83 /** @remarks This is not a UTF-8 string. */
84 char *mCompRegLocation;
85 /** @remarks This is not a UTF-8 string. */
86 char *mXPTIDatLocation;
87 /** @remarks This is not a UTF-8 string. */
88 char *mComponentDirLocation;
89 /** @remarks This is not a UTF-8 string. */
90 char *mCurrProcDirLocation;
91};
92
93NS_IMPL_ISUPPORTS1(DirectoryServiceProvider, nsIDirectoryServiceProvider)
94
95DirectoryServiceProvider::~DirectoryServiceProvider()
96{
97 if (mCompRegLocation)
98 {
99 RTStrFree(mCompRegLocation);
100 mCompRegLocation = NULL;
101 }
102 if (mXPTIDatLocation)
103 {
104 RTStrFree(mXPTIDatLocation);
105 mXPTIDatLocation = NULL;
106 }
107 if (mComponentDirLocation)
108 {
109 RTStrFree(mComponentDirLocation);
110 mComponentDirLocation = NULL;
111 }
112 if (mCurrProcDirLocation)
113 {
114 RTStrFree(mCurrProcDirLocation);
115 mCurrProcDirLocation = NULL;
116 }
117}
118
119/**
120 * @param aCompRegLocation Path to compreg.dat, in Utf8.
121 * @param aXPTIDatLocation Path to xpti.data, in Utf8.
122 */
123HRESULT
124DirectoryServiceProvider::init(const char *aCompRegLocation,
125 const char *aXPTIDatLocation,
126 const char *aComponentDirLocation,
127 const char *aCurrProcDirLocation)
128{
129 AssertReturn(aCompRegLocation, NS_ERROR_INVALID_ARG);
130 AssertReturn(aXPTIDatLocation, NS_ERROR_INVALID_ARG);
131
132/** @todo r=bird: Gotta check how this encoding stuff plays out on darwin!
133 * We get down to [VBoxNsxp]NS_NewNativeLocalFile and that file isn't
134 * nsLocalFileUnix.cpp on 32-bit darwin. On 64-bit darwin it's a question
135 * of what we're doing in IPRT and such... We should probably add a
136 * RTPathConvertToNative for use here. */
137 int vrc = RTStrUtf8ToCurrentCP(&mCompRegLocation, aCompRegLocation);
138 if (RT_SUCCESS(vrc))
139 vrc = RTStrUtf8ToCurrentCP(&mXPTIDatLocation, aXPTIDatLocation);
140 if (RT_SUCCESS(vrc) && aComponentDirLocation)
141 vrc = RTStrUtf8ToCurrentCP(&mComponentDirLocation, aComponentDirLocation);
142 if (RT_SUCCESS(vrc) && aCurrProcDirLocation)
143 vrc = RTStrUtf8ToCurrentCP(&mCurrProcDirLocation, aCurrProcDirLocation);
144
145 return RT_SUCCESS(vrc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
146}
147
148NS_IMETHODIMP
149DirectoryServiceProvider::GetFile(const char *aProp,
150 PRBool *aPersistent,
151 nsIFile **aRetval)
152{
153 nsCOMPtr <nsILocalFile> localFile;
154 nsresult rv = NS_ERROR_FAILURE;
155
156 *aRetval = nsnull;
157 *aPersistent = PR_TRUE;
158
159 const char *fileLocation = NULL;
160
161 if (strcmp(aProp, NS_XPCOM_COMPONENT_REGISTRY_FILE) == 0)
162 fileLocation = mCompRegLocation;
163 else if (strcmp(aProp, NS_XPCOM_XPTI_REGISTRY_FILE) == 0)
164 fileLocation = mXPTIDatLocation;
165 else if (mComponentDirLocation && strcmp(aProp, NS_XPCOM_COMPONENT_DIR) == 0)
166 fileLocation = mComponentDirLocation;
167 else if (mCurrProcDirLocation && strcmp(aProp, NS_XPCOM_CURRENT_PROCESS_DIR) == 0)
168 fileLocation = mCurrProcDirLocation;
169 else
170 return NS_ERROR_FAILURE;
171
172 rv = NS_NewNativeLocalFile(nsEmbedCString(fileLocation),
173 PR_TRUE, getter_AddRefs(localFile));
174 if (NS_FAILED(rv))
175 return rv;
176
177 return localFile->QueryInterface(NS_GET_IID(nsIFile), (void **)aRetval);
178}
179
180/**
181 * Global XPCOM initialization flag (we maintain it ourselves since XPCOM
182 * doesn't provide such functionality)
183 */
184static bool volatile gIsXPCOMInitialized = false;
185
186/**
187 * Number of Initialize() calls on the main thread.
188 */
189static unsigned int gXPCOMInitCount = 0;
190
191#else /* !defined(VBOX_WITH_XPCOM) */
192
193/**
194 * The COM main thread handle. (The first caller of com::Initialize().)
195 */
196static RTTHREAD volatile gCOMMainThread = NIL_RTTHREAD;
197
198/**
199 * Number of Initialize() calls on the main thread.
200 */
201static uint32_t gCOMMainInitCount = 0;
202
203#endif /* !defined(VBOX_WITH_XPCOM) */
204
205
206/**
207 * Initializes the COM runtime.
208 *
209 * This method must be called on each thread of the client application that
210 * wants to access COM facilities. The initialization must be performed before
211 * calling any other COM method or attempting to instantiate COM objects.
212 *
213 * On platforms using XPCOM, this method uses the following scheme to search for
214 * XPCOM runtime:
215 *
216 * 1. If the VBOX_APP_HOME environment variable is set, the path it specifies
217 * is used to search XPCOM libraries and components. If this method fails to
218 * initialize XPCOM runtime using this path, it will immediately return a
219 * failure and will NOT check for other paths as described below.
220 *
221 * 2. If VBOX_APP_HOME is not set, this methods tries the following paths in the
222 * given order:
223 *
224 * a) Compiled-in application data directory (as returned by
225 * RTPathAppPrivateArch())
226 * b) "/usr/lib/virtualbox" (Linux only)
227 * c) "/opt/VirtualBox" (Linux only)
228 *
229 * The first path for which the initialization succeeds will be used.
230 *
231 * On MS COM platforms, the COM runtime is provided by the system and does not
232 * need to be searched for.
233 *
234 * Once the COM subsystem is no longer necessary on a given thread, Shutdown()
235 * must be called to free resources allocated for it. Note that a thread may
236 * call Initialize() several times but for each of tese calls there must be a
237 * corresponding Shutdown() call.
238 *
239 * @return S_OK on success and a COM result code in case of failure.
240 */
241HRESULT Initialize(bool fGui /*= false*/, bool fAutoRegUpdate /*= true*/)
242{
243 HRESULT rc = E_FAIL;
244 NOREF(fAutoRegUpdate);
245
246#if !defined(VBOX_WITH_XPCOM)
247
248# ifdef VBOX_WITH_AUTO_COM_REG_UPDATE
249 /*
250 * First time we're called in a process, we refresh the VBox COM registrations.
251 */
252 if (fAutoRegUpdate && gCOMMainThread == NIL_RTTHREAD)
253 {
254 char szPath[RTPATH_MAX];
255 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
256 if (RT_SUCCESS(vrc))
257 {
258# ifndef VBOX_IN_32_ON_64_MAIN_API
259 rc = RTPathAppend(szPath, sizeof(szPath),
260 RT_MAKE_U64(((PKUSER_SHARED_DATA)MM_SHARED_USER_DATA_VA)->NtMinorVersion,
261 ((PKUSER_SHARED_DATA)MM_SHARED_USER_DATA_VA)->NtMajorVersion)
262 >= RT_MAKE_U64(1/*Lo*/,6/*Hi*/)
263 ? "VBoxProxyStub.dll" : "VBoxProxyStubLegacy.dll");
264# else
265 rc = RTPathAppend(szPath, sizeof(szPath), "x86\\VBoxProxyStub-x86.dll");
266# endif
267 }
268 if (RT_SUCCESS(vrc))
269 {
270 RTLDRMOD hMod;
271 vrc = RTLdrLoad(szPath, &hMod);
272 if (RT_SUCCESS(vrc))
273 {
274 union
275 {
276 void *pv;
277 DECLCALLBACKMEMBER(uint32_t, pfnRegUpdate)(void);
278 } u;
279 rc = RTLdrGetSymbol(hMod, "VbpsUpdateRegistrations", &u.pv);
280 if (RT_SUCCESS(rc))
281 u.pfnRegUpdate();
282 /* Just keep it loaded. */
283 }
284 }
285 }
286# endif
287
288 /*
289 * We initialize COM in GUI thread in STA, to be compliant with QT and
290 * OLE requirments (for example to allow D&D), while other threads
291 * initialized in regular MTA. To allow fast proxyless access from
292 * GUI thread to COM objects, we explicitly provide our COM objects
293 * with free threaded marshaller.
294 * !!!!! Please think twice before touching this code !!!!!
295 */
296 DWORD flags = fGui ?
297 COINIT_APARTMENTTHREADED
298 | COINIT_SPEED_OVER_MEMORY
299 :
300 COINIT_MULTITHREADED
301 | COINIT_DISABLE_OLE1DDE
302 | COINIT_SPEED_OVER_MEMORY;
303
304 rc = CoInitializeEx(NULL, flags);
305
306 /* the overall result must be either S_OK or S_FALSE (S_FALSE means
307 * "already initialized using the same apartment model") */
308 AssertMsg(rc == S_OK || rc == S_FALSE, ("rc=%08X\n", rc));
309
310 /* To be flow compatible with the XPCOM case, we return here if this isn't
311 * the main thread or if it isn't its first initialization call.
312 * Note! CoInitializeEx and CoUninitialize does it's own reference
313 * counting, so this exercise is entirely for the EventQueue init. */
314 bool fRc;
315 RTTHREAD hSelf = RTThreadSelf();
316 if (hSelf != NIL_RTTHREAD)
317 ASMAtomicCmpXchgHandle(&gCOMMainThread, hSelf, NIL_RTTHREAD, fRc);
318 else
319 fRc = false;
320
321 if (fGui)
322 Assert(RTThreadIsMain(hSelf));
323
324 if (!fRc)
325 {
326 if ( gCOMMainThread == hSelf
327 && SUCCEEDED(rc))
328 gCOMMainInitCount++;
329
330 AssertComRC(rc);
331 return rc;
332 }
333 Assert(RTThreadIsMain(hSelf));
334
335 /* this is the first main thread initialization */
336 Assert(gCOMMainInitCount == 0);
337 if (SUCCEEDED(rc))
338 gCOMMainInitCount = 1;
339
340#else /* !defined(VBOX_WITH_XPCOM) */
341
342 /* Unused here */
343 NOREF(fGui);
344
345 if (ASMAtomicXchgBool(&gIsXPCOMInitialized, true) == true)
346 {
347 /* XPCOM is already initialized on the main thread, no special
348 * initialization is necessary on additional threads. Just increase
349 * the init counter if it's a main thread again (to correctly support
350 * nested calls to Initialize()/Shutdown() for compatibility with
351 * Win32). */
352
353 nsCOMPtr<nsIEventQueue> eventQ;
354 rc = NS_GetMainEventQ(getter_AddRefs(eventQ));
355
356 if (NS_SUCCEEDED(rc))
357 {
358 PRBool isOnMainThread = PR_FALSE;
359 rc = eventQ->IsOnCurrentThread(&isOnMainThread);
360 if (NS_SUCCEEDED(rc) && isOnMainThread)
361 ++gXPCOMInitCount;
362 }
363
364 AssertComRC(rc);
365 return rc;
366 }
367 Assert(RTThreadIsMain(RTThreadSelf()));
368
369 /* this is the first initialization */
370 gXPCOMInitCount = 1;
371
372 /* prepare paths for registry files */
373 char szCompReg[RTPATH_MAX];
374 char szXptiDat[RTPATH_MAX];
375
376 int vrc = GetVBoxUserHomeDirectory(szCompReg, sizeof(szCompReg));
377 if (vrc == VERR_ACCESS_DENIED)
378 return NS_ERROR_FILE_ACCESS_DENIED;
379 AssertRCReturn(vrc, NS_ERROR_FAILURE);
380 vrc = RTStrCopy(szXptiDat, sizeof(szXptiDat), szCompReg);
381 AssertRCReturn(vrc, NS_ERROR_FAILURE);
382#ifdef VBOX_IN_32_ON_64_MAIN_API
383 vrc = RTPathAppend(szCompReg, sizeof(szCompReg), "compreg-x86.dat");
384 AssertRCReturn(vrc, NS_ERROR_FAILURE);
385 vrc = RTPathAppend(szXptiDat, sizeof(szXptiDat), "xpti-x86.dat");
386 AssertRCReturn(vrc, NS_ERROR_FAILURE);
387#else
388 vrc = RTPathAppend(szCompReg, sizeof(szCompReg), "compreg.dat");
389 AssertRCReturn(vrc, NS_ERROR_FAILURE);
390 vrc = RTPathAppend(szXptiDat, sizeof(szXptiDat), "xpti.dat");
391 AssertRCReturn(vrc, NS_ERROR_FAILURE);
392#endif
393
394 LogFlowFunc(("component registry : \"%s\"\n", szCompReg));
395 LogFlowFunc(("XPTI data file : \"%s\"\n", szXptiDat));
396
397 static const char *kAppPathsToProbe[] =
398 {
399 NULL, /* 0: will use VBOX_APP_HOME */
400 NULL, /* 1: will try RTPathAppPrivateArch(), correctly installed release builds will never go further */
401 NULL, /* 2: will try parent directory of RTPathAppPrivateArch(), only for testcases in non-hardened builds */
402 /* There used to be hard coded paths, but they only caused trouble
403 * because they often led to mixing of builds or even versions.
404 * If you feel tempted to add anything here, think again. They would
405 * only be used if option 1 would not work, which is a sign of a big
406 * problem, as it returns a fixed location defined at compile time.
407 * It is better to fail than blindly trying to cover the problem. */
408 };
409
410 /* Find out the directory where VirtualBox binaries are located */
411 for (size_t i = 0; i < RT_ELEMENTS(kAppPathsToProbe); ++ i)
412 {
413 char szAppHomeDir[RTPATH_MAX];
414
415 if (i == 0)
416 {
417 /* Use VBOX_APP_HOME if present */
418 vrc = RTEnvGetEx(RTENV_DEFAULT, "VBOX_APP_HOME", szAppHomeDir, sizeof(szAppHomeDir), NULL);
419 if (vrc == VERR_ENV_VAR_NOT_FOUND)
420 continue;
421 AssertRC(vrc);
422 }
423 else if (i == 1)
424 {
425 /* Use RTPathAppPrivateArch() first */
426 vrc = RTPathAppPrivateArch(szAppHomeDir, sizeof(szAppHomeDir));
427 AssertRC(vrc);
428 }
429 else if (i == 2)
430 {
431#ifdef VBOX_WITH_HARDENING
432 continue;
433#else /* !VBOX_WITH_HARDENING */
434 /* Use parent of RTPathAppPrivateArch() if ends with "testcase" */
435 vrc = RTPathAppPrivateArch(szAppHomeDir, sizeof(szAppHomeDir));
436 AssertRC(vrc);
437 vrc = RTPathStripTrailingSlash(szAppHomeDir);
438 AssertRC(vrc);
439 char *filename = RTPathFilename(szAppHomeDir);
440 if (!filename || strcmp(filename, "testcase"))
441 continue;
442 RTPathStripFilename(szAppHomeDir);
443#endif /* !VBOX_WITH_HARDENING */
444 }
445 else
446 {
447 /* Iterate over all other paths */
448 RTStrCopy(szAppHomeDir, sizeof(szAppHomeDir), kAppPathsToProbe[i]);
449 vrc = VINF_SUCCESS;
450 }
451 if (RT_FAILURE(vrc))
452 {
453 rc = NS_ERROR_FAILURE;
454 continue;
455 }
456 char szCompDir[RTPATH_MAX];
457 vrc = RTStrCopy(szCompDir, sizeof(szCompDir), szAppHomeDir);
458 if (RT_FAILURE(vrc))
459 {
460 rc = NS_ERROR_FAILURE;
461 continue;
462 }
463 vrc = RTPathAppend(szCompDir, sizeof(szCompDir), "components");
464 if (RT_FAILURE(vrc))
465 {
466 rc = NS_ERROR_FAILURE;
467 continue;
468 }
469 LogFlowFunc(("component directory : \"%s\"\n", szCompDir));
470
471 nsCOMPtr<DirectoryServiceProvider> dsProv;
472 dsProv = new DirectoryServiceProvider();
473 if (dsProv)
474 rc = dsProv->init(szCompReg, szXptiDat, szCompDir, szAppHomeDir);
475 else
476 rc = NS_ERROR_OUT_OF_MEMORY;
477 if (NS_FAILED(rc))
478 break;
479
480 /* Setup the application path for NS_InitXPCOM2. Note that we properly
481 * answer the NS_XPCOM_CURRENT_PROCESS_DIR query in our directory
482 * service provider but it seems to be activated after the directory
483 * service is used for the first time (see the source NS_InitXPCOM2). So
484 * use the same value here to be on the safe side. */
485 nsCOMPtr <nsIFile> appDir;
486 {
487 char *appDirCP = NULL;
488 vrc = RTStrUtf8ToCurrentCP(&appDirCP, szAppHomeDir);
489 if (RT_SUCCESS(vrc))
490 {
491 nsCOMPtr<nsILocalFile> file;
492 rc = NS_NewNativeLocalFile(nsEmbedCString(appDirCP),
493 PR_FALSE, getter_AddRefs(file));
494 if (NS_SUCCEEDED(rc))
495 appDir = do_QueryInterface(file, &rc);
496
497 RTStrFree(appDirCP);
498 }
499 else
500 rc = NS_ERROR_FAILURE;
501 }
502 if (NS_FAILED(rc))
503 break;
504
505 /* Set VBOX_XPCOM_HOME to the same app path to make XPCOM sources that
506 * still use it instead of the directory service happy */
507 vrc = RTEnvSetEx(RTENV_DEFAULT, "VBOX_XPCOM_HOME", szAppHomeDir);
508 AssertRC(vrc);
509
510 /* Finally, initialize XPCOM */
511 {
512 nsCOMPtr<nsIServiceManager> serviceManager;
513 rc = NS_InitXPCOM2(getter_AddRefs(serviceManager), appDir, dsProv);
514 if (NS_SUCCEEDED(rc))
515 {
516 nsCOMPtr<nsIComponentRegistrar> registrar =
517 do_QueryInterface(serviceManager, &rc);
518 if (NS_SUCCEEDED(rc))
519 {
520 rc = registrar->AutoRegister(nsnull);
521 if (NS_SUCCEEDED(rc))
522 {
523 /* We succeeded, stop probing paths */
524 LogFlowFunc(("Succeeded.\n"));
525 break;
526 }
527 }
528 }
529 }
530
531 /* clean up before the new try */
532 HRESULT rc2 = NS_ShutdownXPCOM(nsnull);
533 if (SUCCEEDED(rc))
534 rc = rc2;
535
536 if (i == 0)
537 {
538 /* We failed with VBOX_APP_HOME, don't probe other paths */
539 break;
540 }
541 }
542
543#endif /* !defined(VBOX_WITH_XPCOM) */
544
545 AssertComRCReturnRC(rc);
546
547 // for both COM and XPCOM, we only get here if this is the main thread;
548 // only then initialize the autolock system (AutoLock.cpp)
549 Assert(RTThreadIsMain(RTThreadSelf()));
550 util::InitAutoLockSystem();
551
552 /*
553 * Init the main event queue (ASSUMES it cannot fail).
554 */
555 if (SUCCEEDED(rc))
556 NativeEventQueue::init();
557
558 return rc;
559}
560
561HRESULT Shutdown()
562{
563 HRESULT rc = S_OK;
564
565#if !defined(VBOX_WITH_XPCOM)
566
567 /* EventQueue::uninit reference counting fun. */
568 RTTHREAD hSelf = RTThreadSelf();
569 if ( hSelf == gCOMMainThread
570 && hSelf != NIL_RTTHREAD)
571 {
572 if (-- gCOMMainInitCount == 0)
573 {
574 NativeEventQueue::uninit();
575 ASMAtomicWriteHandle(&gCOMMainThread, NIL_RTTHREAD);
576 }
577 }
578
579 CoUninitialize();
580
581#else /* !defined(VBOX_WITH_XPCOM) */
582
583 nsCOMPtr<nsIEventQueue> eventQ;
584 rc = NS_GetMainEventQ(getter_AddRefs(eventQ));
585
586 if (NS_SUCCEEDED(rc) || rc == NS_ERROR_NOT_AVAILABLE)
587 {
588 /* NS_ERROR_NOT_AVAILABLE seems to mean that
589 * nsIEventQueue::StopAcceptingEvents() has been called (see
590 * nsEventQueueService.cpp). We hope that this error code always means
591 * just that in this case and assume that we're on the main thread
592 * (it's a kind of unexpected behavior if a non-main thread ever calls
593 * StopAcceptingEvents() on the main event queue). */
594
595 PRBool isOnMainThread = PR_FALSE;
596 if (NS_SUCCEEDED(rc))
597 {
598 rc = eventQ->IsOnCurrentThread(&isOnMainThread);
599 eventQ = nsnull; /* early release before shutdown */
600 }
601 else
602 {
603 isOnMainThread = RTThreadIsMain(RTThreadSelf());
604 rc = NS_OK;
605 }
606
607 if (NS_SUCCEEDED(rc) && isOnMainThread)
608 {
609 /* only the main thread needs to uninitialize XPCOM and only if
610 * init counter drops to zero */
611 if (--gXPCOMInitCount == 0)
612 {
613 NativeEventQueue::uninit();
614 rc = NS_ShutdownXPCOM(nsnull);
615
616 /* This is a thread initialized XPCOM and set gIsXPCOMInitialized to
617 * true. Reset it back to false. */
618 bool wasInited = ASMAtomicXchgBool(&gIsXPCOMInitialized, false);
619 Assert(wasInited == true);
620 NOREF(wasInited);
621 }
622 }
623 }
624
625#endif /* !defined(VBOX_WITH_XPCOM) */
626
627 AssertComRC(rc);
628
629 return rc;
630}
631
632} /* namespace com */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette