IMetaDataImport Interface
Provides methods for importing and manipulating existing metadata from a portable executable (PE) file or other source, such as a type library or a stand-alone, run-time metadata binary.
interface IMetaDataImport : IUnknown {
HRESULT CloseEnum (
HCORENUM hEnum
);
HRESULT CountEnum (
HCORENUM hEnum,
ULONG *pulCount
);
HRESULT EnumCustomAttributes (
HCORENUM *phEnum,
mdToken tk,
mdToken tkType,
mdCustomAttribute rCustomAttributes[],
ULONG cMax,
ULONG *pcCustomAttributes
);
HRESULT EnumEvents (
HCORENUM *phEnum,
mdTypeDef td,
mdEvent rEvents[],
ULONG cMax,
ULONG *pcEvents
);
HRESULT EnumFields (
HCORENUM *phEnum,
mdTypeDef cl,
mdFieldDef rFields[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumFieldsWithName (
HCORENUM *phEnum,
mdTypeDef cl,
LPCWSTR szName,
mdFieldDef rFields[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumInterfaceImpls (
HCORENUM *phEnum,
mdTypeDef td,
mdInterfaceImpl rImpls[],
ULONG cMax,
ULONG* pcImpls
);
HRESULT EnumMemberRefs (
HCORENUM *phEnum,
mdToken tkParent,
mdMemberRef rMemberRefs[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumMembers (
HCORENUM *phEnum,
mdTypeDef cl,
mdToken rMembers[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumMembersWithName (
HCORENUM *phEnum,
mdTypeDef cl,
LPCWSTR szName,
mdToken rMembers[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumMethodImpls (
HCORENUM *phEnum,
mdTypeDef td,
mdToken rMethodBody[],
mdToken rMethodDecl[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumMethods (
HCORENUM *phEnum,
mdTypeDef cl,
mdMethodDef rMethods[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumMethodSemantics (
HCORENUM *phEnum,
mdMethodDef mb,
mdToken rEventProp[],
ULONG cMax,
ULONG *pcEventProp
);
HRESULT EnumMethodsWithName (
HCORENUM *phEnum,
mdTypeDef cl,
LPCWSTR szName,
mdMethodDef rMethods[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumModuleRefs (
HCORENUM *phEnum,
mdModuleRef rModuleRefs[],
ULONG cMax,
ULONG *pcModuleRefs
);
HRESULT EnumParams (
HCORENUM *phEnum,
mdMethodDef mb,
mdParamDef rParams[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumPermissionSets
HCORENUM *phEnum,
mdToken tk,
DWORD dwActions,
mdPermission rPermission[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumProperties (
HCORENUM *phEnum,
mdTypeDef td,
mdProperty rProperties[],
ULONG cMax,
ULONG *pcProperties
);
HRESULT EnumSignatures (
HCORENUM *phEnum,
mdSignature rSignatures[],
ULONG cMax,
ULONG *pcSignatures
);
HRESULT EnumTypeDefs (
HCORENUM *phEnum,
mdTypeDef rTypeDefs[],
ULONG cMax,
ULONG *pcTypeDefs
);
HRESULT EnumTypeRefs (
HCORENUM *phEnum,
mdTypeRef rTypeRefs[],
ULONG cMax,
ULONG *pcTypeRefs
);
HRESULT EnumTypeSpecs (
HCORENUM *phEnum,
mdTypeSpec rTypeSpecs[],
ULONG cMax,
ULONG *pcTypeSpecs
);
HRESULT EnumUnresolvedMethods (
HCORENUM *phEnum,
mdToken rMethods[],
ULONG cMax,
ULONG *pcTokens
);
HRESULT EnumUserStrings (
HCORENUM *phEnum,
mdString rStrings[],
ULONG cMax,
ULONG *pcStrings
);
HRESULT FindField (
mdTypeDef td,
LPCWSTR szName,
PCCOR_SIGNATURE pvSigBlob,
ULONG cbSigBlob,
mdFieldDef *pmb
);
HRESULT FindMember (
mdTypeDef td,
LPCWSTR szName,
PCCOR_SIGNATURE pvSigBlob,
ULONG cbSigBlob,
mdToken *pmb
);
HRESULT FindMemberRef (
mdTypeRef td,
LPCWSTR szName,
PCCOR_SIGNATURE pvSigBlob,
ULONG cbSigBlob,
mdMemberRef *pmr
);
HRESULT FindMethod (
mdTypeDef td,
LPCWSTR szName,
PCCOR_SIGNATURE pvSigBlob,
ULONG cbSigBlob,
mdMethodDef *pmb
);
HRESULT FindTypeDefByName
LPCWSTR szTypeDef,
mdToken tkEnclosingClass,
mdTypeDef *ptd
);
HRESULT FindTypeRef (
mdToken tkResolutionScope,
LPCWSTR szName,
mdTypeRef *ptr
);
HRESULT GetClassLayout (
mdTypeDef td,
DWORD *pdwPackSize,
COR_FIELD_OFFSET rFieldOffset[],
ULONG cMax,
ULONG *pcFieldOffset,
ULONG *pulClassSize
);
HRESULT GetCustomAttributeByName (
mdToken tkObj,
LPCWSTR szName,
const void **ppData,
ULONG *pcbData
);
HRESULT GetCustomAttributeProps (
mdCustomAttribute cv,
mdToken *ptkObj,
mdToken *ptkType,
void const **ppBlob,
ULONG *pcbSize
);
HRESULT GetEventProps (
mdEvent ev,
mdTypeDef *pClass,
LPCWSTR szEvent,
ULONG cchEvent,
ULONG *pchEvent,
DWORD *pdwEventFlags,
mdToken *ptkEventType,
mdMethodDef *pmdAddOn,
mdMethodDef *pmdRemoveOn,
mdMethodDef *pmdFire,
mdMethodDef rmdOtherMethod[],
ULONG cMax,
ULONG *pcOtherMethod
);
HRESULT GetFieldMarshal (
mdToken tk,
PCCOR_SIGNATURE *ppvNativeType,
ULONG *pcbNativeType
);
HRESULT GetFieldProps (
mdFieldDef mb,
mdTypeDef *pClass,
LPWSTR szField,
ULONG cchField,
ULONG *pchField,
DWORD *pdwAttr,
PCCOR_SIGNATURE *ppvSigBlob,
ULONG *pcbSigBlob,
DWORD *pdwCPlusTypeFlag,
UVCP_CONSTANT *ppValue,
ULONG *pcchValue
);
HRESULT GetInterfaceImplProps (
mdInterfaceImpl iiImpl,
mdTypeDef *pClass,
mdToken *ptkIface)
);
HRESULT GetMemberProps (
mdToken mb,
mdTypeDef *pClass,
LPWSTR szMember,
ULONG cchMember,
ULONG *pchMember,
DWORD *pdwAttr,
PCCOR_SIGNATURE *ppvSigBlob,
ULONG *pcbSigBlob,
ULONG *pulCodeRVA,
DWORD *pdwImplFlags,
DWORD *pdwCPlusTypeFlag,
UVCP_CONSTANT *ppValue,
ULONG *pcchValue
);
HRESULT GetMemberRefProps (
mdMemberRef mr,
mdToken *ptk,
LPWSTR szMember,
ULONG cchMember,
ULONG *pchMember,
PCCOR_SIGNATURE *ppvSigBlob,
ULONG *pbSig
);
HRESULT GetMethodProps (
mdMethodDef mb,
mdTypeDef *pClass,
LPWSTR szMethod,
ULONG cchMethod,
ULONG *pchMethod,
DWORD *pdwAttr,
PCCOR_SIGNATURE *ppvSigBlob,
ULONG *pcbSigBlob,
ULONG *pulCodeRVA,
DWORD *pdwImplFlags
);
HRESULT GetMethodSemantics (
mdMethodDef mb,
mdToken tkEventProp,
DWORD *pdwSemanticsFlags
);
HRESULT GetModuleFromScope (
mdModule *pmd
);
HRESULT GetModuleRefProps (
mdModuleRef mur,
LPWSTR szName,
ULONG cchName,
ULONG *pchName
);
HRESULT GetNameFromToken (
mdToken tk,
MDUTF8CSTR *pszUtf8NamePtr
);
HRESULT GetNativeCallConvFromSig (
void const *pvSig,
ULONG cbSig,
ULONG *pCallConv
);
HRESULT GetNestedClassProps (
mdTypeDef tdNestedClass,
mdTypeDef *ptdEnclosingClass
);
HRESULT GetParamForMethodIndex (
mdMethodDef md,
ULONG ulParamSeq,
mdParamDef *ppd
);
HRESULT GetParamProps (
mdParamDef tk,
mdMethodDef *pmd,
ULONG *pulSequence,
LPWSTR szName,
ULONG cchName,
ULONG *pchName,
DWORD *pdwAttr,
DWORD *pdwCPlusTypeFlag,
UVCP_CONSTANT *ppValue,
ULONG *pcchValue
);
HRESULT GetPermissionSetProps (
mdPermission pm,
DWORD *pdwAction,
void const **ppvPermission,
ULONG *pcbPermission
);
HRESULT GetPinvokeMap (
mdToken tk,
DWORD *pdwMappingFlags,
LPWSTR szImportName,
ULONG cchImportName,
ULONG *pchImportName,
mdModuleRef *pmrImportDLL
);
HRESULT GetPropertyProps (
mdProperty prop,
mdTypeDef *pClass,
LPCWSTR szProperty,
ULONG cchProperty,
ULONG *pchProperty,
DWORD *pdwPropFlags,
PCCOR_SIGNATURE *ppvSig,
ULONG *pbSig,
DWORD *pdwCPlusTypeFlag,
UVCP_CONSTANT *ppDefaultValue,
ULONG *pcchDefaultValue,
mdMethodDef *pmdSetter,
mdMethodDef *pmdGetter,
mdMethodDef rmdOtherMethod[],
ULONG cMax,
ULONG *pcOtherMethod
);
HRESULT GetRVA (
mdToken tk,
ULONG *pulCodeRVA,
DWORD *pdwImplFlags
);
HRESULT GetScopeProps (
LPWSTR szName,
ULONG cchName,
ULONG *pchName,
GUID *pmvid
);
HRESULT GetSigFromToken (
mdSignature mdSig,
PCCOR_SIGNATURE *ppvSig,
ULONG *pcbSig
);
HRESULT GetTypeDefProps
mdTypeDef td,
LPWSTR szTypeDef,
ULONG cchTypeDef,
ULONG *pchTypeDef,
DWORD *pdwTypeDefFlags,
mdToken *ptkExtends
);
HRESULT GetTypeRefProps (
mdTypeRef tr,
mdToken *ptkResolutionScope,
LPWSTR szName,
ULONG cchName,
ULONG *pchName
);
HRESULT GetTypeSpecFromToken (
mdTypeSpec typespec,
PCCOR_SIGNATURE *ppvSig,
ULONG *pcbSig
);
HRESULT GetUserString (
mdString stk,
LPWSTR szString,
ULONG cchString,
ULONG *pchString
);
HRESULT IsGlobal (
mdToken pd,
int *pbGlobal
);
BOOL IsValidToken (
mdToken tk
);
HRESULT ResetEnum (
HCORENUM hEnum,
ULONG ulPos
);
HRESULT ResolveTypeRef (
mdTypeRef tr,
REFIID riid,
IUnknown **ppIScope,
mdTypeDef *ptd
);
};
Methods
Method |
Description |
---|---|
Closes the enumerator with the specified handle. |
|
Gets the number of elements in the enumerator with the specified handle. |
|
Enumerates a list of custom attribute-definition tokens associated with the specified type or member. |
|
Enumerates event definition tokens for the specified TypeDef token. |
|
Enumerates FieldDef tokens for the type referenced by the specified TypeDef token. |
|
Enumerates FieldDef tokens of the specified type with the specified name. |
|
Enumerates MethodDef tokens representing interface implementations. |
|
Enumerates MemberRef tokens representing members of the specified type. |
|
Enumerates MemberDef tokens representing members of the specified type. |
|
Enumerates MemberDef tokens representing members of the specified type with the specified name. |
|
Enumerates MethodBody and MethodDeclaration tokens representing methods of the specified type. |
|
Enumerates MethodDef tokens representing methods of the specified type. |
|
Enumerates the properties and the property-change events to which the specified method is related. |
|
Enumerates methods that have the specified name and that are defined by the type referenced by the specified TypeDef token. |
|
Enumerates ModuleRef tokens that represent imported modules. |
|
Enumerates ParamDef tokens representing the parameters of the method referenced by the specified MethodDef token. |
|
Enumerates permissions for the objects in a specified metadata scope. |
|
Enumerates PropertyDef tokens representing the properties of the type referenced by the specified TypeDef token. |
|
Enumerates Signature tokens representing stand-alone signatures in the current scope. |
|
Enumerates TypeDef tokens representing all types within the current scope. |
|
Enumerates TypeRef tokens defined in the current metadata scope. |
|
Enumerates TypeSpec tokens defined in the current metadata scope. |
|
Enumerates MemberDef tokens representing the unresolved methods in the current metadata scope. |
|
Enumerates String tokens representing hard-coded strings in the current metadata scope. |
|
Gets the FieldDef token for the field that is a member of the specified type, and has the specified name and metadata signature. |
|
Gets a pointer to the MemberDef token for the member defined by the specified type with the specified name and metadata signature. |
|
Gets a pointer to the MemberRef token for the member defined by the specified type with the specified name and metadata signature. |
|
Gets a pointer to the MethodDef token for the method defined by the specified type with the specified name and metadata signature. |
|
Gets a pointer to the TypeDef metadata token for the type with the specified name. |
|
Gets a pointer to the TypeRef metadata token that references the type in the specified search scope with the specified name. |
|
Gets layout information for the class referenced by the specified TypeDef token. |
|
Gets the value of the custom attribute, given its name. |
|
Gets the value of the custom attribute, given its metadata token. |
|
Gets metadata information (including the declaring type, the add and remove methods for delegates, and any flags and other associated data) for the event represented by the specified event token. |
|
Gets a pointer to the native, unmanaged type of the field represented by the specified Field metadata token. |
|
Gets metadata associated with the field referenced by the specified FieldDef token. |
|
Gets a pointer to the metadata tokens for the type that implements the specified method and for the interface that declares that method. |
|
Gets metadata information (including the name, binary signature, and relative virtual address) of the type member referenced by the specified metadata token. |
|
Gets metadata associated with the member referenced by the specified token. |
|
Gets the metadata associated with the method referenced by the specified MethodDef token. |
|
Gets a pointer to the relationship between the method referenced by the specified MethodDef token and the paired property and event referenced by the specified EventProp token. |
|
Gets a pointer to the metadata token for the module referenced in the current metadata scope. |
|
Gets the name of the module referenced by the specified metadata token. |
|
Gets the UTF-8 name of the object referenced by the specified metadata token. |
|
Gets the native calling convention for the method that is represented by the specified signature pointer. |
|
Gets the TypeDef token for the enclosing parent type of the specified nested type. |
|
Gets a pointer to the token that represents the parameter at the specified ordinal position in the sequence of method parameters for the method represented by the specified MethodDef token. |
|
Gets metadata values for the parameter referenced by the specified ParamDef token. |
|
Gets the metadata associated with the System.Security.PermissionSet represented by the specified Permission token. |
|
Gets a ModuleRef token to represent the target assembly of a PInvoke call. |
|
Gets the metadata associated with the property represented by the specified token. |
|
Gets the offset of the relative virtual address of the code object represented by the specified token. |
|
Gets the name and optionally the version identifier of the assembly or module in the current metadata scope. |
|
Gets the binary metadata signature associated with the specified token. |
|
Returns metadata information for the type represented by the specified TypeDef token. |
|
Gets the metadata associated with the type referenced by the specified TypeRef token. |
|
Gets the binary metadata signature of the type specification represented by the specified token. |
|
Gets the literal string represented by the specified metadata token. |
|
Gets a value indicating whether the field, method, or type represented by the specified metadata token has global scope. |
|
Gets a value indicating whether the specified token holds a valid reference to a code object. |
|
Resets the specified enumerator to the specified position. |
|
Gets type information for the type referenced by the specified TypeRef token. |
Remarks
The design of the IMetaDataImport interface is intended primarily to be used by tools and services that will be importing type information (for example, development tools) or managing deployed components (for example, resolution/activation services). The methods in IMetaDataImport fall into the following task categories:
Enumerating collections of items in the metadata scope.
Finding an item that has a specific set of characteristics.
Getting properties of a specified item.
The Get methods are specifically designed to return single-valued properties of a metadata item. When the property is a reference to another item, a token for that item is returned. Any pointer input type can be NULL to indicate that the particular value is not being requested. To obtain properties that are essentially collection objects (for example, the collection of interfaces that a class implements), use the enumeration methods.
Requirements
Platforms: Windows 2000, Windows XP, Windows Server 2003 family
Header: Cor.h
Library: Used as a resource in MsCorEE.dll
.NET Framework Version: 2.0, 1.1, 1.0