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
6
7#include "common.h"
8#include "profilermetadataemitvalidator.h"
9
10ProfilerMetadataEmitValidator::ProfilerMetadataEmitValidator(IMetaDataEmit* pInnerEmit) :
11m_cRefCount(0)
12{
13 LIMITED_METHOD_CONTRACT;
14
15 ReleaseHolder<IGetIMDInternalImport> pGetIMDInternalImport;
16 pInnerEmit->QueryInterface(IID_IGetIMDInternalImport, (void**)&pGetIMDInternalImport);
17 pGetIMDInternalImport->GetIMDInternalImport(&m_pInnerInternalImport);
18
19 pInnerEmit->QueryInterface(IID_IMetaDataImport2, (void**)&m_pInnerImport);
20 pInnerEmit->QueryInterface(IID_IMetaDataAssemblyImport, (void**)&m_pInnerAssemblyImport);
21 pInnerEmit->QueryInterface(IID_IMetaDataEmit2, (void**) &m_pInner);
22 pInnerEmit->QueryInterface(IID_IMetaDataAssemblyEmit, (void**) &m_pInnerAssembly);
23
24 // GetCountWithTokenType does not count the 0 RID token, thus the max valid RID = count
25 // Confusingly the method treats TypeDef specially by ignoring 0x02000001 as well. For TypeDef max RID is count+1
26 maxInitialTypeDef = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtTypeDef) + 1, mdtTypeDef);
27 maxInitialMethodDef = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtMethodDef), mdtMethodDef);
28 maxInitialFieldDef = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtFieldDef), mdtFieldDef);
29 maxInitialMemberRef = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtMemberRef), mdtMemberRef);
30 maxInitialParamDef = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtParamDef), mdtParamDef);
31 maxInitialCustomAttribute = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtCustomAttribute), mdtCustomAttribute);
32 maxInitialEvent = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtEvent), mdtEvent);
33 maxInitialProperty = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtProperty), mdtProperty);
34 maxInitialGenericParam = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtGenericParam), mdtGenericParam);
35}
36
37ProfilerMetadataEmitValidator::~ProfilerMetadataEmitValidator()
38{
39 LIMITED_METHOD_CONTRACT;
40}
41
42 //IUnknown
43HRESULT ProfilerMetadataEmitValidator::QueryInterface(REFIID riid, void** ppInterface)
44{
45 if(riid == IID_IUnknown)
46 {
47 *ppInterface = static_cast<IUnknown*>(static_cast<IMetaDataEmit*>(this));
48 AddRef();
49 }
50 else if(riid == IID_IMetaDataEmit)
51 {
52 *ppInterface = static_cast<IMetaDataEmit*>(this);
53 AddRef();
54 }
55 else if(riid == IID_IMetaDataEmit2)
56 {
57 *ppInterface = static_cast<IMetaDataEmit2*>(this);
58 AddRef();
59 }
60 else if(riid == IID_IMetaDataAssemblyEmit)
61 {
62 *ppInterface = static_cast<IMetaDataAssemblyEmit*>(this);
63 AddRef();
64 }
65 else if (riid == IID_IMetaDataImport)
66 {
67 *ppInterface = static_cast<IMetaDataImport*>(this);
68 AddRef();
69 }
70 else if (riid == IID_IMetaDataImport2)
71 {
72 *ppInterface = static_cast<IMetaDataImport2*>(this);
73 AddRef();
74 }
75 else if (riid == IID_IMetaDataAssemblyImport)
76 {
77 *ppInterface = static_cast<IMetaDataAssemblyImport*>(this);
78 AddRef();
79 }
80 else
81 {
82 return E_NOINTERFACE;
83 }
84
85 return S_OK;
86}
87
88ULONG ProfilerMetadataEmitValidator::AddRef()
89{
90 return InterlockedIncrement(&m_cRefCount);
91}
92
93ULONG ProfilerMetadataEmitValidator::Release()
94{
95 ULONG ret = InterlockedDecrement(&m_cRefCount);
96 if(ret == 0)
97 {
98 delete this;
99 }
100 return ret;
101}
102
103 //IMetaDataEmit
104HRESULT ProfilerMetadataEmitValidator::SetModuleProps(
105 LPCWSTR szName)
106{
107 LIMITED_METHOD_CONTRACT;
108 return COR_E_NOTSUPPORTED;
109}
110
111HRESULT ProfilerMetadataEmitValidator::Save(
112 LPCWSTR szFile,
113 DWORD dwSaveFlags)
114{
115 LIMITED_METHOD_CONTRACT;
116 return COR_E_NOTSUPPORTED;
117}
118
119HRESULT ProfilerMetadataEmitValidator::SaveToStream(
120 IStream *pIStream,
121 DWORD dwSaveFlags)
122{
123 LIMITED_METHOD_CONTRACT;
124 return COR_E_NOTSUPPORTED;
125}
126
127HRESULT ProfilerMetadataEmitValidator::GetSaveSize(
128 CorSaveSize fSave,
129 DWORD *pdwSaveSize)
130{
131 LIMITED_METHOD_CONTRACT;
132 return COR_E_NOTSUPPORTED;
133}
134
135HRESULT ProfilerMetadataEmitValidator::DefineTypeDef(
136 LPCWSTR szTypeDef,
137 DWORD dwTypeDefFlags,
138 mdToken tkExtends,
139 mdToken rtkImplements[],
140 mdTypeDef *ptd)
141{
142 LIMITED_METHOD_CONTRACT;
143 return m_pInner->DefineTypeDef(szTypeDef, dwTypeDefFlags, tkExtends, rtkImplements, ptd);
144}
145
146HRESULT ProfilerMetadataEmitValidator::DefineNestedType(
147 LPCWSTR szTypeDef,
148 DWORD dwTypeDefFlags,
149 mdToken tkExtends,
150 mdToken rtkImplements[],
151 mdTypeDef tdEncloser,
152 mdTypeDef *ptd)
153{
154 LIMITED_METHOD_CONTRACT;
155 return m_pInner->DefineNestedType(szTypeDef, dwTypeDefFlags, tkExtends, rtkImplements, tdEncloser, ptd);
156}
157
158HRESULT ProfilerMetadataEmitValidator::SetHandler(
159 IUnknown *pUnk)
160{
161 LIMITED_METHOD_CONTRACT;
162 return COR_E_NOTSUPPORTED;
163}
164
165HRESULT ProfilerMetadataEmitValidator::DefineMethod(
166 mdTypeDef td,
167 LPCWSTR szName,
168 DWORD dwMethodFlags,
169 PCCOR_SIGNATURE pvSigBlob,
170 ULONG cbSigBlob,
171 ULONG ulCodeRVA,
172 DWORD dwImplFlags,
173 mdMethodDef *pmd)
174{
175 LIMITED_METHOD_CONTRACT;
176 //modifying pre-existing types is not allowed
177 if (td <= maxInitialTypeDef)
178 {
179 return COR_E_NOTSUPPORTED;
180 }
181 return m_pInner->DefineMethod(td, szName, dwMethodFlags, pvSigBlob, cbSigBlob, ulCodeRVA, dwImplFlags, pmd);
182}
183
184HRESULT ProfilerMetadataEmitValidator::DefineMethodImpl(
185 mdTypeDef td,
186 mdToken tkBody,
187 mdToken tkDecl)
188{
189 LIMITED_METHOD_CONTRACT;
190 //modifying pre-existing types is not allowed
191 if (td <= maxInitialTypeDef)
192 {
193 return COR_E_NOTSUPPORTED;
194 }
195 return m_pInner->DefineMethodImpl(td, tkBody, tkDecl);
196}
197
198HRESULT ProfilerMetadataEmitValidator::DefineTypeRefByName(
199 mdToken tkResolutionScope,
200 LPCWSTR szName,
201 mdTypeRef *ptr)
202{
203 LIMITED_METHOD_CONTRACT;
204 return m_pInner->DefineTypeRefByName(tkResolutionScope, szName, ptr);
205}
206
207HRESULT ProfilerMetadataEmitValidator::DefineImportType(
208 IMetaDataAssemblyImport *pAssemImport,
209 const void *pbHashValue,
210 ULONG cbHashValue,
211 IMetaDataImport *pImport,
212 mdTypeDef tdImport,
213 IMetaDataAssemblyEmit *pAssemEmit,
214 mdTypeRef *ptr)
215{
216 LIMITED_METHOD_CONTRACT;
217 return COR_E_NOTSUPPORTED;
218}
219
220HRESULT ProfilerMetadataEmitValidator::DefineMemberRef(
221 mdToken tkImport,
222 LPCWSTR szName,
223 PCCOR_SIGNATURE pvSigBlob,
224 ULONG cbSigBlob,
225 mdMemberRef *pmr)
226{
227 LIMITED_METHOD_CONTRACT;
228 return m_pInner->DefineMemberRef(tkImport, szName, pvSigBlob, cbSigBlob, pmr);
229}
230
231HRESULT ProfilerMetadataEmitValidator::DefineImportMember(
232 IMetaDataAssemblyImport *pAssemImport,
233 const void *pbHashValue,
234 ULONG cbHashValue,
235 IMetaDataImport *pImport,
236 mdToken mbMember,
237 IMetaDataAssemblyEmit *pAssemEmit,
238 mdToken tkParent,
239 mdMemberRef *pmr)
240{
241 LIMITED_METHOD_CONTRACT;
242 return COR_E_NOTSUPPORTED;
243}
244
245HRESULT ProfilerMetadataEmitValidator::DefineEvent(
246 mdTypeDef td,
247 LPCWSTR szEvent,
248 DWORD dwEventFlags,
249 mdToken tkEventType,
250 mdMethodDef mdAddOn,
251 mdMethodDef mdRemoveOn,
252 mdMethodDef mdFire,
253 mdMethodDef rmdOtherMethods[],
254 mdEvent *pmdEvent)
255{
256 LIMITED_METHOD_CONTRACT;
257 //modifying pre-existing types is not allowed
258 if (td <= maxInitialTypeDef)
259 {
260 return COR_E_NOTSUPPORTED;
261 }
262 return m_pInner->DefineEvent(td, szEvent, dwEventFlags, tkEventType, mdAddOn, mdRemoveOn, mdFire, rmdOtherMethods, pmdEvent);
263}
264
265HRESULT ProfilerMetadataEmitValidator::SetClassLayout(
266 mdTypeDef td,
267 DWORD dwPackSize,
268 COR_FIELD_OFFSET rFieldOffsets[],
269 ULONG ulClassSize)
270{
271 LIMITED_METHOD_CONTRACT;
272 //modifying pre-existing types is not allowed
273 if (td <= maxInitialTypeDef)
274 {
275 return COR_E_NOTSUPPORTED;
276 }
277 return m_pInner->SetClassLayout(td, dwPackSize, rFieldOffsets, ulClassSize);
278}
279
280HRESULT ProfilerMetadataEmitValidator::DeleteClassLayout(
281 mdTypeDef td)
282{
283 LIMITED_METHOD_CONTRACT;
284 return COR_E_NOTSUPPORTED;
285}
286
287HRESULT ProfilerMetadataEmitValidator::SetFieldMarshal(
288 mdToken tk,
289 PCCOR_SIGNATURE pvNativeType,
290 ULONG cbNativeType)
291{
292 LIMITED_METHOD_CONTRACT;
293 //modifying pre-existing field/property is not allowed
294 if ((TypeFromToken(tk) == mdtProperty && tk <= maxInitialProperty) ||
295 (TypeFromToken(tk) == mdtFieldDef && tk <= maxInitialFieldDef))
296 {
297 return COR_E_NOTSUPPORTED;
298 }
299 //if the token wasn't a field/param we let it through just to get
300 //the appropriate error behavior from the inner emitter
301 return m_pInner->SetFieldMarshal(tk, pvNativeType, cbNativeType);
302}
303
304HRESULT ProfilerMetadataEmitValidator::DeleteFieldMarshal(
305 mdToken tk)
306{
307 LIMITED_METHOD_CONTRACT;
308 return COR_E_NOTSUPPORTED;
309}
310
311HRESULT ProfilerMetadataEmitValidator::DefinePermissionSet(
312 mdToken tk,
313 DWORD dwAction,
314 void const *pvPermission,
315 ULONG cbPermission,
316 mdPermission *ppm)
317{
318 LIMITED_METHOD_CONTRACT;
319 return COR_E_NOTSUPPORTED;
320}
321
322HRESULT ProfilerMetadataEmitValidator::SetRVA(
323 mdMethodDef md,
324 ULONG ulRVA)
325{
326 LIMITED_METHOD_CONTRACT;
327 return COR_E_NOTSUPPORTED;
328}
329
330HRESULT ProfilerMetadataEmitValidator::GetTokenFromSig(
331 PCCOR_SIGNATURE pvSig,
332 ULONG cbSig,
333 mdSignature *pmsig)
334{
335 LIMITED_METHOD_CONTRACT;
336 return m_pInner->GetTokenFromSig(pvSig, cbSig, pmsig);
337}
338
339HRESULT ProfilerMetadataEmitValidator::DefineModuleRef(
340 LPCWSTR szName,
341 mdModuleRef *pmur)
342{
343 LIMITED_METHOD_CONTRACT;
344 return m_pInner->DefineModuleRef(szName, pmur);
345}
346
347HRESULT ProfilerMetadataEmitValidator::SetParent(
348 mdMemberRef mr,
349 mdToken tk)
350{
351 LIMITED_METHOD_CONTRACT;
352 //modifying pre-existing memberref is not allowed
353 if (mr <= maxInitialMemberRef)
354 {
355 return COR_E_NOTSUPPORTED;
356 }
357 return m_pInner->SetParent(mr, tk);
358}
359
360HRESULT ProfilerMetadataEmitValidator::GetTokenFromTypeSpec(
361 PCCOR_SIGNATURE pvSig,
362 ULONG cbSig,
363 mdTypeSpec *ptypespec)
364{
365 LIMITED_METHOD_CONTRACT;
366 return m_pInner->GetTokenFromTypeSpec(pvSig, cbSig, ptypespec);
367}
368
369HRESULT ProfilerMetadataEmitValidator::SaveToMemory(
370 void *pbData,
371 ULONG cbData)
372{
373 LIMITED_METHOD_CONTRACT;
374 return COR_E_NOTSUPPORTED;
375}
376
377HRESULT ProfilerMetadataEmitValidator::DefineUserString(
378 LPCWSTR szString,
379 ULONG cchString,
380 mdString *pstk)
381{
382 LIMITED_METHOD_CONTRACT;
383 return m_pInner->DefineUserString(szString, cchString, pstk);
384}
385
386HRESULT ProfilerMetadataEmitValidator::DeleteToken(
387 mdToken tkObj)
388{
389 LIMITED_METHOD_CONTRACT;
390 return COR_E_NOTSUPPORTED;
391}
392
393HRESULT ProfilerMetadataEmitValidator::SetMethodProps(
394 mdMethodDef md,
395 DWORD dwMethodFlags,
396 ULONG ulCodeRVA,
397 DWORD dwImplFlags)
398{
399 LIMITED_METHOD_CONTRACT;
400 //modifying pre-existing methods is not allowed
401 if (md <= maxInitialMethodDef)
402 {
403 return COR_E_NOTSUPPORTED;
404 }
405 return m_pInner->SetMethodProps(md, dwMethodFlags, ulCodeRVA, dwImplFlags);
406}
407
408HRESULT ProfilerMetadataEmitValidator::SetTypeDefProps(
409 mdTypeDef td,
410 DWORD dwTypeDefFlags,
411 mdToken tkExtends,
412 mdToken rtkImplements[])
413{
414 LIMITED_METHOD_CONTRACT;
415 //modifying pre-existing types is not allowed
416 if (td <= maxInitialTypeDef)
417 {
418 return COR_E_NOTSUPPORTED;
419 }
420 return m_pInner->SetTypeDefProps(td, dwTypeDefFlags, tkExtends, rtkImplements);
421}
422
423HRESULT ProfilerMetadataEmitValidator::SetEventProps(
424 mdEvent ev,
425 DWORD dwEventFlags,
426 mdToken tkEventType,
427 mdMethodDef mdAddOn,
428 mdMethodDef mdRemoveOn,
429 mdMethodDef mdFire,
430 mdMethodDef rmdOtherMethods[])
431{
432 LIMITED_METHOD_CONTRACT;
433 //modifying pre-existing events is not allowed
434 if (ev <= maxInitialEvent)
435 {
436 return COR_E_NOTSUPPORTED;
437 }
438 return m_pInner->SetEventProps(ev, dwEventFlags, tkEventType, mdAddOn, mdRemoveOn, mdFire, rmdOtherMethods);
439}
440
441HRESULT ProfilerMetadataEmitValidator::SetPermissionSetProps(
442 mdToken tk,
443 DWORD dwAction,
444 void const *pvPermission,
445 ULONG cbPermission,
446 mdPermission *ppm)
447{
448 LIMITED_METHOD_CONTRACT;
449 return COR_E_NOTSUPPORTED;
450}
451
452HRESULT ProfilerMetadataEmitValidator::DefinePinvokeMap(
453 mdToken tk,
454 DWORD dwMappingFlags,
455 LPCWSTR szImportName,
456 mdModuleRef mrImportDLL)
457{
458 LIMITED_METHOD_CONTRACT;
459 //modifying pre-existing methods is not allowed
460 if (tk <= maxInitialMethodDef)
461 {
462 return COR_E_NOTSUPPORTED;
463 }
464 return m_pInner->DefinePinvokeMap(tk, dwMappingFlags, szImportName, mrImportDLL);
465}
466
467HRESULT ProfilerMetadataEmitValidator::SetPinvokeMap(
468 mdToken tk,
469 DWORD dwMappingFlags,
470 LPCWSTR szImportName,
471 mdModuleRef mrImportDLL)
472{
473 LIMITED_METHOD_CONTRACT;
474 //modifying pre-existing types is not allowed
475 if (tk <= maxInitialTypeDef)
476 {
477 return COR_E_NOTSUPPORTED;
478 }
479 return m_pInner->SetPinvokeMap(tk, dwMappingFlags, szImportName, mrImportDLL);
480}
481
482HRESULT ProfilerMetadataEmitValidator::DeletePinvokeMap(
483 mdToken tk)
484{
485 LIMITED_METHOD_CONTRACT;
486 return COR_E_NOTSUPPORTED;
487}
488
489HRESULT ProfilerMetadataEmitValidator::DefineCustomAttribute(
490 mdToken tkOwner,
491 mdToken tkCtor,
492 void const *pCustomAttribute,
493 ULONG cbCustomAttribute,
494 mdCustomAttribute *pcv)
495{
496 LIMITED_METHOD_CONTRACT;
497 return m_pInner->DefineCustomAttribute(tkOwner, tkCtor, pCustomAttribute, cbCustomAttribute, pcv);
498}
499
500HRESULT ProfilerMetadataEmitValidator::SetCustomAttributeValue(
501 mdCustomAttribute pcv,
502 void const *pCustomAttribute,
503 ULONG cbCustomAttribute)
504{
505 LIMITED_METHOD_CONTRACT;
506 //modifying pre-existing CAs is not allowed
507 if (pcv <= maxInitialCustomAttribute)
508 {
509 return COR_E_NOTSUPPORTED;
510 }
511 return m_pInner->SetCustomAttributeValue(pcv, pCustomAttribute, cbCustomAttribute);
512}
513
514HRESULT ProfilerMetadataEmitValidator::DefineField(
515 mdTypeDef td,
516 LPCWSTR szName,
517 DWORD dwFieldFlags,
518 PCCOR_SIGNATURE pvSigBlob,
519 ULONG cbSigBlob,
520 DWORD dwCPlusTypeFlag,
521 void const *pValue,
522 ULONG cchValue,
523 mdFieldDef *pmd)
524{
525 LIMITED_METHOD_CONTRACT;
526 //modifying pre-existing types is not allowed
527 if (td <= maxInitialTypeDef)
528 {
529 return COR_E_NOTSUPPORTED;
530 }
531 return m_pInner->DefineField(td, szName, dwFieldFlags, pvSigBlob, cbSigBlob, dwCPlusTypeFlag, pValue, cchValue, pmd);
532}
533
534HRESULT ProfilerMetadataEmitValidator::DefineProperty(
535 mdTypeDef td,
536 LPCWSTR szProperty,
537 DWORD dwPropFlags,
538 PCCOR_SIGNATURE pvSig,
539 ULONG cbSig,
540 DWORD dwCPlusTypeFlag,
541 void const *pValue,
542 ULONG cchValue,
543 mdMethodDef mdSetter,
544 mdMethodDef mdGetter,
545 mdMethodDef rmdOtherMethods[],
546 mdProperty *pmdProp)
547{
548 LIMITED_METHOD_CONTRACT;
549 //modifying pre-existing types is not allowed
550 if (td <= maxInitialTypeDef)
551 {
552 return COR_E_NOTSUPPORTED;
553 }
554 return m_pInner->DefineProperty(td, szProperty, dwPropFlags, pvSig, cbSig, dwCPlusTypeFlag, pValue, cchValue, mdSetter, mdGetter, rmdOtherMethods, pmdProp);
555}
556
557HRESULT ProfilerMetadataEmitValidator::DefineParam(
558 mdMethodDef md,
559 ULONG ulParamSeq,
560 LPCWSTR szName,
561 DWORD dwParamFlags,
562 DWORD dwCPlusTypeFlag,
563 void const *pValue,
564 ULONG cchValue,
565 mdParamDef *ppd)
566{
567 LIMITED_METHOD_CONTRACT;
568 //modifying pre-existing methods is not allowed
569 if (md <= maxInitialMethodDef)
570 {
571 return COR_E_NOTSUPPORTED;
572 }
573 return m_pInner->DefineParam(md, ulParamSeq, szName, dwParamFlags, dwCPlusTypeFlag, pValue, cchValue, ppd);
574}
575
576HRESULT ProfilerMetadataEmitValidator::SetFieldProps(
577 mdFieldDef fd,
578 DWORD dwFieldFlags,
579 DWORD dwCPlusTypeFlag,
580 void const *pValue,
581 ULONG cchValue)
582{
583 LIMITED_METHOD_CONTRACT;
584 //modifying pre-existing fields is not allowed
585 if (fd <= maxInitialFieldDef)
586 {
587 return COR_E_NOTSUPPORTED;
588 }
589 return m_pInner->SetFieldProps(fd, dwFieldFlags, dwCPlusTypeFlag, pValue, cchValue);
590}
591
592HRESULT ProfilerMetadataEmitValidator::SetPropertyProps(
593 mdProperty pr,
594 DWORD dwPropFlags,
595 DWORD dwCPlusTypeFlag,
596 void const *pValue,
597 ULONG cchValue,
598 mdMethodDef mdSetter,
599 mdMethodDef mdGetter,
600 mdMethodDef rmdOtherMethods[])
601{
602 LIMITED_METHOD_CONTRACT;
603 //modifying pre-existing properties is not allowed
604 if (pr <= maxInitialProperty)
605 {
606 return COR_E_NOTSUPPORTED;
607 }
608 return m_pInner->SetPropertyProps(pr, dwPropFlags, dwCPlusTypeFlag, pValue, cchValue, mdSetter, mdGetter, rmdOtherMethods);
609}
610
611HRESULT ProfilerMetadataEmitValidator::SetParamProps(
612 mdParamDef pd,
613 LPCWSTR szName,
614 DWORD dwParamFlags,
615 DWORD dwCPlusTypeFlag,
616 void const *pValue,
617 ULONG cchValue)
618{
619 LIMITED_METHOD_CONTRACT;
620 //modifying pre-existing params is not allowed
621 if (pd <= maxInitialParamDef)
622 {
623 return COR_E_NOTSUPPORTED;
624 }
625 return m_pInner->SetParamProps(pd, szName, dwParamFlags, dwCPlusTypeFlag, pValue, cchValue);
626}
627
628HRESULT ProfilerMetadataEmitValidator::DefineSecurityAttributeSet(
629 mdToken tkObj,
630 COR_SECATTR rSecAttrs[],
631 ULONG cSecAttrs,
632 ULONG *pulErrorAttr)
633{
634 LIMITED_METHOD_CONTRACT;
635 return COR_E_NOTSUPPORTED;
636}
637
638HRESULT ProfilerMetadataEmitValidator::ApplyEditAndContinue(
639 IUnknown *pImport)
640{
641 LIMITED_METHOD_CONTRACT;
642 return COR_E_NOTSUPPORTED;
643}
644
645HRESULT ProfilerMetadataEmitValidator::TranslateSigWithScope(
646 IMetaDataAssemblyImport *pAssemImport,
647 const void *pbHashValue,
648 ULONG cbHashValue,
649 IMetaDataImport *import,
650 PCCOR_SIGNATURE pbSigBlob,
651 ULONG cbSigBlob,
652 IMetaDataAssemblyEmit *pAssemEmit,
653 IMetaDataEmit *emit,
654 PCOR_SIGNATURE pvTranslatedSig,
655 ULONG cbTranslatedSigMax,
656 ULONG *pcbTranslatedSig)
657{
658 LIMITED_METHOD_CONTRACT;
659 return COR_E_NOTSUPPORTED;
660}
661
662HRESULT ProfilerMetadataEmitValidator::SetMethodImplFlags(
663 mdMethodDef md,
664 DWORD dwImplFlags)
665{
666 LIMITED_METHOD_CONTRACT;
667 //modifying pre-existing methods is not supported
668 if (md <= maxInitialMethodDef)
669 {
670 return COR_E_NOTSUPPORTED;
671 }
672 return m_pInner->SetMethodImplFlags(md, dwImplFlags);
673}
674
675HRESULT ProfilerMetadataEmitValidator::SetFieldRVA(
676 mdFieldDef fd,
677 ULONG ulRVA)
678{
679 LIMITED_METHOD_CONTRACT;
680 return COR_E_NOTSUPPORTED;
681}
682
683HRESULT ProfilerMetadataEmitValidator::Merge(
684 IMetaDataImport *pImport,
685 IMapToken *pHostMapToken,
686 IUnknown *pHandler)
687{
688 LIMITED_METHOD_CONTRACT;
689 return COR_E_NOTSUPPORTED;
690}
691
692HRESULT ProfilerMetadataEmitValidator::MergeEnd()
693{
694 LIMITED_METHOD_CONTRACT;
695 return COR_E_NOTSUPPORTED;
696}
697
698 // IMetaDataEmit2
699HRESULT ProfilerMetadataEmitValidator::DefineMethodSpec(
700 mdToken tkParent,
701 PCCOR_SIGNATURE pvSigBlob,
702 ULONG cbSigBlob,
703 mdMethodSpec *pmi)
704{
705 LIMITED_METHOD_CONTRACT;
706 return m_pInner->DefineMethodSpec(tkParent, pvSigBlob, cbSigBlob, pmi);
707}
708
709HRESULT ProfilerMetadataEmitValidator::GetDeltaSaveSize(
710 CorSaveSize fSave,
711 DWORD *pdwSaveSize)
712{
713 LIMITED_METHOD_CONTRACT;
714 return COR_E_NOTSUPPORTED;
715}
716
717HRESULT ProfilerMetadataEmitValidator::SaveDelta(
718 LPCWSTR szFile,
719 DWORD dwSaveFlags)
720{
721 LIMITED_METHOD_CONTRACT;
722 return COR_E_NOTSUPPORTED;
723}
724
725HRESULT ProfilerMetadataEmitValidator::SaveDeltaToStream(
726 IStream *pIStream,
727 DWORD dwSaveFlags)
728{
729 LIMITED_METHOD_CONTRACT;
730 return COR_E_NOTSUPPORTED;
731}
732
733HRESULT ProfilerMetadataEmitValidator::SaveDeltaToMemory(
734 void *pbData,
735 ULONG cbData)
736{
737 LIMITED_METHOD_CONTRACT;
738 return COR_E_NOTSUPPORTED;
739}
740
741HRESULT ProfilerMetadataEmitValidator::DefineGenericParam(
742 mdToken tk,
743 ULONG ulParamSeq,
744 DWORD dwParamFlags,
745 LPCWSTR szname,
746 DWORD reserved,
747 mdToken rtkConstraints[],
748 mdGenericParam *pgp)
749{
750 LIMITED_METHOD_CONTRACT;
751 //modifying pre-existing methods/types is not allowed
752 if ((TypeFromToken(tk) == mdtTypeDef && tk <= maxInitialTypeDef) ||
753 (TypeFromToken(tk) == mdtMethodDef && tk <= maxInitialMethodDef))
754 {
755 return COR_E_NOTSUPPORTED;
756 }
757 return m_pInner->DefineGenericParam(tk, ulParamSeq, dwParamFlags, szname, reserved, rtkConstraints, pgp);
758}
759
760HRESULT ProfilerMetadataEmitValidator::SetGenericParamProps(
761 mdGenericParam gp,
762 DWORD dwParamFlags,
763 LPCWSTR szName,
764 DWORD reserved,
765 mdToken rtkConstraints[])
766{
767 LIMITED_METHOD_CONTRACT;
768 //modifying pre-existing generic param is not allowed
769 if (gp <= maxInitialGenericParam)
770 {
771 return COR_E_NOTSUPPORTED;
772 }
773 return m_pInner->SetGenericParamProps(gp, dwParamFlags, szName, reserved, rtkConstraints);
774}
775
776HRESULT ProfilerMetadataEmitValidator::ResetENCLog()
777{
778 LIMITED_METHOD_CONTRACT;
779 return COR_E_NOTSUPPORTED;
780}
781
782 //IMetaDataAssemblyEmit
783HRESULT ProfilerMetadataEmitValidator::DefineAssembly(
784 const void *pbPublicKey,
785 ULONG cbPublicKey,
786 ULONG ulHashAlgId,
787 LPCWSTR szName,
788 const ASSEMBLYMETADATA *pMetaData,
789 DWORD dwAssemblyFlags,
790 mdAssembly *pma)
791{
792 LIMITED_METHOD_CONTRACT;
793 return COR_E_NOTSUPPORTED;
794}
795
796HRESULT ProfilerMetadataEmitValidator::DefineAssemblyRef(
797 const void *pbPublicKeyOrToken,
798 ULONG cbPublicKeyOrToken,
799 LPCWSTR szName,
800 const ASSEMBLYMETADATA *pMetaData,
801 const void *pbHashValue,
802 ULONG cbHashValue,
803 DWORD dwAssemblyRefFlags,
804 mdAssemblyRef *pmdar)
805{
806 LIMITED_METHOD_CONTRACT;
807 return COR_E_NOTSUPPORTED;
808}
809
810HRESULT ProfilerMetadataEmitValidator::DefineFile(
811 LPCWSTR szName,
812 const void *pbHashValue,
813 ULONG cbHashValue,
814 DWORD dwFileFlags,
815 mdFile *pmdf)
816{
817 LIMITED_METHOD_CONTRACT;
818 return COR_E_NOTSUPPORTED;
819}
820
821HRESULT ProfilerMetadataEmitValidator::DefineExportedType(
822 LPCWSTR szName,
823 mdToken tkImplementation,
824 mdTypeDef tkTypeDef,
825 DWORD dwExportedTypeFlags,
826 mdExportedType *pmdct)
827{
828 LIMITED_METHOD_CONTRACT;
829 return COR_E_NOTSUPPORTED;
830}
831
832HRESULT ProfilerMetadataEmitValidator::DefineManifestResource(
833 LPCWSTR szName,
834 mdToken tkImplementation,
835 DWORD dwOffset,
836 DWORD dwResourceFlags,
837 mdManifestResource *pmdmr)
838{
839 LIMITED_METHOD_CONTRACT;
840 return COR_E_NOTSUPPORTED;
841}
842
843HRESULT ProfilerMetadataEmitValidator::SetAssemblyProps(
844 mdAssembly pma,
845 const void *pbPublicKey,
846 ULONG cbPublicKey,
847 ULONG ulHashAlgId,
848 LPCWSTR szName,
849 const ASSEMBLYMETADATA *pMetaData,
850 DWORD dwAssemblyFlags)
851{
852 LIMITED_METHOD_CONTRACT;
853 return COR_E_NOTSUPPORTED;
854}
855
856HRESULT ProfilerMetadataEmitValidator::SetAssemblyRefProps(
857 mdAssemblyRef ar,
858 const void *pbPublicKeyOrToken,
859 ULONG cbPublicKeyOrToken,
860 LPCWSTR szName,
861 const ASSEMBLYMETADATA *pMetaData,
862 const void *pbHashValue,
863 ULONG cbHashValue,
864 DWORD dwAssemblyRefFlags)
865{
866 LIMITED_METHOD_CONTRACT;
867 return COR_E_NOTSUPPORTED;
868}
869
870HRESULT ProfilerMetadataEmitValidator::SetFileProps(
871 mdFile file,
872 const void *pbHashValue,
873 ULONG cbHashValue,
874 DWORD dwFileFlags)
875{
876 LIMITED_METHOD_CONTRACT;
877 return COR_E_NOTSUPPORTED;
878}
879
880HRESULT ProfilerMetadataEmitValidator::SetExportedTypeProps(
881 mdExportedType ct,
882 mdToken tkImplementation,
883 mdTypeDef tkTypeDef,
884 DWORD dwExportedTypeFlags)
885{
886 LIMITED_METHOD_CONTRACT;
887 return COR_E_NOTSUPPORTED;
888}
889
890HRESULT ProfilerMetadataEmitValidator::SetManifestResourceProps(
891 mdManifestResource mr,
892 mdToken tkImplementation,
893 DWORD dwOffset,
894 DWORD dwResourceFlags)
895{
896 LIMITED_METHOD_CONTRACT;
897 return COR_E_NOTSUPPORTED;
898}
899
900//IMetaDataImport
901void ProfilerMetadataEmitValidator::CloseEnum(HCORENUM hEnum)
902{
903 LIMITED_METHOD_CONTRACT;
904 m_pInnerImport->CloseEnum(hEnum);
905}
906
907HRESULT ProfilerMetadataEmitValidator::CountEnum(HCORENUM hEnum, ULONG *pulCount)
908{
909 LIMITED_METHOD_CONTRACT;
910 return m_pInnerImport->CountEnum(hEnum, pulCount);
911}
912
913HRESULT ProfilerMetadataEmitValidator::ResetEnum(HCORENUM hEnum, ULONG ulPos)
914{
915 LIMITED_METHOD_CONTRACT;
916 return m_pInnerImport->ResetEnum(hEnum, ulPos);
917}
918
919HRESULT ProfilerMetadataEmitValidator::EnumTypeDefs(HCORENUM *phEnum, mdTypeDef rTypeDefs[],
920 ULONG cMax, ULONG *pcTypeDefs)
921{
922 LIMITED_METHOD_CONTRACT;
923 return m_pInnerImport->EnumTypeDefs(phEnum, rTypeDefs, cMax, pcTypeDefs);
924}
925
926HRESULT ProfilerMetadataEmitValidator::EnumInterfaceImpls(HCORENUM *phEnum, mdTypeDef td,
927 mdInterfaceImpl rImpls[], ULONG cMax,
928 ULONG* pcImpls)
929{
930 LIMITED_METHOD_CONTRACT;
931 return m_pInnerImport->EnumInterfaceImpls(phEnum, td, rImpls, cMax, pcImpls);
932}
933
934HRESULT ProfilerMetadataEmitValidator::EnumTypeRefs(HCORENUM *phEnum, mdTypeRef rTypeRefs[],
935 ULONG cMax, ULONG* pcTypeRefs)
936{
937 LIMITED_METHOD_CONTRACT;
938 return m_pInnerImport->EnumTypeRefs(phEnum, rTypeRefs, cMax, pcTypeRefs);
939}
940
941HRESULT ProfilerMetadataEmitValidator::FindTypeDefByName(
942 LPCWSTR szTypeDef,
943 mdToken tkEnclosingClass,
944 mdTypeDef *ptd)
945{
946 LIMITED_METHOD_CONTRACT;
947 return m_pInnerImport->FindTypeDefByName(szTypeDef, tkEnclosingClass, ptd);
948}
949
950HRESULT ProfilerMetadataEmitValidator::GetScopeProps(
951 LPWSTR szName,
952 ULONG cchName,
953 ULONG *pchName,
954 GUID *pmvid)
955{
956 LIMITED_METHOD_CONTRACT;
957 return m_pInnerImport->GetScopeProps(szName, cchName, pchName, pmvid);
958}
959
960HRESULT ProfilerMetadataEmitValidator::GetModuleFromScope(
961 mdModule *pmd)
962{
963 LIMITED_METHOD_CONTRACT;
964 return m_pInnerImport->GetModuleFromScope(pmd);
965}
966
967HRESULT ProfilerMetadataEmitValidator::GetTypeDefProps(
968 mdTypeDef td,
969 LPWSTR szTypeDef,
970 ULONG cchTypeDef,
971 ULONG *pchTypeDef,
972 DWORD *pdwTypeDefFlags,
973 mdToken *ptkExtends)
974{
975 LIMITED_METHOD_CONTRACT;
976 return m_pInnerImport->GetTypeDefProps(td, szTypeDef, cchTypeDef, pchTypeDef, pdwTypeDefFlags, ptkExtends);
977}
978
979HRESULT ProfilerMetadataEmitValidator::GetInterfaceImplProps(
980 mdInterfaceImpl iiImpl,
981 mdTypeDef *pClass,
982 mdToken *ptkIface)
983{
984 LIMITED_METHOD_CONTRACT;
985 return m_pInnerImport->GetInterfaceImplProps(iiImpl, pClass, ptkIface);
986}
987
988HRESULT ProfilerMetadataEmitValidator::GetTypeRefProps(
989 mdTypeRef tr,
990 mdToken *ptkResolutionScope,
991 LPWSTR szName,
992 ULONG cchName,
993 ULONG *pchName)
994{
995 LIMITED_METHOD_CONTRACT;
996 return m_pInnerImport->GetTypeRefProps(tr, ptkResolutionScope, szName, cchName, pchName);
997}
998
999HRESULT ProfilerMetadataEmitValidator::ResolveTypeRef(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd)
1000{
1001 LIMITED_METHOD_CONTRACT;
1002 return m_pInnerImport->ResolveTypeRef(tr, riid, ppIScope, ptd);
1003}
1004
1005HRESULT ProfilerMetadataEmitValidator::EnumMembers(
1006 HCORENUM *phEnum,
1007 mdTypeDef cl,
1008 mdToken rMembers[],
1009 ULONG cMax,
1010 ULONG *pcTokens)
1011{
1012 LIMITED_METHOD_CONTRACT;
1013 return m_pInnerImport->EnumMembers(phEnum, cl, rMembers, cMax, pcTokens);
1014}
1015
1016HRESULT ProfilerMetadataEmitValidator::EnumMembersWithName(
1017 HCORENUM *phEnum,
1018 mdTypeDef cl,
1019 LPCWSTR szName,
1020 mdToken rMembers[],
1021 ULONG cMax,
1022 ULONG *pcTokens)
1023{
1024 LIMITED_METHOD_CONTRACT;
1025 return m_pInnerImport->EnumMembersWithName(phEnum, cl, szName, rMembers, cMax, pcTokens);
1026}
1027
1028HRESULT ProfilerMetadataEmitValidator::EnumMethods(
1029 HCORENUM *phEnum,
1030 mdTypeDef cl,
1031 mdMethodDef rMethods[],
1032 ULONG cMax,
1033 ULONG *pcTokens)
1034{
1035 LIMITED_METHOD_CONTRACT;
1036 return m_pInnerImport->EnumMethods(phEnum, cl, rMethods, cMax, pcTokens);
1037}
1038
1039HRESULT ProfilerMetadataEmitValidator::EnumMethodsWithName(
1040 HCORENUM *phEnum,
1041 mdTypeDef cl,
1042 LPCWSTR szName,
1043 mdMethodDef rMethods[],
1044 ULONG cMax,
1045 ULONG *pcTokens)
1046{
1047 LIMITED_METHOD_CONTRACT;
1048 return m_pInnerImport->EnumMethodsWithName(phEnum, cl, szName, rMethods, cMax, pcTokens);
1049}
1050
1051HRESULT ProfilerMetadataEmitValidator::EnumFields(
1052 HCORENUM *phEnum,
1053 mdTypeDef cl,
1054 mdFieldDef rFields[],
1055 ULONG cMax,
1056 ULONG *pcTokens)
1057{
1058 LIMITED_METHOD_CONTRACT;
1059 return m_pInnerImport->EnumFields(phEnum, cl, rFields, cMax, pcTokens);
1060}
1061
1062HRESULT ProfilerMetadataEmitValidator::EnumFieldsWithName(
1063 HCORENUM *phEnum,
1064 mdTypeDef cl,
1065 LPCWSTR szName,
1066 mdFieldDef rFields[],
1067 ULONG cMax,
1068 ULONG *pcTokens)
1069{
1070 LIMITED_METHOD_CONTRACT;
1071 return m_pInnerImport->EnumFieldsWithName(phEnum, cl, szName, rFields, cMax, pcTokens);
1072}
1073
1074
1075HRESULT ProfilerMetadataEmitValidator::EnumParams(
1076 HCORENUM *phEnum,
1077 mdMethodDef mb,
1078 mdParamDef rParams[],
1079 ULONG cMax,
1080 ULONG *pcTokens)
1081{
1082 LIMITED_METHOD_CONTRACT;
1083 return m_pInnerImport->EnumParams(phEnum, mb, rParams, cMax, pcTokens);
1084}
1085
1086HRESULT ProfilerMetadataEmitValidator::EnumMemberRefs(
1087 HCORENUM *phEnum,
1088 mdToken tkParent,
1089 mdMemberRef rMemberRefs[],
1090 ULONG cMax,
1091 ULONG *pcTokens)
1092{
1093 LIMITED_METHOD_CONTRACT;
1094 return m_pInnerImport->EnumMemberRefs(phEnum, tkParent, rMemberRefs, cMax, pcTokens);
1095}
1096
1097HRESULT ProfilerMetadataEmitValidator::EnumMethodImpls(
1098 HCORENUM *phEnum,
1099 mdTypeDef td,
1100 mdToken rMethodBody[],
1101 mdToken rMethodDecl[],
1102 ULONG cMax,
1103 ULONG *pcTokens)
1104{
1105 LIMITED_METHOD_CONTRACT;
1106 return m_pInnerImport->EnumMethodImpls(phEnum, td, rMethodBody, rMethodDecl, cMax, pcTokens);
1107}
1108
1109HRESULT ProfilerMetadataEmitValidator::EnumPermissionSets(
1110 HCORENUM *phEnum,
1111 mdToken tk,
1112 DWORD dwActions,
1113 mdPermission rPermission[],
1114 ULONG cMax,
1115 ULONG *pcTokens)
1116{
1117 LIMITED_METHOD_CONTRACT;
1118 return m_pInnerImport->EnumPermissionSets(phEnum, tk, dwActions, rPermission, cMax, pcTokens);
1119}
1120
1121HRESULT ProfilerMetadataEmitValidator::FindMember(
1122 mdTypeDef td,
1123 LPCWSTR szName,
1124 PCCOR_SIGNATURE pvSigBlob,
1125 ULONG cbSigBlob,
1126 mdToken *pmb)
1127{
1128 LIMITED_METHOD_CONTRACT;
1129 return m_pInnerImport->FindMember(td, szName, pvSigBlob, cbSigBlob, pmb);
1130}
1131
1132HRESULT ProfilerMetadataEmitValidator::FindMethod(
1133 mdTypeDef td,
1134 LPCWSTR szName,
1135 PCCOR_SIGNATURE pvSigBlob,
1136 ULONG cbSigBlob,
1137 mdMethodDef *pmb)
1138{
1139 LIMITED_METHOD_CONTRACT;
1140 return m_pInnerImport->FindMethod(td, szName, pvSigBlob, cbSigBlob, pmb);
1141}
1142
1143HRESULT ProfilerMetadataEmitValidator::FindField(
1144 mdTypeDef td,
1145 LPCWSTR szName,
1146 PCCOR_SIGNATURE pvSigBlob,
1147 ULONG cbSigBlob,
1148 mdFieldDef *pmb)
1149{
1150 LIMITED_METHOD_CONTRACT;
1151 return m_pInnerImport->FindField(td, szName, pvSigBlob, cbSigBlob, pmb);
1152}
1153
1154HRESULT ProfilerMetadataEmitValidator::FindMemberRef(
1155 mdTypeRef td,
1156 LPCWSTR szName,
1157 PCCOR_SIGNATURE pvSigBlob,
1158 ULONG cbSigBlob,
1159 mdMemberRef *pmr)
1160{
1161 LIMITED_METHOD_CONTRACT;
1162 return m_pInnerImport->FindMemberRef(td, szName, pvSigBlob, cbSigBlob, pmr);
1163}
1164
1165HRESULT ProfilerMetadataEmitValidator::GetMethodProps(
1166 mdMethodDef mb,
1167 mdTypeDef *pClass,
1168 LPWSTR szMethod,
1169 ULONG cchMethod,
1170 ULONG *pchMethod,
1171 DWORD *pdwAttr,
1172 PCCOR_SIGNATURE *ppvSigBlob,
1173 ULONG *pcbSigBlob,
1174 ULONG *pulCodeRVA,
1175 DWORD *pdwImplFlags)
1176{
1177 LIMITED_METHOD_CONTRACT;
1178 return m_pInnerImport->GetMethodProps(mb, pClass, szMethod, cchMethod, pchMethod, pdwAttr, ppvSigBlob, pcbSigBlob, pulCodeRVA, pdwImplFlags);
1179}
1180
1181HRESULT ProfilerMetadataEmitValidator::GetMemberRefProps(
1182 mdMemberRef mr,
1183 mdToken *ptk,
1184 LPWSTR szMember,
1185 ULONG cchMember,
1186 ULONG *pchMember,
1187 PCCOR_SIGNATURE *ppvSigBlob,
1188 ULONG *pbSig)
1189{
1190 LIMITED_METHOD_CONTRACT;
1191 return m_pInnerImport->GetMemberRefProps(mr, ptk, szMember, cchMember, pchMember, ppvSigBlob, pbSig);
1192}
1193
1194HRESULT ProfilerMetadataEmitValidator::EnumProperties(
1195 HCORENUM *phEnum,
1196 mdTypeDef td,
1197 mdProperty rProperties[],
1198 ULONG cMax,
1199 ULONG *pcProperties)
1200{
1201 LIMITED_METHOD_CONTRACT;
1202 return m_pInnerImport->EnumProperties(phEnum, td, rProperties, cMax, pcProperties);
1203}
1204
1205HRESULT ProfilerMetadataEmitValidator::EnumEvents(
1206 HCORENUM *phEnum,
1207 mdTypeDef td,
1208 mdEvent rEvents[],
1209 ULONG cMax,
1210 ULONG *pcEvents)
1211{
1212 LIMITED_METHOD_CONTRACT;
1213 return m_pInnerImport->EnumEvents(phEnum, td, rEvents, cMax, pcEvents);
1214}
1215
1216HRESULT ProfilerMetadataEmitValidator::GetEventProps(
1217 mdEvent ev,
1218 mdTypeDef *pClass,
1219 LPCWSTR szEvent,
1220 ULONG cchEvent,
1221 ULONG *pchEvent,
1222 DWORD *pdwEventFlags,
1223 mdToken *ptkEventType,
1224 mdMethodDef *pmdAddOn,
1225 mdMethodDef *pmdRemoveOn,
1226 mdMethodDef *pmdFire,
1227 mdMethodDef rmdOtherMethod[],
1228 ULONG cMax,
1229 ULONG *pcOtherMethod)
1230{
1231 LIMITED_METHOD_CONTRACT;
1232 return m_pInnerImport->GetEventProps(ev, pClass, szEvent, cchEvent, pchEvent, pdwEventFlags, ptkEventType, pmdAddOn, pmdRemoveOn, pmdFire, rmdOtherMethod, cMax, pcOtherMethod);
1233}
1234
1235HRESULT ProfilerMetadataEmitValidator::EnumMethodSemantics(
1236 HCORENUM *phEnum,
1237 mdMethodDef mb,
1238 mdToken rEventProp[],
1239 ULONG cMax,
1240 ULONG *pcEventProp)
1241{
1242 LIMITED_METHOD_CONTRACT;
1243 return m_pInnerImport->EnumMethodSemantics(phEnum, mb, rEventProp, cMax, pcEventProp);
1244}
1245
1246HRESULT ProfilerMetadataEmitValidator::GetMethodSemantics(
1247 mdMethodDef mb,
1248 mdToken tkEventProp,
1249 DWORD *pdwSemanticsFlags)
1250{
1251 LIMITED_METHOD_CONTRACT;
1252 return m_pInnerImport->GetMethodSemantics(mb, tkEventProp, pdwSemanticsFlags);
1253}
1254
1255HRESULT ProfilerMetadataEmitValidator::GetClassLayout(
1256 mdTypeDef td,
1257 DWORD *pdwPackSize,
1258 COR_FIELD_OFFSET rFieldOffset[],
1259 ULONG cMax,
1260 ULONG *pcFieldOffset,
1261 ULONG *pulClassSize)
1262{
1263 LIMITED_METHOD_CONTRACT;
1264 return m_pInnerImport->GetClassLayout(td, pdwPackSize, rFieldOffset, cMax, pcFieldOffset, pulClassSize);
1265}
1266
1267HRESULT ProfilerMetadataEmitValidator::GetFieldMarshal(
1268 mdToken tk,
1269 PCCOR_SIGNATURE *ppvNativeType,
1270 ULONG *pcbNativeType)
1271{
1272 LIMITED_METHOD_CONTRACT;
1273 return m_pInnerImport->GetFieldMarshal(tk, ppvNativeType, pcbNativeType);
1274}
1275
1276HRESULT ProfilerMetadataEmitValidator::GetRVA(
1277 mdToken tk,
1278 ULONG *pulCodeRVA,
1279 DWORD *pdwImplFlags)
1280{
1281 LIMITED_METHOD_CONTRACT;
1282 return m_pInnerImport->GetRVA(tk, pulCodeRVA, pdwImplFlags);
1283}
1284
1285HRESULT ProfilerMetadataEmitValidator::GetPermissionSetProps(
1286 mdPermission pm,
1287 DWORD *pdwAction,
1288 void const **ppvPermission,
1289 ULONG *pcbPermission)
1290{
1291 LIMITED_METHOD_CONTRACT;
1292 return m_pInnerImport->GetPermissionSetProps(pm, pdwAction, ppvPermission, pcbPermission);
1293}
1294
1295HRESULT ProfilerMetadataEmitValidator::GetSigFromToken(
1296 mdSignature mdSig,
1297 PCCOR_SIGNATURE *ppvSig,
1298 ULONG *pcbSig)
1299{
1300 LIMITED_METHOD_CONTRACT;
1301 return m_pInnerImport->GetSigFromToken(mdSig, ppvSig, pcbSig);
1302}
1303
1304HRESULT ProfilerMetadataEmitValidator::GetModuleRefProps(
1305 mdModuleRef mur,
1306 LPWSTR szName,
1307 ULONG cchName,
1308 ULONG *pchName)
1309{
1310 LIMITED_METHOD_CONTRACT;
1311 return m_pInnerImport->GetModuleRefProps(mur, szName, cchName, pchName);
1312}
1313
1314HRESULT ProfilerMetadataEmitValidator::EnumModuleRefs(
1315 HCORENUM *phEnum,
1316 mdModuleRef rModuleRefs[],
1317 ULONG cmax,
1318 ULONG *pcModuleRefs)
1319{
1320 LIMITED_METHOD_CONTRACT;
1321 return m_pInnerImport->EnumModuleRefs(phEnum, rModuleRefs, cmax, pcModuleRefs);
1322}
1323
1324HRESULT ProfilerMetadataEmitValidator::GetTypeSpecFromToken(
1325 mdTypeSpec typespec,
1326 PCCOR_SIGNATURE *ppvSig,
1327 ULONG *pcbSig)
1328{
1329 LIMITED_METHOD_CONTRACT;
1330 return m_pInnerImport->GetTypeSpecFromToken(typespec, ppvSig, pcbSig);
1331}
1332
1333HRESULT ProfilerMetadataEmitValidator::GetNameFromToken(
1334 mdToken tk,
1335 MDUTF8CSTR *pszUtf8NamePtr)
1336{
1337 LIMITED_METHOD_CONTRACT;
1338 return m_pInnerImport->GetNameFromToken(tk, pszUtf8NamePtr);
1339}
1340
1341HRESULT ProfilerMetadataEmitValidator::EnumUnresolvedMethods(
1342 HCORENUM *phEnum,
1343 mdToken rMethods[],
1344 ULONG cMax,
1345 ULONG *pcTokens)
1346{
1347 LIMITED_METHOD_CONTRACT;
1348 return m_pInnerImport->EnumUnresolvedMethods(phEnum, rMethods, cMax, pcTokens);
1349}
1350
1351HRESULT ProfilerMetadataEmitValidator::GetUserString(
1352 mdString stk,
1353 LPWSTR szString,
1354 ULONG cchString,
1355 ULONG *pchString)
1356{
1357 LIMITED_METHOD_CONTRACT;
1358 return m_pInnerImport->GetUserString(stk, szString, cchString, pchString);
1359}
1360
1361HRESULT ProfilerMetadataEmitValidator::GetPinvokeMap(
1362 mdToken tk,
1363 DWORD *pdwMappingFlags,
1364 LPWSTR szImportName,
1365 ULONG cchImportName,
1366 ULONG *pchImportName,
1367 mdModuleRef *pmrImportDLL)
1368{
1369 LIMITED_METHOD_CONTRACT;
1370 return m_pInnerImport->GetPinvokeMap(tk, pdwMappingFlags, szImportName, cchImportName, pchImportName, pmrImportDLL);
1371}
1372
1373HRESULT ProfilerMetadataEmitValidator::EnumSignatures(
1374 HCORENUM *phEnum,
1375 mdSignature rSignatures[],
1376 ULONG cmax,
1377 ULONG *pcSignatures)
1378{
1379 LIMITED_METHOD_CONTRACT;
1380 return m_pInnerImport->EnumSignatures(phEnum, rSignatures, cmax, pcSignatures);
1381}
1382
1383HRESULT ProfilerMetadataEmitValidator::EnumTypeSpecs(
1384 HCORENUM *phEnum,
1385 mdTypeSpec rTypeSpecs[],
1386 ULONG cmax,
1387 ULONG *pcTypeSpecs)
1388{
1389 LIMITED_METHOD_CONTRACT;
1390 return m_pInnerImport->EnumTypeSpecs(phEnum, rTypeSpecs, cmax, pcTypeSpecs);
1391}
1392
1393HRESULT ProfilerMetadataEmitValidator::EnumUserStrings(
1394 HCORENUM *phEnum,
1395 mdString rStrings[],
1396 ULONG cmax,
1397 ULONG *pcStrings)
1398{
1399 LIMITED_METHOD_CONTRACT;
1400 return m_pInnerImport->EnumUserStrings(phEnum, rStrings, cmax, pcStrings);
1401}
1402
1403HRESULT ProfilerMetadataEmitValidator::GetParamForMethodIndex(
1404 mdMethodDef md,
1405 ULONG ulParamSeq,
1406 mdParamDef *ppd)
1407{
1408 LIMITED_METHOD_CONTRACT;
1409 return m_pInnerImport->GetParamForMethodIndex(md, ulParamSeq, ppd);
1410}
1411
1412HRESULT ProfilerMetadataEmitValidator::EnumCustomAttributes(
1413 HCORENUM *phEnum,
1414 mdToken tk,
1415 mdToken tkType,
1416 mdCustomAttribute rCustomAttributes[],
1417 ULONG cMax,
1418 ULONG *pcCustomAttributes)
1419{
1420 LIMITED_METHOD_CONTRACT;
1421 return m_pInnerImport->EnumCustomAttributes(phEnum, tk, tkType, rCustomAttributes, cMax, pcCustomAttributes);
1422}
1423
1424HRESULT ProfilerMetadataEmitValidator::GetCustomAttributeProps(
1425 mdCustomAttribute cv,
1426 mdToken *ptkObj,
1427 mdToken *ptkType,
1428 void const **ppBlob,
1429 ULONG *pcbSize)
1430{
1431 LIMITED_METHOD_CONTRACT;
1432 return m_pInnerImport->GetCustomAttributeProps(cv, ptkObj, ptkType, ppBlob, pcbSize);
1433}
1434
1435HRESULT ProfilerMetadataEmitValidator::FindTypeRef(
1436 mdToken tkResolutionScope,
1437 LPCWSTR szName,
1438 mdTypeRef *ptr)
1439{
1440 LIMITED_METHOD_CONTRACT;
1441 return m_pInnerImport->FindTypeRef(tkResolutionScope, szName, ptr);
1442}
1443
1444HRESULT ProfilerMetadataEmitValidator::GetMemberProps(
1445 mdToken mb,
1446 mdTypeDef *pClass,
1447 LPWSTR szMember,
1448 ULONG cchMember,
1449 ULONG *pchMember,
1450 DWORD *pdwAttr,
1451 PCCOR_SIGNATURE *ppvSigBlob,
1452 ULONG *pcbSigBlob,
1453 ULONG *pulCodeRVA,
1454 DWORD *pdwImplFlags,
1455 DWORD *pdwCPlusTypeFlag,
1456 UVCP_CONSTANT *ppValue,
1457 ULONG *pcchValue)
1458{
1459 LIMITED_METHOD_CONTRACT;
1460 return m_pInnerImport->GetMemberProps(mb, pClass, szMember, cchMember, pchMember, pdwAttr, ppvSigBlob, pcbSigBlob, pulCodeRVA, pdwImplFlags, pdwCPlusTypeFlag, ppValue, pcchValue);
1461}
1462
1463HRESULT ProfilerMetadataEmitValidator::GetFieldProps(
1464 mdFieldDef mb,
1465 mdTypeDef *pClass,
1466 LPWSTR szField,
1467 ULONG cchField,
1468 ULONG *pchField,
1469 DWORD *pdwAttr,
1470 PCCOR_SIGNATURE *ppvSigBlob,
1471 ULONG *pcbSigBlob,
1472 DWORD *pdwCPlusTypeFlag,
1473 UVCP_CONSTANT *ppValue,
1474 ULONG *pcchValue)
1475{
1476 LIMITED_METHOD_CONTRACT;
1477 return m_pInnerImport->GetFieldProps(mb, pClass, szField, cchField, pchField, pdwAttr, ppvSigBlob, pcbSigBlob, pdwCPlusTypeFlag, ppValue, pcchValue);
1478}
1479
1480HRESULT ProfilerMetadataEmitValidator::GetPropertyProps(
1481 mdProperty prop,
1482 mdTypeDef *pClass,
1483 LPCWSTR szProperty,
1484 ULONG cchProperty,
1485 ULONG *pchProperty,
1486 DWORD *pdwPropFlags,
1487 PCCOR_SIGNATURE *ppvSig,
1488 ULONG *pbSig,
1489 DWORD *pdwCPlusTypeFlag,
1490 UVCP_CONSTANT *ppDefaultValue,
1491 ULONG *pcchDefaultValue,
1492 mdMethodDef *pmdSetter,
1493 mdMethodDef *pmdGetter,
1494 mdMethodDef rmdOtherMethod[],
1495 ULONG cMax,
1496 ULONG *pcOtherMethod)
1497{
1498 LIMITED_METHOD_CONTRACT;
1499 return m_pInnerImport->GetPropertyProps(prop, pClass, szProperty, cchProperty, pchProperty, pdwPropFlags, ppvSig, pbSig, pdwCPlusTypeFlag, ppDefaultValue, pcchDefaultValue, pmdSetter, pmdGetter,
1500 rmdOtherMethod, cMax, pcOtherMethod);
1501}
1502
1503HRESULT ProfilerMetadataEmitValidator::GetParamProps(
1504 mdParamDef tk,
1505 mdMethodDef *pmd,
1506 ULONG *pulSequence,
1507 LPWSTR szName,
1508 ULONG cchName,
1509 ULONG *pchName,
1510 DWORD *pdwAttr,
1511 DWORD *pdwCPlusTypeFlag,
1512 UVCP_CONSTANT *ppValue,
1513 ULONG *pcchValue)
1514{
1515 LIMITED_METHOD_CONTRACT;
1516 return m_pInnerImport->GetParamProps(tk, pmd, pulSequence, szName, cchName, pchName, pdwAttr, pdwCPlusTypeFlag, ppValue, pcchValue);
1517}
1518
1519HRESULT ProfilerMetadataEmitValidator::GetCustomAttributeByName(
1520 mdToken tkObj,
1521 LPCWSTR szName,
1522 const void **ppData,
1523 ULONG *pcbData)
1524{
1525 LIMITED_METHOD_CONTRACT;
1526 return m_pInnerImport->GetCustomAttributeByName(tkObj, szName, ppData, pcbData);
1527}
1528
1529BOOL ProfilerMetadataEmitValidator::IsValidToken(
1530 mdToken tk)
1531{
1532 LIMITED_METHOD_CONTRACT;
1533 return m_pInnerImport->IsValidToken(tk);
1534}
1535
1536HRESULT ProfilerMetadataEmitValidator::GetNestedClassProps(
1537 mdTypeDef tdNestedClass,
1538 mdTypeDef *ptdEnclosingClass)
1539{
1540 LIMITED_METHOD_CONTRACT;
1541 return m_pInnerImport->GetNestedClassProps(tdNestedClass, ptdEnclosingClass);
1542}
1543
1544HRESULT ProfilerMetadataEmitValidator::GetNativeCallConvFromSig(
1545 void const *pvSig,
1546 ULONG cbSig,
1547 ULONG *pCallConv)
1548{
1549 LIMITED_METHOD_CONTRACT;
1550 return m_pInnerImport->GetNativeCallConvFromSig(pvSig, cbSig, pCallConv);
1551}
1552
1553HRESULT ProfilerMetadataEmitValidator::IsGlobal(
1554 mdToken pd,
1555 int *pbGlobal)
1556{
1557 LIMITED_METHOD_CONTRACT;
1558 return m_pInnerImport->IsGlobal(pd, pbGlobal);
1559}
1560
1561//IMetaDataImport2
1562HRESULT ProfilerMetadataEmitValidator::EnumGenericParams(
1563 HCORENUM *phEnum,
1564 mdToken tk,
1565 mdGenericParam rGenericParams[],
1566 ULONG cMax,
1567 ULONG *pcGenericParams)
1568{
1569 LIMITED_METHOD_CONTRACT;
1570 return m_pInnerImport->EnumGenericParams(phEnum, tk, rGenericParams, cMax, pcGenericParams);
1571}
1572
1573
1574HRESULT ProfilerMetadataEmitValidator::GetGenericParamProps(
1575 mdGenericParam gp,
1576 ULONG *pulParamSeq,
1577 DWORD *pdwParamFlags,
1578 mdToken *ptOwner,
1579 DWORD *reserved,
1580 LPWSTR wzname,
1581 ULONG cchName,
1582 ULONG *pchName)
1583{
1584 LIMITED_METHOD_CONTRACT;
1585 return m_pInnerImport->GetGenericParamProps(gp, pulParamSeq, pdwParamFlags, ptOwner, reserved, wzname, cchName, pchName);
1586}
1587
1588HRESULT ProfilerMetadataEmitValidator::GetMethodSpecProps(
1589 mdMethodSpec mi,
1590 mdToken *tkParent,
1591 PCCOR_SIGNATURE *ppvSigBlob,
1592 ULONG *pcbSigBlob)
1593{
1594 LIMITED_METHOD_CONTRACT;
1595 return m_pInnerImport->GetMethodSpecProps(mi, tkParent, ppvSigBlob, pcbSigBlob);
1596}
1597
1598HRESULT ProfilerMetadataEmitValidator::EnumGenericParamConstraints(
1599 HCORENUM *phEnum,
1600 mdGenericParam tk,
1601 mdGenericParamConstraint rGenericParamConstraints[],
1602 ULONG cMax,
1603 ULONG *pcGenericParamConstraints)
1604{
1605 LIMITED_METHOD_CONTRACT;
1606 return m_pInnerImport->EnumGenericParamConstraints(phEnum, tk, rGenericParamConstraints, cMax, pcGenericParamConstraints);
1607}
1608
1609HRESULT ProfilerMetadataEmitValidator::GetGenericParamConstraintProps(
1610 mdGenericParamConstraint gpc,
1611 mdGenericParam *ptGenericParam,
1612 mdToken *ptkConstraintType)
1613{
1614 LIMITED_METHOD_CONTRACT;
1615 return m_pInnerImport->GetGenericParamConstraintProps(gpc, ptGenericParam, ptkConstraintType);
1616}
1617
1618HRESULT ProfilerMetadataEmitValidator::GetPEKind(
1619 DWORD* pdwPEKind,
1620 DWORD* pdwMachine)
1621{
1622 LIMITED_METHOD_CONTRACT;
1623 return m_pInnerImport->GetPEKind(pdwPEKind, pdwMachine);
1624}
1625
1626HRESULT ProfilerMetadataEmitValidator::GetVersionString(
1627 LPWSTR pwzBuf,
1628 DWORD ccBufSize,
1629 DWORD *pccBufSize)
1630{
1631 LIMITED_METHOD_CONTRACT;
1632 return m_pInnerImport->GetVersionString(pwzBuf, ccBufSize, pccBufSize);
1633}
1634
1635HRESULT ProfilerMetadataEmitValidator::EnumMethodSpecs(
1636 HCORENUM *phEnum,
1637 mdToken tk,
1638 mdMethodSpec rMethodSpecs[],
1639 ULONG cMax,
1640 ULONG *pcMethodSpecs)
1641{
1642 LIMITED_METHOD_CONTRACT;
1643 return m_pInnerImport->EnumMethodSpecs(phEnum, tk, rMethodSpecs, cMax, pcMethodSpecs);
1644}
1645
1646
1647// IMetaDataAssemblyImport
1648HRESULT ProfilerMetadataEmitValidator::GetAssemblyProps(
1649 mdAssembly mda,
1650 const void **ppbPublicKey,
1651 ULONG *pcbPublicKey,
1652 ULONG *pulHashAlgId,
1653 LPWSTR szName,
1654 ULONG cchName,
1655 ULONG *pchName,
1656 ASSEMBLYMETADATA *pMetaData,
1657 DWORD *pdwAssemblyFlags)
1658{
1659 LIMITED_METHOD_CONTRACT;
1660 return m_pInnerAssemblyImport->GetAssemblyProps(mda, ppbPublicKey, pcbPublicKey, pulHashAlgId, szName, cchName, pchName, pMetaData, pdwAssemblyFlags);
1661}
1662
1663HRESULT ProfilerMetadataEmitValidator::GetAssemblyRefProps(
1664 mdAssemblyRef mdar,
1665 const void **ppbPublicKeyOrToken,
1666 ULONG *pcbPublicKeyOrToken,
1667 LPWSTR szName,
1668 ULONG cchName,
1669 ULONG *pchName,
1670 ASSEMBLYMETADATA *pMetaData,
1671 const void **ppbHashValue,
1672 ULONG *pcbHashValue,
1673 DWORD *pdwAssemblyRefFlags)
1674{
1675 LIMITED_METHOD_CONTRACT;
1676 return m_pInnerAssemblyImport->GetAssemblyRefProps(mdar, ppbPublicKeyOrToken, pcbPublicKeyOrToken, szName, cchName, pchName, pMetaData, ppbHashValue, pcbHashValue, pdwAssemblyRefFlags);
1677}
1678
1679HRESULT ProfilerMetadataEmitValidator::GetFileProps(
1680 mdFile mdf,
1681 LPWSTR szName,
1682 ULONG cchName,
1683 ULONG *pchName,
1684 const void **ppbHashValue,
1685 ULONG *pcbHashValue,
1686 DWORD *pdwFileFlags)
1687{
1688 LIMITED_METHOD_CONTRACT;
1689 return m_pInnerAssemblyImport->GetFileProps(mdf, szName, cchName, pchName, ppbHashValue, pcbHashValue, pdwFileFlags);
1690}
1691
1692HRESULT ProfilerMetadataEmitValidator::GetExportedTypeProps(
1693 mdExportedType mdct,
1694 LPWSTR szName,
1695 ULONG cchName,
1696 ULONG *pchName,
1697 mdToken *ptkImplementation,
1698 mdTypeDef *ptkTypeDef,
1699 DWORD *pdwExportedTypeFlags)
1700{
1701 LIMITED_METHOD_CONTRACT;
1702 return m_pInnerAssemblyImport->GetExportedTypeProps(mdct, szName, cchName, pchName, ptkImplementation, ptkTypeDef, pdwExportedTypeFlags);
1703}
1704
1705HRESULT ProfilerMetadataEmitValidator::GetManifestResourceProps(
1706 mdManifestResource mdmr,
1707 LPWSTR szName,
1708 ULONG cchName,
1709 ULONG *pchName,
1710 mdToken *ptkImplementation,
1711 DWORD *pdwOffset,
1712 DWORD *pdwResourceFlags)
1713{
1714 LIMITED_METHOD_CONTRACT;
1715 return m_pInnerAssemblyImport->GetManifestResourceProps(mdmr, szName, cchName, pchName, ptkImplementation, pdwOffset, pdwResourceFlags);
1716}
1717
1718HRESULT ProfilerMetadataEmitValidator::EnumAssemblyRefs(
1719 HCORENUM *phEnum,
1720 mdAssemblyRef rAssemblyRefs[],
1721 ULONG cMax,
1722 ULONG *pcTokens)
1723{
1724 LIMITED_METHOD_CONTRACT;
1725 return m_pInnerAssemblyImport->EnumAssemblyRefs(phEnum, rAssemblyRefs, cMax, pcTokens);
1726}
1727
1728HRESULT ProfilerMetadataEmitValidator::EnumFiles(
1729 HCORENUM *phEnum,
1730 mdFile rFiles[],
1731 ULONG cMax,
1732 ULONG *pcTokens)
1733{
1734 LIMITED_METHOD_CONTRACT;
1735 return m_pInnerAssemblyImport->EnumFiles(phEnum, rFiles, cMax, pcTokens);
1736}
1737
1738HRESULT ProfilerMetadataEmitValidator::EnumExportedTypes(
1739 HCORENUM *phEnum,
1740 mdExportedType rExportedTypes[],
1741 ULONG cMax,
1742 ULONG *pcTokens)
1743{
1744 LIMITED_METHOD_CONTRACT;
1745 return m_pInnerAssemblyImport->EnumExportedTypes(phEnum, rExportedTypes, cMax, pcTokens);
1746}
1747
1748HRESULT ProfilerMetadataEmitValidator::EnumManifestResources(
1749 HCORENUM *phEnum,
1750 mdManifestResource rManifestResources[],
1751 ULONG cMax,
1752 ULONG *pcTokens)
1753{
1754 LIMITED_METHOD_CONTRACT;
1755 return m_pInnerAssemblyImport->EnumManifestResources(phEnum, rManifestResources, cMax, pcTokens);
1756}
1757
1758HRESULT ProfilerMetadataEmitValidator::GetAssemblyFromScope(
1759 mdAssembly *ptkAssembly)
1760{
1761 LIMITED_METHOD_CONTRACT;
1762 return m_pInnerAssemblyImport->GetAssemblyFromScope(ptkAssembly);
1763}
1764
1765HRESULT ProfilerMetadataEmitValidator::FindExportedTypeByName(
1766 LPCWSTR szName,
1767 mdToken mdtExportedType,
1768 mdExportedType *ptkExportedType)
1769{
1770 LIMITED_METHOD_CONTRACT;
1771 return m_pInnerAssemblyImport->FindExportedTypeByName(szName, mdtExportedType, ptkExportedType);
1772}
1773
1774HRESULT ProfilerMetadataEmitValidator::FindManifestResourceByName(
1775 LPCWSTR szName,
1776 mdManifestResource *ptkManifestResource)
1777{
1778 LIMITED_METHOD_CONTRACT;
1779 return m_pInnerAssemblyImport->FindManifestResourceByName(szName, ptkManifestResource);
1780}
1781
1782HRESULT ProfilerMetadataEmitValidator::FindAssembliesByName(
1783 LPCWSTR szAppBase,
1784 LPCWSTR szPrivateBin,
1785 LPCWSTR szAssemblyName,
1786 IUnknown *ppIUnk[],
1787 ULONG cMax,
1788 ULONG *pcAssemblies)
1789{
1790 LIMITED_METHOD_CONTRACT;
1791 return m_pInnerAssemblyImport->FindAssembliesByName(szAppBase, szPrivateBin, szAssemblyName, ppIUnk, cMax, pcAssemblies);
1792}
1793