1 | /* $Id: GuestSessionImpl.h 75891 2018-12-03 11:27:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - Guest session handling.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012-2018 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_GUESTSESSIONIMPL
|
---|
19 | #define ____H_GUESTSESSIONIMPL
|
---|
20 |
|
---|
21 | #include "GuestSessionWrap.h"
|
---|
22 | #include "EventImpl.h"
|
---|
23 |
|
---|
24 | #include "GuestCtrlImplPrivate.h"
|
---|
25 | #include "GuestProcessImpl.h"
|
---|
26 | #include "GuestDirectoryImpl.h"
|
---|
27 | #include "GuestFileImpl.h"
|
---|
28 | #include "GuestFsObjInfoImpl.h"
|
---|
29 | #include "GuestSessionImplTasks.h"
|
---|
30 |
|
---|
31 | #include <iprt/asm.h> /** @todo r=bird: Needed for ASMBitSet() in GuestSession::Data constructor. Removed when
|
---|
32 | * that is moved into the class implementation file as it should be. */
|
---|
33 | #include <deque>
|
---|
34 |
|
---|
35 | class GuestSessionTaskInternalOpen; /* Needed for i_startSessionThreadTask(). */
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Guest session implementation.
|
---|
39 | */
|
---|
40 | class ATL_NO_VTABLE GuestSession
|
---|
41 | : public GuestSessionWrap
|
---|
42 | , public GuestBase
|
---|
43 | {
|
---|
44 | public:
|
---|
45 | /** @name COM and internal init/term/mapping cruft.
|
---|
46 | * @{ */
|
---|
47 | DECLARE_EMPTY_CTOR_DTOR(GuestSession)
|
---|
48 |
|
---|
49 | int init(Guest *pGuest, const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds);
|
---|
50 | void uninit(void);
|
---|
51 | HRESULT FinalConstruct(void);
|
---|
52 | void FinalRelease(void);
|
---|
53 | /** @} */
|
---|
54 |
|
---|
55 | private:
|
---|
56 |
|
---|
57 | /** Wrapped @name IGuestSession properties.
|
---|
58 | * @{ */
|
---|
59 | HRESULT getUser(com::Utf8Str &aUser);
|
---|
60 | HRESULT getDomain(com::Utf8Str &aDomain);
|
---|
61 | HRESULT getName(com::Utf8Str &aName);
|
---|
62 | HRESULT getId(ULONG *aId);
|
---|
63 | HRESULT getTimeout(ULONG *aTimeout);
|
---|
64 | HRESULT setTimeout(ULONG aTimeout);
|
---|
65 | HRESULT getProtocolVersion(ULONG *aProtocolVersion);
|
---|
66 | HRESULT getStatus(GuestSessionStatus_T *aStatus);
|
---|
67 | HRESULT getEnvironmentChanges(std::vector<com::Utf8Str> &aEnvironmentChanges);
|
---|
68 | HRESULT setEnvironmentChanges(const std::vector<com::Utf8Str> &aEnvironmentChanges);
|
---|
69 | HRESULT getEnvironmentBase(std::vector<com::Utf8Str> &aEnvironmentBase);
|
---|
70 | HRESULT getProcesses(std::vector<ComPtr<IGuestProcess> > &aProcesses);
|
---|
71 | HRESULT getPathStyle(PathStyle_T *aPathStyle);
|
---|
72 | HRESULT getCurrentDirectory(com::Utf8Str &aCurrentDirectory);
|
---|
73 | HRESULT setCurrentDirectory(const com::Utf8Str &aCurrentDirectory);
|
---|
74 | HRESULT getUserDocuments(com::Utf8Str &aUserDocuments);
|
---|
75 | HRESULT getUserHome(com::Utf8Str &aUserHome);
|
---|
76 | HRESULT getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories);
|
---|
77 | HRESULT getFiles(std::vector<ComPtr<IGuestFile> > &aFiles);
|
---|
78 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
79 | /** @} */
|
---|
80 |
|
---|
81 | /** Wrapped @name IGuestSession methods.
|
---|
82 | * @{ */
|
---|
83 | HRESULT close();
|
---|
84 |
|
---|
85 | HRESULT copyFromGuest(const std::vector<com::Utf8Str> &aSources,
|
---|
86 | const std::vector<com::Utf8Str> &aFilters,
|
---|
87 | const std::vector<com::Utf8Str> &aFlags,
|
---|
88 | const com::Utf8Str &aDestination,
|
---|
89 | ComPtr<IProgress> &aProgress);
|
---|
90 | HRESULT copyToGuest(const std::vector<com::Utf8Str> &aSources,
|
---|
91 | const std::vector<com::Utf8Str> &aFilters,
|
---|
92 | const std::vector<com::Utf8Str> &aFlags,
|
---|
93 | const com::Utf8Str &aDestination,
|
---|
94 | ComPtr<IProgress> &aProgress);
|
---|
95 |
|
---|
96 | HRESULT directoryCopy(const com::Utf8Str &aSource,
|
---|
97 | const com::Utf8Str &aDestination,
|
---|
98 | const std::vector<DirectoryCopyFlag_T> &aFlags,
|
---|
99 | ComPtr<IProgress> &aProgress);
|
---|
100 | HRESULT directoryCopyFromGuest(const com::Utf8Str &aSource,
|
---|
101 | const com::Utf8Str &aDestination,
|
---|
102 | const std::vector<DirectoryCopyFlag_T> &aFlags,
|
---|
103 | ComPtr<IProgress> &aProgress);
|
---|
104 | HRESULT directoryCopyToGuest(const com::Utf8Str &aSource,
|
---|
105 | const com::Utf8Str &aDestination,
|
---|
106 | const std::vector<DirectoryCopyFlag_T> &aFlags,
|
---|
107 | ComPtr<IProgress> &aProgress);
|
---|
108 | HRESULT directoryCreate(const com::Utf8Str &aPath,
|
---|
109 | ULONG aMode,
|
---|
110 | const std::vector<DirectoryCreateFlag_T> &aFlags);
|
---|
111 | HRESULT directoryCreateTemp(const com::Utf8Str &aTemplateName,
|
---|
112 | ULONG aMode,
|
---|
113 | const com::Utf8Str &aPath,
|
---|
114 | BOOL aSecure,
|
---|
115 | com::Utf8Str &aDirectory);
|
---|
116 | HRESULT directoryExists(const com::Utf8Str &aPath,
|
---|
117 | BOOL aFollowSymlinks,
|
---|
118 | BOOL *aExists);
|
---|
119 | HRESULT directoryOpen(const com::Utf8Str &aPath,
|
---|
120 | const com::Utf8Str &aFilter,
|
---|
121 | const std::vector<DirectoryOpenFlag_T> &aFlags,
|
---|
122 | ComPtr<IGuestDirectory> &aDirectory);
|
---|
123 | HRESULT directoryRemove(const com::Utf8Str &aPath);
|
---|
124 | HRESULT directoryRemoveRecursive(const com::Utf8Str &aPath,
|
---|
125 | const std::vector<DirectoryRemoveRecFlag_T> &aFlags,
|
---|
126 | ComPtr<IProgress> &aProgress);
|
---|
127 | HRESULT environmentScheduleSet(const com::Utf8Str &aName,
|
---|
128 | const com::Utf8Str &aValue);
|
---|
129 | HRESULT environmentScheduleUnset(const com::Utf8Str &aName);
|
---|
130 | HRESULT environmentGetBaseVariable(const com::Utf8Str &aName,
|
---|
131 | com::Utf8Str &aValue);
|
---|
132 | HRESULT environmentDoesBaseVariableExist(const com::Utf8Str &aName,
|
---|
133 | BOOL *aExists);
|
---|
134 |
|
---|
135 | HRESULT fileCopy(const com::Utf8Str &aSource,
|
---|
136 | const com::Utf8Str &aDestination,
|
---|
137 | const std::vector<FileCopyFlag_T> &aFlags,
|
---|
138 | ComPtr<IProgress> &aProgress);
|
---|
139 | HRESULT fileCopyToGuest(const com::Utf8Str &aSource,
|
---|
140 | const com::Utf8Str &aDestination,
|
---|
141 | const std::vector<FileCopyFlag_T> &aFlags,
|
---|
142 | ComPtr<IProgress> &aProgress);
|
---|
143 | HRESULT fileCopyFromGuest(const com::Utf8Str &aSource,
|
---|
144 | const com::Utf8Str &aDestination,
|
---|
145 | const std::vector<FileCopyFlag_T> &aFlags,
|
---|
146 | ComPtr<IProgress> &aProgress);
|
---|
147 | HRESULT fileCreateTemp(const com::Utf8Str &aTemplateName,
|
---|
148 | ULONG aMode,
|
---|
149 | const com::Utf8Str &aPath,
|
---|
150 | BOOL aSecure,
|
---|
151 | ComPtr<IGuestFile> &aFile);
|
---|
152 | HRESULT fileExists(const com::Utf8Str &aPath,
|
---|
153 | BOOL aFollowSymlinks,
|
---|
154 | BOOL *aExists);
|
---|
155 | HRESULT fileOpen(const com::Utf8Str &aPath,
|
---|
156 | FileAccessMode_T aAccessMode,
|
---|
157 | FileOpenAction_T aOpenAction,
|
---|
158 | ULONG aCreationMode,
|
---|
159 | ComPtr<IGuestFile> &aFile);
|
---|
160 | HRESULT fileOpenEx(const com::Utf8Str &aPath,
|
---|
161 | FileAccessMode_T aAccessMode,
|
---|
162 | FileOpenAction_T aOpenAction,
|
---|
163 | FileSharingMode_T aSharingMode,
|
---|
164 | ULONG aCreationMode,
|
---|
165 | const std::vector<FileOpenExFlag_T> &aFlags,
|
---|
166 | ComPtr<IGuestFile> &aFile);
|
---|
167 | HRESULT fileQuerySize(const com::Utf8Str &aPath,
|
---|
168 | BOOL aFollowSymlinks,
|
---|
169 | LONG64 *aSize);
|
---|
170 | HRESULT fsObjExists(const com::Utf8Str &aPath,
|
---|
171 | BOOL aFollowSymlinks,
|
---|
172 | BOOL *pfExists);
|
---|
173 | HRESULT fsObjQueryInfo(const com::Utf8Str &aPath,
|
---|
174 | BOOL aFollowSymlinks,
|
---|
175 | ComPtr<IGuestFsObjInfo> &aInfo);
|
---|
176 | HRESULT fsObjRemove(const com::Utf8Str &aPath);
|
---|
177 | HRESULT fsObjRemoveArray(const std::vector<com::Utf8Str> &aPaths,
|
---|
178 | ComPtr<IProgress> &aProgress);
|
---|
179 | HRESULT fsObjRename(const com::Utf8Str &aOldPath,
|
---|
180 | const com::Utf8Str &aNewPath,
|
---|
181 | const std::vector<FsObjRenameFlag_T> &aFlags);
|
---|
182 | HRESULT fsObjMove(const com::Utf8Str &aSource,
|
---|
183 | const com::Utf8Str &aDestination,
|
---|
184 | const std::vector<FsObjMoveFlag_T> &aFlags,
|
---|
185 | ComPtr<IProgress> &aProgress);
|
---|
186 | HRESULT fsObjMoveArray(const std::vector<com::Utf8Str> &aSource,
|
---|
187 | const com::Utf8Str &aDestination,
|
---|
188 | const std::vector<FsObjMoveFlag_T> &aFlags,
|
---|
189 | ComPtr<IProgress> &aProgress);
|
---|
190 | HRESULT fsObjCopyArray(const std::vector<com::Utf8Str> &aSource,
|
---|
191 | const com::Utf8Str &aDestination,
|
---|
192 | const std::vector<FileCopyFlag_T> &aFlags,
|
---|
193 | ComPtr<IProgress> &aProgress);
|
---|
194 | HRESULT fsObjSetACL(const com::Utf8Str &aPath,
|
---|
195 | BOOL aFollowSymlinks,
|
---|
196 | const com::Utf8Str &aAcl,
|
---|
197 | ULONG aMode);
|
---|
198 | HRESULT processCreate(const com::Utf8Str &aCommand,
|
---|
199 | const std::vector<com::Utf8Str> &aArguments,
|
---|
200 | const std::vector<com::Utf8Str> &aEnvironment,
|
---|
201 | const std::vector<ProcessCreateFlag_T> &aFlags,
|
---|
202 | ULONG aTimeoutMS,
|
---|
203 | ComPtr<IGuestProcess> &aGuestProcess);
|
---|
204 | HRESULT processCreateEx(const com::Utf8Str &aCommand,
|
---|
205 | const std::vector<com::Utf8Str> &aArguments,
|
---|
206 | const std::vector<com::Utf8Str> &aEnvironment,
|
---|
207 | const std::vector<ProcessCreateFlag_T> &aFlags,
|
---|
208 | ULONG aTimeoutMS,
|
---|
209 | ProcessPriority_T aPriority,
|
---|
210 | const std::vector<LONG> &aAffinity,
|
---|
211 | ComPtr<IGuestProcess> &aGuestProcess);
|
---|
212 | HRESULT processGet(ULONG aPid,
|
---|
213 | ComPtr<IGuestProcess> &aGuestProcess);
|
---|
214 | HRESULT symlinkCreate(const com::Utf8Str &aSource,
|
---|
215 | const com::Utf8Str &aTarget,
|
---|
216 | SymlinkType_T aType);
|
---|
217 | HRESULT symlinkExists(const com::Utf8Str &aSymlink,
|
---|
218 | BOOL *aExists);
|
---|
219 | HRESULT symlinkRead(const com::Utf8Str &aSymlink,
|
---|
220 | const std::vector<SymlinkReadFlag_T> &aFlags,
|
---|
221 | com::Utf8Str &aTarget);
|
---|
222 | HRESULT waitFor(ULONG aWaitFor,
|
---|
223 | ULONG aTimeoutMS,
|
---|
224 | GuestSessionWaitResult_T *aReason);
|
---|
225 | HRESULT waitForArray(const std::vector<GuestSessionWaitForFlag_T> &aWaitFor,
|
---|
226 | ULONG aTimeoutMS,
|
---|
227 | GuestSessionWaitResult_T *aReason);
|
---|
228 | /** @} */
|
---|
229 |
|
---|
230 | /** Map of guest directories. The key specifies the internal directory ID. */
|
---|
231 | typedef std::map <uint32_t, ComObjPtr<GuestDirectory> > SessionDirectories;
|
---|
232 | /** Map of guest files. The key specifies the internal file ID. */
|
---|
233 | typedef std::map <uint32_t, ComObjPtr<GuestFile> > SessionFiles;
|
---|
234 | /** Map of guest processes. The key specifies the internal process number.
|
---|
235 | * To retrieve the process' guest PID use the Id() method of the IProcess interface. */
|
---|
236 | typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
|
---|
237 |
|
---|
238 | /** Guest session object type enumeration. */
|
---|
239 | enum SESSIONOBJECTTYPE
|
---|
240 | {
|
---|
241 | /** Anonymous object. */
|
---|
242 | SESSIONOBJECTTYPE_ANONYMOUS = 0,
|
---|
243 | /** Session object. */
|
---|
244 | SESSIONOBJECTTYPE_SESSION = 1,
|
---|
245 | /** Directory object. */
|
---|
246 | SESSIONOBJECTTYPE_DIRECTORY = 2,
|
---|
247 | /** File object. */
|
---|
248 | SESSIONOBJECTTYPE_FILE = 3,
|
---|
249 | /** Process object. */
|
---|
250 | SESSIONOBJECTTYPE_PROCESS = 4,
|
---|
251 | /** The usual 32-bit hack. */
|
---|
252 | SESSIONOBJECTTYPE_32BIT_HACK = 0x7fffffff
|
---|
253 | };
|
---|
254 |
|
---|
255 | struct SessionObject
|
---|
256 | {
|
---|
257 | /** Creation timestamp (in ms).
|
---|
258 | * @note not used by anyone at the moment. */
|
---|
259 | uint64_t msBirth;
|
---|
260 | /** The object type. */
|
---|
261 | SESSIONOBJECTTYPE enmType;
|
---|
262 | };
|
---|
263 |
|
---|
264 | /** Map containing all objects bound to a guest session.
|
---|
265 | * The key specifies the (global) context ID. */
|
---|
266 | typedef std::map <uint32_t, SessionObject> SessionObjects;
|
---|
267 |
|
---|
268 | public:
|
---|
269 | /** @name Public internal methods.
|
---|
270 | * @todo r=bird: Most of these are public for no real reason...
|
---|
271 | * @{ */
|
---|
272 | HRESULT i_copyFromGuest(const GuestSessionFsSourceSet &SourceSet, const com::Utf8Str &strDestination,
|
---|
273 | ComPtr<IProgress> &pProgress);
|
---|
274 | HRESULT i_copyToGuest(const GuestSessionFsSourceSet &SourceSet, const com::Utf8Str &strDestination,
|
---|
275 | ComPtr<IProgress> &pProgress);
|
---|
276 | int i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
|
---|
277 | HRESULT i_directoryCopyFlagFromStr(const com::Utf8Str &strFlags, DirectoryCopyFlag_T *pfFlags);
|
---|
278 | inline bool i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir);
|
---|
279 | int i_directoryUnregister(GuestDirectory *pDirectory);
|
---|
280 | int i_directoryRemove(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc);
|
---|
281 | int i_directoryCreate(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc);
|
---|
282 | int i_directoryOpen(const GuestDirectoryOpenInfo &openInfo,
|
---|
283 | ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc);
|
---|
284 | int i_directoryQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
|
---|
285 | int i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
286 | int i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
|
---|
287 | HRESULT i_fileCopyFlagFromStr(const com::Utf8Str &strFlags, FileCopyFlag_T *pfFlags);
|
---|
288 | inline bool i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile);
|
---|
289 | int i_fileUnregister(GuestFile *pFile);
|
---|
290 | int i_fileRemove(const Utf8Str &strPath, int *pGuestRc);
|
---|
291 | int i_fileOpenEx(const com::Utf8Str &aPath, FileAccessMode_T aAccessMode, FileOpenAction_T aOpenAction,
|
---|
292 | FileSharingMode_T aSharingMode, ULONG aCreationMode,
|
---|
293 | const std::vector<FileOpenExFlag_T> &aFlags,
|
---|
294 | ComObjPtr<GuestFile> &pFile, int *prcGuest);
|
---|
295 | int i_fileOpen(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
|
---|
296 | int i_fileQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
|
---|
297 | int i_fileQuerySize(const Utf8Str &strPath, bool fFollowSymlinks, int64_t *pllSize, int *pGuestRc);
|
---|
298 | int i_fsCreateTemp(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory,
|
---|
299 | Utf8Str &strName, int *pGuestRc);
|
---|
300 | int i_fsQueryInfo(const Utf8Str &strPath, bool fFollowSymlinks, GuestFsObjData &objData, int *pGuestRc);
|
---|
301 | const GuestCredentials &i_getCredentials(void);
|
---|
302 | EventSource *i_getEventSource(void) { return mEventSource; }
|
---|
303 | Utf8Str i_getName(void);
|
---|
304 | ULONG i_getId(void) { return mData.mSession.mID; }
|
---|
305 | static Utf8Str i_guestErrorToString(int guestRc);
|
---|
306 | HRESULT i_isReadyExternal(void);
|
---|
307 | int i_onRemove(void);
|
---|
308 | int i_onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
|
---|
309 | PathStyle_T i_getPathStyle(void);
|
---|
310 | int i_startSession(int *pGuestRc);
|
---|
311 | int i_startSessionAsync(void);
|
---|
312 | static void i_startSessionThreadTask(GuestSessionTaskInternalOpen *pTask);
|
---|
313 | Guest *i_getParent(void) { return mParent; }
|
---|
314 | uint32_t i_getProtocolVersion(void) { return mData.mProtocolVersion; }
|
---|
315 | int i_objectRegister(SESSIONOBJECTTYPE enmType, uint32_t *pidObject);
|
---|
316 | int i_objectUnregister(uint32_t uObjectID);
|
---|
317 | int i_pathRename(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pGuestRc);
|
---|
318 | int i_pathUserDocuments(Utf8Str &strPath, int *prcGuest);
|
---|
319 | int i_pathUserHome(Utf8Str &strPath, int *prcGuest);
|
---|
320 | int i_processUnregister(GuestProcess *pProcess);
|
---|
321 | int i_processCreateEx(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
|
---|
322 | inline bool i_processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
|
---|
323 | inline int i_processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
|
---|
324 | int i_sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms,
|
---|
325 | uint64_t fDst = VBOX_GUESTCTRL_DST_SESSION);
|
---|
326 | static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
|
---|
327 | int i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
|
---|
328 | int i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
|
---|
329 | int i_determineProtocolVersion(void);
|
---|
330 | int i_waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
|
---|
331 | int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS,
|
---|
332 | GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
|
---|
333 | /** @} */
|
---|
334 |
|
---|
335 | private:
|
---|
336 |
|
---|
337 | /** Pointer to the parent (Guest). */
|
---|
338 | Guest *mParent;
|
---|
339 | /**
|
---|
340 | * The session's event source. This source is used for
|
---|
341 | * serving the internal listener as well as all other
|
---|
342 | * external listeners that may register to it.
|
---|
343 | *
|
---|
344 | * Note: This can safely be used without holding any locks.
|
---|
345 | * An AutoCaller suffices to prevent it being destroy while in use and
|
---|
346 | * internally there is a lock providing the necessary serialization.
|
---|
347 | */
|
---|
348 | const ComObjPtr<EventSource> mEventSource;
|
---|
349 |
|
---|
350 | /** @todo r=bird: One of the core points of the DATA sub-structures in Main is
|
---|
351 | * hinding implementation details and stuff that requires including iprt/asm.h.
|
---|
352 | * The way it's used here totally defeats that purpose. You need to make it
|
---|
353 | * a pointer to a anynmous Data struct and define that structure in
|
---|
354 | * GuestSessionImpl.cpp and allocate it in the Init() function.
|
---|
355 | */
|
---|
356 | struct Data
|
---|
357 | {
|
---|
358 | /** The session credentials. */
|
---|
359 | GuestCredentials mCredentials;
|
---|
360 | /** The session's startup info. */
|
---|
361 | GuestSessionStartupInfo mSession;
|
---|
362 | /** The session's object ID.
|
---|
363 | * Needed for registering wait events which are bound directly to this session. */
|
---|
364 | uint32_t mObjectID;
|
---|
365 | /** The session's current status. */
|
---|
366 | GuestSessionStatus_T mStatus;
|
---|
367 | /** The set of environment changes for the session for use when
|
---|
368 | * creating new guest processes. */
|
---|
369 | GuestEnvironmentChanges mEnvironmentChanges;
|
---|
370 | /** Pointer to the immutable base environment for the session.
|
---|
371 | * @note This is not allocated until the guest reports it to the host. It is
|
---|
372 | * also shared with child processes. */
|
---|
373 | GuestEnvironment const *mpBaseEnvironment;
|
---|
374 | /** Directory objects bound to this session. */
|
---|
375 | SessionDirectories mDirectories;
|
---|
376 | /** File objects bound to this session. */
|
---|
377 | SessionFiles mFiles;
|
---|
378 | /** Process objects bound to this session. */
|
---|
379 | SessionProcesses mProcesses;
|
---|
380 | /** Map of registered session objects (files, directories, ...). */
|
---|
381 | SessionObjects mObjects;
|
---|
382 | /** Guest control protocol version to be used.
|
---|
383 | * Guest Additions < VBox 4.3 have version 1,
|
---|
384 | * any newer version will have version 2. */
|
---|
385 | uint32_t mProtocolVersion;
|
---|
386 | /** Session timeout (in ms). */
|
---|
387 | uint32_t mTimeout;
|
---|
388 | /** The last returned session status
|
---|
389 | * returned from the guest side. */
|
---|
390 | int mRC;
|
---|
391 | /** Object ID allocation bitmap; clear bits are free, set bits are busy. */
|
---|
392 | uint64_t bmObjectIds[VBOX_GUESTCTRL_MAX_OBJECTS / sizeof(uint64_t) / 8];
|
---|
393 |
|
---|
394 | Data(void)
|
---|
395 | : mpBaseEnvironment(NULL)
|
---|
396 | {
|
---|
397 | RT_ZERO(bmObjectIds);
|
---|
398 | ASMBitSet(&bmObjectIds, VBOX_GUESTCTRL_MAX_OBJECTS - 1); /* Reserved for the session itself? */
|
---|
399 | ASMBitSet(&bmObjectIds, 0); /* Let's reserve this too. */
|
---|
400 | }
|
---|
401 | Data(const Data &rThat)
|
---|
402 | : mCredentials(rThat.mCredentials)
|
---|
403 | , mSession(rThat.mSession)
|
---|
404 | , mStatus(rThat.mStatus)
|
---|
405 | , mEnvironmentChanges(rThat.mEnvironmentChanges)
|
---|
406 | , mpBaseEnvironment(NULL)
|
---|
407 | , mDirectories(rThat.mDirectories)
|
---|
408 | , mFiles(rThat.mFiles)
|
---|
409 | , mProcesses(rThat.mProcesses)
|
---|
410 | , mObjects(rThat.mObjects)
|
---|
411 | , mProtocolVersion(rThat.mProtocolVersion)
|
---|
412 | , mTimeout(rThat.mTimeout)
|
---|
413 | , mRC(rThat.mRC)
|
---|
414 | {
|
---|
415 | memcpy(&bmObjectIds, &rThat.bmObjectIds, sizeof(bmObjectIds));
|
---|
416 | }
|
---|
417 | ~Data(void)
|
---|
418 | {
|
---|
419 | if (mpBaseEnvironment)
|
---|
420 | {
|
---|
421 | mpBaseEnvironment->releaseConst();
|
---|
422 | mpBaseEnvironment = NULL;
|
---|
423 | }
|
---|
424 | }
|
---|
425 | } mData;
|
---|
426 | };
|
---|
427 |
|
---|
428 | #endif /* !____H_GUESTSESSIONIMPL */
|
---|
429 |
|
---|