VirtualBox

source: vbox/trunk/src/VBox/Main/include/VirtualBoxClientImpl.h@ 68938

Last change on this file since 68938 was 66902, checked in by vboxsync, 8 years ago

VBox/Main: ​bugref:3300: VBoxSVC from terminal server session is not 'visible' - added client token to track client lifetime

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: VirtualBoxClientImpl.h 66902 2017-05-15 23:21:57Z vboxsync $ */
2
3/** @file
4 * Header file for the VirtualBoxClient (IVirtualBoxClient) class, VBoxC.
5 */
6
7/*
8 * Copyright (C) 2010-2016 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.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#ifndef ____H_VIRTUALBOXCLIENTIMPL
20#define ____H_VIRTUALBOXCLIENTIMPL
21
22#include "VirtualBoxClientWrap.h"
23#include "EventImpl.h"
24
25#ifdef RT_OS_WINDOWS
26# include "win/resource.h"
27#endif
28
29class ATL_NO_VTABLE VirtualBoxClient :
30 public VirtualBoxClientWrap
31#ifdef RT_OS_WINDOWS
32 , public ATL::CComCoClass<VirtualBoxClient, &CLSID_VirtualBoxClient>
33#endif
34{
35public:
36 DECLARE_CLASSFACTORY_SINGLETON(VirtualBoxClient)
37
38 // Do not use any ATL registry support.
39 //DECLARE_REGISTRY_RESOURCEID(IDR_VIRTUALBOX)
40
41 DECLARE_NOT_AGGREGATABLE(VirtualBoxClient)
42
43 HRESULT FinalConstruct();
44 void FinalRelease();
45
46 // public initializer/uninitializer for internal purposes only
47 HRESULT init();
48 void uninit();
49
50#ifdef RT_OS_WINDOWS
51 /* HACK ALERT! Implemented in dllmain.cpp. */
52 ULONG InternalRelease();
53#endif
54
55private:
56 // wrapped IVirtualBoxClient properties
57 virtual HRESULT getVirtualBox(ComPtr<IVirtualBox> &aVirtualBox);
58 virtual HRESULT getSession(ComPtr<ISession> &aSession);
59 virtual HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
60
61 // wrapped IVirtualBoxClient methods
62 virtual HRESULT checkMachineError(const ComPtr<IMachine> &aMachine);
63
64 /** Instance counter for simulating something similar to a singleton.
65 * Only the first instance will be a usable object, all additional
66 * instances will return a failure at creation time and will not work. */
67 static uint32_t g_cInstances;
68
69#ifdef RT_OS_WINDOWS
70 virtual HRESULT i_investigateVirtualBoxObjectCreationFailure(HRESULT hrc);
71#endif
72
73#ifdef VBOX_WITH_SDS
74 int getServiceAccount(const wchar_t *pwszServiceName, wchar_t *pwszAccountName, size_t cwcAccountName);
75 HRESULT isServiceDisabled(const wchar_t *pwszServiceName, bool *pfOutIsDisabled);
76#endif
77
78 static DECLCALLBACK(int) SVCWatcherThread(RTTHREAD ThreadSelf, void *pvUser);
79
80 struct Data
81 {
82 Data() : m_ThreadWatcher(NIL_RTTHREAD), m_SemEvWatcher(NIL_RTSEMEVENT)
83 {}
84
85 ~Data()
86 {
87 /* HACK ALERT! This is for DllCanUnloadNow(). */
88 if (m_pEventSource.isNotNull())
89 {
90 s_cUnnecessaryAtlModuleLocks--;
91 AssertMsg(s_cUnnecessaryAtlModuleLocks == 0, ("%d\n", s_cUnnecessaryAtlModuleLocks));
92 }
93 }
94
95 ComPtr<IVirtualBox> m_pVirtualBox;
96 ComPtr<IToken> m_pToken;
97 const ComObjPtr<EventSource> m_pEventSource;
98
99 RTTHREAD m_ThreadWatcher;
100 RTSEMEVENT m_SemEvWatcher;
101 };
102
103 Data mData;
104
105public:
106 /** Hack for discounting the AtlModule lock held by Data::m_pEventSource during
107 * DllCanUnloadNow(). This is incremented to 1 when init() initialized
108 * m_pEventSource and is decremented by the Data destructor (above). */
109 static LONG s_cUnnecessaryAtlModuleLocks;
110};
111
112#endif
113/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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