STDMETHODIMP CConnectionPoint::QueryInterface(REFIID riid, void** ppv) { LOGCALL(("CConnectionPoint::QueryInterface(riid = %s)\n", StringFromGuid(riid))); if (ppv == NULL) return E_INVALIDARG; *ppv = NULL; if (riid == IID_IUnknown || riid == IID_IConnectionPoint) { AddRef(); *ppv = static_cast<IConnectionPoint*>(this); return S_OK; } else if (riid == IID_IMarshal) { CriticalSection critical_section(&Module::m_GlobalSync); if (m_pUnkFTM == NULL) CoCreateFreeThreadedMarshaler(static_cast<IConnectionPoint*>(this), &m_pUnkFTM); if (m_pUnkFTM != NULL) return m_pUnkFTM->QueryInterface(riid, ppv); } return E_NOINTERFACE; }
HRESULT loEnum<BASE,ITEM,IFACE>::initiate(loObjTracker *list) { RefCount = 1; LO_IAM_INITIATE(); #if LO_USE_FREEMARSH_ENUM if (!base || base->freemarsh) CoCreateFreeThreadedMarshaler((BASE*)this, &freemarsh); #endif return ot_connect(this, list); }
HRESULT CRScriptCore::FinalConstruct() { s_crit.Lock(); m_lCookie = ++s_lCookie; // for WIN95 - InterlockedIncrement(&s_lCookie); if (m_lCookie >= FIXNUM_MAX) { m_lCookie = s_lCookie = 0; } s_listEngine.push_front(this); s_crit.Unlock(); return CoCreateFreeThreadedMarshaler( GetControllingUnknown(), &m_pUnkMarshaler.p); }
static HRESULT WINAPI FTMarshalCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pUnk, REFIID riid, LPVOID *ppv) { IUnknown *pUnknown; HRESULT hr; TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv); *ppv = NULL; hr = CoCreateFreeThreadedMarshaler(pUnk, &pUnknown); if (SUCCEEDED(hr)) { hr = IUnknown_QueryInterface(pUnknown, riid, ppv); IUnknown_Release(pUnknown); } return hr; }
HRESULT CEnumConnectionPoints::GetInterface(REFIID riid, IUnknown** ppUnknown) { LOGCALL (("CEnumConnectionPoints::GetInterface(%s)\n", STRINGFROMGUID (riid))); IUnknown* pUnknown = NULL; if (riid == IID_IEnumConnectionPoints) pUnknown = static_cast<IEnumConnectionPoints*>(this); else if (riid == IID_IMarshal) { CriticalSection critical_section(this); if (m_pUnkFTM == NULL) CoCreateFreeThreadedMarshaler(GetControllingUnknown(), &m_pUnkFTM); if (m_pUnkFTM != NULL) return m_pUnkFTM->QueryInterface(riid, (void**) ppUnknown); } if (pUnknown == NULL) return E_NOINTERFACE; *ppUnknown = pUnknown; return S_OK; }
HRESULT CGetDataSequentialStream::GetInterface(REFIID riid, IUnknown** ppUnknown) { LOGCALL (("CGetDataSequentialStream::GetInterface(%s)\n", STRINGFROMGUID (riid))); IUnknown* pUnknown = NULL; if (riid == IID_ISequentialStream) pUnknown = static_cast<ISequentialStream*>(this); else if (riid == IID_ISupportErrorInfo) pUnknown = static_cast<ISupportErrorInfo*>(this); else if (riid == IID_IMarshal) { CriticalSection critical_section(m_pStreamSync); if (m_pUnkFTM == NULL) CoCreateFreeThreadedMarshaler(GetControllingUnknown(), &m_pUnkFTM); if (m_pUnkFTM != NULL) return m_pUnkFTM->QueryInterface(riid, (void**) ppUnknown); } if (pUnknown == NULL) return E_NOINTERFACE; *ppUnknown = pUnknown; return S_OK; }
/** * Register active event listener for the selected VM. * * @param virtualBox ptr to IVirtualBox object * @param session ptr to ISession object */ static void registerActiveEventListener(IVirtualBox *virtualBox, ISession *session) { IConsole *console = NULL; HRESULT rc; rc = ISession_get_Console(session, &console); if ((SUCCEEDED(rc)) && console) { IEventSource *es = NULL; rc = IConsole_get_EventSource(console, &es); if (SUCCEEDED(rc) && es) { static const ULONG s_auInterestingEvents[] = { VBoxEventType_OnMousePointerShapeChanged, VBoxEventType_OnMouseCapabilityChanged, VBoxEventType_OnKeyboardLedsChanged, VBoxEventType_OnStateChanged, VBoxEventType_OnAdditionsStateChanged, VBoxEventType_OnNetworkAdapterChanged, VBoxEventType_OnSerialPortChanged, VBoxEventType_OnParallelPortChanged, VBoxEventType_OnStorageControllerChanged, VBoxEventType_OnMediumChanged, VBoxEventType_OnVRDEServerChanged, VBoxEventType_OnUSBControllerChanged, VBoxEventType_OnUSBDeviceStateChanged, VBoxEventType_OnSharedFolderChanged, VBoxEventType_OnRuntimeError, VBoxEventType_OnCanShowWindow, VBoxEventType_OnShowWindow }; SAFEARRAY *interestingEventsSA = NULL; IEventListenerDemo *consoleListener = NULL; /* The VirtualBox API expects enum values as VT_I4, which in the * future can be hopefully relaxed. */ interestingEventsSA = g_pVBoxFuncs->pfnSafeArrayCreateVector(VT_I4, 0, sizeof(s_auInterestingEvents) / sizeof(s_auInterestingEvents[0])); g_pVBoxFuncs->pfnSafeArrayCopyInParamHelper(interestingEventsSA, &s_auInterestingEvents, sizeof(s_auInterestingEvents)); consoleListener = calloc(1, sizeof(IEventListenerDemo)); if (consoleListener) { consoleListener->lpVtbl = &(g_IEventListenerDemoVtblInt.lpVtbl); #ifdef WIN32 CoCreateFreeThreadedMarshaler((IUnknown *)consoleListener, &consoleListener->pUnkMarshaler); #endif IEventListenerDemo_AddRef(consoleListener); rc = IEventSource_RegisterListener(es, (IEventListener *)consoleListener, ComSafeArrayAsInParam(interestingEventsSA), 1 /* active */); if (SUCCEEDED(rc)) { /* Just wait here for events, no easy way to do this better * as there's not much to do after this completes. */ printf("Entering event loop, PowerOff the machine to exit or press Ctrl-C to terminate\n"); fflush(stdout); #ifdef WIN32 SetConsoleCtrlHandler(ctrlCHandler, TRUE); #else signal(SIGINT, (void (*)(int))ctrlCHandler); #endif while (!g_fStop) g_pVBoxFuncs->pfnProcessEventQueue(250); #ifdef WIN32 SetConsoleCtrlHandler(ctrlCHandler, FALSE); #else signal(SIGINT, SIG_DFL); #endif } else printf("Failed to register event listener.\n"); IEventSource_UnregisterListener(es, (IEventListener *)consoleListener); #ifdef WIN32 if (consoleListener->pUnkMarshaler) IUnknown_Release(consoleListener->pUnkMarshaler); #endif IEventListenerDemo_Release(consoleListener); } else printf("Failed while allocating memory for console event listener.\n"); g_pVBoxFuncs->pfnSafeArrayDestroy(interestingEventsSA); IEventSource_Release(es); } else printf("Failed to get the event source instance.\n"); IConsole_Release(console); } }
HRESULT CPreviewPlugin::FinalConstruct() { return CoCreateFreeThreadedMarshaler( GetControllingUnknown(), &m_pUnkMarshaler.p ); }
HRESULT CSWFBuilder::FinalConstruct() throw() { return CoCreateFreeThreadedMarshaler( GetControllingUnknown(), &m_pUnkMarshaler.p ); }
HRESULT CColorPicker::FinalConstruct() { return CoCreateFreeThreadedMarshaler(GetControllingUnknown(), &m_pUnkMarshaler.p); }
public: ApartmentTearDownHandler(HRESULT& hr) { CONTRACTL { NOTHROW; GC_TRIGGERS; MODE_ANY; } CONTRACTL_END; GCX_PREEMP(); m_pMarshalerObj = NULL; m_cbRefCount = 1; hr = CoCreateFreeThreadedMarshaler(this, &m_pMarshalerObj); if (hr == S_OK) m_cbRefCount = 0; else Release(); } virtual ~ApartmentTearDownHandler() { CONTRACTL { NOTHROW; GC_TRIGGERS; MODE_ANY; } CONTRACTL_END;
// address: 0x404f80 void _start() { __size32 eax; // r24 eax = CoCreateFreeThreadedMarshaler(); /* goto eax - 0x7fc6e5ea*/ }
HRESULT RegMeta::QueryInterface( REFIID riid, void ** ppUnk) { HRESULT hr = S_OK; BEGIN_ENTRYPOINT_NOTHROW; int fIsInterfaceRW = false; *ppUnk = 0; if (riid == IID_IUnknown) { *ppUnk = (IUnknown *)(IMetaDataImport2 *)this; } else if (riid == IID_IMDCommon) { *ppUnk = (IMDCommon *)this; } else if (riid == IID_IMetaDataImport) { *ppUnk = (IMetaDataImport2 *)this; } else if (riid == IID_IMetaDataImport2) { *ppUnk = (IMetaDataImport2 *)this; } else if (riid == IID_IMetaDataAssemblyImport) { *ppUnk = (IMetaDataAssemblyImport *)this; } else if (riid == IID_IMetaDataTables) { *ppUnk = static_cast<IMetaDataTables *>(this); } else if (riid == IID_IMetaDataTables2) { *ppUnk = static_cast<IMetaDataTables2 *>(this); } #ifndef FEATURE_METADATA_STANDALONE_WINRT else if (riid == IID_IMetaDataInfo) { *ppUnk = static_cast<IMetaDataInfo *>(this); } #endif //!FEATURE_METADATA_STANDALONE_WINRT #ifdef FEATURE_METADATA_EMIT else if (riid == IID_IMetaDataEmit) { *ppUnk = (IMetaDataEmit2 *)this; fIsInterfaceRW = true; } else if (riid == IID_IMetaDataEmit2) { *ppUnk = (IMetaDataEmit2 *)this; fIsInterfaceRW = true; } else if (riid == IID_IMetaDataAssemblyEmit) { *ppUnk = (IMetaDataAssemblyEmit *)this; fIsInterfaceRW = true; } #endif //FEATURE_METADATA_EMIT #if defined(FEATURE_METADATA_IN_VM) && !defined(FEATURE_CORECLR) else if (riid == IID_IMetaDataValidate) { *ppUnk = (IMetaDataValidate *)this; } #endif //defined(FEATURE_METADATA_IN_VM) && !defined(FEATURE_CORECLR) #ifdef FEATURE_METADATA_EMIT_ALL else if (riid == IID_IMetaDataFilter) { *ppUnk = (IMetaDataFilter *)this; } #endif //FEATURE_METADATA_EMIT_ALL #ifdef FEATURE_METADATA_INTERNAL_APIS else if (riid == IID_IMetaDataHelper) { *ppUnk = (IMetaDataHelper *)this; } else if (riid == IID_IMDInternalEmit) { *ppUnk = static_cast<IMDInternalEmit *>(this); } else if (riid == IID_IGetIMDInternalImport) { *ppUnk = static_cast<IGetIMDInternalImport *>(this); } #endif //FEATURE_METADATA_INTERNAL_APIS #if defined(FEATURE_METADATA_EMIT) && defined(FEATURE_METADATA_INTERNAL_APIS) else if (riid == IID_IMetaDataEmitHelper) { *ppUnk = (IMetaDataEmitHelper *)this; fIsInterfaceRW = true; } #endif //FEATURE_METADATA_EMIT && FEATURE_METADATA_INTERNAL_APIS #ifdef FEATURE_METADATA_IN_VM #ifdef FEATURE_COMINTEROP else if (riid == IID_IMarshal) { // We will only repond to this interface if scope is opened for ReadOnly if (IsOfReadOnly(m_OpenFlags)) { if (m_pFreeThreadedMarshaler == NULL) { // Guard ourselves against first time QI on IMarshal from two different threads.. LOCKWRITE(); if (m_pFreeThreadedMarshaler == NULL) { // First time! Create the FreeThreadedMarshaler IfFailGo(CoCreateFreeThreadedMarshaler((IUnknown *)(IMetaDataEmit2 *)this, &m_pFreeThreadedMarshaler)); } } _ASSERTE(m_pFreeThreadedMarshaler != NULL); IfFailGo(m_pFreeThreadedMarshaler->QueryInterface(riid, ppUnk)); // AddRef has happened in the QueryInterface and thus should just return goto ErrExit; } else { IfFailGo(E_NOINTERFACE); } } #endif // FEATURE_COMINTEROP #ifdef FEATURE_PREJIT else if (riid == IID_IMetaDataCorProfileData) { *ppUnk = (IMetaDataCorProfileData *)this; } else if (riid == IID_IMDInternalMetadataReorderingOptions) { *ppUnk = (IMDInternalMetadataReorderingOptions *)this; } #endif //FEATURE_PREJIT #endif //FEATURE_METADATA_IN_VM else { IfFailGo(E_NOINTERFACE); } if (fIsInterfaceRW && IsOfReadOnly(m_OpenFlags)) { // They are asking for a read/write interface and this scope was // opened as Read-Only *ppUnk = NULL; IfFailGo(CLDB_E_INCOMPATIBLE); } if (fIsInterfaceRW) { LOCKWRITENORET(); if (SUCCEEDED(hr)) { hr = m_pStgdb->m_MiniMd.ConvertToRW(); } if (FAILED(hr)) { *ppUnk = NULL; goto ErrExit; } } AddRef(); ErrExit: END_ENTRYPOINT_NOTHROW; return hr; } // RegMeta::QueryInterface