STDMETHODIMP NetworkAdapter::GetProperties(IN_BSTR aNames, ComSafeArrayOut(BSTR, aReturnNames), ComSafeArrayOut(BSTR, aReturnValues)) { CheckComArgOutSafeArrayPointerValid(aReturnNames); CheckComArgOutSafeArrayPointerValid(aReturnValues); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); /// @todo make use of aNames according to the documentation NOREF(aNames); com::SafeArray<BSTR> names(mData->mGenericProperties.size()); com::SafeArray<BSTR> values(mData->mGenericProperties.size()); size_t i = 0; for (settings::StringsMap::const_iterator it = mData->mGenericProperties.begin(); it != mData->mGenericProperties.end(); ++it) { it->first.cloneTo(&names[i]); it->second.cloneTo(&values[i]); ++i; } names.detachTo(ComSafeArrayOutArg(aReturnNames)); values.detachTo(ComSafeArrayOutArg(aReturnValues)); return S_OK; }
STDMETHODIMP SystemProperties::GetDeviceTypesForStorageBus(StorageBus_T aBus, ComSafeArrayOut(DeviceType_T, aDeviceTypes)) { CheckComArgOutSafeArrayPointerValid(aDeviceTypes); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); /* no need to lock, this is const */ switch (aBus) { case StorageBus_IDE: case StorageBus_SATA: case StorageBus_SCSI: case StorageBus_SAS: { com::SafeArray<DeviceType_T> saDeviceTypes(2); saDeviceTypes[0] = DeviceType_DVD; saDeviceTypes[1] = DeviceType_HardDisk; saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); break; } case StorageBus_Floppy: { com::SafeArray<DeviceType_T> saDeviceTypes(1); saDeviceTypes[0] = DeviceType_Floppy; saDeviceTypes.detachTo(ComSafeArrayOutArg(aDeviceTypes)); break; } default: AssertMsgFailed(("Invalid bus type %d\n", aBus)); } return S_OK; }
STDMETHODIMP MachineDebuggerWrap::GetRegisters(ULONG aCpuId, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues)) { LogRelFlow(("{%p} %s:enter aCpuId=%RU32 aNames=%p aValues=%p\n", this, "MachineDebugger::getRegisters", aCpuId, aNames, aValues)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aNames); CheckComArgOutPointerValidThrow(aValues); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getRegisters(aCpuId, ArrayBSTROutConverter(ComSafeArrayOutArg(aNames)).array(), ArrayBSTROutConverter(ComSafeArrayOutArg(aValues)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aNames=%zu *aValues=%zu hrc=%Rhrc\n", this, "MachineDebugger::getRegisters", ComSafeArraySize(*aNames), ComSafeArraySize(*aValues), hrc)); return hrc; }
STDMETHODIMP Session::EnumerateGuestProperties(IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(LONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags)) { #ifdef VBOX_WITH_GUEST_PROPS 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); if (!VALID_PTR(aPatterns) && (aPatterns != NULL)) return E_POINTER; if (ComSafeArrayOutIsNull(aNames)) return E_POINTER; if (ComSafeArrayOutIsNull(aValues)) return E_POINTER; if (ComSafeArrayOutIsNull(aTimestamps)) return E_POINTER; if (ComSafeArrayOutIsNull(aFlags)) return E_POINTER; return mConsole->enumerateGuestProperties(aPatterns, ComSafeArrayOutArg(aNames), ComSafeArrayOutArg(aValues), ComSafeArrayOutArg(aTimestamps), ComSafeArrayOutArg(aFlags)); #else /* VBOX_WITH_GUEST_PROPS not defined */ ReturnComNotImplemented(); #endif /* VBOX_WITH_GUEST_PROPS not defined */ }
STDMETHODIMP NATEngine::COMGETTER(Redirects)(ComSafeArrayOut(BSTR , aNatRules)) { CheckComArgOutSafeArrayPointerValid(aNatRules); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); SafeArray<BSTR> sf(mNATRules.size()); size_t i = 0; NATRuleMap::const_iterator it; for (it = mNATRules.begin(); it != mNATRules.end(); ++it, ++i) { settings::NATRule r = it->second; BstrFmt bstr("%s,%d,%s,%d,%s,%d", r.strName.c_str(), r.proto, r.strHostIP.c_str(), r.u16HostPort, r.strGuestIP.c_str(), r.u16GuestPort); bstr.detachTo(&sf[i]); } sf.detachTo(ComSafeArrayOutArg(aNatRules)); return S_OK; }
STDMETHODIMP ProcessWrap::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment)) { LogRelFlow(("{%p} %s: enter aEnvironment=%p\n", this, "Process::getEnvironment", aEnvironment)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aEnvironment); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getEnvironment(ArrayBSTROutConverter(ComSafeArrayOutArg(aEnvironment)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aEnvironment=%zu hrc=%Rhrc\n", this, "Process::getEnvironment", ComSafeArraySize(*aEnvironment), hrc)); return hrc; }
STDMETHODIMP CanShowWindowEventWrap::GetVetos(ComSafeArrayOut(BSTR, aResult)) { LogRelFlow(("{%p} %s:enter aResult=%p\n", this, "CanShowWindowEvent::getVetos", aResult)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aResult); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getVetos(ArrayBSTROutConverter(ComSafeArrayOutArg(aResult)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave aResult=%zu hrc=%Rhrc\n", this, "CanShowWindowEvent::getVetos", ComSafeArraySize(*aResult), hrc)); return hrc; }
STDMETHODIMP MachineDebuggerWrap::ReadPhysicalMemory(LONG64 aAddress, ULONG aSize, ComSafeArrayOut(BYTE, aBytes)) { LogRelFlow(("{%p} %s:enter aAddress=%RI64 aSize=%RU32 aBytes=%p\n", this, "MachineDebugger::readPhysicalMemory", aAddress, aSize, aBytes)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aBytes); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = readPhysicalMemory(aAddress, aSize, ArrayOutConverter<BYTE>(ComSafeArrayOutArg(aBytes)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave aBytes=%zu hrc=%Rhrc\n", this, "MachineDebugger::readPhysicalMemory", ComSafeArraySize(*aBytes), hrc)); return hrc; }
STDMETHODIMP NATNetworkWrap::COMGETTER(PortForwardRules6)(ComSafeArrayOut(BSTR, aPortForwardRules6)) { LogRelFlow(("{%p} %s: enter aPortForwardRules6=%p\n", this, "NATNetwork::getPortForwardRules6", aPortForwardRules6)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aPortForwardRules6); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getPortForwardRules6(ArrayBSTROutConverter(ComSafeArrayOutArg(aPortForwardRules6)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aPortForwardRules6=%zu hrc=%Rhrc\n", this, "NATNetwork::getPortForwardRules6", ComSafeArraySize(*aPortForwardRules6), hrc)); return hrc; }
STDMETHODIMP GuestSessionWrap::COMGETTER(Files)(ComSafeArrayOut(IGuestFile *, aFiles)) { LogRelFlow(("{%p} %s: enter aFiles=%p\n", this, "GuestSession::getFiles", aFiles)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aFiles); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getFiles(ArrayComTypeOutConverter<IGuestFile>(ComSafeArrayOutArg(aFiles)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aFiles=%zu hrc=%Rhrc\n", this, "GuestSession::getFiles", ComSafeArraySize(*aFiles), 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; }
STDMETHODIMP Guest::DragGHPending(ULONG uScreenId, ComSafeArrayOut(BSTR, formats), ComSafeArrayOut(DragAndDropAction_T, allowedActions), DragAndDropAction_T *pDefaultAction) { /* Input validation */ CheckComArgSafeArrayNotNull(formats); CheckComArgSafeArrayNotNull(allowedActions); CheckComArgOutPointerValid(pDefaultAction); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); #if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH) return m_pGuestDnD->dragGHPending(uScreenId, ComSafeArrayOutArg(formats), ComSafeArrayOutArg(allowedActions), pDefaultAction); #else /* VBOX_WITH_DRAG_AND_DROP */ ReturnComNotImplemented(); #endif /* !VBOX_WITH_DRAG_AND_DROP */ }
STDMETHODIMP MousePointerShapeChangedEventWrap::COMGETTER(Shape)(ComSafeArrayOut(BYTE, aShape)) { LogRelFlow(("{%p} %s: enter aShape=%p\n", this, "MousePointerShapeChangedEvent::getShape", aShape)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aShape); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getShape(ArrayOutConverter<BYTE>(ComSafeArrayOutArg(aShape)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aShape=%zu hrc=%Rhrc\n", this, "MousePointerShapeChangedEvent::getShape", ComSafeArraySize(*aShape), hrc)); return hrc; }
STDMETHODIMP GuestMultiTouchEventWrap::COMGETTER(ContactFlags)(ComSafeArrayOut(USHORT, aContactFlags)) { LogRelFlow(("{%p} %s: enter aContactFlags=%p\n", this, "GuestMultiTouchEvent::getContactFlags", aContactFlags)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aContactFlags); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getContactFlags(ArrayOutConverter<USHORT>(ComSafeArrayOutArg(aContactFlags)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aContactFlags=%zu hrc=%Rhrc\n", this, "GuestMultiTouchEvent::getContactFlags", ComSafeArraySize(*aContactFlags), hrc)); return hrc; }
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; }
/** * Gets the collection of USB devices, slave of Host::USBDevices. * * This is an interface for the HostImpl::USBDevices property getter. * * * @param aUSBDevices Where to store the pointer to the collection. * * @returns COM status code. * * @remarks The caller must own the write lock of the host object. */ HRESULT USBProxyService::getDeviceCollection(ComSafeArrayOut(IHostUSBDevice *, aUSBDevices)) { AssertReturn(isWriteLockOnCurrentThread(), E_FAIL); CheckComArgOutSafeArrayPointerValid(aUSBDevices); AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); SafeIfaceArray<IHostUSBDevice> Collection(mDevices); Collection.detachTo(ComSafeArrayOutArg(aUSBDevices)); return S_OK; }
STDMETHODIMP Session::EnumerateGuestProperties(IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(LONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags)) { #if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_COM_INPROC_API_CLIENT) 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); if (!VALID_PTR(aPatterns) && (aPatterns != NULL)) return E_POINTER; if (ComSafeArrayOutIsNull(aNames)) return E_POINTER; if (ComSafeArrayOutIsNull(aValues)) return E_POINTER; if (ComSafeArrayOutIsNull(aTimestamps)) return E_POINTER; if (ComSafeArrayOutIsNull(aFlags)) return E_POINTER; /* If this session is not in a VM process fend off the call. The caller * handles this correctly, by doing the operation in VBoxSVC. */ if (!mConsole) return E_ACCESSDENIED; return mConsole->enumerateGuestProperties(aPatterns, ComSafeArrayOutArg(aNames), ComSafeArrayOutArg(aValues), ComSafeArrayOutArg(aTimestamps), ComSafeArrayOutArg(aFlags)); #else /* VBOX_WITH_GUEST_PROPS not defined */ ReturnComNotImplemented(); #endif /* VBOX_WITH_GUEST_PROPS not defined */ }
STDMETHODIMP VFSExplorerWrap::EntryList(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(ULONG, aTypes), ComSafeArrayOut(LONG64, aSizes), ComSafeArrayOut(ULONG, aModes)) { LogRelFlow(("{%p} %s:enter aNames=%p aTypes=%p aSizes=%p aModes=%p\n", this, "VFSExplorer::entryList", aNames, aTypes, aSizes, aModes)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aNames); CheckComArgOutPointerValidThrow(aTypes); CheckComArgOutPointerValidThrow(aSizes); CheckComArgOutPointerValidThrow(aModes); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = entryList(ArrayBSTROutConverter(ComSafeArrayOutArg(aNames)).array(), ArrayOutConverter<ULONG>(ComSafeArrayOutArg(aTypes)).array(), ArrayOutConverter<LONG64>(ComSafeArrayOutArg(aSizes)).array(), ArrayOutConverter<ULONG>(ComSafeArrayOutArg(aModes)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aNames=%zu *aTypes=%zu *aSizes=%zu *aModes=%zu hrc=%Rhrc\n", this, "VFSExplorer::entryList", ComSafeArraySize(*aNames), ComSafeArraySize(*aTypes), ComSafeArraySize(*aSizes), ComSafeArraySize(*aModes), hrc)); return hrc; }
STDMETHODIMP Guest::DragGHGetData(ComSafeArrayOut(BYTE, data)) { /* Input validation */ CheckComArgSafeArrayNotNull(data); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); #if defined(VBOX_WITH_DRAG_AND_DROP) && defined(VBOX_WITH_DRAG_AND_DROP_GH) return m_pGuestDnD->dragGHGetData(ComSafeArrayOutArg(data)); #else /* VBOX_WITH_DRAG_AND_DROP */ ReturnComNotImplemented(); #endif /* !VBOX_WITH_DRAG_AND_DROP */ }
STDMETHODIMP Guest::COMGETTER(Sessions)(ComSafeArrayOut(IGuestSession *, aSessions)) { CheckComArgOutSafeArrayPointerValid(aSessions); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); SafeIfaceArray<IGuestSession> collection(mData.mGuestSessions); collection.detachTo(ComSafeArrayOutArg(aSessions)); return S_OK; }
STDMETHODIMP Guest::COMGETTER(Facilities)(ComSafeArrayOut(IAdditionsFacility*, aFacilities)) { CheckComArgOutPointerValid(aFacilities); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); SafeIfaceArray<IAdditionsFacility> fac(mData.mFacilityMap); fac.detachTo(ComSafeArrayOutArg(aFacilities)); return S_OK; }
STDMETHODIMP SystemProperties::COMGETTER(MediumFormats)(ComSafeArrayOut(IMediumFormat *, aMediumFormats)) { CheckComArgOutSafeArrayPointerValid(aMediumFormats); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); SafeIfaceArray<IMediumFormat> mediumFormats(m_llMediumFormats); mediumFormats.detachTo(ComSafeArrayOutArg(aMediumFormats)); return S_OK; }
STDMETHODIMP VFSExplorer::EntryList(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(VFSFileType_T, aTypes), ComSafeArrayOut(LONG64, aSizes), ComSafeArrayOut(ULONG, aModes)) { if (ComSafeArrayOutIsNull(aNames) || ComSafeArrayOutIsNull(aTypes)) return E_POINTER; AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); com::SafeArray<BSTR> sfaNames(m->entryList.size()); com::SafeArray<ULONG> sfaTypes(m->entryList.size()); com::SafeArray<LONG64> sfaSizes(m->entryList.size()); com::SafeArray<ULONG> sfaModes(m->entryList.size()); std::list<VFSExplorer::Data::DirEntry>::const_iterator it; size_t i = 0; for (it = m->entryList.begin(); it != m->entryList.end(); ++it, ++i) { const VFSExplorer::Data::DirEntry &entry = (*it); Bstr bstr(entry.name); bstr.cloneTo(&sfaNames[i]); sfaTypes[i] = entry.type; sfaSizes[i] = entry.size; sfaModes[i] = entry.mode; } sfaNames.detachTo(ComSafeArrayOutArg(aNames)); sfaTypes.detachTo(ComSafeArrayOutArg(aTypes)); sfaSizes.detachTo(ComSafeArrayOutArg(aSizes)); sfaModes.detachTo(ComSafeArrayOutArg(aModes)); return S_OK; }
STDMETHODIMP HostDnsService::COMGETTER(NameServers)(ComSafeArrayOut(BSTR, aNameServers)) { RTCritSectEnter(&m_hCritSect); com::SafeArray<BSTR> nameServers(m_llNameServers.size()); Utf8StrListIterator it; int i = 0; for (it = m_llNameServers.begin(); it != m_llNameServers.end(); ++it, ++i) (*it).cloneTo(&nameServers[i]); nameServers.detachTo(ComSafeArrayOutArg(aNameServers)); RTCritSectLeave(&m_hCritSect); return S_OK; }
void BusAssignmentManager::State::listAttachedPCIDevices(ComSafeArrayOut(IPCIDeviceAttachment*, aAttached)) { com::SafeIfaceArray<IPCIDeviceAttachment> result(mPCIMap.size()); size_t iIndex = 0; ComObjPtr<PCIDeviceAttachment> dev; for (PCIMap::const_iterator it = mPCIMap.begin(); it != mPCIMap.end(); ++it) { dev.createObject(); com::Bstr devname(it->second.szDevName); dev->init(NULL, devname, it->second.HostAddress.valid() ? it->second.HostAddress.asLong() : -1, it->first.asLong(), it->second.HostAddress.valid()); result.setElement(iIndex++, dev); } result.detachTo(ComSafeArrayOutArg(aAttached)); }
STDMETHODIMP HostDnsService::COMGETTER(SearchStrings)(ComSafeArrayOut(BSTR, aSearchStrings)) { RTCritSectEnter(&m_hCritSect); com::SafeArray<BSTR> searchString(m_llSearchStrings.size()); Utf8StrListIterator it; int i = 0; for (it = m_llSearchStrings.begin(); it != m_llSearchStrings.end(); ++it, ++i) (*it).cloneTo(&searchString[i]); searchString.detachTo(ComSafeArrayOutArg(aSearchStrings)); RTCritSectLeave(&m_hCritSect); return S_OK; }
STDMETHODIMP GuestFile::ReadAt(LONG64 aOffset, ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData)) { #ifndef VBOX_WITH_GUEST_CONTROL ReturnComNotImplemented(); #else if (aToRead == 0) return setError(E_INVALIDARG, tr("The size to read is zero")); CheckComArgOutSafeArrayPointerValid(aData); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); com::SafeArray<BYTE> data((size_t)aToRead); Assert(data.size() >= aToRead); HRESULT hr = S_OK; size_t cbRead; int vrc = readDataAt(aOffset, aToRead, aTimeoutMS, data.raw(), aToRead, &cbRead); if (RT_SUCCESS(vrc)) { if (data.size() != cbRead) data.resize(cbRead); data.detachTo(ComSafeArrayOutArg(aData)); } else { switch (vrc) { default: hr = setError(VBOX_E_IPRT_ERROR, tr("Reading from file \"%s\" (at offset %RU64) failed: %Rrc"), mData.mOpenInfo.mFileName.c_str(), aOffset, vrc); break; } } LogFlowFuncLeaveRC(vrc); return hr; #endif /* VBOX_WITH_GUEST_CONTROL */ }
STDMETHODIMP USBController::COMGETTER(DeviceFilters) (ComSafeArrayOut(IUSBDeviceFilter *, aDevicesFilters)) { #ifdef VBOX_WITH_USB CheckComArgOutSafeArrayPointerValid(aDevicesFilters); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); SafeIfaceArray<IUSBDeviceFilter> collection (*m->llDeviceFilters.data()); collection.detachTo(ComSafeArrayOutArg(aDevicesFilters)); return S_OK; #else NOREF(aDevicesFilters); # ifndef RT_OS_WINDOWS NOREF(aDevicesFiltersSize); # endif ReturnComNotImplemented(); #endif }
STDMETHODIMP VBoxVetoEvent::GetVetos(ComSafeArrayOut(BSTR, aVetos)) { if (ComSafeArrayOutIsNull(aVetos)) return E_POINTER; AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); com::SafeArray<BSTR> vetos(m->mVetoList.size()); int i = 0; for (VetoList::const_iterator it = m->mVetoList.begin(); it != m->mVetoList.end(); ++it, ++i) { const Bstr &str = *it; str.cloneTo(&vetos[i]); } vetos.detachTo(ComSafeArrayOutArg(aVetos)); return S_OK; }
STDMETHODIMP ProcessWrap::Read(ULONG aHandle, ULONG aToRead, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData)) { LogRelFlow(("{%p} %s:enter aHandle=%RU32 aToRead=%RU32 aTimeoutMS=%RU32 aData=%p\n", this, "Process::read", aHandle, aToRead, aTimeoutMS, aData)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aData); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = read(aHandle, aToRead, aTimeoutMS, ArrayOutConverter<BYTE>(ComSafeArrayOutArg(aData)).array()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave aData=%zu hrc=%Rhrc\n", this, "Process::read", ComSafeArraySize(*aData), hrc)); return hrc; }