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.
12 #include "custommarshalerinfo.h"
14 #ifdef FEATURE_COMINTEROP
15 #include <windows.ui.xaml.h>
21 #define NATIVE_TYPE_DEFAULT NATIVE_TYPE_MAX
22 #define VARIABLESIZE ((BYTE)(-1))
25 #ifdef FEATURE_COMINTEROP
26 class DispParamMarshaler;
27 #endif // FEATURE_COMINTEROP
29 #ifdef FEATURE_COMINTEROP
30 enum DispatchWrapperType
32 DispatchWrapperType_Unknown = 0x00000001,
33 DispatchWrapperType_Dispatch = 0x00000002,
34 //DispatchWrapperType_Record = 0x00000004,
35 DispatchWrapperType_Error = 0x00000008,
36 DispatchWrapperType_Currency = 0x00000010,
37 DispatchWrapperType_BStr = 0x00000020,
38 DispatchWrapperType_SafeArray = 0x00010000
40 #endif // FEATURE_COMINTEROP
47 } MarshalerOverrideStatus;
52 MARSHAL_FLAG_CLR_TO_NATIVE = 0x01,
53 MARSHAL_FLAG_IN = 0x02,
54 MARSHAL_FLAG_OUT = 0x04,
55 MARSHAL_FLAG_BYREF = 0x08,
56 MARSHAL_FLAG_HRESULT_SWAP = 0x10,
57 MARSHAL_FLAG_RETVAL = 0x20,
58 MARSHAL_FLAG_HIDDENLENPARAM = 0x40,
62 // Captures arguments for C array marshaling.
63 struct CREATE_MARSHALER_CARRAY_OPERANDS
65 MethodTable* methodTable;
71 BYTE throwonunmappablechar;
75 struct OverrideProcArgs
77 class MarshalInfo* m_pMarshalInfo;
85 MethodTable* m_pArrayMT;
87 #ifdef FEATURE_COMINTEROP
88 SIZE_T m_cbElementSize;
89 WinMDAdapter::RedirectedTypeIndex m_redirectedTypeIndex;
90 #endif // FEATURE_COMINTEROP
96 MethodDesc* m_pCopyCtor;
103 mdToken m_paramToken;
104 void* m_hndManagedType; // TypeHandle cannot be a union member
105 } rcm; // MARSHAL_TYPE_REFERENCECUSTOMMARSHALER
110 typedef MarshalerOverrideStatus (*OVERRIDEPROC)(NDirectStubLinker* psl,
114 BOOL fManagedToNative,
115 OverrideProcArgs* pargs,
118 UINT nativeStackOffset);
120 typedef MarshalerOverrideStatus (*RETURNOVERRIDEPROC)(NDirectStubLinker* psl,
121 BOOL fManagedToNative,
123 OverrideProcArgs* pargs,
126 //==========================================================================
127 // This structure contains the native type information for a given
129 //==========================================================================
130 struct NativeTypeParamInfo
132 NativeTypeParamInfo()
133 : m_NativeType(NATIVE_TYPE_DEFAULT)
134 , m_ArrayElementType(NATIVE_TYPE_DEFAULT)
135 , m_SizeIsSpecified(FALSE)
139 , m_strCMMarshalerTypeName(NULL)
140 , m_cCMMarshalerTypeNameBytes(0)
141 , m_strCMCookie(NULL)
142 , m_cCMCookieStrBytes(0)
143 #ifdef FEATURE_COMINTEROP
144 , m_SafeArrayElementVT(VT_EMPTY)
145 , m_strSafeArrayUserDefTypeName(NULL)
146 , m_cSafeArrayUserDefTypeNameBytes(0)
147 , m_IidParamIndex(-1)
148 , m_strInterfaceTypeName(NULL)
149 , m_cInterfaceTypeNameBytes(0)
150 #endif // FEATURE_COMINTEROP
152 LIMITED_METHOD_CONTRACT;
155 // The native type of the parameter.
156 CorNativeType m_NativeType;
159 CorNativeType m_ArrayElementType; // The array element type.
161 BOOL m_SizeIsSpecified; // used to do some validation
162 UINT16 m_CountParamIdx; // index of "sizeis" parameter
163 UINT32 m_Multiplier; // multipler for "sizeis"
164 UINT32 m_Additive; // additive for 'sizeis"
166 // For NT_CUSTOMMARSHALER only.
167 LPUTF8 m_strCMMarshalerTypeName;
168 DWORD m_cCMMarshalerTypeNameBytes;
169 LPUTF8 m_strCMCookie;
170 DWORD m_cCMCookieStrBytes;
172 #ifdef FEATURE_COMINTEROP
173 // For NT_SAFEARRAY only.
174 VARTYPE m_SafeArrayElementVT;
175 LPUTF8 m_strSafeArrayUserDefTypeName;
176 DWORD m_cSafeArrayUserDefTypeNameBytes;
178 DWORD m_IidParamIndex; // Capture iid_is syntax from IDL.
180 // for NATIVE_TYPE_SPECIFIED_INTERFACE
181 LPUTF8 m_strInterfaceTypeName;
182 DWORD m_cInterfaceTypeNameBytes;
183 #endif // FEATURE_COMINTEROP
186 HRESULT CheckForCompressedData(PCCOR_SIGNATURE pvNativeTypeStart, PCCOR_SIGNATURE pvNativeType, ULONG cbNativeType);
188 BOOL ParseNativeTypeInfo(mdToken token,
189 IMDInternalImport* pScope,
190 NativeTypeParamInfo* pParamInfo);
192 void VerifyAndAdjustNormalizedType(
195 const SigTypeContext * pTypeContext,
196 CorElementType * pManagedElemType,
197 CorNativeType * pNativeType);
199 #ifdef FEATURE_COMINTEROP
201 class EventArgsMarshalingInfo
205 EventArgsMarshalingInfo();
208 ~EventArgsMarshalingInfo();
210 // EventArgsMarshalingInfo's are always allocated on the loader heap so we need to redefine
211 // the new and delete operators to ensure this.
212 void *operator new(size_t size, LoaderHeap *pHeap);
213 void operator delete(void *pMem);
216 TypeHandle GetSystemNCCEventArgsType()
218 LIMITED_METHOD_CONTRACT;
219 return m_hndSystemNCCEventArgsType;
222 TypeHandle GetSystemPCEventArgsType()
224 LIMITED_METHOD_CONTRACT;
225 return m_hndSystemPCEventArgsType;
228 MethodDesc *GetSystemNCCEventArgsToWinRTNCCEventArgsMD()
230 LIMITED_METHOD_CONTRACT;
231 return m_pSystemNCCEventArgsToWinRTNCCEventArgsMD;
234 MethodDesc *GetWinRTNCCEventArgsToSystemNCCEventArgsMD()
236 LIMITED_METHOD_CONTRACT;
237 return m_pWinRTNCCEventArgsToSystemNCCEventArgsMD;
240 MethodDesc *GetSystemPCEventArgsToWinRTPCEventArgsMD()
242 LIMITED_METHOD_CONTRACT;
243 return m_pSystemPCEventArgsToWinRTPCEventArgsMD;
246 MethodDesc *GetWinRTPCEventArgsToSystemPCEventArgsMD()
248 LIMITED_METHOD_CONTRACT;
249 return m_pWinRTPCEventArgsToSystemPCEventArgsMD;
254 TypeHandle m_hndSystemNCCEventArgsType;
255 TypeHandle m_hndSystemPCEventArgsType;
257 MethodDesc *m_pSystemNCCEventArgsToWinRTNCCEventArgsMD;
258 MethodDesc *m_pWinRTNCCEventArgsToSystemNCCEventArgsMD;
259 MethodDesc *m_pSystemPCEventArgsToWinRTPCEventArgsMD;
260 MethodDesc *m_pWinRTPCEventArgsToSystemPCEventArgsMD;
263 class UriMarshalingInfo
270 ~UriMarshalingInfo();
272 // UriMarshalingInfo's are always allocated on the loader heap so we need to redefine
273 // the new and delete operators to ensure this.
274 void *operator new(size_t size, LoaderHeap *pHeap);
275 void operator delete(void *pMem);
278 TypeHandle GetSystemUriType()
280 LIMITED_METHOD_CONTRACT;
281 return m_hndSystemUriType;
284 ABI::Windows::Foundation::IUriRuntimeClassFactory* GetUriFactory()
289 GC_TRIGGERS; // For potential COOP->PREEMP->COOP switch
291 PRECONDITION(!GetAppDomain()->IsCompilationDomain());
295 if (m_pUriFactory.Load() == NULL)
299 SafeComHolderPreemp<ABI::Windows::Foundation::IUriRuntimeClassFactory> pUriFactory;
301 // IUriRuntimeClassFactory: 44A9796F-723E-4FDF-A218-033E75B0C084
302 IfFailThrow(clr::winrt::GetActivationFactory(g_WinRTUriClassNameW, (ABI::Windows::Foundation::IUriRuntimeClassFactory **)&pUriFactory));
303 _ASSERTE_MSG(pUriFactory, "Got Null Uri factory!");
305 if (InterlockedCompareExchangeT(&m_pUriFactory, (ABI::Windows::Foundation::IUriRuntimeClassFactory *) pUriFactory, NULL) == NULL)
306 pUriFactory.SuppressRelease();
309 return m_pUriFactory;
312 MethodDesc *GetSystemUriCtorMD()
314 LIMITED_METHOD_CONTRACT;
315 return m_SystemUriCtorMD;
318 MethodDesc *GetSystemUriOriginalStringMD()
320 LIMITED_METHOD_CONTRACT;
321 return m_SystemUriOriginalStringGetterMD;
326 TypeHandle m_hndSystemUriType;
328 MethodDesc* m_SystemUriCtorMD;
329 MethodDesc* m_SystemUriOriginalStringGetterMD;
331 VolatilePtr<ABI::Windows::Foundation::IUriRuntimeClassFactory> m_pUriFactory;
334 class OleColorMarshalingInfo
338 OleColorMarshalingInfo();
340 // OleColorMarshalingInfo's are always allocated on the loader heap so we need to redefine
341 // the new and delete operators to ensure this.
342 void *operator new(size_t size, LoaderHeap *pHeap);
343 void operator delete(void *pMem);
346 TypeHandle GetColorType()
348 LIMITED_METHOD_CONTRACT;
349 return m_hndColorType;
351 MethodDesc *GetOleColorToSystemColorMD()
353 LIMITED_METHOD_CONTRACT;
354 return m_OleColorToSystemColorMD;
356 MethodDesc *GetSystemColorToOleColorMD()
358 LIMITED_METHOD_CONTRACT;
359 return m_SystemColorToOleColorMD;
364 TypeHandle m_hndColorType;
365 MethodDesc* m_OleColorToSystemColorMD;
366 MethodDesc* m_SystemColorToOleColorMD;
369 #endif // FEATURE_COMINTEROP
372 class EEMarshalingData
375 EEMarshalingData(LoaderAllocator *pAllocator, CrstBase *pCrst);
378 // EEMarshalingData's are always allocated on the loader heap so we need to redefine
379 // the new and delete operators to ensure this.
380 void *operator new(size_t size, LoaderHeap *pHeap);
381 void operator delete(void *pMem);
383 // This method returns the custom marshaling helper associated with the name cookie pair. If the
384 // CM info has not been created yet for this pair then it will be created and returned.
385 CustomMarshalerHelper *GetCustomMarshalerHelper(Assembly *pAssembly, TypeHandle hndManagedType, LPCUTF8 strMarshalerTypeName, DWORD cMarshalerTypeNameBytes, LPCUTF8 strCookie, DWORD cCookieStrBytes);
387 // This method returns the custom marshaling info associated with shared CM helper.
388 CustomMarshalerInfo *GetCustomMarshalerInfo(SharedCustomMarshalerHelper *pSharedCMHelper);
390 #ifdef FEATURE_COMINTEROP
391 // This method retrieves OLE_COLOR marshaling info.
392 OleColorMarshalingInfo *GetOleColorMarshalingInfo();
393 UriMarshalingInfo *GetUriMarshalingInfo();
394 EventArgsMarshalingInfo *GetEventArgsMarshalingInfo();
397 #endif // FEATURE_COMINTEROP
400 #ifndef CROSSGEN_COMPILE
401 EECMHelperHashTable m_CMHelperHashtable;
402 EEPtrHashTable m_SharedCMHelperToCMInfoMap;
403 #endif // CROSSGEN_COMPILE
404 LoaderAllocator* m_pAllocator;
406 CMINFOLIST m_pCMInfoList;
407 #ifdef FEATURE_COMINTEROP
408 OleColorMarshalingInfo* m_pOleColorInfo;
409 UriMarshalingInfo* m_pUriInfo;
410 EventArgsMarshalingInfo* m_pEventArgsInfo;
411 #endif // FEATURE_COMINTEROP
415 struct ItfMarshalInfo;
422 #define DEFINE_MARSHALER_TYPE(mtype, mclass, fWinRTSupported) mtype,
429 MARSHAL_SCENARIO_NDIRECT,
430 #ifdef FEATURE_COMINTEROP
431 MARSHAL_SCENARIO_COMINTEROP,
432 MARSHAL_SCENARIO_WINRT,
433 #endif // FEATURE_COMINTEROP
434 MARSHAL_SCENARIO_FIELD
440 void *operator new(size_t size, void *pInPlace)
442 LIMITED_METHOD_CONTRACT;
446 MarshalInfo(Module* pModule,
448 const SigTypeContext *pTypeContext,
451 CorNativeLinkType nlType,
452 CorNativeLinkFlags nlFlags,
454 UINT paramidx, // parameter # for use in error messages (ignored if not parameter)
455 UINT numArgs, // number of arguments. used to check SizeParamIndex is within valid range
457 BOOL ThrowOnUnmappableChar,
459 BOOL onInstanceMethod,
460 MethodDesc* pMD = NULL,
461 BOOL fUseCustomMarshal = TRUE
464 LPCUTF8 pDebugName = NULL,
465 LPCUTF8 pDebugClassName = NULL,
466 UINT argidx = 0 // 0 for return value, -1 for field
471 VOID EmitOrThrowInteropParamException(NDirectStubLinker* psl, BOOL fMngToNative, UINT resID, UINT paramIdx);
473 // These methods retrieve the information for different element types.
474 HRESULT HandleArrayElemType(NativeTypeParamInfo *pParamInfo,
475 TypeHandle elemTypeHnd,
479 Assembly *pAssembly);
481 void GenerateArgumentIL(NDirectStubLinker* psl,
482 int argOffset, // the argument's index is m_paramidx + argOffset
483 UINT nativeStackOffset, // offset of the argument on the native stack
486 void GenerateReturnIL(NDirectStubLinker* psl,
487 int argOffset, // the argument's index is m_paramidx + argOffset
492 void SetupArgumentSizes();
494 UINT16 GetNativeArgSize()
496 LIMITED_METHOD_CONTRACT;
497 return m_nativeArgSize;
500 MarshalType GetMarshalType()
502 LIMITED_METHOD_CONTRACT;
506 BYTE GetBestFitMapping()
508 LIMITED_METHOD_CONTRACT;
509 return ((m_BestFit == 0) ? 0 : 1);
512 BYTE GetThrowOnUnmappableChar()
514 LIMITED_METHOD_CONTRACT;
515 return ((m_ThrowOnUnmappableChar == 0) ? 0 : 1);
520 LIMITED_METHOD_CONTRACT;
521 return m_type == MARSHAL_TYPE_FLOAT || m_type == MARSHAL_TYPE_DOUBLE;
526 LIMITED_METHOD_CONTRACT;
532 LIMITED_METHOD_CONTRACT;
538 LIMITED_METHOD_CONTRACT;
544 LIMITED_METHOD_CONTRACT;
550 LIMITED_METHOD_CONTRACT;
554 BOOL GetNoLowerBounds()
556 LIMITED_METHOD_CONTRACT;
557 return m_nolowerbounds;
560 #ifdef FEATURE_COMINTEROP
561 void SetHiddenLengthParamIndex(UINT16 index)
563 LIMITED_METHOD_CONTRACT;
564 _ASSERTE(m_hiddenLengthParamIndex == (UINT16)-1);
565 m_hiddenLengthParamIndex = index;
568 UINT16 HiddenLengthParamIndex()
570 LIMITED_METHOD_CONTRACT;
571 _ASSERTE(m_hiddenLengthParamIndex != (UINT16)-1);
572 return m_hiddenLengthParamIndex;
575 DWORD GetHiddenLengthManagedHome()
577 LIMITED_METHOD_CONTRACT;
578 _ASSERTE(m_dwHiddenLengthManagedHomeLocal != 0xFFFFFFFF);
579 return m_dwHiddenLengthManagedHomeLocal;
582 DWORD GetHiddenLengthNativeHome()
584 LIMITED_METHOD_CONTRACT;
585 _ASSERTE(m_dwHiddenLengthNativeHomeLocal != 0xFFFFFFFF);
586 return m_dwHiddenLengthNativeHomeLocal;
589 MarshalType GetHiddenLengthParamMarshalType();
590 CorElementType GetHiddenLengthParamElementType();
591 UINT16 GetHiddenLengthParamStackSize();
593 void MarshalHiddenLengthArgument(NDirectStubLinker *psl, BOOL managedToNative, BOOL isForReturnArray);
594 #endif // FEATURE_COMINTEROP
596 // used the same logic of tlbexp to check whether the argument of the method is a VarArg
597 BOOL IsOleVarArgCandidate()
599 LIMITED_METHOD_CONTRACT;
600 return m_fOleVarArgCandidate; // m_fOleVarArgCandidate is set in the constructor method
603 void GetMops(CREATE_MARSHALER_CARRAY_OPERANDS* pMopsOut)
606 pMopsOut->methodTable = m_hndArrayElemType.AsMethodTable();
607 pMopsOut->elementType = m_arrayElementType;
608 pMopsOut->countParamIdx = m_countParamIdx;
609 pMopsOut->multiplier = m_multiplier;
610 pMopsOut->additive = m_additive;
611 pMopsOut->bestfitmapping = GetBestFitMapping();
612 pMopsOut->throwonunmappablechar = GetThrowOnUnmappableChar();
615 TypeHandle GetArrayElementTypeHandle()
617 return m_hndArrayElemType;
620 #ifdef FEATURE_COMINTEROP
621 DispParamMarshaler *GenerateDispParamMarshaler();
622 DispatchWrapperType GetDispWrapperType();
623 #endif // FEATURE_COMINTEROP
625 void GetItfMarshalInfo(ItfMarshalInfo* pInfo);
627 // Helper functions used to map the specified type to its interface marshalling info.
628 static void GetItfMarshalInfo(TypeHandle th, TypeHandle thItf, BOOL fDispItf, BOOL fInspItf, MarshalScenario ms, ItfMarshalInfo *pInfo);
629 static HRESULT TryGetItfMarshalInfo(TypeHandle th, BOOL fDispItf, BOOL fInspItf, ItfMarshalInfo *pInfo);
631 VOID MarshalTypeToString(SString& strMarshalType, BOOL fSizeIsSpecified);
632 static VOID VarTypeToString(VARTYPE vt, SString& strVarType);
634 // Returns true if the specified marshaler requires COM to have been started.
635 bool MarshalerRequiresCOM();
637 MethodDesc *GetMethodDesc()
639 LIMITED_METHOD_CONTRACT;
645 LIMITED_METHOD_CONTRACT;
649 #ifdef FEATURE_COMINTEROP
650 BOOL IsWinRTScenario()
652 LIMITED_METHOD_CONTRACT;
654 return m_ms == MarshalInfo::MARSHAL_SCENARIO_WINRT;
656 #endif // FEATURE_COMINTEROP
660 UINT16 GetManagedSize(MarshalType mtype, MarshalScenario ms);
661 UINT16 GetNativeSize(MarshalType mtype, MarshalScenario ms);
662 static bool IsInOnly(MarshalType mtype);
663 static bool IsSupportedForWinRT(MarshalType mtype);
665 static OVERRIDEPROC GetArgumentOverrideProc(MarshalType mtype);
666 static RETURNOVERRIDEPROC GetReturnOverrideProc(MarshalType mtype);
669 VOID DumpMarshalInfo(Module* pModule, SigPointer sig, const SigTypeContext *pTypeContext, mdToken token,
670 MarshalScenario ms, CorNativeLinkType nlType, CorNativeLinkFlags nlFlags);
678 MethodTable* m_pMT; // Used if this is a true value type
679 MethodDesc* m_pMD; // Save MethodDesc for later inspection so that we can pass SizeParamIndex by ref
680 TypeHandle m_hndArrayElemType;
681 VARTYPE m_arrayElementType;
683 BOOL m_nolowerbounds; // if managed type is SZARRAY, don't allow lower bounds
686 UINT32 m_multiplier; // multipler for "sizeis"
687 UINT32 m_additive; // additive for 'sizeis"
688 UINT16 m_countParamIdx; // index of "sizeis" parameter
690 #ifdef FEATURE_COMINTEROP
691 // For NATIVE_TYPE_HIDDENLENGTHARRAY
692 UINT16 m_hiddenLengthParamIndex; // index of the injected hidden length parameter
693 DWORD m_dwHiddenLengthManagedHomeLocal; // home local for the managed hidden length parameter
694 DWORD m_dwHiddenLengthNativeHomeLocal; // home local for the native hidden length parameter
696 MethodTable* m_pDefaultItfMT; // WinRT default interface (if m_pMT is a class)
697 #endif // FEATURE_COMINTEROP
699 UINT16 m_nativeArgSize;
700 UINT16 m_managedArgSize;
702 MarshalScenario m_ms;
706 #ifdef FEATURE_COMINTEROP
707 BOOL m_fErrorNativeType;
708 #endif // FEATURE_COMINTEROP
710 // Information used by NT_CUSTOMMARSHALER.
711 CustomMarshalerHelper* m_pCMHelper;
714 OverrideProcArgs m_args;
717 UINT m_resID; // resource ID for error message (if any)
719 BOOL m_ThrowOnUnmappableChar;
721 BOOL m_fOleVarArgCandidate; // indicate whether the arg is a candidate for vararg or not
724 LPCUTF8 m_strDebugMethName;
725 LPCUTF8 m_strDebugClassName;
726 UINT m_iArg; // 0 for return value, -1 for field
735 // Flags used to control the behavior of the ArrayMarshalInfo class.
738 enum ArrayMarshalInfoFlags
741 amiExport32Bit = 0x0002,
742 amiExport64Bit = 0x0004,
744 amiSafeArraySubTypeExplicitlySpecified = 0x0010
747 #define IsAMIRuntime(flags) (flags & amiRuntime)
748 #define IsAMIExport(flags) (flags & (amiExport32Bit | amiExport64Bit))
749 #define IsAMIExport32Bit(flags) (flags & amiExport32Bit)
750 #define IsAMIExport64Bit(flags) (flags & amiExport64Bit)
751 #define IsAMIPtr(flags) (flags & amiIsPtr)
752 #define IsAMISafeArraySubTypeExplicitlySpecified(flags) (flags & amiSafeArraySubTypeExplicitlySpecified)
754 // Helper classes to determine the marshalling information for arrays.
757 class ArrayMarshalInfo
760 ArrayMarshalInfo(ArrayMarshalInfoFlags flags)
761 : m_vtElement(VT_EMPTY)
762 , m_errorResourceId(0)
764 #ifdef FEATURE_COMINTEROP
765 , m_redirectedTypeIndex((WinMDAdapter::RedirectedTypeIndex)0)
767 #endif // FEATURE_COMINTEROP
772 void InitForNativeArray(MarshalInfo::MarshalScenario ms, TypeHandle elemTypeHnd, CorNativeType elementNativeType, BOOL isAnsi);
773 void InitForFixedArray(TypeHandle elemTypeHnd, CorNativeType elementNativeType, BOOL isAnsi);
775 #ifdef FEATURE_COMINTEROP
776 void InitForSafeArray(MarshalInfo::MarshalScenario ms, TypeHandle elemTypeHnd, VARTYPE elementVT, BOOL isAnsi);
777 void InitForHiddenLengthArray(TypeHandle elemTypeHnd);
778 #endif // FEATURE_COMINTEROP
780 TypeHandle GetElementTypeHandle()
782 LIMITED_METHOD_CONTRACT;
788 LIMITED_METHOD_CONTRACT;
789 return IsAMIPtr(m_flags);
792 VARTYPE GetElementVT()
794 LIMITED_METHOD_CONTRACT;
795 if ((IsAMIRuntime(m_flags) && IsAMIPtr(m_flags)) != 0)
797 // for the purpose of marshaling, we don't care about the inner
798 // type - we just marshal pointer-sized values
799 return (sizeof(LPVOID) == 4 ? VT_I4 : VT_I8);
817 return m_vtElement != VT_EMPTY;
820 BOOL IsSafeArraySubTypeExplicitlySpecified()
822 LIMITED_METHOD_CONTRACT;
824 return IsAMISafeArraySubTypeExplicitlySpecified(m_flags);
827 DWORD GetErrorResourceId()
834 PRECONDITION(!IsValid());
838 return m_errorResourceId;
841 #ifdef FEATURE_COMINTEROP
842 WinMDAdapter::RedirectedTypeIndex GetRedirectedTypeIndex()
844 LIMITED_METHOD_CONTRACT;
845 return m_redirectedTypeIndex;
848 SIZE_T GetElementSize()
850 LIMITED_METHOD_CONTRACT;
851 return m_cbElementSize;
853 #endif // FEATURE_COMINTEROP
856 // Helper function that does the actual work to figure out the element type handle and var type.
857 void InitElementInfo(CorNativeType arrayNativeType, MarshalInfo::MarshalScenario ms, TypeHandle elemTypeHnd, CorNativeType elementNativeType, BOOL isAnsi);
859 VARTYPE GetPointerSize()
861 LIMITED_METHOD_CONTRACT;
863 // If we are exporting, use the pointer size specified via the flags, otherwise use
864 // the current size of a pointer.
865 if (IsAMIExport32Bit(m_flags))
867 else if (IsAMIExport64Bit(m_flags))
870 return sizeof(LPVOID);
874 TypeHandle m_thElement;
875 TypeHandle m_thInterfaceArrayElementClass;
877 DWORD m_errorResourceId;
878 ArrayMarshalInfoFlags m_flags;
880 #ifdef FEATURE_COMINTEROP
881 WinMDAdapter::RedirectedTypeIndex m_redirectedTypeIndex;
882 SIZE_T m_cbElementSize;
883 #endif // FEATURE_COMINTEROP
887 //===================================================================================
888 // Throws an exception indicating a param has invalid element type / native type
890 //===================================================================================
891 VOID ThrowInteropParamException(UINT resID, UINT paramIdx);
893 VOID CollateParamTokens(IMDInternalImport *pInternalImport, mdMethodDef md, ULONG numargs, mdParamDef *aParams);
894 bool IsUnsupportedTypedrefReturn(MetaSig& msig);
896 void FindCopyCtor(Module *pModule, MethodTable *pMT, MethodDesc **pMDOut);
897 void FindDtor(Module *pModule, MethodTable *pMT, MethodDesc **pMDOut);
899 // We'll cap the total native size at a (somewhat) arbitrary limit to ensure
900 // that we don't expose some overflow bug later on.
901 #define MAX_SIZE_FOR_INTEROP 0x7ffffff0