GuestSessionImpl.cpp revision 6b9d50a0f466bd5a61458ed53925480ab28a3c17
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * VirtualBox Main - XXX.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * Copyright (C) 2012 Oracle Corporation
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * available from http://www.virtualbox.org. This file is free software;
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * General Public License (GPL) as published by the Free Software
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync/*******************************************************************************
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync* Header Files *
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync*******************************************************************************/
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync// constructor / destructor
b9a21c3c91c47e090316e28d759194e46628ed49vboxsync/////////////////////////////////////////////////////////////////////////////
return BaseFinalConstruct();
uninit();
return VINF_SUCCESS;
&& fCanceled)
return VERR_CANCELLED;
&& !fCompleted)
return VINF_SUCCESS;
return VINF_SUCCESS;
return VINF_SUCCESS;
&& !fCanceled
&& !fCompleted)
return VINF_SUCCESS;
return VINF_SUCCESS;
&& !fCanceled
&& !fCompleted)
return VERR_COM_UNEXPECTED;
return VINF_SUCCESS;
if (mCopyFileFlags)
int rc;
procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" to the guest to \"%s\" (%RU64 bytes)"),
procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
&& fCanceled)
#ifdef DEBUG
if (fCanceled)
cbFileSize > 0
if (!cbToRead)
if ( !fCanceled
if ( cbFileSize > 0
&& cbWrittenTotal == 0)
Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed with wait result %ld"),
&& exitCode != 0)
catch (int rc2)
return rc;
return rc;
int rc;
RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); /** @todo Use the correct open modes! */
procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"),
&cbRead);
if (cbRead)
&& fCanceled)
if (cbToRead == 0)
if ( !fCanceled
&& cbWrittenTotal == 0)
&& exitCode != 0)
catch (int rc2)
return rc;
return rc;
// public initializer/uninitializer for internal purposes only
return VINF_SUCCESS;
#ifdef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
if (uMode)
if (lExitCode != 0)
return VERR_CANT_CREATE;
return rc;
catch (int rc2)
return rc;
int GuestSession::dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData)
#ifdef DEBUG
int rc;
return rc;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int GuestSession::fileOpenInternal(const Utf8Str &strPath, const Utf8Str &strOpenMode, const Utf8Str &strDisposition,
LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, iOffset=%RI64\n",
int rc;
catch (int rc2)
return rc;
&cbRead);
if (cbRead)
return rc;
return rc;
LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes)\n",
mData.mId, itProcs->second->getProcessID(), itProcs->second->getPID(), mData.mProcesses.size() - 1));
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int GuestSession::processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
#ifdef DEBUG
it++;
return VERR_INVALID_PARAMETER;
return rc;
uNewProcessID = 0;
LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes)\n",
catch (int rc2)
return rc;
if (pProcess)
return VERR_COM_INVALID_OBJECT_STATE;
if (pProcess)
return VINF_SUCCESS;
return VERR_NOT_FOUND;
int rc;
catch (int rc2)
return rc;
static short s_gctrlLegacyWarning = 0;
LogRel((tr("Warning: Guest Additions are older (%ld.%ld) than host capabilities for guest control, please upgrade them. Using protocol version %ld now\n"),
VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions), mData.mProtocolVersion));
return VINF_SUCCESS;
#ifndef VBOX_WITH_GUEST_CONTROL
uninit();
return S_OK;
STDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
#ifndef VBOX_WITH_GUEST_CONTROL
if (aFlags)
int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
return hr;
STDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
#ifndef VBOX_WITH_GUEST_CONTROL
if (aFlags)
int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
if (aFlags)
if (fFlags)
if (aDirectory)
switch (rc)
case VERR_INVALID_PARAMETER:
case VERR_BROKEN_PIPE:
case VERR_CANT_CREATE:
return hr;
STDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
STDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, IN_BSTR aFlags, IGuestDirectory **aDirectory)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
#ifndef VBOX_WITH_GUEST_CONTROL
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
return S_OK;
STDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
return E_OUTOFMEMORY;
&cbRead);
return S_OK;
STDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
switch (rc)
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
#ifndef VBOX_WITH_GUEST_CONTROL
HRESULT hr = ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
return hr;
STDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
#ifndef VBOX_WITH_GUEST_CONTROL
if (aArguments)
* have the chance of overwriting/deleting session entries.
if (aEnvironment)
if (aFlags)
if (aAffinity)
switch (rc)
case VERR_MAX_PROCS_REACHED:
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
if (aPID == 0)
return hr;
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
STDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL
#ifndef VBOX_WITH_GUEST_CONTROL