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// MDInternalRO.h
6//
7
8//
9// Contains utility code for MD directory
10//
11//*****************************************************************************
12#ifndef __MDInternalRO__h__
13#define __MDInternalRO__h__
14
15#include "winmdinterfaces.h"
16
17#ifdef FEATURE_METADATA_INTERNAL_APIS
18
19class MDInternalRO : public IMDInternalImport, IMDCommon
20{
21public:
22
23 MDInternalRO();
24 virtual ~MDInternalRO();
25 __checkReturn
26 HRESULT Init(LPVOID pData, ULONG cbData);
27
28 // *** IUnknown methods ***
29 __checkReturn
30 STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
31 STDMETHODIMP_(ULONG) AddRef(void);
32 STDMETHODIMP_(ULONG) Release(void);
33
34 __checkReturn
35 STDMETHODIMP TranslateSigWithScope(
36 IMDInternalImport *pAssemImport, // [IN] import assembly scope.
37 const void *pbHashValue, // [IN] hash value for the import assembly.
38 ULONG cbHashValue, // [IN] count of bytes in the hash value.
39 PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope
40 ULONG cbSigBlob, // [IN] count of bytes of signature
41 IMetaDataAssemblyEmit *pAssemEmit, // [IN] assembly emit scope.
42 IMetaDataEmit *emit, // [IN] emit interface
43 CQuickBytes *pqkSigEmit, // [OUT] buffer to hold translated signature
44 ULONG *pcbSig) // [OUT] count of bytes in the translated signature
45 DAC_UNEXPECTED();
46
47
48 __checkReturn
49 STDMETHODIMP GetTypeDefRefTokenInTypeSpec(// return S_FALSE if enclosing type does not have a token
50 mdTypeSpec tkTypeSpec, // [IN] TypeSpec token to look at
51 mdToken *tkEnclosedToken); // [OUT] The enclosed type token
52
53
54
55 STDMETHODIMP_(IMetaModelCommon*) GetMetaModelCommon()
56 {
57 return static_cast<IMetaModelCommon*>(&m_LiteWeightStgdb.m_MiniMd);
58 }
59
60 STDMETHODIMP_(IMetaModelCommonRO*) GetMetaModelCommonRO()
61 {
62 if (m_LiteWeightStgdb.m_MiniMd.IsWritable())
63 {
64 _ASSERTE(!"IMetaModelCommonRO methods cannot be used because this importer is writable.");
65 return NULL;
66 }
67 return static_cast<IMetaModelCommonRO*>(&m_LiteWeightStgdb.m_MiniMd);
68 }
69
70 __checkReturn
71 STDMETHODIMP SetOptimizeAccessForSpeed(
72 BOOL fOptSpeed)
73 {
74#ifdef FEATURE_PREJIT
75 // The metadata cache of hot items is an optional working-set optimization
76 // that has a large speed cost relative to direct table lookup
77 if (fOptSpeed)
78 { // We want to disable usage of hot data (e.g. in ngen compilation process)
79 m_LiteWeightStgdb.m_MiniMd.DisableHotDataUsage();
80 }
81#endif
82 return S_OK;
83 }
84
85 //*****************************************************************************
86 // return the count of entries of a given kind in a scope
87 // For example, pass in mdtMethodDef will tell you how many MethodDef
88 // contained in a scope
89 //*****************************************************************************
90 STDMETHODIMP_(ULONG) GetCountWithTokenKind(// return hresult
91 DWORD tkKind) // [IN] pass in the kind of token.
92 DAC_UNEXPECTED();
93
94 //*****************************************************************************
95 // enumerator for typedef
96 //*****************************************************************************
97 __checkReturn
98 STDMETHODIMP EnumTypeDefInit( // return hresult
99 HENUMInternal *phEnum); // [OUT] buffer to fill for enumerator data
100
101 STDMETHODIMP_(ULONG) EnumTypeDefGetCount(
102 HENUMInternal *phEnum); // [IN] the enumerator to retrieve information
103
104 STDMETHODIMP_(void) EnumTypeDefReset(
105 HENUMInternal *phEnum); // [IN] the enumerator to retrieve information
106
107 STDMETHODIMP_(bool) EnumTypeDefNext( // return hresult
108 HENUMInternal *phEnum, // [IN] input enum
109 mdTypeDef *ptd); // [OUT] return token
110
111 STDMETHODIMP_(void) EnumTypeDefClose(
112 HENUMInternal *phEnum); // [IN] the enumerator to retrieve information
113
114 //*****************************************************************************
115 // enumerator for MethodImpl
116 //*****************************************************************************
117 __checkReturn
118 STDMETHODIMP EnumMethodImplInit( // return hresult
119 mdTypeDef td, // [IN] TypeDef over which to scope the enumeration.
120 HENUMInternal *phEnumBody, // [OUT] buffer to fill for enumerator data for MethodBody tokens.
121 HENUMInternal *phEnumDecl); // [OUT] buffer to fill for enumerator data for MethodDecl tokens.
122
123 STDMETHODIMP_(ULONG) EnumMethodImplGetCount(
124 HENUMInternal *phEnumBody, // [IN] MethodBody enumerator.
125 HENUMInternal *phEnumDecl); // [IN] MethodDecl enumerator.
126
127 STDMETHODIMP_(void) EnumMethodImplReset(
128 HENUMInternal *phEnumBody, // [IN] MethodBody enumerator.
129 HENUMInternal *phEnumDecl); // [IN] MethodDecl enumerator.
130
131 __checkReturn
132 STDMETHODIMP EnumMethodImplNext( // return hresult
133 HENUMInternal *phEnumBody, // [IN] input enum for MethodBody
134 HENUMInternal *phEnumDecl, // [IN] input enum for MethodDecl
135 mdToken *ptkBody, // [OUT] return token for MethodBody
136 mdToken *ptkDecl); // [OUT] return token for MethodDecl
137
138 STDMETHODIMP_(void) EnumMethodImplClose(
139 HENUMInternal *phEnumBody, // [IN] MethodBody enumerator.
140 HENUMInternal *phEnumDecl); // [IN] MethodDecl enumerator.
141
142 //*****************************************
143 // Enumerator helpers for memberdef, memberref, interfaceimp,
144 // event, property, param, methodimpl
145 //*****************************************
146
147 __checkReturn
148 STDMETHODIMP EnumGlobalFunctionsInit( // return hresult
149 HENUMInternal *phEnum); // [OUT] buffer to fill for enumerator data
150
151 __checkReturn
152 STDMETHODIMP EnumGlobalFieldsInit( // return hresult
153 HENUMInternal *phEnum); // [OUT] buffer to fill for enumerator data
154
155 __checkReturn
156 STDMETHODIMP EnumInit( // return S_FALSE if record not found
157 DWORD tkKind, // [IN] which table to work on
158 mdToken tkParent, // [IN] token to scope the search
159 HENUMInternal *phEnum); // [OUT] the enumerator to fill
160
161 __checkReturn
162 STDMETHODIMP EnumAllInit( // return S_FALSE if record not found
163 DWORD tkKind, // [IN] which table to work on
164 HENUMInternal *phEnum); // [OUT] the enumerator to fill
165
166 STDMETHODIMP_(bool) EnumNext(
167 HENUMInternal *phEnum, // [IN] the enumerator to retrieve information
168 mdToken *ptk); // [OUT] token to scope the search
169
170 STDMETHODIMP_(ULONG) EnumGetCount(
171 HENUMInternal *phEnum); // [IN] the enumerator to retrieve information
172
173 STDMETHODIMP_(void) EnumReset(
174 HENUMInternal *phEnum); // [IN] the enumerator to be reset
175
176 STDMETHODIMP_(void) EnumClose(
177 HENUMInternal *phEnum); // [IN] the enumerator to be closed
178
179 __checkReturn
180 STDMETHODIMP EnumPermissionSetsInit( // return S_FALSE if record not found
181 mdToken tkParent, // [IN] token to scope the search
182 CorDeclSecurity Action, // [IN] Action to scope the search
183 HENUMInternal *phEnum); // [OUT] the enumerator to fill
184
185 __checkReturn
186 STDMETHODIMP EnumCustomAttributeByNameInit(// return S_FALSE if record not found
187 mdToken tkParent, // [IN] token to scope the search
188 LPCSTR szName, // [IN] CustomAttribute's name to scope the search
189 HENUMInternal *phEnum); // [OUT] the enumerator to fill
190
191 __checkReturn
192 STDMETHODIMP GetParentToken(
193 mdToken tkChild, // [IN] given child token
194 mdToken *ptkParent); // [OUT] returning parent
195
196 __checkReturn
197 STDMETHODIMP GetCustomAttributeProps(
198 mdCustomAttribute at, // [IN] The attribute.
199 mdToken *ptkType); // [OUT] Put attribute type here.
200
201 __checkReturn
202 STDMETHODIMP GetCustomAttributeAsBlob(
203 mdCustomAttribute cv, // [IN] given custom attribute token
204 void const **ppBlob, // [OUT] return the pointer to internal blob
205 ULONG *pcbSize); // [OUT] return the size of the blob
206
207 __checkReturn
208 STDMETHODIMP GetCustomAttributeByName( // S_OK or error.
209 mdToken tkObj, // [IN] Object with Custom Attribute.
210 LPCUTF8 szName, // [IN] Name of desired Custom Attribute.
211 const void **ppData, // [OUT] Put pointer to data here.
212 ULONG *pcbData); // [OUT] Put size of data here.
213
214 __checkReturn
215 STDMETHODIMP GetNameOfCustomAttribute( // S_OK or error.
216 mdCustomAttribute mdAttribute, // [IN] The Custom Attribute
217 LPCUTF8 *pszNamespace, // [OUT] Namespace of Custom Attribute.
218 LPCUTF8 *pszName); // [OUT] Name of Custom Attribute.
219
220 __checkReturn
221 STDMETHODIMP SafeAndSlowEnumCustomAttributeByNameInit(// return S_FALSE if record not found
222 mdToken tkParent, // [IN] token to scope the search
223 LPCSTR szName, // [IN] CustomAttribute's name to scope the search
224 HENUMInternal *phEnum); // [OUT] The enumerator
225
226 __checkReturn
227 STDMETHODIMP SafeAndSlowEnumCustomAttributeByNameNext(// return S_FALSE if record not found
228 mdToken tkParent, // [IN] token to scope the search
229 LPCSTR szName, // [IN] CustomAttribute's name to scope the search
230 HENUMInternal *phEnum, // [IN] The enumerator
231 mdCustomAttribute *mdAttribute); // [OUT] The custom attribute that was found
232
233 __checkReturn
234 STDMETHODIMP GetScopeProps(
235 LPCSTR *pszName, // [OUT] scope name
236 GUID *pmvid); // [OUT] version id
237
238 // finding a particular method
239 __checkReturn
240 STDMETHODIMP FindMethodDef(
241 mdTypeDef classdef, // [IN] given typedef
242 LPCSTR szName, // [IN] member name
243 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of COM+ signature
244 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
245 mdMethodDef *pmd); // [OUT] matching memberdef
246
247 // return a iSeq's param given a MethodDef
248 __checkReturn
249 STDMETHODIMP FindParamOfMethod( // S_OK or error.
250 mdMethodDef md, // [IN] The owning method of the param.
251 ULONG iSeq, // [IN] The sequence # of the param.
252 mdParamDef *pparamdef); // [OUT] Put ParamDef token here.
253
254 //*****************************************
255 //
256 // GetName* functions
257 //
258 //*****************************************
259
260 // return the name and namespace of typedef
261 __checkReturn
262 STDMETHODIMP GetNameOfTypeDef(
263 mdTypeDef classdef, // given classdef
264 LPCSTR *pszname, // return class name(unqualified)
265 LPCSTR *psznamespace); // return the name space name
266
267 __checkReturn
268 STDMETHODIMP GetIsDualOfTypeDef(
269 mdTypeDef classdef, // [IN] given classdef.
270 ULONG *pDual); // [OUT] return dual flag here.
271
272 __checkReturn
273 STDMETHODIMP GetIfaceTypeOfTypeDef(
274 mdTypeDef classdef, // [IN] given classdef.
275 ULONG *pIface); // [OUT] 0=dual, 1=vtable, 2=dispinterface
276
277 // get the name of either methoddef
278 __checkReturn
279 STDMETHODIMP GetNameOfMethodDef( // return the name of the memberdef in UTF8
280 mdMethodDef md, // given memberdef
281 LPCSTR *pszName);
282
283 __checkReturn
284 STDMETHODIMP GetNameAndSigOfMethodDef(
285 mdMethodDef methoddef, // [IN] given memberdef
286 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to a blob value of COM+ signature
287 ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob
288 LPCSTR *pszName);
289
290 // return the name of a FieldDef
291 __checkReturn
292 STDMETHODIMP GetNameOfFieldDef(
293 mdFieldDef fd, // given memberdef
294 LPCSTR *pszName);
295
296 // return the name of typeref
297 __checkReturn
298 STDMETHODIMP GetNameOfTypeRef(
299 mdTypeRef classref, // [IN] given typeref
300 LPCSTR *psznamespace, // [OUT] return typeref name
301 LPCSTR *pszname); // [OUT] return typeref namespace
302
303 // return the resolutionscope of typeref
304 __checkReturn
305 STDMETHODIMP GetResolutionScopeOfTypeRef(
306 mdTypeRef classref, // given classref
307 mdToken *ptkResolutionScope);
308
309 // return the typeref token given the name.
310 __checkReturn
311 STDMETHODIMP FindTypeRefByName(
312 LPCSTR szNamespace, // [IN] Namespace for the TypeRef.
313 LPCSTR szName, // [IN] Name of the TypeRef.
314 mdToken tkResolutionScope, // [IN] Resolution Scope fo the TypeRef.
315 mdTypeRef *ptk); // [OUT] TypeRef token returned.
316
317 // return the TypeDef properties
318 __checkReturn
319 STDMETHODIMP GetTypeDefProps( // return hresult
320 mdTypeDef classdef, // given classdef
321 DWORD *pdwAttr, // return flags on class, tdPublic, tdAbstract
322 mdToken *ptkExtends); // [OUT] Put base class TypeDef/TypeRef here.
323
324 // return the item's guid
325 __checkReturn
326 STDMETHODIMP GetItemGuid( // return hresult
327 mdToken tkObj, // [IN] given item.
328 CLSID *pGuid); // [OUT] Put guid here.
329
330 // get enclosing class of NestedClass.
331 __checkReturn
332 STDMETHODIMP GetNestedClassProps( // S_OK or error
333 mdTypeDef tkNestedClass, // [IN] NestedClass token.
334 mdTypeDef *ptkEnclosingClass); // [OUT] EnclosingClass token.
335
336 // Get count of Nested classes given the enclosing class.
337 __checkReturn
338 STDMETHODIMP GetCountNestedClasses( // return count of Nested classes.
339 mdTypeDef tkEnclosingClass, // [IN]Enclosing class.
340 ULONG *pcNestedClassesCount);
341
342 // Return array of Nested classes given the enclosing class.
343 __checkReturn
344 STDMETHODIMP GetNestedClasses( // Return actual count.
345 mdTypeDef tkEnclosingClass, // [IN] Enclosing class.
346 mdTypeDef *rNestedClasses, // [OUT] Array of nested class tokens.
347 ULONG ulNestedClasses, // [IN] Size of array.
348 ULONG *pcNestedClasses);
349
350 // return the ModuleRef properties
351 __checkReturn
352 STDMETHODIMP GetModuleRefProps(
353 mdModuleRef mur, // [IN] moduleref token
354 LPCSTR *pszName); // [OUT] buffer to fill with the moduleref name
355
356 //*****************************************
357 //
358 // GetSig* functions
359 //
360 //*****************************************
361 __checkReturn
362 STDMETHODIMP GetSigOfMethodDef(
363 mdMethodDef methoddef, // [IN] given memberdef
364 ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob
365 PCCOR_SIGNATURE *ppSig);
366
367 __checkReturn
368 STDMETHODIMP GetSigOfFieldDef(
369 mdMethodDef methoddef, // [IN] given memberdef
370 ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob
371 PCCOR_SIGNATURE *ppSig);
372
373 __checkReturn
374 STDMETHODIMP GetSigFromToken(
375 mdToken tk, // FieldDef, MethodDef, Signature or TypeSpec token
376 ULONG * pcbSig,
377 PCCOR_SIGNATURE * ppSig);
378
379
380
381 //*****************************************
382 // get method property
383 //*****************************************
384 __checkReturn
385 STDMETHODIMP GetMethodDefProps(
386 mdMethodDef md, // The method for which to get props.
387 DWORD *pdwFlags);
388
389 __checkReturn
390 STDMETHODIMP_(ULONG) GetMethodDefSlot(
391 mdMethodDef mb); // The method for which to get props.
392
393 //*****************************************
394 // return method implementation informaiton, like RVA and implflags
395 //*****************************************
396 __checkReturn
397 STDMETHODIMP GetMethodImplProps(
398 mdMethodDef tk, // [IN] MethodDef
399 ULONG *pulCodeRVA, // [OUT] CodeRVA
400 DWORD *pdwImplFlags); // [OUT] Impl. Flags
401
402 //*****************************************************************************
403 // return the field RVA
404 //*****************************************************************************
405 __checkReturn
406 STDMETHODIMP GetFieldRVA(
407 mdToken fd, // [IN] FieldDef
408 ULONG *pulCodeRVA); // [OUT] CodeRVA
409
410 //*****************************************************************************
411 // return the field offset for a given field
412 //*****************************************************************************
413 __checkReturn
414 STDMETHODIMP GetFieldOffset(
415 mdFieldDef fd, // [IN] fielddef
416 ULONG *pulOffset); // [OUT] FieldOffset
417
418 //*****************************************
419 // get field property
420 //*****************************************
421 __checkReturn
422 STDMETHODIMP GetFieldDefProps(
423 mdFieldDef fd, // [IN] given fielddef
424 DWORD *pdwFlags); // [OUT] return fdPublic, fdPrive, etc flags
425
426 //*****************************************************************************
427 // return default value of a token (could be paramdef, fielddef, or property)
428 //*****************************************************************************
429 __checkReturn
430 STDMETHODIMP GetDefaultValue(
431 mdToken tk, // [IN] given FieldDef, ParamDef, or Property
432 MDDefaultValue *pDefaultValue); // [OUT] default value to fill
433
434
435 //*****************************************
436 // get dispid of a MethodDef or a FieldDef
437 //*****************************************
438 __checkReturn
439 STDMETHODIMP GetDispIdOfMemberDef( // return hresult
440 mdToken tk, // [IN] given methoddef or fielddef
441 ULONG *pDispid); // [OUT] Put the dispid here.
442
443 //*****************************************
444 // return TypeRef/TypeDef given an InterfaceImpl token
445 //*****************************************
446 __checkReturn
447 STDMETHODIMP GetTypeOfInterfaceImpl( // return the TypeRef/typedef token for the interfaceimpl
448 mdInterfaceImpl iiImpl, // given a interfaceimpl
449 mdToken *ptkType);
450
451 //*****************************************
452 // return information about a generic method instantiation
453 //*****************************************
454 __checkReturn
455 STDMETHODIMP GetMethodSpecProps(
456 mdMethodSpec mi, // [IN] The method instantiation
457 mdToken *tkParent, // [OUT] MethodDef or MemberRef
458 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data
459 ULONG *pcbSigBlob); // [OUT] actual size of signature blob
460
461 //*****************************************
462 // look up function for TypeDef
463 //*****************************************
464 __checkReturn
465 STDMETHODIMP FindTypeDef(
466 LPCSTR szNamespace, // [IN] Namespace for the TypeDef.
467 LPCSTR szName, // [IN] Name of the TypeDef.
468 mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef of enclosing class.
469 mdTypeDef *ptypedef); // [OUT] return typedef
470
471 __checkReturn
472 STDMETHODIMP FindTypeDefByGUID(
473 REFGUID guid, // guid to look up
474 mdTypeDef *ptypedef); // return typedef
475
476
477
478 //*****************************************
479 // return name and sig of a memberref
480 //*****************************************
481 __checkReturn
482 STDMETHODIMP GetNameAndSigOfMemberRef( // return name here
483 mdMemberRef memberref, // given memberref
484 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to a blob value of COM+ signature
485 ULONG *pcbSigBlob, // [OUT] count of bytes in the signature blob
486 LPCSTR *pszName);
487
488 //*****************************************************************************
489 // Given memberref, return the parent. It can be TypeRef, ModuleRef, MethodDef
490 //*****************************************************************************
491 __checkReturn
492 STDMETHODIMP GetParentOfMemberRef(
493 mdMemberRef memberref, // given memberref
494 mdToken *ptkParent); // return the parent token
495
496 __checkReturn
497 STDMETHODIMP GetParamDefProps(
498 mdParamDef paramdef, // given a paramdef
499 USHORT *pusSequence, // [OUT] slot number for this parameter
500 DWORD *pdwAttr, // [OUT] flags
501 LPCSTR *pszName); // [OUT] return the name of the parameter
502
503 //******************************************
504 // property info for method.
505 //******************************************
506 __checkReturn
507 STDMETHODIMP GetPropertyInfoForMethodDef( // Result.
508 mdMethodDef md, // [IN] memberdef
509 mdProperty *ppd, // [OUT] put property token here
510 LPCSTR *pName, // [OUT] put pointer to name here
511 ULONG *pSemantic) // [OUT] put semantic here
512 DAC_UNEXPECTED();
513
514 //*****************************************
515 // class layout/sequence information
516 //*****************************************
517 __checkReturn
518 STDMETHODIMP GetClassPackSize( // [OUT] return error if a class doesn't have packsize info
519 mdTypeDef td, // [IN] give typedef
520 ULONG *pdwPackSize); // [OUT] return the pack size of the class. 1, 2, 4, 8 or 16
521
522 __checkReturn
523 STDMETHODIMP GetClassTotalSize( // [OUT] return error if a class doesn't have total size info
524 mdTypeDef td, // [IN] give typedef
525 ULONG *pdwClassSize); // [OUT] return the total size of the class
526
527 __checkReturn
528 STDMETHODIMP GetClassLayoutInit(
529 mdTypeDef td, // [IN] give typedef
530 MD_CLASS_LAYOUT *pLayout); // [OUT] set up the status of query here
531
532 __checkReturn
533 STDMETHODIMP GetClassLayoutNext(
534 MD_CLASS_LAYOUT *pLayout, // [IN|OUT] set up the status of query here
535 mdFieldDef *pfd, // [OUT] return the fielddef
536 ULONG *pulOffset); // [OUT] return the offset/ulSequence associate with it
537
538 //*****************************************
539 // marshal information of a field
540 //*****************************************
541 __checkReturn
542 STDMETHODIMP GetFieldMarshal( // return error if no native type associate with the token
543 mdFieldDef fd, // [IN] given fielddef
544 PCCOR_SIGNATURE *pSigNativeType, // [OUT] the native type signature
545 ULONG *pcbNativeType); // [OUT] the count of bytes of *ppvNativeType
546
547
548 //*****************************************
549 // property APIs
550 //*****************************************
551 // find a property by name
552 __checkReturn
553 STDMETHODIMP FindProperty(
554 mdTypeDef td, // [IN] given a typdef
555 LPCSTR szPropName, // [IN] property name
556 mdProperty *pProp); // [OUT] return property token
557
558 __checkReturn
559 STDMETHODIMP GetPropertyProps(
560 mdProperty prop, // [IN] property token
561 LPCSTR *szProperty, // [OUT] property name
562 DWORD *pdwPropFlags, // [OUT] property flags.
563 PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob
564 ULONG *pcbSig); // [OUT] count of bytes in *ppvSig
565
566 //**********************************
567 // Event APIs
568 //**********************************
569 __checkReturn
570 STDMETHODIMP FindEvent(
571 mdTypeDef td, // [IN] given a typdef
572 LPCSTR szEventName, // [IN] event name
573 mdEvent *pEvent); // [OUT] return event token
574
575 __checkReturn
576 STDMETHODIMP GetEventProps( // S_OK, S_FALSE, or error.
577 mdEvent ev, // [IN] event token
578 LPCSTR *pszEvent, // [OUT] Event name
579 DWORD *pdwEventFlags, // [OUT] Event flags.
580 mdToken *ptkEventType); // [OUT] EventType class
581
582 //**********************************
583 // Generics APIs
584 //**********************************
585 __checkReturn
586 STDMETHODIMP GetGenericParamProps( // S_OK or error.
587 mdGenericParam rd, // [IN] The type parameter
588 ULONG* pulSequence, // [OUT] Parameter sequence number
589 DWORD* pdwAttr, // [OUT] Type parameter flags (for future use)
590 mdToken *ptOwner, // [OUT] The owner (TypeDef or MethodDef)
591 DWORD *reserved, // [OUT] The kind (TypeDef/Ref/Spec, for future use)
592 LPCSTR *szName); // [OUT] The name
593
594 __checkReturn
595 STDMETHODIMP GetGenericParamConstraintProps( // S_OK or error.
596 mdGenericParamConstraint rd, // [IN] The constraint token
597 mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained
598 mdToken *ptkConstraintType); // [OUT] TypeDef/Ref/Spec constraint
599
600
601 //**********************************
602 // find a particular associate of a property or an event
603 //**********************************
604 __checkReturn
605 STDMETHODIMP FindAssociate(
606 mdToken evprop, // [IN] given a property or event token
607 DWORD associate, // [IN] given a associate semantics(setter, getter, testdefault, reset, AddOn, RemoveOn, Fire)
608 mdMethodDef *pmd); // [OUT] return method def token
609
610 __checkReturn
611 STDMETHODIMP EnumAssociateInit(
612 mdToken evprop, // [IN] given a property or an event token
613 HENUMInternal *phEnum); // [OUT] cursor to hold the query result
614
615 __checkReturn
616 STDMETHODIMP GetAllAssociates(
617 HENUMInternal *phEnum, // [IN] query result form GetPropertyAssociateCounts
618 ASSOCIATE_RECORD *pAssociateRec, // [OUT] struct to fill for output
619 ULONG cAssociateRec); // [IN] size of the buffer
620
621
622 //**********************************
623 // Get info about a PermissionSet.
624 //**********************************
625 __checkReturn
626 STDMETHODIMP GetPermissionSetProps(
627 mdPermission pm, // [IN] the permission token.
628 DWORD *pdwAction, // [OUT] CorDeclSecurity.
629 void const **ppvPermission, // [OUT] permission blob.
630 ULONG *pcbPermission); // [OUT] count of bytes of pvPermission.
631
632 //****************************************
633 // Get the String given the String token.
634 // Returns a pointer to the string, or NULL in case of error.
635 //****************************************
636 __checkReturn
637 STDMETHODIMP GetUserString(
638 mdString stk, // [IN] the string token.
639 ULONG *pchString, // [OUT] count of characters in the string.
640 BOOL *pbIs80Plus, // [OUT] specifies where there are extended characters >= 0x80.
641 LPCWSTR *pwszUserString);
642
643 //*****************************************************************************
644 // p-invoke APIs.
645 //*****************************************************************************
646 __checkReturn
647 STDMETHODIMP GetPinvokeMap(
648 mdMethodDef tk, // [IN] FieldDef or MethodDef.
649 DWORD *pdwMappingFlags, // [OUT] Flags used for mapping.
650 LPCSTR *pszImportName, // [OUT] Import name.
651 mdModuleRef *pmrImportDLL); // [OUT] ModuleRef token for the target DLL.
652
653 //*****************************************************************************
654 // Assembly MetaData APIs.
655 //*****************************************************************************
656 __checkReturn
657 STDMETHODIMP GetAssemblyProps(
658 mdAssembly mda, // [IN] The Assembly for which to get the properties.
659 const void **ppbPublicKey, // [OUT] Pointer to the public key.
660 ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key.
661 ULONG *pulHashAlgId, // [OUT] Hash Algorithm.
662 LPCSTR *pszName, // [OUT] Buffer to fill with name.
663 AssemblyMetaDataInternal *pMetaData,// [OUT] Assembly MetaData.
664 DWORD *pdwAssemblyFlags); // [OUT] Flags.
665
666 __checkReturn
667 STDMETHODIMP GetAssemblyRefProps(
668 mdAssemblyRef mdar, // [IN] The AssemblyRef for which to get the properties.
669 const void **ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token.
670 ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or token.
671 LPCSTR *pszName, // [OUT] Buffer to fill with name.
672 AssemblyMetaDataInternal *pMetaData,// [OUT] Assembly MetaData.
673 const void **ppbHashValue, // [OUT] Hash blob.
674 ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob.
675 DWORD *pdwAssemblyRefFlags); // [OUT] Flags.
676
677 __checkReturn
678 STDMETHODIMP GetFileProps(
679 mdFile mdf, // [IN] The File for which to get the properties.
680 LPCSTR *pszName, // [OUT] Buffer to fill with name.
681 const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob.
682 ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob.
683 DWORD *pdwFileFlags); // [OUT] Flags.
684
685 __checkReturn
686 STDMETHODIMP GetExportedTypeProps(
687 mdExportedType mdct, // [IN] The ExportedType for which to get the properties.
688 LPCSTR *pszNamespace, // [OUT] Buffer to fill with namespace.
689 LPCSTR *pszName, // [OUT] Buffer to fill with name.
690 mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ExportedType.
691 mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file.
692 DWORD *pdwExportedTypeFlags); // [OUT] Flags.
693
694 __checkReturn
695 STDMETHODIMP GetManifestResourceProps(
696 mdManifestResource mdmr, // [IN] The ManifestResource for which to get the properties.
697 LPCSTR *pszName, // [OUT] Buffer to fill with name.
698 mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ExportedType.
699 DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within the file.
700 DWORD *pdwResourceFlags); // [OUT] Flags.
701
702 __checkReturn
703 STDMETHODIMP FindExportedTypeByName( // S_OK or error
704 LPCSTR szNamespace, // [IN] Namespace of the ExportedType.
705 LPCSTR szName, // [IN] Name of the ExportedType.
706 mdExportedType tkEnclosingType, // [IN] Enclosing ExportedType.
707 mdExportedType *pmct); // [OUT] Put ExportedType token here.
708
709 __checkReturn
710 STDMETHODIMP FindManifestResourceByName(// S_OK or error
711 LPCSTR szName, // [IN] Name of the resource.
712 mdManifestResource *pmmr); // [OUT] Put ManifestResource token here.
713
714 __checkReturn
715 STDMETHODIMP GetAssemblyFromScope( // S_OK or error
716 mdAssembly *ptkAssembly); // [OUT] Put token here.
717
718 //***************************************************************************
719 // return properties regarding a TypeSpec
720 //***************************************************************************
721 __checkReturn
722 STDMETHODIMP GetTypeSpecFromToken( // S_OK or error.
723 mdTypeSpec typespec, // [IN] Signature token.
724 PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token.
725 ULONG *pcbSig); // [OUT] return size of signature.
726
727 //*****************************************************************************
728 // This function gets the "built for" version of a metadata scope.
729 // NOTE: if the scope has never been saved, it will not have a built-for
730 // version, and an empty string will be returned.
731 //*****************************************************************************
732 __checkReturn
733 STDMETHODIMP GetVersionString( // S_OK or error.
734 LPCSTR *pVer); // [OUT] Put version string here.
735
736
737 //*****************************************************************************
738 // helpers to convert a text signature to a com format
739 //*****************************************************************************
740 __checkReturn
741 STDMETHODIMP ConvertTextSigToComSig( // Return hresult.
742 BOOL fCreateTrIfNotFound, // [IN] create typeref if not found
743 LPCSTR pSignature, // [IN] class file format signature
744 CQuickBytes *pqbNewSig, // [OUT] place holder for COM+ signature
745 ULONG *pcbCount); // [OUT] the result size of signature
746
747 __checkReturn
748 STDMETHODIMP SetUserContextData( // S_OK or E_NOTIMPL
749 IUnknown *pIUnk) // The user context.
750 { return E_NOTIMPL; }
751
752 STDMETHODIMP_(BOOL) IsValidToken( // True or False.
753 mdToken tk); // [IN] Given token.
754
755 STDMETHODIMP_(IUnknown *) GetCachedPublicInterface(BOOL fWithLock) { return NULL;} // return the cached public interface
756 __checkReturn
757 STDMETHODIMP SetCachedPublicInterface(IUnknown *pUnk) { return E_FAIL;} ;// return hresult
758 STDMETHODIMP_(UTSemReadWrite*) GetReaderWriterLock() {return NULL;} // return the reader writer lock
759 __checkReturn
760 STDMETHODIMP SetReaderWriterLock(UTSemReadWrite *pSem) { return NOERROR; }
761 STDMETHODIMP_(mdModule) GetModuleFromScope(void);
762
763 // Find a paticular method and pass in the signature comparison routine. Very
764 // helpful when the passed in signature does not come from the same scope.
765 __checkReturn
766 STDMETHODIMP FindMethodDefUsingCompare(
767 mdTypeDef classdef, // [IN] given typedef
768 LPCSTR szName, // [IN] member name
769 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of COM+ signature
770 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
771 PSIGCOMPARE pSignatureCompare, // [IN] Routine to compare signatures
772 void* pSignatureArgs, // [IN] Additional info to supply the compare function
773 mdMethodDef *pmd); // [OUT] matching memberdef
774
775
776 //*****************************************************************************
777 // return the table pointer and size for a given table index
778 //*****************************************************************************
779 __checkReturn
780 STDMETHODIMP GetTableInfoWithIndex(
781 ULONG index, // [IN] pass in the index
782 void **pTable, // [OUT] pointer to table at index
783 void **pTableSize); // [OUT] size of table at index
784
785 __checkReturn
786 STDMETHODIMP ApplyEditAndContinue(
787 void *pData, // [IN] the delta metadata
788 ULONG cbData, // [IN] length of pData
789 IMDInternalImport **ppv); // [OUT] the resulting metadata interface
790
791 STDMETHODIMP GetRvaOffsetData(
792 DWORD *pFirstMethodRvaOffset, // [OUT] Offset (from start of metadata) to the first RVA field in MethodDef table.
793 DWORD *pMethodDefRecordSize, // [OUT] Size of each record in MethodDef table.
794 DWORD *pMethodDefCount, // [OUT] Number of records in MethodDef table.
795 DWORD *pFirstFieldRvaOffset, // [OUT] Offset (from start of metadata) to the first RVA field in FieldRVA table.
796 DWORD *pFieldRvaRecordSize, // [OUT] Size of each record in FieldRVA table.
797 DWORD *pFieldRvaCount // [OUT] Number of records in FieldRVA table.
798 );
799
800 CLiteWeightStgdb<CMiniMd> m_LiteWeightStgdb;
801
802private:
803
804 struct CMethodSemanticsMap
805 {
806 mdToken m_mdMethod; // Method token.
807 RID m_ridSemantics; // RID of semantics record.
808 };
809 CMethodSemanticsMap *m_pMethodSemanticsMap; // Possible array of method semantics pointers, ordered by method token.
810
811#ifndef DACCESS_COMPILE
812 class CMethodSemanticsMapSorter : public CQuickSort<CMethodSemanticsMap>
813 {
814 public:
815 CMethodSemanticsMapSorter(CMethodSemanticsMap *pBase, int iCount) : CQuickSort<CMethodSemanticsMap>(pBase, iCount) {}
816 virtual int Compare(CMethodSemanticsMap *psFirst, CMethodSemanticsMap *psSecond);
817 };
818#endif //!DACCESS_COMPILE
819
820 class CMethodSemanticsMapSearcher : public CBinarySearch<CMethodSemanticsMap>
821 {
822 public:
823 CMethodSemanticsMapSearcher(const CMethodSemanticsMap *pBase, int iCount) : CBinarySearch<CMethodSemanticsMap>(pBase, iCount) {}
824 virtual int Compare(const CMethodSemanticsMap *psFirst, const CMethodSemanticsMap *psSecond);
825 };
826
827 static BOOL CompareSignatures(PCCOR_SIGNATURE pvFirstSigBlob, DWORD cbFirstSigBlob,
828 PCCOR_SIGNATURE pvSecondSigBlob, DWORD cbSecondSigBlob,
829 void* SigARguments);
830
831 mdTypeDef m_tdModule; // <Module> typedef value.
832 LONG m_cRefs; // Ref count.
833
834public:
835 STDMETHODIMP_(DWORD) GetMetadataStreamVersion()
836 {
837 return (DWORD)m_LiteWeightStgdb.m_MiniMd.m_Schema.m_minor |
838 ((DWORD)m_LiteWeightStgdb.m_MiniMd.m_Schema.m_major << 16);
839 };
840
841 STDMETHODIMP SetVerifiedByTrustedSource(// return hresult
842 BOOL fVerified)
843 {
844 m_LiteWeightStgdb.m_MiniMd.SetVerifiedByTrustedSource(fVerified);
845 return S_OK;
846 }
847}; // class MDInternalRO
848
849#endif //FEATURE_METADATA_INTERNAL_APIS
850
851#endif // __MDInternalRO__h__
852