GuestSessionImpl.cpp revision c4b821bf03ae7641a0791e3fd161247e66433b68
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox Main - XXX.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Copyright (C) 2012 Oracle Corporation
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * available from http://www.virtualbox.org. This file is free software;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * General Public License (GPL) as published by the Free Software
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*******************************************************************************
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync* Header Files *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync*******************************************************************************/
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// constructor / destructor
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync// session task classes
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/////////////////////////////////////////////////////////////////////////////
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncGuestSessionTask::GuestSessionTask(GuestSession *pSession)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync return VERR_COM_UNEXPECTED; /** @todo Find a better rc. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncHRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync/** @todo Merge this and the above call and let the above call do the open/close file handling so that the
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync * inner code only has to deal with file handles. No time now ... */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
3d33b6a3faf40871bae75119c2569cdc4acb2d46vboxsync PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copy flags (%#x) not implemented yet"),
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Does our source file exist? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Source file \"%s\" does not exist or is not a file"),
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Could not open source file \"%s\" for reading: %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Could not query file size of \"%s\": %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Size + offset are optional. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" to the guest to \"%s\" (%RU64 bytes)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Set arguments.*/
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Startup process. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Unable to start guest process: %Rrc"), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (mSourceSize) /* If we have nothing to write, take a shortcut. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /** @todo Not very efficient, but works for now. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileSeek(*pFile, mSourceOffset + cbWrittenTotal,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Some other error occured? There might be a chance that RTFileRead
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * could not resolve/map the native error code to an IPRT code, so just
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * print a generic error.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Could not read from file \"%s\" (%Rrc)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Seeking file \"%s\" offset %RU64 failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did we reach the end of the content we want to transfer (last chunk)? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did we reach the last block which is exactly _64K? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* ... or does the user want to cancel? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Writing to file \"%s\" (offset %RU64) failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowThisFunc(("cbWritten=%RU32, cbToRead=%RU64, cbWrittenTotal=%RU64, cbFileSize=%RU64\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync cbWritten, cbToRead - cbWritten, cbWrittenTotal + cbWritten, mSourceSize));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Only subtract bytes reported written by the guest. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Update total bytes written to the guest. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did the user cancel the operation above? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Update the progress.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Watch out for division by zero. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ? rc = setProgress((ULONG)(cbWrittenTotal * 100 / mSourceSize))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* End of file reached? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync } /* for */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Even if we succeeded until here make sure to check whether we really transfered
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * everything.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * to the destination -> access denied. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If we did not copy all let the user know. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed with wait result %ld"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %ld"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync } /* processCreateExInteral */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (!mSourceFile) /* Only close locally opened files. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint SessionTaskCopyTo::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, mCopyFileFlags=%x\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mCopyFileFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyTo::taskThread, this,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync "gctlCpyTo");
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/* static */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyTo::taskThread(RTTHREAD Thread, void *pvUser)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<SessionTaskCopyTo> task(static_cast<SessionTaskCopyTo*>(pvUser));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncSessionTaskCopyFrom::SessionTaskCopyFrom(GuestSession *pSession,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Note: There will be races between querying file size + reading the guest file's
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * content because we currently *do not* lock down the guest file when doing the
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * actual operations.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync ** @todo Implement guest file locking!
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = pSession->fileQueryInfoInternal(Utf8Str(mSource), objData);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Querying guest file information for \"%s\" failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else if (objData.mType != FsObjType_File) /* Only single files are supported at the moment. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Guest file \"%s\" is not a file"), mSource.c_str()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); /** @todo Use the correct open modes! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Error opening destination file \"%s\": %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), mDest.c_str(), objData.mObjectSize);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Set arguments.*/
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(mSource); /* Which file to output? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Startup process. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Unable to start guest process: %Rrc"), rc));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Reading from file \"%s\" (offset %RU64) failed: %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = RTFileWrite(fileDest, byBuf, cbRead, NULL /* No partial writes */);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Error writing to file \"%s\" (%RU64 bytes left): %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Only subtract bytes reported written by the guest. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Update total bytes written to the guest. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Assert(cbWrittenTotal <= (uint64_t)objData.mObjectSize);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Did the user cancel the operation above? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = setProgress((ULONG)(cbWrittenTotal / ((uint64_t)objData.mObjectSize / 100.0)));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* End of file reached? */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync } /* for */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Even if we succeeded until here make sure to check whether we really transfered
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * everything.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * to the destination -> access denied. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else if (cbWrittenTotal < (uint64_t)objData.mObjectSize)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If we did not copy all let the user know. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), cbWrittenTotal, objData.mObjectSize));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %d"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else /* Yay, success! */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint SessionTaskCopyFrom::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, uFlags=%x\n",
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyFrom::taskThread, this,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync "gctlCpyFrom");
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/* static */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyFrom::taskThread(RTTHREAD Thread, void *pvUser)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<SessionTaskCopyFrom> task(static_cast<SessionTaskCopyFrom*>(pvUser));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncSessionTaskUpdateAdditions::SessionTaskUpdateAdditions(GuestSession *pSession,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncSessionTaskUpdateAdditions::~SessionTaskUpdateAdditions(void)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsyncint SessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8Str const &strFileSource, const Utf8Str &strFileDest,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* pcbSize is optional. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync int rc = RTIsoFsGetFileInfo(pISO, strFileSource.c_str(), &cbOffset, &cbSize);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = RTFileSeek(pISO->file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Copy over the Guest Additions file to the guest. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(pSession /* GuestSession */,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->startTaskAsync(Utf8StrFmt(GuestSession::tr("Copying Guest Additions installer file \"%s\" to \"%s\" on guest"),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync HRESULT hr = pProgressCopyTo->WaitForCompletion(-1);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if ( SUCCEEDED(pProgressCopyTo->COMGETTER(Canceled)(&fCanceled))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /** @todo Note: Since there is no file locking involved at the moment, there can be modifications
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * between finished copying, the verification and the actual execution. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Determine where the installer image ended up and if it has the correct size. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Verifying Guest Additions installer file \"%s\" ...\n", strFileDest.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->fileQuerySizeInternal(strFileDest, &cbSizeOnGuest);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Ugly hack: Because older Guest Additions have problems with environment variable
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync expansion in parameters we have to check an alternative location on Windows.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync So check for "%TEMP%\" being "C:\\Windows\\system32\\EMP" actually. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (strFileDest.startsWith("%TEMP%\\", RTCString::CaseSensitive))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8Str strFileDestBug = "C:\\Windows\\system32\\EMP" + strFileDest.substr(sizeof("%TEMP%\\") - sizeof(char));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->fileQuerySizeInternal(strFileDestBug, &cbSizeOnGuest);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Guest Additions installer file \"%s\" successfully verified\n",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = VERR_BROKEN_PIPE; /** @todo FInd a better error. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsyncint SessionTaskUpdateAdditions::runFile(GuestSession *pSession, GuestProcessStartupInfo &procInfo)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync int rc = pSession->fileQueryInfoInternal(procInfo.mCommand, objData);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mCommand = "C:\\Windows\\system32\\EMP" + procInfo.mCommand.substr(sizeof("%TEMP%\\") - sizeof(char));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Running %s ...\n", procInfo.mName.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if (waitRes.mResult == ProcessWaitResult_Terminate)
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Running %s failed with status %ld, exit code %ld"),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync else /* Yay, success! */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("%s successfully completed\n", procInfo.mName.c_str()));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Error while waiting running %s: %Rrc"),
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR, pProcess->errorMsg());
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogRel(("Automatic update of Guest Additions started, using \"%s\"\n", mSource.c_str()));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Determine guest OS type and the required installer image.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * At the moment only Windows guests are supported.
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( SUCCEEDED(pGuest->COMGETTER(OSTypeId(osTypeId.asOutParam())))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8Str osTypeIdUtf8(osTypeId); /* Needed for .contains(). */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if ( osTypeIdUtf8.contains("Microsoft", Utf8Str::CaseInsensitive)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync || osTypeIdUtf8.contains("Windows", Utf8Str::CaseInsensitive))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (osTypeIdUtf8.contains("64", Utf8Str::CaseInsensitive))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strInstallerImage = "VBOXWINDOWSADDITIONS_AMD64.EXE";
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strInstallerImage = "VBOXWINDOWSADDITIONS_X86.EXE";
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Since the installers are located in the root directory,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * no further path processing needs to be done (yet). */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync else /* Everything else is not supported (yet). */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8StrFmt(GuestSession::tr("Could not detected guest OS type/version, please update manually")));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Try to open the .ISO file and locate the specified installer.
ce46b563e3317d0c792fbe141e2978bfa0e91aaevboxsync Utf8StrFmt(GuestSession::tr("Unable to open Guest Additions .ISO file \"%s\": %Rrc"),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /** @todo Add support for non-Windows as well! */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Utf8Str strInstallerDest = "%TEMP%\\VBoxWindowsAdditions.exe";
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * Copy over main installer to the guest.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = copyFileToGuest(pSession, &iso, strInstallerImage, strInstallerDest,
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync false /* File is not optional */, NULL /* cbSize */);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * Install needed certificates for the WHQL crap.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync ** @todo Only for Windows!
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = copyFileToGuest(pSession, &iso, "CERT/ORACLE_VBOX.CER", "%TEMP%\\oracle-vbox.cer",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = copyFileToGuest(pSession, &iso, "CERT/VBOXCERTUTIL.EXE", "%TEMP%\\VBoxCertUtil.exe",
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Error while copying certificate installation tool to the guest: %Rrc"), rc));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync Utf8StrFmt(GuestSession::tr("Error while copying certificate to the guest: %Rrc"), rc));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync * Run VBoxCertUtil.exe to install the Oracle certificate.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync LogRel(("Installing certificates on the guest ...\n"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("VirtualBox Guest Additions Certificate Utility"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mCommand = Utf8Str("%TEMP%\\VBoxCertUtil.exe");
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Construct arguments. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /** @todo Remove hardcoded paths. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mArguments.push_back(Utf8Str("add-trusted-publisher"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Ugly hack: Because older Guest Additions have problems with environment variable
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync expansion in parameters we have to check an alternative location on Windows.
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync So check for "%TEMP%\VBoxWindowsAdditions.exe" in a screwed up way. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync rc = pSession->fileQueryInfoInternal("%TEMP%\\oracle-vbox.cer", objData);
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mArguments.push_back(Utf8Str("%TEMP%\\oracle-vbox.cer"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mArguments.push_back(Utf8Str("C:\\Windows\\system32\\EMPoracle-vbox.cer"));
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* Overwrite rc in any case. */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("VirtualBox Guest Additions Setup"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* If the caller does not want to wait for out guest update process to end,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * complete the progress object now so that the caller can do other work. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mFlags |= ProcessCreateFlag_WaitForProcessStartOnly;
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Construct arguments. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/S")); /* We want to install in silent mode. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/l")); /* ... and logging enabled. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Don't quit VBoxService during upgrade because it still is used for this
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * piece of code we're in right now (that is, here!) ... */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/no_vboxservice_exit"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Tell the installer to report its current installation status
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * using a running VBoxTray instance via balloon messages in the
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync * Windows taskbar. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync procInfo.mArguments.push_back(Utf8Str("/post_installstatus"));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncint SessionTaskUpdateAdditions::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, uFlags=%x\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = RTThreadCreate(NULL, SessionTaskUpdateAdditions::taskThread, this,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync "gctlUpGA");
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync/* static */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncint SessionTaskUpdateAdditions::taskThread(RTTHREAD Thread, void *pvUser)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync std::auto_ptr<SessionTaskUpdateAdditions> task(static_cast<SessionTaskUpdateAdditions*>(pvUser));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// public initializer/uninitializer for internal purposes only
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncint GuestSession::init(Guest *aGuest, ULONG aSessionID,
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Enclose the state transition NotReady->InInit->Ready. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync mData.mTimeout = 30 * 60 * 1000; /* Session timeout is 30 mins by default. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Confirm a successful initialization when it's the case. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Uninitializes the instance.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Called from FinalRelease().
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Enclose the state transition Ready->InUninit->NotReady. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// implementation of public getters/setters for attributes
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(User)(BSTR *aUser)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Domain)(BSTR *aDomain)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Name)(BSTR *aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Id)(ULONG *aId)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Timeout)(ULONG *aTimeout)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
7e8ef90d3160234df0f254131b87af4243d79476vboxsyncSTDMETHODIMP GuestSession::COMSETTER(Timeout)(ULONG aTimeout)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFunc(("%s cEnvVars=%RU32\n", mData.mName.c_str(), cEnvVars));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync environment.detachTo(ComSafeArrayOutArg(aEnvironment));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsyncSTDMETHODIMP GuestSession::COMSETTER(Environment)(ComSafeArrayIn(IN_BSTR, aValues))
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aValues));
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (!strEnv.isEmpty()) /* Silently skip empty entries. */
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Processes)(ComSafeArrayOut(IGuestProcess *, aProcesses))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestProcess> collection(mData.mProcesses);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aProcesses));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Directories)(ComSafeArrayOut(IGuestDirectory *, aDirectories))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestDirectory> collection(mData.mDirectories);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aDirectories));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Files)(ComSafeArrayOut(IGuestFile *, aFiles))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestFile> collection(mData.mFiles);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync// private methods
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync/////////////////////////////////////////////////////////////////////////////
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::directoryClose(ComObjPtr<GuestDirectory> pDirectory)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncint GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mName = Utf8StrFmt(tr("Creating directory \"%s\"", strPath.c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKDIR);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Construct arguments. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str("--mode")); /* Set the creation mode. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RTStrPrintf(szMode, sizeof(szMode), "%o", uMode))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(strPath); /* The directory we want to create. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate, 30 * 1000 /* Timeout */, waitRes);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync HRESULT hr = pProcess->COMGETTER(Status)(&procStatus);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (procStatus == ProcessStatus_TerminatedNormally)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = VERR_BROKEN_PIPE; /** @todo Find a better rc. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Note: There will be a race between creating and getting/initing the directory
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync object here. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
8bc8d66f188d5357155b8340e2d489573be2b607vboxsyncint GuestSession::directoryOpenInternal(const Utf8Str &strPath, const Utf8Str &strFilter,
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowThisFunc(("strPath=%s, strPath=%s, uFlags=%x\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncint GuestSession::dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData)
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_PROCESS(uContextID);
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync rc = pProcess->callbackDispatcher(uContextID, uFunction, pvData, cbData);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::fileClose(ComObjPtr<GuestFile> pFile)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
004d74842597dacc4009803171296dfcf9398c69vboxsync * Implementation of FileRemove(). Can throw an exception due to the use of
004d74842597dacc4009803171296dfcf9398c69vboxsync * Utf8Str, Utf8StrFmt and std::vector near the beginning (and others?). The
004d74842597dacc4009803171296dfcf9398c69vboxsync * caller should catch this. On success, *prc will be set to the return code
004d74842597dacc4009803171296dfcf9398c69vboxsync * of the delete operation to distinguish between API and command failure.
004d74842597dacc4009803171296dfcf9398c69vboxsyncint GuestSession::fileRemoveInternal(Utf8Str strPath, int *prc)
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mName = Utf8StrFmt(tr("Removing file \"%s\"",
004d74842597dacc4009803171296dfcf9398c69vboxsync /* Construct arguments. */
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mArguments.push_back(strPath); /* The directory we want to create. */
004d74842597dacc4009803171296dfcf9398c69vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
004d74842597dacc4009803171296dfcf9398c69vboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n",
004d74842597dacc4009803171296dfcf9398c69vboxsync LogThisFunc(("Error starting delete tool on guest: %Rrc\n", rc));
004d74842597dacc4009803171296dfcf9398c69vboxsync LogThisFunc(("Error running delete tool on guest: %Rrc\n", rc));
004d74842597dacc4009803171296dfcf9398c69vboxsync LogThisFunc(("No return code after deleting file"));
004d74842597dacc4009803171296dfcf9398c69vboxsync Log(("Error getting return code from deleting file: %Rrc\n", rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::fileOpenInternal(const Utf8Str &strPath, const Utf8Str &strOpenMode, const Utf8Str &strDisposition,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint32_t uCreationMode, int64_t iOffset, ComObjPtr<GuestFile> &pFile)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, iOffset=%RI64\n",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath.c_str(), strOpenMode.c_str(), strDisposition.c_str(), uCreationMode, iOffset));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Note: There will be a race between creating and getting/initing the directory
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync object here. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath, strOpenMode, strDisposition, uCreationMode, iOffset);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new file \"%s\" (Session: %RU32\n",
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync/* Note: Will work on directories and others, too. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsyncint GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mName = Utf8StrFmt(tr("Querying info for \"%s\""), strPath.c_str());
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_STAT);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /* Construct arguments. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = processCreateExInteral(procInfo, pProcess);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /** @todo Merge with GuestDirectory::read. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64, cbStreamOut=%RU32\n",
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync AssertMsgFailed(("Parsing stream block failed: %Rrc\n", rc));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsyncint GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsyncconst GuestCredentials& GuestSession::getCredentials(void)
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsyncconst GuestEnvironment& GuestSession::getEnvironment(void)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::processClose(ComObjPtr<GuestProcess> pProcess)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes)\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mData.mId, itProcs->second->getProcessID(), itProcs->second->getPID(), mData.mProcesses.size() - 1));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * Creates but does *not* start the process yet. See GuestProcess::startProcess() or
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * GuestProcess::startProcessAsync() for that.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @return IPRT status code.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @param procInfo
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @param pProcess
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync LogFlowFunc(("mCmd=%s, mFlags=%x, mTimeoutMS=%RU32\n",
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync procInfo.mCommand.c_str(), procInfo.mFlags, procInfo.mTimeoutMS));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ProcessArguments::const_iterator it = procInfo.mArguments.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Validate flags. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if ( !(procInfo.mFlags & ProcessCreateFlag_IgnoreOrphanedProcesses)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForProcessStartOnly)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_NoProfile)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForStdOut)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForStdErr))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Adjust timeout. If set to 0, we define
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync * an infinite timeout. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** @tood Implement process priority + affinity. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (mData.mProcesses.size() >= VBOX_GUESTCTRL_MAX_PROCESSES)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /* Create a new (host-based) process ID and assign it. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync /* Is the context ID already used? */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (!processExists(uNewProcessID, NULL /* pProgress */))
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /* Callback with context ID was not found. This means
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * we can use this context ID for our new callback we want
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * to add below. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync break; /* Don't try too hard. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the process object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->init(mData.mParent->getConsole() /* Console */, this /* Session */,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created process to our map. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes)\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mId, uNewProcessID, mData.mProcesses.size()));
ccbdc11833996cb9f3be7868f1ebaefcacafb94dvboxsyncinline bool GuestSession::processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::const_iterator it = mData.mProcesses.find(uProcessID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return true;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return false;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncinline int GuestSession::processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /* pProcess is optional. */
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::iterator it = mData.mProcesses.begin();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint GuestSession::startTaskAsync(const Utf8Str &strTaskDesc,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowThisFunc(("strTaskDesc=%s, pTask=%p\n", strTaskDesc.c_str(), pTask));
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the progress object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync hr = pProgress->init(static_cast<IGuestSession*>(this),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Initialize our worker task. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Don't destruct on success. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * Queries/collects information prior to establishing a guest session.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * This is necessary to know which guest control protocol version to use,
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * among other things (later).
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * @return IPRT status code.
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Since the new functions were not implemented yet, force Main to use protocol ver 1. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * Try querying the guest control protocol version running on the guest.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * This is done using the Guest Additions version
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync uint32_t uVerAdditions = pGuest->getAdditionsVersion();
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync mData.mProtocolVersion = ( VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions) >= 4
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && VBOX_FULL_VERSION_GET_MINOR(uVerAdditions) >= 2) /** @todo What's about v5.0 ? */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /* Build revision is ignored. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /* Tell the user but don't bitch too often. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync static short s_gctrlLegacyWarning = 0;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync if (s_gctrlLegacyWarning++ < 3) /** @todo Find a bit nicer text. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync LogRel((tr("Warning: Guest Additions are older (%ld.%ld) than host capabilities for guest control, please upgrade them. Using protocol version %ld now\n"),
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions), mData.mProtocolVersion));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// implementation of public methods
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSTDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No source specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No destination specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync SessionTaskCopyFrom *pTask = new SessionTaskCopyFrom(this /* GuestSession */,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Return progress to the caller. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync tr("Starting task for copying file \"%ls\" from guest to \"%ls\" on the host failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSTDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No source specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No destination specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(this /* GuestSession */,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Return progress to the caller. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync tr("Starting task for copying file \"%ls\" from host to \"%ls\" on the guest failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncSTDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode,
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return setError(E_INVALIDARG, tr("No directory to create specified"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* aDirectory is optional. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync com::SafeArray<DirectoryCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), fFlags);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Return directory object to the caller. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Invalid parameters given"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Unexpectedly aborted"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Could not create directory"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_UNLIKELY((aTemplate) == NULL || *(aTemplate) == '\0'))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_INVALIDARG, tr("No file to remove specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync try /* Can this be done without exceptions? */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mName = Utf8StrFmt(tr("Creating temporary directory from template \"%s\"",
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync /* Construct arguments. */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mArguments.push_back(Bstr(aTemplate)); /* The template we want to use. */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync catch (...)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n",
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while starting temporary directory creation tool on guest: %Rrc"), rc);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while running temporary directory creation tool: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("No return code after creating temporary directory"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("No return code after creating temporary directory"));
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(VBOX_E_IPRT_ERROR, tr("File deletion failed: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("Error while getting return code from creating temporary directory: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryExists(IN_BSTR aPath, BOOL *aExists)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return setError(E_INVALIDARG, tr("No directory to check existence for specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync /** @todo Add more errors here! */
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory existence failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
8bc8d66f188d5357155b8340e2d489573be2b607vboxsyncSTDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, ComSafeArrayIn(DirectoryOpenFlag_T, aFlags), IGuestDirectory **aDirectory)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("No directory to open specified"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_UNLIKELY((aFilter) != NULL && *(aFilter) != '\0'))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("Directory filters not implemented yet"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync com::SafeArray<DirectoryOpenFlag_T> flags(ComSafeArrayInArg(aFlags));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("Open flags (%#x) not implemented yet"), fFlags);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync int rc = directoryOpenInternal(Utf8Str(aPath), Utf8Str(aFilter), fFlags, pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /* Return directory object to the caller. */
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: Invalid parameters given"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: Unexpectedly aborted"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryRemove(IN_BSTR aPath)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectorySetACL(IN_BSTR aPath, IN_BSTR aACL)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsyncSTDMETHODIMP GuestSession::EnvironmentGet(IN_BSTR aName, BSTR *aValue)
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return setError(E_INVALIDARG, tr("No value name specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync Bstr strValue(mData.mEnvironment.Get(Utf8Str(aName)));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::EnvironmentSet(IN_BSTR aName, IN_BSTR aValue)
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return setError(E_INVALIDARG, tr("No value name specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync int rc = mData.mEnvironment.Set(Utf8Str(aName), Utf8Str(aValue));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::EnvironmentUnset(IN_BSTR aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileExists(IN_BSTR aPath, BOOL *aExists)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return setError(E_INVALIDARG, tr("No file to check existence for specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync /** @todo Add more errors here! */
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file existence failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsyncSTDMETHODIMP GuestSession::FileRemove(IN_BSTR aPath)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return setError(E_INVALIDARG, tr("No file to remove specified"));
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync try /* Can this be done without exceptions? */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync catch (...)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No file to open specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aOpenMode) == NULL || *(aOpenMode) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No open mode specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aDisposition) == NULL || *(aDisposition) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No disposition mode specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate open mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate disposition mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate creation mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc = fileOpenInternal(Utf8Str(aPath), Utf8Str(aOpenMode), Utf8Str(aDisposition),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Return directory object to the caller. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Add more error info! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileQuerySize(IN_BSTR aPath, LONG64 *aSize)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return setError(E_INVALIDARG, tr("No file to query size for specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = fileQuerySizeInternal(Utf8Str(aPath), &llSize);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /** @todo Add more errors here! */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file size failed: %Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileSetACL(IN_BSTR aPath, IN_BSTR aACL)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync HRESULT hr = ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (RT_UNLIKELY((aCommand) == NULL || *(aCommand) == '\0'))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return setError(E_INVALIDARG, tr("No command to execute specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync procInfo.mArguments.push_back(Utf8Str(arguments[i]));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync * Create the process environment:
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * - Apply the session environment in a first step, and
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * - Apply environment variables specified by this call to
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * have the chance of overwriting/deleting session entries.
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mEnvironment = mData.mEnvironment; /* Apply original session environment. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync rc = procInfo.mEnvironment.Set(Utf8Str(environment[i]));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<ProcessCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<LONG> affinity(ComSafeArrayInArg(aAffinity));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mAffinity[i] = affinity[i]; /** @todo Really necessary? Later. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /* Return guest session to the caller. */
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest processes per session (%ld) reached"),
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /** @todo Add more errors here. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Could not create guest process, rc=%Rrc"), rc);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncSTDMETHODIMP GuestSession::ProcessGet(ULONG aPID, IGuestProcess **aProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return setError(E_INVALIDARG, tr("No valid process ID (PID) specified"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync hr = setError(E_INVALIDARG, tr("No process with PID %RU32 found"), aPID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /* This will set (*aProcess) to NULL if pProgress is NULL. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync LogFlowThisFunc(("aProcess=%p, hr=%Rhrc\n", *aProcess, hr));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::SymlinkCreate(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkExists(IN_BSTR aSymlink, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkRemoveDirectory(IN_BSTR aPath)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkRemoveFile(IN_BSTR aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */