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 // ===========================================================================
8 // ===========================================================================
11 #include "symbinder.h"
13 /* ------------------------------------------------------------------------- *
15 * ------------------------------------------------------------------------- */
18 SymBinder::QueryInterface(
25 _ASSERTE(IsValidIID(riid));
26 _ASSERTE(IsValidWritePtr(ppvObject, void*));
28 IfFalseGo( ppvObject, E_INVALIDARG );
30 if (riid == IID_ISymUnmanagedBinder)
32 *ppvObject = (ISymUnmanagedBinder*) this;
34 else if (riid == IID_ISymUnmanagedBinder2)
36 *ppvObject = (ISymUnmanagedBinder2*) this;
38 else if (riid == IID_IUnknown)
40 *ppvObject = (IUnknown*)this;
59 SymBinder::NewSymBinder(
65 SymBinder* pSymBinder = NULL;
67 _ASSERTE(IsValidCLSID(clsid));
68 _ASSERTE(IsValidWritePtr(ppObj, IUnknown*));
70 if (clsid != IID_ISymUnmanagedBinder)
71 return (E_UNEXPECTED);
73 IfFalseGo( ppObj, E_INVALIDARG );
77 IfNullGo( pSymBinder = NEW(SymBinder()) );
84 RELEASE( pSymBinder );
89 //-----------------------------------------------------------
91 //-----------------------------------------------------------
93 SymBinder::GetReaderForFile(
94 IUnknown *importer, // IMetaDataImporter
95 const WCHAR *fileName, // File we're looking symbols for
96 const WCHAR *searchPath, // Search path for file
97 ISymUnmanagedReader **ppRetVal) // Out: SymReader for file
100 ISymUnmanagedReader *pSymReader = NULL;
101 IfFalseGo( ppRetVal && fileName && fileName[0] != '\0', E_INVALIDARG );
103 // Init Out parameter
106 // Call the class factory directly.
107 IfFailGo(IldbSymbolsCreateInstance(CLSID_CorSymReader_SxS,
108 IID_ISymUnmanagedReader,
109 (void**)&pSymReader));
111 IfFailGo(pSymReader->Initialize(importer, fileName, searchPath, NULL));
113 // Transfer ownership to the out parameter
114 *ppRetVal = pSymReader;
123 SymBinder::GetReaderFromStream(
126 ISymUnmanagedReader **ppRetVal
130 ISymUnmanagedReader *pSymReader = NULL;
131 IfFalseGo( ppRetVal && importer && pStream, E_INVALIDARG );
133 // Init Out parameter
136 // Call the class factory directly
137 IfFailGo(IldbSymbolsCreateInstance(CLSID_CorSymReader_SxS,
138 IID_ISymUnmanagedReader,
139 (void**)&pSymReader));
141 IfFailGo(pSymReader->Initialize(importer, NULL, NULL, pStream));
143 // Transfer ownership to the out parameter
144 *ppRetVal = pSymReader;
152 HRESULT SymBinder::GetReaderForFile2(
154 const WCHAR *fileName,
155 const WCHAR *searchPath,
156 ULONG32 searchPolicy,
157 ISymUnmanagedReader **pRetVal)
159 // This API exists just to allow VS to function properly.
160 // ILDB doesn't support any search policy or search path - we only look
161 // next to the image file.
162 return GetReaderForFile(importer, fileName, searchPath, pRetVal);