1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // ===========================================================================
5 // File: ildbsymbols.cpp
8 // ===========================================================================
12 #include "classfactory.h"
14 // GUID identifying the ILDB format version.
15 extern "C" const GUID ILDB_VERSION_GUID = {0x9e02e5b6, 0x8aef, 0x4d06, { 0x82, 0xe8, 0xe, 0x9b, 0x45, 0x49, 0x97, 0x16} };
17 // Version used for the "first source release", no longer supported.
18 extern "C" const GUID ILDB_VERSION_GUID_FSR = {0xCB2F6723, 0xAB3A, 0x11d, { 0x9C, 0x40, 0x00, 0xC0, 0x4F, 0xA3, 0x0A, 0x3E} };
20 // This map contains the list of coclasses which are exported from this module.
21 const COCLASS_REGISTER g_CoClasses[] =
23 // pClsid szProgID pfnCreateObject
24 { &CLSID_CorSymReader_SxS, W("CorSymReader"), SymReader::NewSymReader},
25 { &CLSID_CorSymWriter_SxS, W("CorSymWriter"), SymWriter::NewSymWriter},
26 { &CLSID_CorSymBinder_SxS, W("CorSymBinder"), SymBinder::NewSymBinder},
30 STDAPI IldbSymbolsGetClassObject(REFCLSID rclsid, REFIID riid, void** ppvObject)
32 CIldbClassFactory *pClassFactory; // To create class factory object.
33 const COCLASS_REGISTER *pCoClass; // Loop control.
34 HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
36 _ASSERTE(IsValidCLSID(rclsid));
37 _ASSERTE(IsValidIID(riid));
38 _ASSERTE(IsValidWritePtr(ppvObject, void*));
44 // Scan for the right one.
45 for (pCoClass=g_CoClasses; pCoClass->pClsid; pCoClass++)
47 if (*pCoClass->pClsid == rclsid)
49 // Allocate the new factory object.
50 pClassFactory = NEW(CIldbClassFactory(pCoClass));
52 return (E_OUTOFMEMORY);
54 // Pick the v-table based on the caller's request.
55 hr = pClassFactory->QueryInterface(riid, ppvObject);
57 // Always release the local reference, if QI failed it will be
58 // the only one and the object gets freed.
59 pClassFactory->Release();
72 /* ------------------------------------------------------------------------- *
73 * CIldbClassFactory class
74 * ------------------------------------------------------------------------- */
76 //*****************************************************************************
77 // QueryInterface is called to pick a v-table on the co-class.
78 //*****************************************************************************
79 HRESULT STDMETHODCALLTYPE CIldbClassFactory::QueryInterface(
85 if (ppvObject == NULL)
93 // Pick the right v-table based on the IID passed in.
94 if (riid == IID_IUnknown)
95 *ppvObject = (IUnknown *) this;
96 else if (riid == IID_IClassFactory)
97 *ppvObject = (IClassFactory *) this;
99 // If successful, add a reference for out pointer and return.
111 //*****************************************************************************
112 // CreateInstance is called to create a new instance of the coclass for which
113 // this class was created in the first place. The returned pointer is the
114 // v-table matching the IID if there.
115 //*****************************************************************************
116 HRESULT STDMETHODCALLTYPE CIldbClassFactory::CreateInstance(
123 _ASSERTE(IsValidIID(riid));
124 _ASSERTE(IsValidWritePtr(ppvObject, void*));
128 _ASSERTE(m_pCoClass);
130 // Aggregation is not supported by these objects.
132 return (CLASS_E_NOAGGREGATION);
134 // Ask the object to create an instance of itself, and check the iid.
135 hr = (*m_pCoClass->pfnCreateObject)(riid, ppvObject);
139 // Version of CreateInstance called directly from clients
140 STDAPI IldbSymbolsCreateInstance(REFCLSID rclsid, REFIID riid, void** ppvIUnknown)
142 IClassFactory *pClassFactory = NULL;
143 HRESULT hr = IldbSymbolsGetClassObject(rclsid, IID_IClassFactory, (void**)&pClassFactory);
145 hr = pClassFactory->CreateInstance(NULL, riid, ppvIUnknown);
147 pClassFactory->Release();
151 HRESULT STDMETHODCALLTYPE CIldbClassFactory::LockServer(