Index: /trunk/src/VBox/Main/include/GuestSessionImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/GuestSessionImpl.h	(revision 50726)
+++ /trunk/src/VBox/Main/include/GuestSessionImpl.h	(revision 50727)
@@ -20,5 +20,5 @@
 #define ____H_GUESTSESSIONIMPL
 
-#include "VirtualBoxBase.h"
+#include "GuestSessionWrap.h"
 #include "EventImpl.h"
 
@@ -53,5 +53,5 @@
 
     int getGuestProperty(const ComObjPtr<Guest> &pGuest,
-                         const Utf8Str &strPath, Utf8Str &strValue);
+                           const Utf8Str &strPath, Utf8Str &strValue);
     int setProgress(ULONG uPercent);
     int setProgressSuccess(void);
@@ -221,10 +221,10 @@
     };
 
-    int addProcessArguments(ProcessArguments &aArgumentsDest,
-                            const ProcessArguments &aArgumentsSource);
-    int copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
-                        Utf8Str const &strFileSource, const Utf8Str &strFileDest,
-                        bool fOptional, uint32_t *pcbSize);
-    int runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
+    int i_addProcessArguments(ProcessArguments &aArgumentsDest,
+                              const ProcessArguments &aArgumentsSource);
+    int i_copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
+                          Utf8Str const &strFileSource, const Utf8Str &strFileDest,
+                          bool fOptional, uint32_t *pcbSize);
+    int i_runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo);
 
     /** Files to handle. */
@@ -243,17 +243,10 @@
  */
 class ATL_NO_VTABLE GuestSession :
-    public VirtualBoxBase,
-    public GuestBase,
-    VBOX_SCRIPTABLE_IMPL(IGuestSession)
+    public GuestSessionWrap,
+    public GuestBase
 {
 public:
     /** @name COM and internal init/term/mapping cruft.
      * @{ */
-    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(GuestSession, IGuestSession)
-    DECLARE_NOT_AGGREGATABLE(GuestSession)
-    DECLARE_PROTECT_FINAL_CONSTRUCT()
-    BEGIN_COM_MAP(GuestSession)
-        VBOX_DEFAULT_INTERFACE_ENTRIES(IGuestSession)
-    END_COM_MAP()
     DECLARE_EMPTY_CTOR_DTOR(GuestSession)
 
@@ -264,66 +257,125 @@
     /** @}  */
 
-    /** @name IGuestSession properties.
-     * @{ */
-    STDMETHOD(COMGETTER(User))(BSTR *aName);
-    STDMETHOD(COMGETTER(Domain))(BSTR *aDomain);
-    STDMETHOD(COMGETTER(Name))(BSTR *aName);
-    STDMETHOD(COMGETTER(Id))(ULONG *aId);
-    STDMETHOD(COMGETTER(Status))(GuestSessionStatus_T *aStatus);
-    STDMETHOD(COMGETTER(Timeout))(ULONG *aTimeout);
-    STDMETHOD(COMSETTER(Timeout))(ULONG aTimeout);
-    STDMETHOD(COMGETTER(ProtocolVersion))(ULONG *aVersion);
-    STDMETHOD(COMGETTER(Environment))(ComSafeArrayOut(BSTR, aEnvironment));
-    STDMETHOD(COMSETTER(Environment))(ComSafeArrayIn(IN_BSTR, aEnvironment));
-    STDMETHOD(COMGETTER(Processes))(ComSafeArrayOut(IGuestProcess *, aProcesses));
-    STDMETHOD(COMGETTER(Directories))(ComSafeArrayOut(IGuestDirectory *, aDirectories));
-    STDMETHOD(COMGETTER(Files))(ComSafeArrayOut(IGuestFile *, aFiles));
-    STDMETHOD(COMGETTER(EventSource))(IEventSource ** aEventSource);
-    /** @}  */
-
-    /** @name IGuestSession methods.
-     * @{ */
-    STDMETHOD(Close)(void);
-    STDMETHOD(CopyFrom)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress);
-    STDMETHOD(CopyTo)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress);
-    STDMETHOD(DirectoryCreate)(IN_BSTR aPath, ULONG aMode, ComSafeArrayIn(DirectoryCreateFlag_T, aFlags));
-    STDMETHOD(DirectoryCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, BSTR *aDirectory);
-    STDMETHOD(DirectoryExists)(IN_BSTR aPath, BOOL *aExists);
-    STDMETHOD(DirectoryOpen)(IN_BSTR aPath, IN_BSTR aFilter, ComSafeArrayIn(DirectoryOpenFlag_T, aFlags), IGuestDirectory **aDirectory);
-    STDMETHOD(DirectoryQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
-    STDMETHOD(DirectoryRemove)(IN_BSTR aPath);
-    STDMETHOD(DirectoryRemoveRecursive)(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress);
-    STDMETHOD(DirectoryRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
-    STDMETHOD(DirectorySetACL)(IN_BSTR aPath, IN_BSTR aACL);
-    STDMETHOD(EnvironmentClear)(void);
-    STDMETHOD(EnvironmentGet)(IN_BSTR aName, BSTR *aValue);
-    STDMETHOD(EnvironmentSet)(IN_BSTR aName, IN_BSTR aValue);
-    STDMETHOD(EnvironmentUnset)(IN_BSTR aName);
-    STDMETHOD(FileCreateTemp)(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, IGuestFile **aFile);
-    STDMETHOD(FileExists)(IN_BSTR aPath, BOOL *aExists);
-    STDMETHOD(FileRemove)(IN_BSTR aPath);
-    STDMETHOD(FileOpen)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, IGuestFile **aFile);
-    STDMETHOD(FileOpenEx)(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile);
-    STDMETHOD(FileQueryInfo)(IN_BSTR aPath, IGuestFsObjInfo **aInfo);
-    STDMETHOD(FileQuerySize)(IN_BSTR aPath, LONG64 *aSize);
-    STDMETHOD(FileRename)(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags));
-    STDMETHOD(FileSetACL)(IN_BSTR aPath, IN_BSTR aACL);
-    STDMETHOD(ProcessCreate)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
-                             ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess);
-    STDMETHOD(ProcessCreateEx)(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
-                               ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
-                               ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
-                               IGuestProcess **aProcess);
-    STDMETHOD(ProcessGet)(ULONG aPID, IGuestProcess **aProcess);
-    STDMETHOD(SymlinkCreate)(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType);
-    STDMETHOD(SymlinkExists)(IN_BSTR aSymlink, BOOL *aExists);
-    STDMETHOD(SymlinkRead)(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget);
-    STDMETHOD(SymlinkRemoveDirectory)(IN_BSTR aPath);
-    STDMETHOD(SymlinkRemoveFile)(IN_BSTR aFile);
-    STDMETHOD(WaitFor)(ULONG aWaitFlags, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason);
-    STDMETHOD(WaitForArray)(ComSafeArrayIn(GuestSessionWaitForFlag_T, aFlags), ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason);
-    /** @}  */
-
 private:
+
+    // Wrapped GuuestSession Properties
+    HRESULT getUser(com::Utf8Str &aUser);
+    HRESULT getDomain(com::Utf8Str &aDomain);
+    HRESULT getName(com::Utf8Str &aName);
+    HRESULT getId(ULONG *aId);
+    HRESULT getTimeout(ULONG *aTimeout);
+    HRESULT setTimeout(ULONG aTimeout);
+    HRESULT getProtocolVersion(ULONG *aProtocolVersion);
+    HRESULT getStatus(GuestSessionStatus_T *aStatus);
+    HRESULT getEnvironment(std::vector<com::Utf8Str> &aEnvironment);
+    HRESULT setEnvironment(const std::vector<com::Utf8Str> &aEnvironment);
+    HRESULT getProcesses(std::vector<ComPtr<IGuestProcess> > &aProcesses);
+    HRESULT getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories);
+    HRESULT getFiles(std::vector<ComPtr<IGuestFile> > &aFiles);
+    HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
+
+    // Wrapped GuuestSession Methods
+    HRESULT close();
+    HRESULT copyFrom(const com::Utf8Str &aSource,
+                     const com::Utf8Str &aDest,
+                     const std::vector<CopyFileFlag_T> &aFlags,
+                     ComPtr<IProgress> &aProgress);
+    HRESULT copyTo(const com::Utf8Str &aSource,
+                   const com::Utf8Str &aDest,
+                   const std::vector<CopyFileFlag_T> &aFlags,
+                   ComPtr<IProgress> &aProgress);
+    HRESULT directoryCreate(const com::Utf8Str &aPath,
+                            ULONG aMode,
+                            const std::vector<DirectoryCreateFlag_T> &aFlags);
+    HRESULT directoryCreateTemp(const com::Utf8Str &aTemplateName,
+                                ULONG aMode,
+                                const com::Utf8Str &aPath,
+                                BOOL aSecure,
+                                com::Utf8Str &aDirectory);
+    HRESULT directoryExists(const com::Utf8Str &aPath,
+                            BOOL *aExists);
+    HRESULT directoryOpen(const com::Utf8Str &aPath,
+                          const com::Utf8Str &aFilter,
+                          const std::vector<DirectoryOpenFlag_T> &aFlags,
+                          ComPtr<IGuestDirectory> &aDirectory);
+    HRESULT directoryQueryInfo(const com::Utf8Str &aPath,
+                               ComPtr<IGuestFsObjInfo> &aInfo);
+    HRESULT directoryRemove(const com::Utf8Str &aPath);
+    HRESULT directoryRemoveRecursive(const com::Utf8Str &aPath,
+                                     const std::vector<DirectoryRemoveRecFlag_T> &aFlags,
+                                     ComPtr<IProgress> &aProgress);
+    HRESULT directoryRename(const com::Utf8Str &aSource,
+                            const com::Utf8Str &aDest,
+                            const std::vector<PathRenameFlag_T> &aFlags);
+    HRESULT directorySetACL(const com::Utf8Str &aPath,
+                             const com::Utf8Str &aAcl);
+    HRESULT environmentClear();
+    HRESULT environmentGet(const com::Utf8Str &aName,
+                           com::Utf8Str &aValue);
+    HRESULT environmentSet(const com::Utf8Str &aName,
+                           const com::Utf8Str &aValue);
+    HRESULT environmentUnset(const com::Utf8Str &aName);
+    HRESULT fileCreateTemp(const com::Utf8Str &aTemplateName,
+                           ULONG aMode,
+                           const com::Utf8Str &aPath,
+                           BOOL aSecure,
+                           ComPtr<IGuestFile> &aFile);
+    HRESULT fileExists(const com::Utf8Str &aPath,
+                       BOOL *aExists);
+    HRESULT fileRemove(const com::Utf8Str &aPath);
+    HRESULT fileOpen(const com::Utf8Str &aPath,
+                     const com::Utf8Str &aOpenMode,
+                     const com::Utf8Str &aDisposition,
+                     ULONG aCreationMode,
+                     ComPtr<IGuestFile> &aFile);
+    HRESULT fileOpenEx(const com::Utf8Str &aPath,
+                       const com::Utf8Str &aOpenMode,
+                       const com::Utf8Str &aDisposition,
+                       const com::Utf8Str &aSharingMode,
+                       ULONG aCreationMode,
+                       LONG64 aOffset,
+                       ComPtr<IGuestFile> &aFile);
+    HRESULT fileQueryInfo(const com::Utf8Str &aPath,
+                          ComPtr<IGuestFsObjInfo> &aInfo);
+    HRESULT fileQuerySize(const com::Utf8Str &aPath,
+                          LONG64 *aSize);
+    HRESULT fileRename(const com::Utf8Str &aSource,
+                       const com::Utf8Str &aDest,
+                       const std::vector<PathRenameFlag_T> &aFlags);
+    HRESULT fileSetACL(const com::Utf8Str &aFile,
+                       const com::Utf8Str &aAcl);
+    HRESULT processCreate(const com::Utf8Str &aCommand,
+                          const std::vector<com::Utf8Str> &aArguments,
+                          const std::vector<com::Utf8Str> &aEnvironment,
+                          const std::vector<ProcessCreateFlag_T> &aFlags,
+                          ULONG aTimeoutMS,
+                          ComPtr<IGuestProcess> &aGuestProcess);
+    HRESULT processCreateEx(const com::Utf8Str &aCommand,
+                            const std::vector<com::Utf8Str> &aArguments,
+                            const std::vector<com::Utf8Str> &aEnvironment,
+                            const std::vector<ProcessCreateFlag_T> &aFlags,
+                            ULONG aTimeoutMS,
+                            ProcessPriority_T aPriority,
+                            const std::vector<LONG> &aAffinity,
+                            ComPtr<IGuestProcess> &aGuestProcess);
+    HRESULT processGet(ULONG aPid,
+                       ComPtr<IGuestProcess> &aGuestProcess);
+    HRESULT symlinkCreate(const com::Utf8Str &aSource,
+                          const com::Utf8Str &aTarget,
+                          SymlinkType_T aType);
+    HRESULT symlinkExists(const com::Utf8Str &aSymlink,
+                          BOOL *aExists);
+    HRESULT symlinkRead(const com::Utf8Str &aSymlink,
+                        const std::vector<SymlinkReadFlag_T> &aFlags,
+                        com::Utf8Str &aTarget);
+    HRESULT symlinkRemoveDirectory(const com::Utf8Str &aPath);
+    HRESULT symlinkRemoveFile(const com::Utf8Str &aFile);
+    HRESULT waitFor(ULONG aWaitFor,
+                    ULONG aTimeoutMS,
+                    GuestSessionWaitResult_T *aReason);
+    HRESULT waitForArray(const std::vector<GuestSessionWaitForFlag_T> &aWaitFor,
+                         ULONG aTimeoutMS,
+                         GuestSessionWaitResult_T *aReason);
+
 
     /** Map of guest directories. The key specifies the internal directory ID. */
@@ -338,52 +390,52 @@
     /** @name Public internal methods.
      * @{ */
-    int                     closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
-    inline bool             directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir);
-    int                     directoryRemoveFromList(GuestDirectory *pDirectory);
-    int                     directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc);
-    int                     directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc);
-    int                     objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory, Utf8Str &strName, int *pGuestRc);
-    int                     directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo, ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc);
-    int                     directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
-    int                     dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
-    int                     dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
-    int                     dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
-    int                     dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
-    int                     dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
-    inline bool             fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile);
-    int                     fileRemoveFromList(GuestFile *pFile);
-    int                     fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc);
-    int                     fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
-    int                     fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
-    int                     fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc);
-    int                     fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
-    const GuestCredentials &getCredentials(void);
-    const GuestEnvironment &getEnvironment(void);
-    EventSource            *getEventSource(void) { return mEventSource; }
-    Utf8Str                 getName(void);
-    ULONG                   getId(void) { return mData.mSession.mID; }
-    static Utf8Str          guestErrorToString(int guestRc);
-    HRESULT                 isReadyExternal(void);
-    int                     onRemove(void);
-    int                     onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
-    int                     startSessionInternal(int *pGuestRc);
-    int                     startSessionAsync(void);
+    int                     i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc);
+    inline bool             i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir);
+    int                     i_directoryRemoveFromList(GuestDirectory *pDirectory);
+    int                     i_directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags, int *pGuestRc);
+    int                     i_directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc);
+    int                     i_objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath, bool fDirectory, Utf8Str &strName, int *pGuestRc);
+    int                     i_directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo, ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc);
+    int                     i_directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
+    int                     i_dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
+    int                     i_dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
+    int                     i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
+    int                     i_dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
+    int                     i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
+    inline bool             i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile);
+    int                     i_fileRemoveFromList(GuestFile *pFile);
+    int                     i_fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc);
+    int                     i_fileOpenInternal(const GuestFileOpenInfo &openInfo, ComObjPtr<GuestFile> &pFile, int *pGuestRc);
+    int                     i_fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
+    int                     i_fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc);
+    int                     i_fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc);
+    const GuestCredentials  &i_getCredentials(void);
+    const GuestEnvironment  &i_getEnvironment(void);
+    EventSource            *i_getEventSource(void) { return mEventSource; }
+    Utf8Str                 i_getName(void);
+    ULONG                   i_getId(void) { return mData.mSession.mID; }
+    static Utf8Str          i_guestErrorToString(int guestRc);
+    HRESULT                 i_isReadyExternal(void);
+    int                     i_onRemove(void);
+    int                     i_onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
+    int                     i_startSessionInternal(int *pGuestRc);
+    int                     i_startSessionAsync(void);
     static DECLCALLBACK(int)
-                            startSessionThread(RTTHREAD Thread, void *pvUser);
-    Guest                  *getParent(void) { return mParent; }
-    uint32_t                getProtocolVersion(void) { return mData.mProtocolVersion; }
-    int                     pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pGuestRc);
-    int                     processRemoveFromList(GuestProcess *pProcess);
-    int                     processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
-    inline bool             processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
-    inline int              processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
-    int                     sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
-    static HRESULT          setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
-    int                     setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
-    int                     signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
-    int                     startTaskAsync(const Utf8Str &strTaskDesc, GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress);
-    int                     queryInfo(void);
-    int                     waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
-    int                     waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS, GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
+                            i_startSessionThread(RTTHREAD Thread, void *pvUser);
+    Guest                  *i_getParent(void) { return mParent; }
+    uint32_t                i_getProtocolVersion(void) { return mData.mProtocolVersion; }
+    int                     i_pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pGuestRc);
+    int                     i_processRemoveFromList(GuestProcess *pProcess);
+    int                     i_processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
+    inline bool             i_processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess);
+    inline int              i_processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
+    int                     i_sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
+    static HRESULT          i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
+    int                     i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
+    int                     i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
+    int                     i_startTaskAsync(const Utf8Str &strTaskDesc, GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress);
+    int                     i_queryInfo(void);
+    int                     i_waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc);
+    int                     i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS, GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
     /** @}  */
 
Index: /trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp	(revision 50727)
@@ -193,5 +193,5 @@
         Assert(!pSession.isNull());
         int guestRc;
-        rc = pSession->startSessionInternal(&guestRc);
+        rc = pSession->i_startSessionInternal(&guestRc);
         if (RT_FAILURE(rc))
         {
@@ -207,5 +207,5 @@
                 SessionTaskUpdateAdditions *pTask = new SessionTaskUpdateAdditions(pSession /* GuestSession */,
                                                                                    Utf8Str(aSource), aArgs, fFlags);
-                rc = pSession->startTaskAsync(tr("Updating Guest Additions"), pTask, pProgress);
+                rc = pSession->i_startTaskAsync(tr("Updating Guest Additions"), pTask, pProgress);
                 if (RT_SUCCESS(rc))
                 {
@@ -294,5 +294,5 @@
             {
                 case GUEST_DISCONNECTED:
-                    rc = pSession->dispatchToThis(pCtxCb, pSvcCb);
+                    rc = pSession->i_dispatchToThis(pCtxCb, pSvcCb);
                     break;
 
@@ -301,13 +301,13 @@
                 case GUEST_EXEC_INPUT_STATUS:
                 case GUEST_EXEC_IO_NOTIFY:
-                    rc = pSession->dispatchToProcess(pCtxCb, pSvcCb);
+                    rc = pSession->i_dispatchToProcess(pCtxCb, pSvcCb);
                     break;
 
                 case GUEST_FILE_NOTIFY:
-                    rc = pSession->dispatchToFile(pCtxCb, pSvcCb);
+                    rc = pSession->i_dispatchToFile(pCtxCb, pSvcCb);
                     break;
 
                 case GUEST_SESSION_NOTIFY:
-                    rc = pSession->dispatchToThis(pCtxCb, pSvcCb);
+                    rc = pSession->i_dispatchToThis(pCtxCb, pSvcCb);
                     break;
 
@@ -320,5 +320,5 @@
                      * in this session object.
                      */
-                    rc = pSession->dispatchToObject(pCtxCb, pSvcCb);
+                    rc = pSession->i_dispatchToObject(pCtxCb, pSvcCb);
                     if (   rc == VERR_NOT_FOUND
                         || rc == VERR_NOT_SUPPORTED)
@@ -355,5 +355,5 @@
     int rc = VERR_NOT_FOUND;
 
-    LogFlowThisFunc(("Removing session (ID=%RU32) ...\n", pSession->getId()));
+    LogFlowThisFunc(("Removing session (ID=%RU32) ...\n", pSession->i_getId()));
 
     GuestSessions::iterator itSessions = mData.mGuestSessions.begin();
@@ -373,7 +373,7 @@
 
             LogFlowThisFunc(("Removing session (pSession=%p, ID=%RU32) (now total %ld sessions)\n",
-                             pSession, pSession->getId(), mData.mGuestSessions.size() - 1));
-
-            rc = pSession->onRemove();
+                             pSession, pSession->i_getId(), mData.mGuestSessions.size() - 1));
+
+            rc = pSession->i_onRemove();
             mData.mGuestSessions.erase(itSessions);
 
@@ -525,5 +525,5 @@
         /* Start (fork) the session asynchronously
          * on the guest. */
-        rc = pSession->startSessionAsync();
+        rc = pSession->i_startSessionAsync();
     }
 
@@ -570,5 +570,5 @@
     while (itSessions != mData.mGuestSessions.end())
     {
-        if (strName.contains(itSessions->second->getName())) /** @todo Use a (simple) pattern match (IPRT?). */
+        if (strName.contains(itSessions->second->i_getName())) /** @todo Use a (simple) pattern match (IPRT?). */
             listSessions.push_back(itSessions->second);
         itSessions++;
Index: /trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp	(revision 50727)
@@ -1226,5 +1226,5 @@
 {
     AssertPtr(mSession);
-    return GuestBase::registerWaitEvent(mSession->getId(), mObjectID, lstEvents, ppEvent);
+    return GuestBase::registerWaitEvent(mSession->i_getId(), mObjectID, lstEvents, ppEvent);
 }
 
Index: /trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp	(revision 50727)
@@ -299,5 +299,5 @@
 
     AssertPtr(mSession);
-    int rc2 = mSession->directoryRemoveFromList(this);
+    int rc2 = mSession->i_directoryRemoveFromList(this);
     if (RT_SUCCESS(rc))
         rc = rc2;
Index: /trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestFileImpl.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestFileImpl.cpp	(revision 50727)
@@ -1238,5 +1238,5 @@
 
     AssertPtr(mSession);
-    int rc2 = mSession->fileRemoveFromList(this);
+    int rc2 = mSession->i_fileRemoveFromList(this);
     if (RT_SUCCESS(rc))
         rc = rc2;
Index: /trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp	(revision 50727)
@@ -884,5 +884,5 @@
          * output event.
          */
-        if (mSession->getProtocolVersion() >= 2)
+        if (mSession->i_getProtocolVersion() >= 2)
             eventTypes.push_back(VBoxEventType_OnGuestProcessStateChanged);
         eventTypes.push_back(VBoxEventType_OnGuestProcessOutput);
@@ -1000,5 +1000,5 @@
     LogFlowThisFunc(("uTimeoutMS=%RU32, procCmd=%s, procTimeoutMS=%RU32, procFlags=%x, sessionID=%RU32\n",
                      uTimeoutMS, mData.mProcess.mCommand.c_str(), mData.mProcess.mTimeoutMS, mData.mProcess.mFlags,
-                     mSession->getId()));
+                     mSession->i_getId()));
 
     /* Wait until the caller function (if kicked off by a thread)
@@ -1029,5 +1029,5 @@
     AssertPtr(pSession);
 
-    const GuestCredentials &sessionCreds = pSession->getCredentials();
+    const GuestCredentials &sessionCreds = pSession->i_getCredentials();
 
     /* Prepare arguments. */
@@ -1077,5 +1077,5 @@
     {
         AssertPtr(mSession);
-        uint32_t uProtocol = mSession->getProtocolVersion();
+        uint32_t uProtocol = mSession->i_getProtocolVersion();
 
         /* Prepare HGCM call. */
@@ -1215,5 +1215,5 @@
         /* Note: VBox < 4.3 (aka protocol version 1) does not
          *       support this, so just skip. */
-        if (mSession->getProtocolVersion() < 2)
+        if (mSession->i_getProtocolVersion() < 2)
             vrc = VERR_NOT_SUPPORTED;
 
@@ -1360,5 +1360,5 @@
     return GuestProcess::i_waitFlagsToResultEx(fWaitFlags,
                                                mData.mStatus /* curStatus */, mData.mStatus /* newStatus */,
-                                               mData.mProcess.mFlags, mSession->getProtocolVersion());
+                                               mData.mProcess.mFlags, mSession->i_getProtocolVersion());
 }
 
@@ -1444,5 +1444,5 @@
 
             waitResult = i_waitFlagsToResultEx(fWaitFlags, curStatus, newStatus,
-                                               mData.mProcess.mFlags, mSession->getProtocolVersion());
+                                               mData.mProcess.mFlags, mSession->i_getProtocolVersion());
 #ifdef DEBUG
             LogFlowThisFunc(("Got new status change: fWaitFlags=0x%x, newStatus=%RU32, waitResult=%RU32\n",
@@ -1690,5 +1690,5 @@
          * input event.
          */
-        if (mSession->getProtocolVersion() >= 2)
+        if (mSession->i_getProtocolVersion() >= 2)
             eventTypes.push_back(VBoxEventType_OnGuestProcessStateChanged);
         eventTypes.push_back(VBoxEventType_OnGuestProcessInputNotify);
@@ -1824,5 +1824,5 @@
      * still can hold references to it. */
     AssertPtr(mSession);
-    int rc2 = mSession->processRemoveFromList(this);
+    int rc2 = mSession->i_processRemoveFromList(this);
     if (RT_SUCCESS(vrc))
         vrc = rc2;
@@ -1979,5 +1979,5 @@
     mStartupInfo.mFlags |= ProcessCreateFlag_Hidden;
 
-    int vrc = pSession->processCreateExInteral(mStartupInfo, pProcess);
+    int vrc = pSession->i_processCreateExInteral(mStartupInfo, pProcess);
     if (RT_SUCCESS(vrc))
         vrc = fAsync
Index: /trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp	(revision 50727)
@@ -204,5 +204,5 @@
     HRESULT hr;
 
-    int rc = queryInfo();
+    int rc = i_queryInfo();
     if (RT_SUCCESS(rc))
     {
@@ -333,19 +333,15 @@
 /////////////////////////////////////////////////////////////////////////////
 
-STDMETHODIMP GuestSession::COMGETTER(User)(BSTR *aUser)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aUser);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getUser(com::Utf8Str &aUser)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    mData.mCredentials.mUser.cloneTo(aUser);
+    aUser = mData.mCredentials.mUser;
 
     LogFlowThisFuncLeave();
@@ -354,19 +350,14 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Domain)(BSTR *aDomain)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aDomain);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getDomain(com::Utf8Str &aDomain)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    mData.mCredentials.mDomain.cloneTo(aDomain);
+    aDomain = mData.mCredentials.mDomain;
 
     LogFlowThisFuncLeave();
@@ -375,19 +366,14 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Name)(BSTR *aName)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aName);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getName(com::Utf8Str &aName)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    mData.mSession.mName.cloneTo(aName);
+    aName = mData.mSession.mName;
 
     LogFlowThisFuncLeave();
@@ -396,15 +382,10 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Id)(ULONG *aId)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aId);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getId(ULONG *aId)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -417,15 +398,10 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Status)(GuestSessionStatus_T *aStatus)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aStatus);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getStatus(GuestSessionStatus_T *aStatus)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -438,15 +414,10 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Timeout)(ULONG *aTimeout)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aTimeout);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getTimeout(ULONG *aTimeout)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -459,13 +430,10 @@
 }
 
-STDMETHODIMP GuestSession::COMSETTER(Timeout)(ULONG aTimeout)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::setTimeout(ULONG aTimeout)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -478,19 +446,14 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(ProtocolVersion)(ULONG *aVersion)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aVersion);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getProtocolVersion(ULONG *aProtocolVersion)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    *aVersion = mData.mProtocolVersion;
+    *aProtocolVersion = mData.mProtocolVersion;
 
     LogFlowThisFuncLeave();
@@ -499,15 +462,10 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutSafeArrayPointerValid(aEnvironment);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getEnvironment(std::vector<com::Utf8Str> &aEnvironment)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -516,12 +474,7 @@
     LogFlowThisFunc(("[%s]: cEnvVars=%RU32\n",
                      mData.mSession.mName.c_str(), cEnvVars));
-    com::SafeArray<BSTR> environment(cEnvVars);
 
     for (size_t i = 0; i < cEnvVars; i++)
-    {
-        Bstr strEnv(mData.mEnvironment.Get(i));
-        strEnv.cloneTo(&environment[i]);
-    }
-    environment.detachTo(ComSafeArrayOutArg(aEnvironment));
+        aEnvironment[i] = mData.mEnvironment.Get(i);
 
     LogFlowThisFuncLeave();
@@ -530,25 +483,17 @@
 }
 
-STDMETHODIMP GuestSession::COMSETTER(Environment)(ComSafeArrayIn(IN_BSTR, aValues))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::setEnvironment(const std::vector<com::Utf8Str> &aEnvironment)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aValues));
-
     int rc = VINF_SUCCESS;
-    for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
-    {
-        Utf8Str strEnv(environment[i]);
-        if (!strEnv.isEmpty()) /* Silently skip empty entries. */
-            rc = mData.mEnvironment.Set(strEnv);
-    }
+    for (size_t i = 0; i < aEnvironment.size() && RT_SUCCESS(rc); ++i)
+        if (!aEnvironment[i].isEmpty()) /* Silently skip empty entries. */
+            rc = mData.mEnvironment.Set(aEnvironment[i]);
 
     HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
@@ -558,84 +503,69 @@
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Processes)(ComSafeArrayOut(IGuestProcess *, aProcesses))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutSafeArrayPointerValid(aProcesses);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getProcesses(std::vector<ComPtr<IGuestProcess> > &aProcesses)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    SafeIfaceArray<IGuestProcess> collection(mData.mProcesses);
-    collection.detachTo(ComSafeArrayOutArg(aProcesses));
-
-    LogFlowFunc(("mProcesses=%zu\n", collection.size()));
+    aProcesses.resize(mData.mProcesses.size());
+    size_t i = 0;
+    for(SessionProcesses::iterator it = mData.mProcesses.begin(); it != mData.mProcesses.end(); ++it, ++i)
+        it->second.queryInterfaceTo(aProcesses[i].asOutParam());
+
+    LogFlowFunc(("mProcesses=%zu\n", aProcesses.size()));
     return S_OK;
 #endif /* VBOX_WITH_GUEST_CONTROL */
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Directories)(ComSafeArrayOut(IGuestDirectory *, aDirectories))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutSafeArrayPointerValid(aDirectories);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getDirectories(std::vector<ComPtr<IGuestDirectory> > &aDirectories)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    SafeIfaceArray<IGuestDirectory> collection(mData.mDirectories);
-    collection.detachTo(ComSafeArrayOutArg(aDirectories));
-
-    LogFlowFunc(("mDirectories=%zu\n", collection.size()));
+    aDirectories.resize(mData.mDirectories.size());
+    size_t i = 0;
+    for(SessionDirectories::iterator it = mData.mDirectories.begin(); it != mData.mDirectories.end(); ++it, ++i)
+        it->second.queryInterfaceTo(aDirectories[i].asOutParam());
+
+    LogFlowFunc(("mDirectories=%zu\n", aDirectories.size()));
     return S_OK;
 #endif /* VBOX_WITH_GUEST_CONTROL */
 }
 
-STDMETHODIMP GuestSession::COMGETTER(Files)(ComSafeArrayOut(IGuestFile *, aFiles))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutSafeArrayPointerValid(aFiles);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getFiles(std::vector<ComPtr<IGuestFile> > &aFiles)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    SafeIfaceArray<IGuestFile> collection(mData.mFiles);
-    collection.detachTo(ComSafeArrayOutArg(aFiles));
-
-    LogFlowFunc(("mFiles=%zu\n", collection.size()));
+    aFiles.resize(mData.mFiles.size());
+    size_t i = 0;
+    for(SessionFiles::iterator it = mData.mFiles.begin(); it != mData.mFiles.end(); ++it, ++i)
+        it->second.queryInterfaceTo(aFiles[i].asOutParam());
+
+    LogFlowFunc(("mDirectories=%zu\n", aFiles.size()));
+
     return S_OK;
 #endif /* VBOX_WITH_GUEST_CONTROL */
 }
 
-STDMETHODIMP GuestSession::COMGETTER(EventSource)(IEventSource ** aEventSource)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aEventSource);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::getEventSource(ComPtr<IEventSource> &aEventSource)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     // no need to lock - lifetime constant
-    mEventSource.queryInterfaceTo(aEventSource);
+    mEventSource.queryInterfaceTo(aEventSource.asOutParam());
 
     LogFlowThisFuncLeave();
@@ -647,5 +577,5 @@
 ///////////////////////////////////////////////////////////////////////////////
 
-int GuestSession::closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc)
+int GuestSession::i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *pGuestRc)
 {
     LogFlowThisFunc(("uFlags=%x, uTimeoutMS=%RU32\n", uFlags, uTimeoutMS));
@@ -699,7 +629,7 @@
     alock.release(); /* Drop the write lock before waiting. */
 
-    vrc = sendCommand(HOST_SESSION_CLOSE, i, paParms);
+    vrc = i_sendCommand(HOST_SESSION_CLOSE, i, paParms);
     if (RT_SUCCESS(vrc))
-        vrc = waitForStatusChange(pEvent, GuestSessionWaitForFlag_Terminate, uTimeoutMS,
+        vrc = i_waitForStatusChange(pEvent, GuestSessionWaitForFlag_Terminate, uTimeoutMS,
                                   NULL /* Session status */, pGuestRc);
 
@@ -710,5 +640,5 @@
 }
 
-int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode,
+int GuestSession::i_directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode,
                                           uint32_t uFlags, int *pGuestRc)
 {
@@ -759,5 +689,5 @@
 }
 
-inline bool GuestSession::directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir)
+inline bool GuestSession::i_directoryExists(uint32_t uDirID, ComObjPtr<GuestDirectory> *pDir)
 {
     SessionDirectories::const_iterator it = mData.mDirectories.find(uDirID);
@@ -771,9 +701,9 @@
 }
 
-int GuestSession::directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
+int GuestSession::i_directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
 {
     LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
 
-    int vrc = fsQueryInfoInternal(strPath, objData, pGuestRc);
+    int vrc = i_fsQueryInfoInternal(strPath, objData, pGuestRc);
     if (RT_SUCCESS(vrc))
     {
@@ -786,5 +716,5 @@
 }
 
-int GuestSession::directoryRemoveFromList(GuestDirectory *pDirectory)
+int GuestSession::i_directoryRemoveFromList(GuestDirectory *pDirectory)
 {
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -825,6 +755,6 @@
 }
 
-int GuestSession::directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags,
-                                          int *pGuestRc)
+int GuestSession::i_directoryRemoveInternal(const Utf8Str &strPath, uint32_t uFlags,
+                                            int *pGuestRc)
 {
     AssertReturn(!(uFlags & ~DIRREMOVE_FLAG_VALID_MASK), VERR_INVALID_PARAMETER);
@@ -850,5 +780,5 @@
     alock.release(); /* Drop write lock before sending. */
 
-    vrc = sendCommand(HOST_DIR_REMOVE, i, paParms);
+    vrc = i_sendCommand(HOST_DIR_REMOVE, i, paParms);
     if (RT_SUCCESS(vrc))
     {
@@ -865,6 +795,6 @@
 }
 
-int GuestSession::objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath,
-                                           bool fDirectory, Utf8Str &strName, int *pGuestRc)
+int GuestSession::i_objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath,
+                                             bool fDirectory, Utf8Str &strName, int *pGuestRc)
 {
     LogFlowThisFunc(("strTemplate=%s, strPath=%s, fDirectory=%RTbool\n",
@@ -928,6 +858,6 @@
 }
 
-int GuestSession::directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo,
-                                        ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc)
+int GuestSession::i_directoryOpenInternal(const GuestDirectoryOpenInfo &openInfo,
+                                          ComObjPtr<GuestDirectory> &pDirectory, int *pGuestRc)
 {
     LogFlowThisFunc(("strPath=%s, strPath=%s, uFlags=%x\n",
@@ -947,5 +877,5 @@
     {
         /* Is the directory ID already used? */
-        if (!directoryExists(uNewDirID, NULL /* pDirectory */))
+        if (!i_directoryExists(uNewDirID, NULL /* pDirectory */))
         {
             /* Callback with context ID was not found. This means
@@ -1016,5 +946,5 @@
 }
 
-int GuestSession::dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
+int GuestSession::i_dispatchToDirectory(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
 {
     LogFlowFunc(("pCtxCb=%p, pSvcCb=%p\n", pCtxCb, pSvcCb));
@@ -1052,5 +982,5 @@
 }
 
-int GuestSession::dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
+int GuestSession::i_dispatchToFile(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
 {
     LogFlowFunc(("pCtxCb=%p, pSvcCb=%p\n", pCtxCb, pSvcCb));
@@ -1085,5 +1015,5 @@
 }
 
-int GuestSession::dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
+int GuestSession::i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
 {
     LogFlowFunc(("pCtxCb=%p, pSvcCb=%p\n", pCtxCb, pSvcCb));
@@ -1108,5 +1038,5 @@
             alock.release();
 
-            rc = dispatchToFile(pCtxCb, pSvcCb);
+            rc = i_dispatchToFile(pCtxCb, pSvcCb);
         }
         else
@@ -1117,5 +1047,5 @@
                 alock.release();
 
-                rc = dispatchToDirectory(pCtxCb, pSvcCb);
+                rc = i_dispatchToDirectory(pCtxCb, pSvcCb);
             }
             else
@@ -1127,5 +1057,5 @@
         alock.release();
 
-        rc = dispatchToProcess(pCtxCb, pSvcCb);
+        rc = i_dispatchToProcess(pCtxCb, pSvcCb);
     }
 
@@ -1134,5 +1064,5 @@
 }
 
-int GuestSession::dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
+int GuestSession::i_dispatchToProcess(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
 {
     LogFlowFunc(("pCtxCb=%p, pSvcCb=%p\n", pCtxCb, pSvcCb));
@@ -1176,5 +1106,5 @@
 }
 
-int GuestSession::dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
+int GuestSession::i_dispatchToThis(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
 {
     AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
@@ -1198,5 +1128,5 @@
         case GUEST_SESSION_NOTIFY: /* Guest Additions >= 4.3.0. */
         {
-            rc = onSessionStatusChange(pCbCtx, pSvcCb);
+            rc = i_onSessionStatusChange(pCbCtx, pSvcCb);
             break;
         }
@@ -1212,5 +1142,5 @@
 }
 
-inline bool GuestSession::fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile)
+inline bool GuestSession::i_fileExists(uint32_t uFileID, ComObjPtr<GuestFile> *pFile)
 {
     SessionFiles::const_iterator it = mData.mFiles.find(uFileID);
@@ -1224,5 +1154,5 @@
 }
 
-int GuestSession::fileRemoveFromList(GuestFile *pFile)
+int GuestSession::i_fileRemoveFromList(GuestFile *pFile)
 {
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -1266,5 +1196,5 @@
 }
 
-int GuestSession::fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc)
+int GuestSession::i_fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc)
 {
     LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
@@ -1295,6 +1225,6 @@
 }
 
-int GuestSession::fileOpenInternal(const GuestFileOpenInfo &openInfo,
-                                   ComObjPtr<GuestFile> &pFile, int *pGuestRc)
+int GuestSession::i_fileOpenInternal(const GuestFileOpenInfo &openInfo,
+                                     ComObjPtr<GuestFile> &pFile, int *pGuestRc)
 {
     LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, uOffset=%RU64\n",
@@ -1323,5 +1253,5 @@
     {
         /* Is the file ID already used? */
-        if (!fileExists(uNewFileID, NULL /* pFile */))
+        if (!i_fileExists(uNewFileID, NULL /* pFile */))
         {
             /* Callback with context ID was not found. This means
@@ -1397,9 +1327,9 @@
 }
 
-int GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
+int GuestSession::i_fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
 {
     LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
 
-    int vrc = fsQueryInfoInternal(strPath, objData, pGuestRc);
+    int vrc = i_fsQueryInfoInternal(strPath, objData, pGuestRc);
     if (RT_SUCCESS(vrc))
     {
@@ -1412,10 +1342,10 @@
 }
 
-int GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc)
+int GuestSession::i_fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc)
 {
     AssertPtrReturn(pllSize, VERR_INVALID_POINTER);
 
     GuestFsObjData objData;
-    int vrc = fileQueryInfoInternal(strPath, objData, pGuestRc);
+    int vrc = i_fileQueryInfoInternal(strPath, objData, pGuestRc);
     if (RT_SUCCESS(vrc))
         *pllSize = objData.mObjectSize;
@@ -1424,5 +1354,5 @@
 }
 
-int GuestSession::fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
+int GuestSession::i_fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
 {
     LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
@@ -1469,15 +1399,15 @@
 }
 
-const GuestCredentials& GuestSession::getCredentials(void)
+const GuestCredentials& GuestSession::i_getCredentials(void)
 {
     return mData.mCredentials;
 }
 
-const GuestEnvironment& GuestSession::getEnvironment(void)
+const GuestEnvironment& GuestSession::i_getEnvironment(void)
 {
     return mData.mEnvironment;
 }
 
-Utf8Str GuestSession::getName(void)
+Utf8Str GuestSession::i_getName(void)
 {
     return mData.mSession.mName;
@@ -1485,5 +1415,5 @@
 
 /* static */
-Utf8Str GuestSession::guestErrorToString(int guestRc)
+Utf8Str GuestSession::i_guestErrorToString(int guestRc)
 {
     Utf8Str strError;
@@ -1542,5 +1472,5 @@
  * error when not ready.
  */
-HRESULT GuestSession::isReadyExternal(void)
+HRESULT GuestSession::i_isReadyExternal(void)
 {
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -1557,5 +1487,5 @@
  * the public session list.
  */
-int GuestSession::onRemove(void)
+int GuestSession::i_onRemove(void)
 {
     LogFlowThisFuncEnter();
@@ -1582,5 +1512,5 @@
 
 /** No locking! */
-int GuestSession::onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
+int GuestSession::i_onSessionStatusChange(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
 {
     AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
@@ -1646,5 +1576,5 @@
     /* Set the session status. */
     if (RT_SUCCESS(vrc))
-        vrc = setSessionStatus(sessionStatus, guestRc);
+        vrc = i_setSessionStatus(sessionStatus, guestRc);
 
     LogFlowThisFunc(("ID=%RU32, guestRc=%Rrc\n", mData.mSession.mID, guestRc));
@@ -1654,5 +1584,5 @@
 }
 
-int GuestSession::startSessionInternal(int *pGuestRc)
+int GuestSession::i_startSessionInternal(int *pGuestRc)
 {
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -1715,10 +1645,10 @@
     alock.release(); /* Drop write lock before sending. */
 
-    vrc = sendCommand(HOST_SESSION_CREATE, i, paParms);
+    vrc = i_sendCommand(HOST_SESSION_CREATE, i, paParms);
     if (RT_SUCCESS(vrc))
     {
-        vrc = waitForStatusChange(pEvent, GuestSessionWaitForFlag_Start,
-                                  30 * 1000 /* 30s timeout */,
-                                  NULL /* Session status */, pGuestRc);
+        vrc = i_waitForStatusChange(pEvent, GuestSessionWaitForFlag_Start,
+                                    30 * 1000 /* 30s timeout */,
+                                    NULL /* Session status */, pGuestRc);
     }
     else
@@ -1740,5 +1670,5 @@
 }
 
-int GuestSession::startSessionAsync(void)
+int GuestSession::i_startSessionAsync(void)
 {
     LogFlowThisFuncEnter();
@@ -1753,5 +1683,5 @@
         AssertReturn(pTask->isOk(), pTask->rc());
 
-        vrc = RTThreadCreate(NULL, GuestSession::startSessionThread,
+        vrc = RTThreadCreate(NULL, GuestSession::i_startSessionThread,
                              (void *)pTask.get(), 0,
                              RTTHREADTYPE_MAIN_WORKER, 0,
@@ -1773,5 +1703,5 @@
 
 /* static */
-DECLCALLBACK(int) GuestSession::startSessionThread(RTTHREAD Thread, void *pvUser)
+DECLCALLBACK(int) GuestSession::i_startSessionThread(RTTHREAD Thread, void *pvUser)
 {
     LogFlowFunc(("pvUser=%p\n", pvUser));
@@ -1786,5 +1716,5 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    int vrc = pSession->startSessionInternal(NULL /* Guest rc, ignored */);
+    int vrc = pSession->i_startSessionInternal(NULL /* Guest rc, ignored */);
     /* Nothing to do here anymore. */
 
@@ -1793,5 +1723,5 @@
 }
 
-int GuestSession::pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest,
+int GuestSession::i_pathRenameInternal(const Utf8Str &strSource, const Utf8Str &strDest,
                                      uint32_t uFlags, int *pGuestRc)
 {
@@ -1821,5 +1751,5 @@
     alock.release(); /* Drop write lock before sending. */
 
-    vrc = sendCommand(HOST_PATH_RENAME, i, paParms);
+    vrc = i_sendCommand(HOST_PATH_RENAME, i, paParms);
     if (RT_SUCCESS(vrc))
     {
@@ -1836,5 +1766,5 @@
 }
 
-int GuestSession::processRemoveFromList(GuestProcess *pProcess)
+int GuestSession::i_processRemoveFromList(GuestProcess *pProcess)
 {
     AssertPtrReturn(pProcess, VERR_INVALID_POINTER);
@@ -1902,5 +1832,5 @@
  * @param   pProcess
  */
-int GuestSession::processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
+int GuestSession::i_processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
 {
     LogFlowFunc(("mCmd=%s, mFlags=%x, mTimeoutMS=%RU32\n",
@@ -1963,5 +1893,5 @@
     {
         /* Is the context ID already used? */
-        if (!processExists(uNewProcessID, NULL /* pProcess */))
+        if (!i_processExists(uNewProcessID, NULL /* pProcess */))
         {
             /* Callback with context ID was not found. This means
@@ -2015,5 +1945,5 @@
 }
 
-inline bool GuestSession::processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess)
+inline bool GuestSession::i_processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess)
 {
     SessionProcesses::const_iterator it = mData.mProcesses.find(uProcessID);
@@ -2027,5 +1957,5 @@
 }
 
-inline int GuestSession::processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess)
+inline int GuestSession::i_processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess)
 {
     AssertReturn(uPID, false);
@@ -2055,6 +1985,6 @@
 }
 
-int GuestSession::sendCommand(uint32_t uFunction,
-                              uint32_t uParms, PVBOXHGCMSVCPARM paParms)
+int GuestSession::i_sendCommand(uint32_t uFunction,
+                                uint32_t uParms, PVBOXHGCMSVCPARM paParms)
 {
     LogFlowThisFuncEnter();
@@ -2083,14 +2013,14 @@
 
 /* static */
-HRESULT GuestSession::setErrorExternal(VirtualBoxBase *pInterface, int guestRc)
+HRESULT GuestSession::i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc)
 {
     AssertPtr(pInterface);
     AssertMsg(RT_FAILURE(guestRc), ("Guest rc does not indicate a failure when setting error\n"));
 
-    return pInterface->setError(VBOX_E_IPRT_ERROR, GuestSession::guestErrorToString(guestRc).c_str());
+    return pInterface->setError(VBOX_E_IPRT_ERROR, GuestSession::i_guestErrorToString(guestRc).c_str());
 }
 
 /* Does not do locking; caller is responsible for that! */
-int GuestSession::setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc)
+int GuestSession::i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc)
 {
     LogFlowThisFunc(("oldStatus=%RU32, newStatus=%RU32, sessionRc=%Rrc\n",
@@ -2117,5 +2047,5 @@
         int rc2 = errorInfo->initEx(VBOX_E_IPRT_ERROR, sessionRc,
                                     COM_IIDOF(IGuestSession), getComponentName(),
-                                    guestErrorToString(sessionRc));
+                                    i_guestErrorToString(sessionRc));
         AssertRC(rc2);
 
@@ -2127,5 +2057,5 @@
 }
 
-int GuestSession::signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */)
+int GuestSession::i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */)
 {
     /*LogFlowThisFunc(("enmWaitResult=%d, rc=%Rrc, mWaitCount=%RU32, mWaitEvent=%p\n",
@@ -2141,6 +2071,6 @@
 }
 
-int GuestSession::startTaskAsync(const Utf8Str &strTaskDesc,
-                                 GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress)
+int GuestSession::i_startTaskAsync(const Utf8Str &strTaskDesc,
+                                   GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress)
 {
     LogFlowThisFunc(("strTaskDesc=%s, pTask=%p\n", strTaskDesc.c_str(), pTask));
@@ -2180,5 +2110,5 @@
  * @return  IPRT status code.
  */
-int GuestSession::queryInfo(void)
+int GuestSession::i_queryInfo(void)
 {
     /*
@@ -2220,5 +2150,5 @@
 }
 
-int GuestSession::waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc)
+int GuestSession::i_waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestSessionWaitResult_T &waitResult, int *pGuestRc)
 {
     LogFlowThisFuncEnter();
@@ -2347,6 +2277,6 @@
 
     GuestSessionStatus_T sessionStatus;
-    vrc = waitForStatusChange(pEvent, fWaitFlags,
-                              uTimeoutMS, &sessionStatus, pGuestRc);
+    vrc = i_waitForStatusChange(pEvent, fWaitFlags,
+                                uTimeoutMS, &sessionStatus, pGuestRc);
     if (RT_SUCCESS(vrc))
     {
@@ -2386,6 +2316,6 @@
 }
 
-int GuestSession::waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS,
-                                      GuestSessionStatus_T *pSessionStatus, int *pGuestRc)
+int GuestSession::i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS,
+                                        GuestSessionStatus_T *pSessionStatus, int *pGuestRc)
 {
     AssertPtrReturn(pEvent, VERR_INVALID_POINTER);
@@ -2431,5 +2361,5 @@
 /////////////////////////////////////////////////////////////////////////////
 
-STDMETHODIMP GuestSession::Close(void)
+STDMETHODIMP GuestSession::close(void)
 {
 #ifndef VBOX_WITH_GUEST_CONTROL
@@ -2443,6 +2373,6 @@
     /* Close session on guest. */
     int guestRc = VINF_SUCCESS;
-    int rc = closeSession(0 /* Flags */, 30 * 1000 /* Timeout */,
-                          &guestRc);
+    int rc = i_closeSession(0 /* Flags */, 30 * 1000 /* Timeout */,
+                            &guestRc);
     /* On failure don't return here, instead do all the cleanup
      * work first and then return an error. */
@@ -2461,5 +2391,5 @@
     {
         if (rc == VERR_GSTCTL_GUEST_ERROR)
-            return GuestSession::setErrorExternal(this, guestRc);
+            return GuestSession::i_setErrorExternal(this, guestRc);
 
         return setError(VBOX_E_IPRT_ERROR,
@@ -2471,29 +2401,22 @@
 }
 
-STDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    CheckComArgStrNotEmptyOrNull(aSource);
-    CheckComArgStrNotEmptyOrNull(aDest);
-    CheckComArgOutPointerValid(aProgress);
-
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
+HRESULT GuestSession::copyFrom(const com::Utf8Str &aSource, const com::Utf8Str &aDest, const std::vector<CopyFileFlag_T> &aFlags, ComPtr<IProgress> &aProgress)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aSource.c_str()) == NULL || *(aSource.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No source specified"));
-    if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
+    if (RT_UNLIKELY((aDest.c_str()) == NULL || *(aDest.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No destination specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     uint32_t fFlags = CopyFileFlag_None;
-    if (aFlags)
-    {
-        com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
-        for (size_t i = 0; i < flags.size(); i++)
-            fFlags |= flags[i];
+    if (aFlags.size())
+    {
+        for (size_t i = 0; i < aFlags.size(); i++)
+            fFlags |= aFlags[i];
     }
 
@@ -2506,15 +2429,13 @@
         ComObjPtr<Progress> pProgress;
         SessionTaskCopyFrom *pTask = new SessionTaskCopyFrom(this /* GuestSession */,
-                                                             Utf8Str(aSource), Utf8Str(aDest), fFlags);
-        int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
+                                                             aSource, aDest, fFlags);
+        int rc = i_startTaskAsync(Utf8StrFmt(tr("Copying \"%s\" from guest to \"%s\" on the host"), aSource.c_str(), aDest.c_str()),
                                 pTask, pProgress);
         if (RT_SUCCESS(rc))
-        {
             /* Return progress to the caller. */
-            hr = pProgress.queryInterfaceTo(aProgress);
-        }
+            hr = pProgress.queryInterfaceTo(aProgress.asOutParam());
         else
             hr = setError(VBOX_E_IPRT_ERROR,
-                          tr("Starting task for copying file \"%ls\" from guest to \"%ls\" on the host failed: %Rrc"), rc);
+                          tr("Starting task for copying file \"%s\" from guest to \"%s\" on the host failed: %Rrc"), rc);
     }
     catch(std::bad_alloc &)
@@ -2527,29 +2448,22 @@
 }
 
-STDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    CheckComArgStrNotEmptyOrNull(aSource);
-    CheckComArgStrNotEmptyOrNull(aDest);
-    CheckComArgOutPointerValid(aProgress);
-
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
+HRESULT GuestSession::copyTo(const com::Utf8Str &aSource, const com::Utf8Str &aDest, const std::vector<CopyFileFlag_T> &aFlags, ComPtr<IProgress> &aProgress)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aSource.c_str()) == NULL || *(aSource.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No source specified"));
-    if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
+    if (RT_UNLIKELY((aDest.c_str()) == NULL || *(aDest.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No destination specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     uint32_t fFlags = CopyFileFlag_None;
-    if (aFlags)
-    {
-        com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
-        for (size_t i = 0; i < flags.size(); i++)
-            fFlags |= flags[i];
+    if (aFlags.size())
+    {
+        for (size_t i = 0; i < aFlags.size(); i++)
+            fFlags |= aFlags[i];
     }
 
@@ -2562,16 +2476,16 @@
         ComObjPtr<Progress> pProgress;
         SessionTaskCopyTo *pTask = new SessionTaskCopyTo(this /* GuestSession */,
-                                                         Utf8Str(aSource), Utf8Str(aDest), fFlags);
+                                                         aSource, aDest, fFlags);
         AssertPtrReturn(pTask, E_OUTOFMEMORY);
-        int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
+        int rc = i_startTaskAsync(Utf8StrFmt(tr("Copying \"%s\" from host to \"%s\" on the guest"), aSource.c_str(), aDest.c_str()),
                                 pTask, pProgress);
         if (RT_SUCCESS(rc))
         {
             /* Return progress to the caller. */
-            hr = pProgress.queryInterfaceTo(aProgress);
+            hr = pProgress.queryInterfaceTo(aProgress.asOutParam());
         }
         else
             hr = setError(VBOX_E_IPRT_ERROR,
-                          tr("Starting task for copying file \"%ls\" from host to \"%ls\" on the guest failed: %Rrc"), rc);
+                          tr("Starting task for copying file \"%s\" from host to \"%s\" on the guest failed: %Rrc"), rc);
     }
     catch(std::bad_alloc &)
@@ -2584,30 +2498,24 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode,
-                                           ComSafeArrayIn(DirectoryCreateFlag_T, aFlags))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::directoryCreate(const com::Utf8Str &aPath, ULONG aMode,
+                                      const std::vector<DirectoryCreateFlag_T> &aFlags)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory to create specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     uint32_t fFlags = DirectoryCreateFlag_None;
-    if (aFlags)
-    {
-        com::SafeArray<DirectoryCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
-        for (size_t i = 0; i < flags.size(); i++)
-            fFlags |= flags[i];
+    if (aFlags.size())
+    {
+        for (size_t i = 0; i < aFlags.size(); i++)
+            fFlags |= aFlags[i];
 
         if (fFlags)
-        {
             if (!(fFlags & DirectoryCreateFlag_Parents))
                 return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), fFlags);
-        }
     }
 
@@ -2615,5 +2523,5 @@
 
     ComObjPtr <GuestDirectory> pDirectory; int guestRc;
-    int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, &guestRc);
+    int rc = i_directoryCreateInternal(aPath, (uint32_t)aMode, fFlags, &guestRc);
     if (RT_FAILURE(rc))
     {
@@ -2643,31 +2551,23 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, BSTR *aDirectory)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aTemplate) == NULL || *(aTemplate) == '\0'))
+HRESULT GuestSession::directoryCreateTemp(const com::Utf8Str &aTemplateName, ULONG aMode, const com::Utf8Str &aPath, BOOL aSecure, com::Utf8Str &aDirectory)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aTemplateName.c_str()) == NULL || *(aTemplateName.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No template specified"));
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory name specified"));
-    CheckComArgOutPointerValid(aDirectory);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     HRESULT hr = S_OK;
 
-    Utf8Str strName; int guestRc;
-    int rc = objectCreateTempInternal(Utf8Str(aTemplate),
-                                      Utf8Str(aPath),
-                                      true /* Directory */, strName, &guestRc);
-    if (RT_SUCCESS(rc))
-    {
-        strName.cloneTo(aDirectory);
-    }
-    else
+    int guestRc;
+    int rc = i_objectCreateTempInternal(aTemplateName,
+                                        aPath,
+                                        true /* Directory */, aDirectory, &guestRc);
+    if (!RT_SUCCESS(rc))
     {
         switch (rc)
@@ -2679,5 +2579,5 @@
             default:
                hr = setError(VBOX_E_IPRT_ERROR, tr("Temporary directory creation \"%s\" with template \"%s\" failed: %Rrc"),
-                             Utf8Str(aPath).c_str(), Utf8Str(aTemplate).c_str(), rc);
+                             aPath.c_str(), aTemplateName.c_str(), rc);
                break;
         }
@@ -2688,26 +2588,20 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryExists(IN_BSTR aPath, BOOL *aExists)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::directoryExists(const com::Utf8Str &aPath, BOOL *aExists)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory to check existence for specified"));
-    CheckComArgOutPointerValid(aExists);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     HRESULT hr = S_OK;
 
     GuestFsObjData objData; int guestRc;
-    int rc = directoryQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
+    int rc = i_directoryQueryInfoInternal(aPath, objData, &guestRc);
     if (RT_SUCCESS(rc))
-    {
         *aExists = objData.mType == FsObjType_Directory;
-    }
     else
     {
@@ -2720,5 +2614,5 @@
             default:
                hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory existence \"%s\" failed: %Rrc"),
-                             Utf8Str(aPath).c_str(), rc);
+                             aPath.c_str(), rc);
                break;
         }
@@ -2729,26 +2623,21 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, ComSafeArrayIn(DirectoryOpenFlag_T, aFlags), IGuestDirectory **aDirectory)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::directoryOpen(const com::Utf8Str &aPath, const com::Utf8Str &aFilter, const std::vector<DirectoryOpenFlag_T> &aFlags, ComPtr<IGuestDirectory> &aDirectory)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory to open specified"));
-    if (RT_UNLIKELY((aFilter) != NULL && *(aFilter) != '\0'))
+    if (RT_UNLIKELY((aFilter.c_str()) != NULL && *(aFilter.c_str()) != '\0'))
         return setError(E_INVALIDARG, tr("Directory filters are not implemented yet"));
-    CheckComArgOutPointerValid(aDirectory);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     uint32_t fFlags = DirectoryOpenFlag_None;
-    if (aFlags)
-    {
-        com::SafeArray<DirectoryOpenFlag_T> flags(ComSafeArrayInArg(aFlags));
-        for (size_t i = 0; i < flags.size(); i++)
-            fFlags |= flags[i];
+    if (aFlags.size())
+    {
+        for (size_t i = 0; i < aFlags.size(); i++)
+            fFlags |= aFlags[i];
 
         if (fFlags)
@@ -2759,14 +2648,14 @@
 
     GuestDirectoryOpenInfo openInfo;
-    openInfo.mPath = Utf8Str(aPath);
-    openInfo.mFilter = Utf8Str(aFilter);
+    openInfo.mPath = aPath;
+    openInfo.mFilter = aFilter;
     openInfo.mFlags = fFlags;
 
     ComObjPtr <GuestDirectory> pDirectory; int guestRc;
-    int rc = directoryOpenInternal(openInfo, pDirectory, &guestRc);
+    int rc = i_directoryOpenInternal(openInfo, pDirectory, &guestRc);
     if (RT_SUCCESS(rc))
     {
         /* Return directory object to the caller. */
-        hr = pDirectory.queryInterfaceTo(aDirectory);
+        hr = pDirectory.queryInterfaceTo(aDirectory.asOutParam());
     }
     else
@@ -2776,5 +2665,5 @@
             case VERR_INVALID_PARAMETER:
                hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory \"%s\" failed; invalid parameters given",
-                                                   Utf8Str(aPath).c_str()));
+                                                   aPath.c_str()));
                break;
 
@@ -2785,5 +2674,5 @@
             default:
                hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory \"%s\" failed: %Rrc"),
-                             Utf8Str(aPath).c_str(),rc);
+                             aPath.c_str(),rc);
                break;
         }
@@ -2794,22 +2683,18 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::directoryQueryInfo(const com::Utf8Str &aPath, ComPtr<IGuestFsObjInfo> &aInfo)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory to query information for specified"));
-    CheckComArgOutPointerValid(aInfo);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     HRESULT hr = S_OK;
 
     GuestFsObjData objData; int guestRc;
-    int vrc = directoryQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
+    int vrc = i_directoryQueryInfoInternal(aPath, objData, &guestRc);
     if (RT_SUCCESS(vrc))
     {
@@ -2823,5 +2708,5 @@
             if (RT_SUCCESS(vrc))
             {
-                hr = pFsObjInfo.queryInterfaceTo(aInfo);
+                hr = pFsObjInfo.queryInterfaceTo(aInfo.asOutParam());
                 if (FAILED(hr)) return hr;
             }
@@ -2839,10 +2724,10 @@
             case VERR_NOT_A_DIRECTORY:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Element \"%s\" exists but is not a directory",
-                                                    Utf8Str(aPath).c_str()));
+                                                    aPath.c_str()));
                 break;
 
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory information for \"%s\" failed: %Rrc"),
-                              Utf8Str(aPath).c_str(), vrc);
+                              aPath.c_str(), vrc);
                 break;
         }
@@ -2853,18 +2738,15 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryRemove(IN_BSTR aPath)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::directoryRemove(const com::Utf8Str &aPath)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory to remove specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    HRESULT hr = isReadyExternal();
+    HRESULT hr = i_isReadyExternal();
     if (FAILED(hr))
         return hr;
@@ -2874,5 +2756,5 @@
 
     int guestRc;
-    int vrc = directoryRemoveInternal(Utf8Str(aPath), uFlags, &guestRc);
+    int vrc = i_directoryRemoveInternal(aPath, uFlags, &guestRc);
     if (RT_FAILURE(vrc))
     {
@@ -2890,5 +2772,5 @@
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Removing guest directory \"%s\" failed: %Rrc"),
-                              Utf8Str(aPath).c_str(), vrc);
+                              aPath.c_str(), vrc);
                 break;
         }
@@ -2899,18 +2781,15 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::directoryRemoveRecursive(const com::Utf8Str &aPath, const std::vector<DirectoryRemoveRecFlag_T> &aFlags, ComPtr<IProgress> &aProgress)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No directory to remove recursively specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    HRESULT hr = isReadyExternal();
+    HRESULT hr = i_isReadyExternal();
     if (FAILED(hr))
         return hr;
@@ -2937,5 +2816,5 @@
                     | DIRREMOVE_FLAG_CONTENT_AND_DIR;
     int guestRc;
-    int vrc = directoryRemoveInternal(Utf8Str(aPath), uFlags, &guestRc);
+    int vrc = i_directoryRemoveInternal(aPath, uFlags, &guestRc);
     if (RT_FAILURE(vrc))
     {
@@ -2953,5 +2832,5 @@
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Recursively removing guest directory \"%s\" failed: %Rrc"),
-                              Utf8Str(aPath).c_str(), vrc);
+                              aPath.c_str(), vrc);
                 break;
         }
@@ -2959,5 +2838,5 @@
     else
     {
-        pProgress.queryInterfaceTo(aProgress);
+        pProgress.queryInterfaceTo(aProgress.asOutParam());
     }
 
@@ -2966,21 +2845,20 @@
 }
 
-STDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
+HRESULT GuestSession::directoryRename(const com::Utf8Str &aSource,
+                                      const com::Utf8Str &aDest,
+                                      const std::vector<PathRenameFlag_T> &aFlags)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aSource.c_str()) == NULL || *(aSource.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No source directory to rename specified"));
 
-    if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
+    if (RT_UNLIKELY((aDest.c_str()) == NULL || *(aDest.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No destination directory to rename the source to specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    HRESULT hr = isReadyExternal();
+    HRESULT hr = i_isReadyExternal();
     if (FAILED(hr))
         return hr;
@@ -2990,5 +2868,5 @@
 
     int guestRc;
-    int vrc = pathRenameInternal(Utf8Str(aSource), Utf8Str(aDest), uFlags, &guestRc);
+    int vrc = i_pathRenameInternal(aSource, aDest, uFlags, &guestRc);
     if (RT_FAILURE(vrc))
     {
@@ -3007,5 +2885,5 @@
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Renaming guest directory \"%s\" failed: %Rrc"),
-                              Utf8Str(aSource).c_str(), vrc);
+                              aSource.c_str(), vrc);
                 break;
         }
@@ -3016,27 +2894,21 @@
 }
 
-STDMETHODIMP GuestSession::DirectorySetACL(IN_BSTR aPath, IN_BSTR aACL)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::EnvironmentClear(void)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::directorySetACL(const com::Utf8Str &aPath, const com::Utf8Str &aAcl)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::environmentClear()
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -3049,23 +2921,17 @@
 }
 
-STDMETHODIMP GuestSession::EnvironmentGet(IN_BSTR aName, BSTR *aValue)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
+HRESULT GuestSession::environmentGet(const com::Utf8Str &aName, com::Utf8Str &aValue)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY(aName.c_str() == NULL) || *(aName.c_str()) == '\0')
         return setError(E_INVALIDARG, tr("No value name specified"));
 
-    CheckComArgOutPointerValid(aValue);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    Bstr strValue(mData.mEnvironment.Get(Utf8Str(aName)));
-    strValue.cloneTo(aValue);
+    aValue =  mData.mEnvironment.Get(aName);
 
     LogFlowThisFuncLeave();
@@ -3074,20 +2940,17 @@
 }
 
-STDMETHODIMP GuestSession::EnvironmentSet(IN_BSTR aName, IN_BSTR aValue)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
+HRESULT GuestSession::environmentSet(const com::Utf8Str &aName, const com::Utf8Str &aValue)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aName.c_str() == NULL) || *(aName.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No value name specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    int rc = mData.mEnvironment.Set(Utf8Str(aName), Utf8Str(aValue));
+    int rc = mData.mEnvironment.Set(aName, aValue);
 
     HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
@@ -3097,17 +2960,14 @@
 }
 
-STDMETHODIMP GuestSession::EnvironmentUnset(IN_BSTR aName)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::environmentUnset(const com::Utf8Str &aName)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    mData.mEnvironment.Unset(Utf8Str(aName));
+    mData.mEnvironment.Unset(aName);
 
     LogFlowThisFuncLeave();
@@ -3116,34 +2976,28 @@
 }
 
-STDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, IGuestFile **aFile)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::FileExists(IN_BSTR aPath, BOOL *aExists)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::fileCreateTemp(const com::Utf8Str &aTemplateName, ULONG aMode, const com::Utf8Str &aPath, BOOL aSecure, ComPtr<IGuestFile> &aFile)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::fileExists(const com::Utf8Str &aPath, BOOL *aExists)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No file to check existence for specified"));
-    CheckComArgOutPointerValid(aExists);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     GuestFsObjData objData; int guestRc;
-    int vrc = fileQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
+    int vrc = i_fileQueryInfoInternal(aPath, objData, &guestRc);
     if (RT_SUCCESS(vrc))
     {
@@ -3166,5 +3020,5 @@
         default:
             hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file information for \"%s\" failed: %Rrc"),
-                          Utf8Str(aPath).c_str(), vrc);
+                          aPath.c_str(), vrc);
             break;
     }
@@ -3174,21 +3028,18 @@
 }
 
-STDMETHODIMP GuestSession::FileRemove(IN_BSTR aPath)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::fileRemove(const com::Utf8Str &aPath)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No file to remove specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     HRESULT hr = S_OK;
 
     int guestRc;
-    int vrc = fileRemoveInternal(Utf8Str(aPath), &guestRc);
+    int vrc = i_fileRemoveInternal(aPath, &guestRc);
     if (RT_FAILURE(vrc))
     {
@@ -3201,5 +3052,5 @@
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Removing file \"%s\" failed: %Rrc"),
-                              Utf8Str(aPath).c_str(), vrc);
+                              aPath.c_str(), vrc);
                 break;
         }
@@ -3210,5 +3061,5 @@
 }
 
-STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, IGuestFile **aFile)
+HRESULT GuestSession::fileOpen(const com::Utf8Str &aPath, const com::Utf8Str &aOpenMode, const com::Utf8Str &aDisposition, ULONG aCreationMode, ComPtr<IGuestFile> &aFile)
 {
 #ifndef VBOX_WITH_GUEST_CONTROL
@@ -3219,31 +3070,26 @@
     Bstr strSharingMode = ""; /* Sharing mode is ignored. */
 
-    return FileOpenEx(aPath, aOpenMode, aDisposition, strSharingMode.raw(), aCreationMode,
+    return fileOpenEx(aPath, aOpenMode, aDisposition, strSharingMode.raw(), aCreationMode,
                       0 /* aOffset */, aFile);
 #endif /* VBOX_WITH_GUEST_CONTROL */
 }
 
-STDMETHODIMP GuestSession::FileOpenEx(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, IN_BSTR aSharingMode,
-                                      ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::fileOpenEx(const com::Utf8Str &aPath, const com::Utf8Str &aOpenMode, const com::Utf8Str &aDisposition, const com::Utf8Str &aSharingMode, ULONG aCreationMode, LONG64 aOffset, ComPtr<IGuestFile> &aFile)
+
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No file to open specified"));
-    if (RT_UNLIKELY((aOpenMode) == NULL || *(aOpenMode) == '\0'))
+    if (RT_UNLIKELY((aOpenMode.c_str()) == NULL || *(aOpenMode.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No open mode specified"));
-    if (RT_UNLIKELY((aDisposition) == NULL || *(aDisposition) == '\0'))
+    if (RT_UNLIKELY((aDisposition.c_str()) == NULL || *(aDisposition.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No disposition mode specified"));
     /* aSharingMode is optional. */
 
-    CheckComArgOutPointerValid(aFile);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    HRESULT hr = isReadyExternal();
+    HRESULT hr = i_isReadyExternal();
     if (FAILED(hr))
         return hr;
@@ -3253,8 +3099,8 @@
 
     GuestFileOpenInfo openInfo;
-    openInfo.mFileName = Utf8Str(aPath);
-    openInfo.mOpenMode = Utf8Str(aOpenMode);
-    openInfo.mDisposition = Utf8Str(aDisposition);
-    openInfo.mSharingMode = Utf8Str(aSharingMode);
+    openInfo.mFileName = aPath;
+    openInfo.mOpenMode = aOpenMode;
+    openInfo.mDisposition = aDisposition;
+    openInfo.mSharingMode = aSharingMode;
     openInfo.mCreationMode = aCreationMode;
     openInfo.mInitialOffset = aOffset;
@@ -3269,10 +3115,8 @@
 
     ComObjPtr <GuestFile> pFile; int guestRc;
-    vrc = fileOpenInternal(openInfo, pFile, &guestRc);
+    vrc = i_fileOpenInternal(openInfo, pFile, &guestRc);
     if (RT_SUCCESS(vrc))
-    {
         /* Return directory object to the caller. */
-        hr = pFile.queryInterfaceTo(aFile);
-    }
+        hr = pFile.queryInterfaceTo(aFile.asOutParam());
     else
     {
@@ -3290,5 +3134,5 @@
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Opening guest file \"%s\" failed: %Rrc"),
-                              Utf8Str(aPath).c_str(), vrc);
+                              aPath.c_str(), vrc);
                 break;
         }
@@ -3299,22 +3143,19 @@
 }
 
-STDMETHODIMP GuestSession::FileQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::fileQueryInfo(const com::Utf8Str &aPath, ComPtr<IGuestFsObjInfo> &aInfo)
+
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No file to query information for specified"));
-    CheckComArgOutPointerValid(aInfo);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     HRESULT hr = S_OK;
 
     GuestFsObjData objData; int guestRc;
-    int vrc = fileQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
+    int vrc = i_fileQueryInfoInternal(aPath, objData, &guestRc);
     if (RT_SUCCESS(vrc))
     {
@@ -3326,5 +3167,5 @@
         if (RT_SUCCESS(vrc))
         {
-            hr = pFsObjInfo.queryInterfaceTo(aInfo);
+            hr = pFsObjInfo.queryInterfaceTo(aInfo.asOutParam());
             if (FAILED(hr)) return hr;
         }
@@ -3353,26 +3194,20 @@
 }
 
-STDMETHODIMP GuestSession::FileQuerySize(IN_BSTR aPath, LONG64 *aSize)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
+HRESULT GuestSession::fileQuerySize(const com::Utf8Str &aPath, LONG64 *aSize)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aPath.c_str()) == NULL || *(aPath.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No file to query size for specified"));
-    CheckComArgOutPointerValid(aSize);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     HRESULT hr = S_OK;
 
     int64_t llSize; int guestRc;
-    int vrc = fileQuerySizeInternal(Utf8Str(aPath), &llSize, &guestRc);
+    int vrc = i_fileQuerySizeInternal(aPath, &llSize, &guestRc);
     if (RT_SUCCESS(vrc))
-    {
         *aSize = llSize;
-    }
     else
     {
@@ -3393,21 +3228,18 @@
 }
 
-STDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
+HRESULT GuestSession::fileRename(const com::Utf8Str &aSource, const com::Utf8Str &aDest, const std::vector<PathRenameFlag_T> &aFlags)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aSource.c_str()) == NULL || *(aSource.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No source file to rename specified"));
 
-    if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
+    if (RT_UNLIKELY((aDest.c_str()) == NULL || *(aDest.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No destination file to rename the source to specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    HRESULT hr = isReadyExternal();
+    HRESULT hr = i_isReadyExternal();
     if (FAILED(hr))
         return hr;
@@ -3417,5 +3249,5 @@
 
     int guestRc;
-    int vrc = pathRenameInternal(Utf8Str(aSource), Utf8Str(aDest), uFlags, &guestRc);
+    int vrc = i_pathRenameInternal(aSource, aDest, uFlags, &guestRc);
     if (RT_FAILURE(vrc))
     {
@@ -3435,5 +3267,5 @@
             default:
                 hr = setError(VBOX_E_IPRT_ERROR, tr("Renaming guest file \"%s\" failed: %Rrc"),
-                              Utf8Str(aSource).c_str(), vrc);
+                              aSource.c_str(), vrc);
                 break;
         }
@@ -3443,64 +3275,48 @@
 #endif /* VBOX_WITH_GUEST_CONTROL */
 }
-
-STDMETHODIMP GuestSession::FileSetACL(IN_BSTR aPath, IN_BSTR aACL)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
-                                         ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    com::SafeArray<LONG> affinityIgnored;
-
-    return ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
-                           ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinityIgnored), aProcess);
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
-                                           ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
-                                           ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
-                                           IGuestProcess **aProcess)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    if (RT_UNLIKELY((aCommand) == NULL || *(aCommand) == '\0'))
+HRESULT GuestSession::fileSetACL(const com::Utf8Str &aFile, const com::Utf8Str &aAcl)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::processCreate(const com::Utf8Str &aCommand, const std::vector<com::Utf8Str> &aArguments, const std::vector<com::Utf8Str> &aEnvironment, const std::vector<ProcessCreateFlag_T> &aFlags, ULONG aTimeoutMS, ComPtr<IGuestProcess> &aGuestProcess)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    std::vector<LONG> affinityIgnored;
+
+    return processCreateEx(aCommand, aArguments, aEnvironment, aFlags, aTimeoutMS, ProcessPriority_Default, affinityIgnored, aGuestProcess);
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::processCreateEx(const com::Utf8Str &aCommand, const std::vector<com::Utf8Str> &aArguments, const std::vector<com::Utf8Str> &aEnvironment, const std::vector<ProcessCreateFlag_T> &aFlags, ULONG aTimeoutMS, ProcessPriority_T aPriority, const std::vector<LONG> &aAffinity, ComPtr<IGuestProcess> &aGuestProcess)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    if (RT_UNLIKELY((aCommand.c_str()) == NULL || *(aCommand.c_str()) == '\0'))
         return setError(E_INVALIDARG, tr("No command to execute specified"));
-    CheckComArgOutPointerValid(aProcess);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    HRESULT hr = isReadyExternal();
+
+    HRESULT hr = i_isReadyExternal();
     if (FAILED(hr))
         return hr;
 
     GuestProcessStartupInfo procInfo;
-    procInfo.mCommand = Utf8Str(aCommand);
-
-    if (aArguments)
-    {
-        com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
-        for (size_t i = 0; i < arguments.size(); i++)
-            procInfo.mArguments.push_back(Utf8Str(arguments[i]));
-    }
+    procInfo.mCommand = aCommand;
+
+    if (aArguments.size())
+        for (size_t i = 0; i < aArguments.size(); i++)
+            procInfo.mArguments.push_back(aArguments[i]);
 
     int rc = VINF_SUCCESS;
@@ -3514,40 +3330,29 @@
     procInfo.mEnvironment = mData.mEnvironment; /* Apply original session environment. */
 
-    if (aEnvironment)
-    {
-        com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
-        for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
-            rc = procInfo.mEnvironment.Set(Utf8Str(environment[i]));
-    }
+    if (aEnvironment.size())
+        for (size_t i = 0; i < aEnvironment.size() && RT_SUCCESS(rc); i++)
+            rc = procInfo.mEnvironment.Set(aEnvironment[i]);
 
     if (RT_SUCCESS(rc))
     {
-        if (aFlags)
-        {
-            com::SafeArray<ProcessCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
-            for (size_t i = 0; i < flags.size(); i++)
-                procInfo.mFlags |= flags[i];
-        }
+        if (aFlags.size())
+            for (size_t i = 0; i < aFlags.size(); i++)
+                procInfo.mFlags |= aFlags[i];
 
         procInfo.mTimeoutMS = aTimeoutMS;
 
-        if (aAffinity)
-        {
-            com::SafeArray<LONG> affinity(ComSafeArrayInArg(aAffinity));
-            for (size_t i = 0; i < affinity.size(); i++)
-            {
-                if (affinity[i])
+        if (aAffinity.size())
+            for (size_t i = 0; i < aAffinity.size(); i++)
+                if (aAffinity[i])
                     procInfo.mAffinity |= (uint64_t)1 << i;
-            }
-        }
 
         procInfo.mPriority = aPriority;
 
         ComObjPtr<GuestProcess> pProcess;
-        rc = processCreateExInteral(procInfo, pProcess);
+        rc = i_processCreateExInteral(procInfo, pProcess);
         if (RT_SUCCESS(rc))
         {
             /* Return guest session to the caller. */
-            HRESULT hr2 = pProcess.queryInterfaceTo(aProcess);
+            HRESULT hr2 = pProcess.queryInterfaceTo(aGuestProcess.asOutParam());
             if (FAILED(hr2))
                 rc = VERR_COM_OBJECT_NOT_FOUND;
@@ -3580,18 +3385,15 @@
 }
 
-STDMETHODIMP GuestSession::ProcessGet(ULONG aPID, IGuestProcess **aProcess)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFunc(("PID=%RU32\n", aPID));
-
-    CheckComArgOutPointerValid(aProcess);
-    if (aPID == 0)
+HRESULT GuestSession::processGet(ULONG aPid, ComPtr<IGuestProcess> &aGuestProcess)
+
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFunc(("PID=%RU32\n", aPid));
+
+    if (aPid == 0)
         return setError(E_INVALIDARG, tr("No valid process ID (PID) specified"));
 
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
@@ -3599,99 +3401,80 @@
 
     ComObjPtr<GuestProcess> pProcess;
-    int rc = processGetByPID(aPID, &pProcess);
+    int rc = i_processGetByPID(aPid, &pProcess);
     if (RT_FAILURE(rc))
-        hr = setError(E_INVALIDARG, tr("No process with PID %RU32 found"), aPID);
+        hr = setError(E_INVALIDARG, tr("No process with PID %RU32 found"), aPid);
 
     /* This will set (*aProcess) to NULL if pProgress is NULL. */
-    HRESULT hr2 = pProcess.queryInterfaceTo(aProcess);
+    HRESULT hr2 = pProcess.queryInterfaceTo(aGuestProcess.asOutParam());
     if (SUCCEEDED(hr))
         hr = hr2;
 
-    LogFlowThisFunc(("aProcess=%p, hr=%Rhrc\n", *aProcess, hr));
+    LogFlowThisFunc(("aProcess=%p, hr=%Rhrc\n", (IGuestProcess*)aGuestProcess, hr));
     return hr;
 #endif /* VBOX_WITH_GUEST_CONTROL */
 }
 
-STDMETHODIMP GuestSession::SymlinkCreate(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::SymlinkExists(IN_BSTR aSymlink, BOOL *aExists)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::SymlinkRemoveDirectory(IN_BSTR aPath)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::SymlinkRemoveFile(IN_BSTR aFile)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    ReturnComNotImplemented();
-#endif /* VBOX_WITH_GUEST_CONTROL */
-}
-
-STDMETHODIMP GuestSession::WaitFor(ULONG aWaitFlags, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aReason);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::symlinkCreate(const com::Utf8Str &aSource, const com::Utf8Str &aTarget, SymlinkType_T aType)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::symlinkExists(const com::Utf8Str &aSymlink, BOOL *aExists)
+
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::symlinkRead(const com::Utf8Str &aSymlink, const std::vector<SymlinkReadFlag_T> &aFlags, com::Utf8Str &aTarget)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::symlinkRemoveDirectory(const com::Utf8Str &aPath)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::symlinkRemoveFile(const com::Utf8Str &aFile)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
+
+    ReturnComNotImplemented();
+#endif /* VBOX_WITH_GUEST_CONTROL */
+}
+
+HRESULT GuestSession::waitFor(ULONG aWaitFor, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     /*
@@ -3701,9 +3484,7 @@
 
     int guestRc; GuestSessionWaitResult_T waitResult;
-    int vrc = waitFor(aWaitFlags, aTimeoutMS, waitResult, &guestRc);
+    int vrc = i_waitFor(aWaitFor, aTimeoutMS, waitResult, &guestRc);
     if (RT_SUCCESS(vrc))
-    {
         *aReason = waitResult;
-    }
     else
     {
@@ -3711,5 +3492,5 @@
         {
             case VERR_GSTCTL_GUEST_ERROR:
-                hr = GuestSession::setErrorExternal(this, guestRc);
+                hr = GuestSession::i_setErrorExternal(this, guestRc);
                 break;
 
@@ -3734,15 +3515,10 @@
 }
 
-STDMETHODIMP GuestSession::WaitForArray(ComSafeArrayIn(GuestSessionWaitForFlag_T, aFlags), ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason)
-{
-#ifndef VBOX_WITH_GUEST_CONTROL
-    ReturnComNotImplemented();
-#else
-    LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aReason);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+HRESULT GuestSession::waitForArray(const std::vector<GuestSessionWaitForFlag_T> &aWaitFor, ULONG aTimeoutMS, GuestSessionWaitResult_T *aReason)
+{
+#ifndef VBOX_WITH_GUEST_CONTROL
+    ReturnComNotImplemented();
+#else
+    LogFlowThisFuncEnter();
 
     /*
@@ -3750,7 +3526,6 @@
      */
     uint32_t fWaitFor = GuestSessionWaitForFlag_None;
-    com::SafeArray<GuestSessionWaitForFlag_T> flags(ComSafeArrayInArg(aFlags));
-    for (size_t i = 0; i < flags.size(); i++)
-        fWaitFor |= flags[i];
+    for (size_t i = 0; i < aWaitFor.size(); i++)
+        fWaitFor |= aWaitFor[i];
 
     return WaitFor(fWaitFor, aTimeoutMS, aReason);
Index: /trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp	(revision 50727)
@@ -186,5 +186,5 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    int vrc = pSession->startSessionInternal(pGuestRc);
+    int vrc = pSession->i_startSessionInternal(pGuestRc);
     /* Nothing to do here anymore. */
 
@@ -319,5 +319,5 @@
     ComObjPtr<GuestProcess> pProcess; int guestRc;
     if (RT_SUCCESS(rc))
-        rc = pSession->processCreateExInteral(procInfo, pProcess);
+        rc = pSession->i_processCreateExInteral(procInfo, pProcess);
     if (RT_SUCCESS(rc))
     {
@@ -603,5 +603,5 @@
      */
     GuestFsObjData objData; int guestRc;
-    int rc = pSession->fileQueryInfoInternal(Utf8Str(mSource), objData, &guestRc);
+    int rc = pSession->i_fileQueryInfoInternal(Utf8Str(mSource), objData, &guestRc);
     if (RT_FAILURE(rc))
     {
@@ -641,5 +641,5 @@
             /* Startup process. */
             ComObjPtr<GuestProcess> pProcess;
-            rc = pSession->processCreateExInteral(procInfo, pProcess);
+            rc = pSession->i_processCreateExInteral(procInfo, pProcess);
             if (RT_SUCCESS(rc))
                 rc = pProcess->i_startProcess(30 * 1000 /* 30s timeout */,
@@ -858,6 +858,6 @@
 }
 
-int SessionTaskUpdateAdditions::addProcessArguments(ProcessArguments &aArgumentsDest,
-                                                    const ProcessArguments &aArgumentsSource)
+int SessionTaskUpdateAdditions::i_addProcessArguments(ProcessArguments &aArgumentsDest,
+                                                      const ProcessArguments &aArgumentsSource)
 {
     int rc = VINF_SUCCESS;
@@ -897,7 +897,7 @@
 }
 
-int SessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
-                                                Utf8Str const &strFileSource, const Utf8Str &strFileDest,
-                                                bool fOptional, uint32_t *pcbSize)
+int SessionTaskUpdateAdditions::i_copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
+                                                  Utf8Str const &strFileSource, const Utf8Str &strFileDest,
+                                                  bool fOptional, uint32_t *pcbSize)
 {
     AssertPtrReturn(pSession, VERR_INVALID_POINTER);
@@ -935,7 +935,7 @@
 
             ComObjPtr<Progress> pProgressCopyTo;
-            rc = pSession->startTaskAsync(Utf8StrFmt(GuestSession::tr("Copying Guest Additions installer file \"%s\" to \"%s\" on guest"),
-                                                     mSource.c_str(), strFileDest.c_str()),
-                                                     pTask, pProgressCopyTo);
+            rc = pSession->i_startTaskAsync(Utf8StrFmt(GuestSession::tr("Copying Guest Additions installer file \"%s\" to \"%s\" on guest"),
+                                                       mSource.c_str(), strFileDest.c_str()),
+                                                       pTask, pProgressCopyTo);
             if (RT_SUCCESS(rc))
             {
@@ -967,5 +967,5 @@
         GuestFsObjData objData;
         int64_t cbSizeOnGuest; int guestRc;
-        rc = pSession->fileQuerySizeInternal(strFileDest, &cbSizeOnGuest, &guestRc);
+        rc = pSession->i_fileQuerySizeInternal(strFileDest, &cbSizeOnGuest, &guestRc);
         if (   RT_SUCCESS(rc)
             && cbSize == (uint64_t)cbSizeOnGuest)
@@ -1010,5 +1010,5 @@
 }
 
-int SessionTaskUpdateAdditions::runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo)
+int SessionTaskUpdateAdditions::i_runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo)
 {
     AssertPtrReturn(pSession, VERR_INVALID_POINTER);
@@ -1077,5 +1077,5 @@
     LogRel(("Automatic update of Guest Additions started, using \"%s\"\n", mSource.c_str()));
 
-    ComObjPtr<Guest> pGuest(mSession->getParent());
+    ComObjPtr<Guest> pGuest(mSession->i_getParent());
 #if 0
     /*
@@ -1280,6 +1280,6 @@
             /* Create the installation directory. */
             int guestRc;
-            rc = pSession->directoryCreateInternal(strUpdateDir,
-                                                   755 /* Mode */, DirectoryCreateFlag_Parents, &guestRc);
+            rc = pSession->i_directoryCreateInternal(strUpdateDir,
+                                                     755 /* Mode */, DirectoryCreateFlag_Parents, &guestRc);
             if (RT_FAILURE(rc))
             {
@@ -1378,5 +1378,5 @@
                         /* Add optional installer command line arguments from the API to the
                          * installer's startup info. */
-                        rc = addProcessArguments(siInstaller.mArguments, mArguments);
+                        rc = i_addProcessArguments(siInstaller.mArguments, mArguments);
                         AssertRC(rc);
                         /* If the caller does not want to wait for out guest update process to end,
@@ -1418,6 +1418,6 @@
                         if (itFiles->fFlags & UPDATEFILE_FLAG_OPTIONAL)
                             fOptional = true;
-                        rc = copyFileToGuest(pSession, &iso, itFiles->strSource, itFiles->strDest,
-                                             fOptional, NULL /* cbSize */);
+                        rc = i_copyFileToGuest(pSession, &iso, itFiles->strSource, itFiles->strDest,
+                                               fOptional, NULL /* cbSize */);
                         if (RT_FAILURE(rc))
                         {
@@ -1455,5 +1455,5 @@
                     if (itFiles->fFlags & UPDATEFILE_FLAG_EXECUTE)
                     {
-                        rc = runFileOnGuest(pSession, itFiles->mProcInfo);
+                        rc = i_runFileOnGuest(pSession, itFiles->mProcInfo);
                         if (RT_FAILURE(rc))
                             break;
Index: /trunk/src/VBox/Main/src-client/xpcom/module.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/xpcom/module.cpp	(revision 50726)
+++ /trunk/src/VBox/Main/src-client/xpcom/module.cpp	(revision 50727)
@@ -68,8 +68,4 @@
 NS_DECL_CLASSINFO(Guest)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Guest, IGuest)
- #ifdef VBOX_WITH_GUEST_CONTROL
-NS_DECL_CLASSINFO(GuestSession)
-NS_IMPL_THREADSAFE_ISUPPORTS1_CI(GuestSession, IGuestSession)
- #endif
 NS_DECL_CLASSINFO(Keyboard)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Keyboard, IKeyboard)
