[13659] | 1 | /* $Id: VirtualBoxClientImpl.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
[34416] | 3 | * Header file for the VirtualBoxClient (IVirtualBoxClient) class, VBoxC.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
[1] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[1] | 26 | */
|
---|
| 27 |
|
---|
[76562] | 28 | #ifndef MAIN_INCLUDED_VirtualBoxClientImpl_h
|
---|
| 29 | #define MAIN_INCLUDED_VirtualBoxClientImpl_h
|
---|
[76487] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[1] | 33 |
|
---|
[52442] | 34 | #include "VirtualBoxClientWrap.h"
|
---|
[34416] | 35 | #include "EventImpl.h"
|
---|
[91373] | 36 | #include "VirtualBoxTranslator.h"
|
---|
[1] | 37 |
|
---|
[34421] | 38 | #ifdef RT_OS_WINDOWS
|
---|
| 39 | # include "win/resource.h"
|
---|
| 40 | #endif
|
---|
| 41 |
|
---|
[34416] | 42 | class ATL_NO_VTABLE VirtualBoxClient :
|
---|
[52442] | 43 | public VirtualBoxClientWrap
|
---|
[34416] | 44 | #ifdef RT_OS_WINDOWS
|
---|
[60765] | 45 | , public ATL::CComCoClass<VirtualBoxClient, &CLSID_VirtualBoxClient>
|
---|
[34416] | 46 | #endif
|
---|
[1] | 47 | {
|
---|
| 48 | public:
|
---|
[62258] | 49 | DECLARE_CLASSFACTORY_SINGLETON(VirtualBoxClient)
|
---|
[1] | 50 |
|
---|
[60765] | 51 | // Do not use any ATL registry support.
|
---|
| 52 | //DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)
|
---|
[52442] | 53 |
|
---|
[34416] | 54 | DECLARE_NOT_AGGREGATABLE(VirtualBoxClient)
|
---|
| 55 |
|
---|
[13659] | 56 | HRESULT FinalConstruct();
|
---|
| 57 | void FinalRelease();
|
---|
| 58 |
|
---|
[1] | 59 | // public initializer/uninitializer for internal purposes only
|
---|
[34416] | 60 | HRESULT init();
|
---|
[13659] | 61 | void uninit();
|
---|
[1] | 62 |
|
---|
[63643] | 63 | #ifdef RT_OS_WINDOWS
|
---|
| 64 | /* HACK ALERT! Implemented in dllmain.cpp. */
|
---|
| 65 | ULONG InternalRelease();
|
---|
| 66 | #endif
|
---|
| 67 |
|
---|
[52442] | 68 | private:
|
---|
| 69 | // wrapped IVirtualBoxClient properties
|
---|
| 70 | virtual HRESULT getVirtualBox(ComPtr<IVirtualBox> &aVirtualBox);
|
---|
| 71 | virtual HRESULT getSession(ComPtr<ISession> &aSession);
|
---|
| 72 | virtual HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
[1] | 73 |
|
---|
[52442] | 74 | // wrapped IVirtualBoxClient methods
|
---|
| 75 | virtual HRESULT checkMachineError(const ComPtr<IMachine> &aMachine);
|
---|
| 76 |
|
---|
[34642] | 77 | /** Instance counter for simulating something similar to a singleton.
|
---|
| 78 | * Only the first instance will be a usable object, all additional
|
---|
| 79 | * instances will return a failure at creation time and will not work. */
|
---|
| 80 | static uint32_t g_cInstances;
|
---|
[1] | 81 |
|
---|
[63814] | 82 | #ifdef RT_OS_WINDOWS
|
---|
| 83 | virtual HRESULT i_investigateVirtualBoxObjectCreationFailure(HRESULT hrc);
|
---|
| 84 | #endif
|
---|
| 85 |
|
---|
[66411] | 86 | #ifdef VBOX_WITH_SDS
|
---|
[69804] | 87 | int i_getServiceAccountAndStartType(const wchar_t *pwszServiceName,
|
---|
| 88 | wchar_t *pwszAccountName, size_t cwcAccountName, uint32_t *puStartType);
|
---|
[66411] | 89 | #endif
|
---|
| 90 |
|
---|
[34416] | 91 | static DECLCALLBACK(int) SVCWatcherThread(RTTHREAD ThreadSelf, void *pvUser);
|
---|
| 92 |
|
---|
[13659] | 93 | struct Data
|
---|
| 94 | {
|
---|
[91592] | 95 | Data()
|
---|
| 96 | : m_ThreadWatcher(NIL_RTTHREAD)
|
---|
| 97 | , m_SemEvWatcher(NIL_RTSEMEVENT)
|
---|
| 98 | #ifdef VBOX_WITH_MAIN_NLS
|
---|
| 99 | , m_pVBoxTranslator(NULL)
|
---|
| 100 | , m_pTrComponent(NULL)
|
---|
| 101 | #endif
|
---|
[34416] | 102 | {}
|
---|
[13659] | 103 |
|
---|
[63639] | 104 | ~Data()
|
---|
| 105 | {
|
---|
| 106 | /* HACK ALERT! This is for DllCanUnloadNow(). */
|
---|
| 107 | if (m_pEventSource.isNotNull())
|
---|
| 108 | {
|
---|
| 109 | s_cUnnecessaryAtlModuleLocks--;
|
---|
| 110 | AssertMsg(s_cUnnecessaryAtlModuleLocks == 0, ("%d\n", s_cUnnecessaryAtlModuleLocks));
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[35135] | 114 | ComPtr<IVirtualBox> m_pVirtualBox;
|
---|
[66902] | 115 | ComPtr<IToken> m_pToken;
|
---|
[34416] | 116 | const ComObjPtr<EventSource> m_pEventSource;
|
---|
[90879] | 117 | ComPtr<IEventSource> m_pVBoxEventSource;
|
---|
| 118 | ComPtr<IEventListener> m_pVBoxEventListener;
|
---|
[13659] | 119 |
|
---|
[34416] | 120 | RTTHREAD m_ThreadWatcher;
|
---|
| 121 | RTSEMEVENT m_SemEvWatcher;
|
---|
[90828] | 122 | #ifdef VBOX_WITH_MAIN_NLS
|
---|
| 123 | VirtualBoxTranslator *m_pVBoxTranslator;
|
---|
[91390] | 124 | PTRCOMPONENT m_pTrComponent;
|
---|
[90828] | 125 | #endif
|
---|
[13659] | 126 | };
|
---|
| 127 |
|
---|
| 128 | Data mData;
|
---|
[63639] | 129 |
|
---|
| 130 | public:
|
---|
| 131 | /** Hack for discounting the AtlModule lock held by Data::m_pEventSource during
|
---|
| 132 | * DllCanUnloadNow(). This is incremented to 1 when init() initialized
|
---|
| 133 | * m_pEventSource and is decremented by the Data destructor (above). */
|
---|
| 134 | static LONG s_cUnnecessaryAtlModuleLocks;
|
---|
[90828] | 135 |
|
---|
| 136 | #ifdef VBOX_WITH_MAIN_NLS
|
---|
| 137 | HRESULT i_reloadApiLanguage();
|
---|
| 138 | HRESULT i_registerEventListener();
|
---|
[90879] | 139 | void i_unregisterEventListener();
|
---|
[90828] | 140 | #endif
|
---|
[1] | 141 | };
|
---|
| 142 |
|
---|
[76562] | 143 | #endif /* !MAIN_INCLUDED_VirtualBoxClientImpl_h */
|
---|
[14949] | 144 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|