Beispiel #1
0
STDMETHODIMP MachineDebuggerWrap::SetRegisters(ULONG aCpuId,
                                               ComSafeArrayIn(IN_BSTR, aNames),
                                               ComSafeArrayIn(IN_BSTR, aValues))
{
    LogRelFlow(("{%p} %s:enter aCpuId=%RU32 aNames=%zu aValues=%zu\n", this, "MachineDebugger::setRegisters", aCpuId, aNames, aValues));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = setRegisters(aCpuId,
                           ArrayBSTRInConverter(ComSafeArrayInArg(aNames)).array(),
                           ArrayBSTRInConverter(ComSafeArrayInArg(aValues)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "MachineDebugger::setRegisters", hrc));
    return hrc;
}
Beispiel #2
0
STDMETHODIMP GuestFile::WriteAt(LONG64 aOffset, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten)
{
#ifndef VBOX_WITH_GUEST_CONTROL
    ReturnComNotImplemented();
#else
    LogFlowThisFuncEnter();

    CheckComArgSafeArrayNotNull(aData);
    CheckComArgOutPointerValid(aWritten);

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    HRESULT hr = S_OK;

    com::SafeArray<BYTE> data(ComSafeArrayInArg(aData));
    int vrc = writeData(aTimeoutMS, data.raw(), (uint32_t)data.size(),
                         (uint32_t*)aWritten);
    if (RT_FAILURE(vrc))
    {
        switch (vrc)
        {
            default:
                hr = setError(VBOX_E_IPRT_ERROR,
                              tr("Writing %zubytes to file \"%s\" (at offset %RU64) failed: %Rrc"),
                              data.size(), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc);
                break;
        }
    }

    LogFlowFuncLeaveRC(vrc);
    return hr;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
Beispiel #3
0
STDMETHODIMP MachineDebuggerWrap::WriteVirtualMemory(ULONG aCpuId,
                                                     LONG64 aAddress,
                                                     ULONG aSize,
                                                     ComSafeArrayIn(BYTE, aBytes))
{
    LogRelFlow(("{%p} %s:enter aCpuId=%RU32 aAddress=%RI64 aSize=%RU32 aBytes=%zu\n", this, "MachineDebugger::writeVirtualMemory", aCpuId, aAddress, aSize, aBytes));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = writeVirtualMemory(aCpuId,
                                 aAddress,
                                 aSize,
                                 ArrayInConverter<BYTE>(ComSafeArrayInArg(aBytes)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "MachineDebugger::writeVirtualMemory", hrc));
    return hrc;
}
Beispiel #4
0
STDMETHODIMP GuestSessionWrap::WaitForArray(ComSafeArrayIn(GuestSessionWaitForFlag_T, aWaitFor),
                                            ULONG aTimeoutMS,
                                            GuestSessionWaitResult_T *aReason)
{
    LogRelFlow(("{%p} %s:enter aWaitFor=%zu aTimeoutMS=%RU32 aReason=%p\n", this, "GuestSession::waitForArray", aWaitFor, aTimeoutMS, aReason));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aReason);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = waitForArray(ArrayInConverter<GuestSessionWaitForFlag_T>(ComSafeArrayInArg(aWaitFor)).array(),
                           aTimeoutMS,
                           aReason);
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aReason=%RU32 hrc=%Rhrc\n", this, "GuestSession::waitForArray", *aReason, hrc));
    return hrc;
}
Beispiel #5
0
STDMETHODIMP Session::OnlineMergeMedium(IMediumAttachment *aMediumAttachment,
                                        ULONG aSourceIdx, ULONG aTargetIdx,
                                        IMedium *aSource, IMedium *aTarget,
                                        BOOL aMergeForward,
                                        IMedium *aParentForTarget,
                                        ComSafeArrayIn(IMedium *, aChildrenToReparent),
                                        IProgress *aProgress)
{
    AutoCaller autoCaller(this);
    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());

    if (mState != SessionState_Locked)
        return setError(VBOX_E_INVALID_VM_STATE,
                        tr("Machine is not locked by session (session state: %s)."),
                        Global::stringifySessionState(mState));
    AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
    AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
    CheckComArgNotNull(aMediumAttachment);
    CheckComArgSafeArrayNotNull(aChildrenToReparent);

    return mConsole->onlineMergeMedium(aMediumAttachment, aSourceIdx,
                                       aTargetIdx, aSource, aTarget,
                                       aMergeForward, aParentForTarget,
                                       ComSafeArrayInArg(aChildrenToReparent),
                                       aProgress);
}
/**
 * Sends a list of scancodes to the keyboard.
 *
 * @returns COM status code
 * @param scancodes   Safe array of scancodes
 * @param codesStored Address of variable to store the number
 *                    of scancodes that were sent to the keyboard.
                      This value can be NULL.
 */
STDMETHODIMP Keyboard::PutScancodes(ComSafeArrayIn (LONG, scancodes),
                                    ULONG *codesStored)
{
    if (ComSafeArrayInIsNull(scancodes))
        return E_INVALIDARG;
    if (!mpDrv)
        return S_OK;

    com::SafeArray <LONG> keys(ComSafeArrayInArg(scancodes));
    int rcVBox = VINF_SUCCESS;

    for (uint32_t i = 0; (i < keys.size()) && RT_SUCCESS(rcVBox); i++)
    {
        rcVBox = mpDrv->pUpPort->pfnPutEvent(mpDrv->pUpPort, (uint8_t)keys[i]);
    }

    if (RT_FAILURE (rcVBox))
        return E_FAIL;

    /// @todo is it actually possible that not all scancodes can be transmitted?
    if (codesStored)
        *codesStored = keys.size();

    return S_OK;
}
Beispiel #7
0
STDMETHODIMP GuestSessionWrap::DirectoryCreate(IN_BSTR aPath,
                                               ULONG aMode,
                                               ComSafeArrayIn(DirectoryCreateFlag_T, aFlags))
{
    LogRelFlow(("{%p} %s:enter aPath=%ls aMode=%RU32 aFlags=%zu\n", this, "GuestSession::directoryCreate", aPath, aMode, aFlags));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = directoryCreate(BSTRInConverter(aPath).str(),
                              aMode,
                              ArrayInConverter<DirectoryCreateFlag_T>(ComSafeArrayInArg(aFlags)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "GuestSession::directoryCreate", hrc));
    return hrc;
}
STDMETHODIMP VFSExplorer::Exists(ComSafeArrayIn(IN_BSTR, aNames), ComSafeArrayOut(BSTR, aExists))
{
    CheckComArgSafeArrayNotNull(aNames);

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);

    com::SafeArray<IN_BSTR> sfaNames(ComSafeArrayInArg(aNames));
    std::list<BSTR> listExists;

    for (size_t a=0; a < sfaNames.size(); ++a)
    {
        std::list<VFSExplorer::Data::DirEntry>::const_iterator it;
        for (it = m->entryList.begin();
             it != m->entryList.end();
             ++it)
        {
            const VFSExplorer::Data::DirEntry &entry = (*it);
            if (entry.name == RTPathFilename(Utf8Str(sfaNames[a]).c_str()))
            {
                BSTR name;
                Bstr tmp(sfaNames[a]); /* gcc-3.3 cruft */
                tmp.cloneTo(&name);
                listExists.push_back(name);
            }
        }
    }

    com::SafeArray<BSTR> sfaExists(listExists);
    sfaExists.detachTo(ComSafeArrayOutArg(aExists));

    return S_OK;
}
Beispiel #9
0
/**
 * Send a multi-touch event. This requires multi-touch pointing device emulation.
 * @note all calls out of this object are made with no locks held!
 *
 * @returns COM status code.
 * @param aCount     Number of contacts.
 * @param aContacts  Information about each contact.
 * @param aScanTime  Timestamp.
 */
STDMETHODIMP Mouse::PutEventMultiTouch(LONG aCount,
                                       ComSafeArrayIn(LONG64, aContacts),
                                       ULONG aScanTime)
{
    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    com::SafeArray <LONG64> arrayContacts(ComSafeArrayInArg(aContacts));

    LogRel3(("%s: aCount %d(actual %d), aScanTime %u\n",
             __FUNCTION__, aCount, arrayContacts.size(), aScanTime));

    HRESULT rc = S_OK;

    if ((LONG)arrayContacts.size() >= aCount)
    {
        LONG64* paContacts = arrayContacts.raw();

        rc = putEventMultiTouch(aCount, paContacts, aScanTime);
    }
    else
    {
        rc = E_INVALIDARG;
    }

    return rc;
}
Beispiel #10
0
STDMETHODIMP VFSExplorerWrap::Exists(ComSafeArrayIn(IN_BSTR, aNames),
                                     ComSafeArrayOut(BSTR, aExists))
{
    LogRelFlow(("{%p} %s:enter aNames=%zu aExists=%p\n", this, "VFSExplorer::exists", aNames, aExists));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aExists);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = exists(ArrayBSTRInConverter(ComSafeArrayInArg(aNames)).array(),
                     ArrayBSTROutConverter(ComSafeArrayOutArg(aExists)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aExists=%zu hrc=%Rhrc\n", this, "VFSExplorer::exists", ComSafeArraySize(*aExists), hrc));
    return hrc;
}
Beispiel #11
0
STDMETHODIMP VFSExplorerWrap::Remove(ComSafeArrayIn(IN_BSTR, aNames),
                                     IProgress **aProgress)
{
    LogRelFlow(("{%p} %s:enter aNames=%zu aProgress=%p\n", this, "VFSExplorer::remove", aNames, aProgress));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aProgress);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = remove(ArrayBSTRInConverter(ComSafeArrayInArg(aNames)).array(),
                     ComTypeOutConverter<IProgress>(aProgress).ptr());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aProgress=%p hrc=%Rhrc\n", this, "VFSExplorer::remove", *aProgress, hrc));
    return hrc;
}
Beispiel #12
0
STDMETHODIMP GuestSessionWrap::DirectoryRemoveRecursive(IN_BSTR aPath,
                                                        ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags),
                                                        IProgress **aProgress)
{
    LogRelFlow(("{%p} %s:enter aPath=%ls aFlags=%zu aProgress=%p\n", this, "GuestSession::directoryRemoveRecursive", aPath, aFlags, aProgress));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aProgress);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = directoryRemoveRecursive(BSTRInConverter(aPath).str(),
                                       ArrayInConverter<DirectoryRemoveRecFlag_T>(ComSafeArrayInArg(aFlags)).array(),
                                       ComTypeOutConverter<IProgress>(aProgress).ptr());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aProgress=%p hrc=%Rhrc\n", this, "GuestSession::directoryRemoveRecursive", *aProgress, hrc));
    return hrc;
}
Beispiel #13
0
STDMETHODIMP GuestSessionWrap::DirectoryRename(IN_BSTR aSource,
                                               IN_BSTR aDest,
                                               ComSafeArrayIn(PathRenameFlag_T, aFlags))
{
    LogRelFlow(("{%p} %s:enter aSource=%ls aDest=%ls aFlags=%zu\n", this, "GuestSession::directoryRename", aSource, aDest, aFlags));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = directoryRename(BSTRInConverter(aSource).str(),
                              BSTRInConverter(aDest).str(),
                              ArrayInConverter<PathRenameFlag_T>(ComSafeArrayInArg(aFlags)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "GuestSession::directoryRename", hrc));
    return hrc;
}
Beispiel #14
0
STDMETHODIMP GuestSessionWrap::COMSETTER(Environment)(ComSafeArrayIn(IN_BSTR, aEnvironment))
{
    LogRelFlow(("{%p} %s: enter aEnvironment=%zu\n", this, "GuestSession::setEnvironment", ComSafeArraySize(aEnvironment)));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = setEnvironment(ArrayBSTRInConverter(ComSafeArrayInArg(aEnvironment)).array());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, "GuestSession::setEnvironment", hrc));
    return hrc;
}
Beispiel #15
0
STDMETHODIMP EventSource::RegisterListener(IEventListener * aListener,
                                           ComSafeArrayIn(VBoxEventType_T, aInterested),
                                           BOOL             aActive)
{
    CheckComArgNotNull(aListener);
    CheckComArgSafeArrayNotNull(aInterested);

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    {
        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);

        Listeners::const_iterator it = m->mListeners.find(aListener);
        if (it != m->mListeners.end())
            return setError(E_INVALIDARG,
                            tr("This listener already registered"));

        com::SafeArray<VBoxEventType_T> interested(ComSafeArrayInArg (aInterested));
        RecordHolder<ListenerRecord> lrh(new ListenerRecord(aListener, interested, aActive, this));
        m->mListeners.insert(Listeners::value_type(aListener, lrh));
    }

    VBoxEventDesc evDesc;
    evDesc.init(this, VBoxEventType_OnEventSourceChanged, aListener, TRUE);
    evDesc.fire(0);

    return S_OK;
}
Beispiel #16
0
STDMETHODIMP GuestSessionWrap::SymlinkRead(IN_BSTR aSymlink,
                                           ComSafeArrayIn(SymlinkReadFlag_T, aFlags),
                                           BSTR *aTarget)
{
    LogRelFlow(("{%p} %s:enter aSymlink=%ls aFlags=%zu aTarget=%p\n", this, "GuestSession::symlinkRead", aSymlink, aFlags, aTarget));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aTarget);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = symlinkRead(BSTRInConverter(aSymlink).str(),
                          ArrayInConverter<SymlinkReadFlag_T>(ComSafeArrayInArg(aFlags)).array(),
                          BSTROutConverter(aTarget).str());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aTarget=%ls hrc=%Rhrc\n", this, "GuestSession::symlinkRead", *aTarget, hrc));
    return hrc;
}
Beispiel #17
0
/**
 * Sends a list of scancodes to the keyboard.
 *
 * @returns COM status code
 * @param scancodes   Pointer to the first scancode
 * @param count       Number of scancodes
 * @param codesStored Address of variable to store the number
 *                    of scancodes that were sent to the keyboard.
                      This value can be NULL.
 */
STDMETHODIMP Keyboard::PutScancodes(ComSafeArrayIn(LONG, scancodes),
                                    ULONG *codesStored)
{
    if (ComSafeArrayInIsNull(scancodes))
        return E_INVALIDARG;

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    com::SafeArray<LONG> keys(ComSafeArrayInArg(scancodes));

    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);

    CHECK_CONSOLE_DRV(mpDrv[0]);

    /* Send input to the last enabled device. Relies on the fact that
     * the USB keyboard is always initialized after the PS/2 keyboard.
     */
    PPDMIKEYBOARDPORT pUpPort = NULL;
    for (int i = KEYBOARD_MAX_DEVICES - 1; i >= 0 ; --i)
    {
        if (mpDrv[i] && (mpDrv[i]->u32DevCaps & KEYBOARD_DEVCAP_ENABLED))
        {
            pUpPort = mpDrv[i]->pUpPort;
            break;
        }
    }
    /* No enabled keyboard - throw the input away. */
    if (!pUpPort)
    {
        if (codesStored)
            *codesStored = (uint32_t)keys.size();
        return S_OK;
    }

    int vrc = VINF_SUCCESS;

    uint32_t sent;
    for (sent = 0; (sent < keys.size()) && RT_SUCCESS(vrc); sent++)
        vrc = pUpPort->pfnPutEvent(pUpPort, (uint8_t)keys[sent]);

    if (codesStored)
        *codesStored = sent;

    /* Only signal the keys in the event which have been actually sent. */
    com::SafeArray<LONG> keysSent(sent);
    memcpy(keysSent.raw(), keys.raw(), sent*sizeof(LONG));

    VBoxEventDesc evDesc;
    evDesc.init(mEventSource, VBoxEventType_OnGuestKeyboard, ComSafeArrayAsInParam(keys));
    evDesc.fire(0);

    if (RT_FAILURE(vrc))
        return setError(VBOX_E_IPRT_ERROR,
                        tr("Could not send all scan codes to the virtual keyboard (%Rrc)"),
                        vrc);

    return S_OK;
}
Beispiel #18
0
STDMETHODIMP GuestSessionWrap::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 **aGuestProcess)
{
    LogRelFlow(("{%p} %s:enter aCommand=%ls aArguments=%zu aEnvironment=%zu aFlags=%zu aTimeoutMS=%RU32 aPriority=%RU32 aAffinity=%zu aGuestProcess=%p\n", this, "GuestSession::processCreateEx", aCommand, aArguments, aEnvironment, aFlags, aTimeoutMS, aPriority, aAffinity, aGuestProcess));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aGuestProcess);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = processCreateEx(BSTRInConverter(aCommand).str(),
                              ArrayBSTRInConverter(ComSafeArrayInArg(aArguments)).array(),
                              ArrayBSTRInConverter(ComSafeArrayInArg(aEnvironment)).array(),
                              ArrayInConverter<ProcessCreateFlag_T>(ComSafeArrayInArg(aFlags)).array(),
                              aTimeoutMS,
                              aPriority,
                              ArrayInConverter<LONG>(ComSafeArrayInArg(aAffinity)).array(),
                              ComTypeOutConverter<IGuestProcess>(aGuestProcess).ptr());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aGuestProcess=%p hrc=%Rhrc\n", this, "GuestSession::processCreateEx", *aGuestProcess, hrc));
    return hrc;
}
Beispiel #19
0
STDMETHODIMP ProcessWrap::WriteArray(ULONG aHandle,
                                     ComSafeArrayIn(ProcessInputFlag_T, aFlags),
                                     ComSafeArrayIn(BYTE, aData),
                                     ULONG aTimeoutMS,
                                     ULONG *aWritten)
{
    LogRelFlow(("{%p} %s:enter aHandle=%RU32 aFlags=%zu aData=%zu aTimeoutMS=%RU32 aWritten=%p\n", this, "Process::writeArray", aHandle, aFlags, aData, aTimeoutMS, aWritten));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aWritten);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = writeArray(aHandle,
                         ArrayInConverter<ProcessInputFlag_T>(ComSafeArrayInArg(aFlags)).array(),
                         ArrayInConverter<BYTE>(ComSafeArrayInArg(aData)).array(),
                         aTimeoutMS,
                         aWritten);
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aWritten=%RU32 hrc=%Rhrc\n", this, "Process::writeArray", *aWritten, hrc));
    return hrc;
}
STDMETHODIMP VFSExplorer::Remove(ComSafeArrayIn(IN_BSTR, aNames), IProgress **aProgress)
{
    CheckComArgSafeArrayNotNull(aNames);
    CheckComArgOutPointerValid(aProgress);

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);

    HRESULT rc = S_OK;

    com::SafeArray<IN_BSTR> sfaNames(ComSafeArrayInArg(aNames));

    ComObjPtr<Progress> progress;
    try
    {
        /* Create the progress object */
        progress.createObject();

        rc = progress->init(mVirtualBox, static_cast<IVFSExplorer*>(this),
                            Bstr(tr("Delete files")).raw(),
                            TRUE /* aCancelable */);
        if (FAILED(rc)) throw rc;

        /* Initialize our worker task */
        std::auto_ptr<TaskVFSExplorer> task(new TaskVFSExplorer(TaskVFSExplorer::Delete, this, progress));

        /* Add all filenames to delete as task data */
        for (size_t a=0; a < sfaNames.size(); ++a)
            task->filenames.push_back(Utf8Str(sfaNames[a]));

        rc = task->startThread();
        if (FAILED(rc)) throw rc;

        /* Don't destruct on success */
        task.release();
    }
    catch (HRESULT aRC)
    {
        rc = aRC;
    }

    if (SUCCEEDED(rc))
        /* Return progress to the caller */
        progress.queryInterfaceTo(aProgress);

    return rc;
}
Beispiel #21
0
STDMETHODIMP Guest::DragHGPutData(ULONG uScreenId, IN_BSTR bstrFormat, ComSafeArrayIn(BYTE, data), IProgress **ppProgress)
{
    /* Input validation */
    CheckComArgStrNotEmptyOrNull(bstrFormat);
    CheckComArgSafeArrayNotNull(data);
    CheckComArgOutPointerValid(ppProgress);

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

#ifdef VBOX_WITH_DRAG_AND_DROP
    return m_pGuestDnD->dragHGPutData(uScreenId, bstrFormat, ComSafeArrayInArg(data), ppProgress);
#else /* VBOX_WITH_DRAG_AND_DROP */
    ReturnComNotImplemented();
#endif /* !VBOX_WITH_DRAG_AND_DROP */
}
Beispiel #22
0
STDMETHODIMP Guest::DragHGMove(ULONG uScreenId, ULONG uX, ULONG uY, DragAndDropAction_T defaultAction, ComSafeArrayIn(DragAndDropAction_T, allowedActions), ComSafeArrayIn(IN_BSTR, formats), DragAndDropAction_T *pResultAction)
{
    /* Input validation */
    CheckComArgSafeArrayNotNull(allowedActions);
    CheckComArgSafeArrayNotNull(formats);
    CheckComArgOutPointerValid(pResultAction);

    AutoCaller autoCaller(this);
    if (FAILED(autoCaller.rc())) return autoCaller.rc();

#ifdef VBOX_WITH_DRAG_AND_DROP
    return m_pGuestDnD->dragHGMove(uScreenId, uX, uY, defaultAction, ComSafeArrayInArg(allowedActions), ComSafeArrayInArg(formats), pResultAction);
#else /* VBOX_WITH_DRAG_AND_DROP */
    ReturnComNotImplemented();
#endif /* !VBOX_WITH_DRAG_AND_DROP */
}
Beispiel #23
0
STDMETHODIMP GuestSessionWrap::CopyTo(IN_BSTR aSource,
                                      IN_BSTR aDest,
                                      ComSafeArrayIn(CopyFileFlag_T, aFlags),
                                      IProgress **aProgress)
{
    LogRelFlow(("{%p} %s:enter aSource=%ls aDest=%ls aFlags=%zu aProgress=%p\n", this, "GuestSession::copyTo", aSource, aDest, aFlags, aProgress));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aProgress);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = copyTo(BSTRInConverter(aSource).str(),
                     BSTRInConverter(aDest).str(),
                     ArrayInConverter<CopyFileFlag_T>(ComSafeArrayInArg(aFlags)).array(),
                     ComTypeOutConverter<IProgress>(aProgress).ptr());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave aProgress=%p hrc=%Rhrc\n", this, "GuestSession::copyTo", *aProgress, hrc));
    return hrc;
}