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