STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppReturn) { *ppReturn = NULL; //if we don't support this classid, return the proper error code if (!IsEqualCLSID(rclsid, CLSID_WorkraveDeskBand)) return CLASS_E_CLASSNOTAVAILABLE; //create a CClassFactory object and check it for validity CClassFactory *pClassFactory = new CClassFactory(rclsid); if (NULL == pClassFactory) return E_OUTOFMEMORY; //get the QueryInterface return for our return value HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn); //call Release to decement the ref count - creating the object set it to one //and QueryInterface incremented it - since its being used externally (not by //us), we only want the ref count to be 1 pClassFactory->Release(); //return the result from QueryInterface return hResult; }
/***************************************************************************** * DllGetClassObject() ***************************************************************************** *//*! * @brief * Retrieves the class object from a DLL object handler or object application. * DllGetClassObject is called from within the CoGetClassObject function when * the class context is a DLL. * Note: OLE does not provide this function. DLLs that support the OLE * Component Object Model (COM) must implement DllGetClassObject in OLE * object handlers or DLL applications. * * @details * If a call to the CoGetClassObject function finds the class object that is * to be loaded in a DLL, CoGetClassObject uses the DLL's exported * DllGetClassObject function. * * Notes to Callers: * You should not call DllGetClassObject directly. When an object is defined * in a DLL, CoGetClassObject calls the CoLoadLibrary function to load the * DLL, which, in turn, calls DllGetClassObject. * * Notes to Implementers: * You need to implement DllGetClassObject in (and export it from) DLLs that * support the OLE Component Object Model. * * @param * rclsid * CLSID that will associate the correct data and code. * * @param * riid * Reference to the identifier of the interface that the caller is to use to * communicate with the class object. Usually, this is IID_IClassFactory * (defined in the OLE headers as the interface identifier for IClassFactory). * * @param * ppv * Address of pointer variable that receives the interface pointer requested * in riid. Upon successful return, *ppv contains the requested interface * pointer. If an error occurs, the interface pointer is NULL. * * @return * This function supports the standard return values E_INVALIDARG, * E_OUTOFMEMORY and E_UNEXPECTED, as well as the following: * - S_OK * The object was retrieved successfully. * - CLASS_E_CLASSNOTAVAILABLE * The DLL does not support the class (object definition). */ STDAPI DllGetClassObject ( IN REFCLSID rclsid, IN REFIID riid, OUT PVOID * ppv ) { HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; CClassFactory * Factory = new CClassFactory(NULL); if (Factory) { Factory->AddRef(); hr = Factory->Init(rclsid); if (SUCCEEDED(hr)) { hr = Factory->QueryInterface(riid, ppv); } Factory->Release(); } else { hr = E_OUTOFMEMORY; } return hr; }
STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv ) { CClassFactory *pClassFactory; const COCLASS_REGISTER *pCoClass; HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; // scan for the right one for ( pCoClass = g_CoClasses; pCoClass->pClsid != NULL; pCoClass++ ) { if ( *pCoClass->pClsid == rclsid ) { pClassFactory = new CClassFactory( pCoClass ); if ( pClassFactory != NULL ) { hr = pClassFactory->QueryInterface( riid, ppv ); pClassFactory->Release(); break; } else { hr = E_OUTOFMEMORY; break; } } } // for return hr; } // DllGetClassObject
//***************************************************************************** // Called by COM to get a class factory for a given CLSID. If it is one we // support, instantiate a class factory object and prepare for create instance. //***************************************************************************** STDAPI DllGetClassObjectInternal( // Return code. REFCLSID rclsid, // The class to desired. REFIID riid, // Interface wanted on class factory. LPVOID FAR *ppv) // Return interface pointer here. { HRESULT hr; CClassFactory *pClassFactory; // To create class factory object. PFN_CREATE_OBJ pfnCreateObject = NULL; #if defined(FEATURE_DBG_PUBLISH) if (rclsid == CLSID_CorpubPublish) { pfnCreateObject = CorpubPublish::CreateObject; } else #endif #if defined(FEATURE_DBGIPC_TRANSPORT_DI) if (rclsid == CLSID_CorDebug_Telesto) { pfnCreateObject = Cordb::CreateObjectTelesto; } #else // !FEATURE_DBGIPC_TRANSPORT_DI if(rclsid == CLSID_CorDebug_V1) { if (0) // if (IsSingleCLR()) { // Don't allow creating backwards objects until we ensure that the v2.0 Right-side // is backwards compat. This may involve using CordbProcess::SupportsVersion to conditionally // emulate old behavior. // If emulating V1.0, QIs for V2.0 interfaces should fail. _ASSERTE(!"Ensure that V2.0 RS is backwards compat"); pfnCreateObject = Cordb::CreateObjectV1; } } #endif // FEATURE_DBGIPC_TRANSPORT_DI if (pfnCreateObject == NULL) return (CLASS_E_CLASSNOTAVAILABLE); // Allocate the new factory object. The ref count is set to 1 in the constructor. pClassFactory = new (nothrow) CClassFactory(pfnCreateObject); if (!pClassFactory) return (E_OUTOFMEMORY); // Pick the v-table based on the caller's request. hr = pClassFactory->QueryInterface(riid, ppv); // Always release the local reference, if QI failed it will be // the only one and the object gets freed. pClassFactory->Release(); return hr; }
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv) { if (rclsid == CMain::ClsId) { return g_classFactory.QueryInterface(riid, ppv); } *ppv = nullptr; return CLASS_E_CLASSNOTAVAILABLE; }
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv) { HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; if (IsEqualCLSID(CLSID_FW_KENSC, rclsid)) { hr = E_OUTOFMEMORY; CClassFactory *pClassFactory = new CClassFactory(); if (pClassFactory) { hr = pClassFactory->QueryInterface(riid, ppv); pClassFactory->Release(); } } return hr; }
//---------------------------------------------------------------------------- // // Description: // Create an instance of the class factory. // // Parameters: // clsid - CLSID of the object being requested // riid - Interface ID to get. // ppv - Interface pointer returned to caller. // // Return Values: // S_OK - Operation completed successfully. // E_OUTOFMEMORY - Error allocating the object. // Other HRESULTs - Error querying for requested interface. // //---------------------------------------------------------------------------- HRESULT CClassFactory_CreateInstance( __in REFCLSID rclsid, __in REFIID riid, __deref_out void **ppv) { *ppv = NULL; HRESULT hr = E_OUTOFMEMORY; CClassFactory *pcf = new CClassFactory(rclsid); if (pcf != NULL) { hr = pcf->QueryInterface(riid, ppv); pcf->Release(); } return hr; } //*** CClassFactory_CreateInstance
STDAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void** ppv) { CClassFactory *pFactory = NULL; HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; // Default to failure if (CLSID_Hack == clsid) { // Found an entry. Create a new class factory object. pFactory = new CClassFactory(); hr = pFactory->QueryInterface(riid, ppv); if (SUCCEEDED(hr)) { pFactory->Release(); } } return hr; }
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv) { if (ppv == NULL) return E_INVALIDARG; *ppv = NULL; if (!IsEqualIID(rclsid, CLSID_ShortNameColumnProvider)) return CLASS_E_CLASSNOTAVAILABLE; CClassFactory *pFactory = new CClassFactory; if (!pFactory) return E_OUTOFMEMORY; HRESULT hResult = NOERROR; hResult = pFactory->QueryInterface (riid, ppv); return hResult; }
// DllGetClassObject --------------------------------------------------------- // // @func This function is exposed to OLE so that the classfactory can // be obtained. // // @rdesc HRESULT indicating status of routine // @flag S_OK | The object was retrieved successfully. // @flag CLASS_E_CLASSNOTAVAILABLE | DLL does not support class. // @flag E_OUTOFMEMORY | Out of memory. // @flag E_INVALIDARG | One or more arguments are invalid. // @flag E_UNEXPECTED | An unexpected error occurred. // @flag OTHER | Other HRESULTs returned by called functions // HRESULT CALLBACK DllGetClassObject ( REFCLSID rclsid, //@parm IN | CLSID of the object class to be loaded REFIID riid, //@parm IN | Interface on object to be instantiated LPVOID * ppvObj //@parm OUT | Pointer to interface that was instantiated ) { CClassFactory * pClassFactory; HRESULT hr; // Check for valid ppvObj pointer if (!ppvObj) return ResultFromScode( E_INVALIDARG ); // In case we fail, we need to zero output arguments *ppvObj = NULL; // We only service CLSID_SampProv if (rclsid != CLSID_SampProv && rclsid != CLSID_SampProvConnectionPage && rclsid != CLSID_SampProvAdvancedPage && rclsid != CLSID_SampProvBinder) return ResultFromScode( CLASS_E_CLASSNOTAVAILABLE ); // We only support the IUnknown and IClassFactory interfaces if (riid != IID_IUnknown && riid != IID_IClassFactory) return ResultFromScode( E_NOINTERFACE ); // Create our ClassFactory object pClassFactory = new CClassFactory(rclsid); if (pClassFactory == NULL) return ResultFromScode( E_OUTOFMEMORY ); // Get the desired interface on this object hr = pClassFactory->QueryInterface( riid, ppvObj ); if (!SUCCEEDED( hr )) SAFE_DELETE( pClassFactory ); return hr; }
HRESULT CClassFactory_CreateInstance(REFCLSID rclsid, REFIID riid, void** ppv) { HRESULT hr; if (CLSID_VBoxCredProvider == rclsid) { CClassFactory* pClassFactory = new CClassFactory; if (pClassFactory) { hr = pClassFactory->QueryInterface(riid, ppv); pClassFactory->Release(); } else { hr = E_OUTOFMEMORY; } } else { hr = CLASS_E_CLASSNOTAVAILABLE; } return hr; }
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppReturn) { *ppReturn = NULL; if(IsEqualCLSID(rclsid, CLSID_ShellFolderProperties)) { _RPTF0(_CRT_WARN, "CLSID_ShellFolderProperties\n"); return CLASS_E_CLASSNOTAVAILABLE; } if(!IsEqualCLSID(rclsid, CLSID_ShellFolderNameSpace)) return CLASS_E_CLASSNOTAVAILABLE; CClassFactory *pClassFactory = new CClassFactory(); if(NULL == pClassFactory) return E_OUTOFMEMORY; HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn); pClassFactory->Release(); return hResult; }