using System;
using System.Runtime.InteropServices;
namespace AnticipatingMinds.PlatformServices.UnmanagedReflection{
/// <summary>Wrapper for the IMetaDataDispenserEx COM unmanaged API</summary>
/// <remarks>The methods on this class are documented in the Metadata Unmanaged API document in the SDK Tool Developers Guide</remarks>
/// <example>
/// <code>
/// IMetaDataDispenserEx dispenser=new MetaDataDispenserEx();
/// IMetaDataImport impScope=null;
/// object rawScope=null;
/// Guid iidImp=Constants.IID_IMetaDataImport;
/// dispenser.OpenScope("bytecode.exe",0,ref iidImp,out rawScope);
/// impScope=(IMetaDataImport)rawScope;
/// </code>
/// </example>
[ComImport,GuidAttribute("31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMetaDataDispenserEx
{
// IMPORTANT: Order of methods in this interface is SIGNIFICANT
/// <summary>Define a new metadata scope</summary>
/// <param name="rclsid">A Guid representing Constants.CLSID_CorMetaDataRuntime.ToByteArray();</param>
/// <param name="flags">Always pass 0</param>
/// <param name="iid">A GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
/// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
/// <returns>The HRESULT from the COM method</returns>
int DefineScope(ref Guid rclsid,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out object scope);
/// <summary>Open a metadata scope on an existing assembly file</summary>
/// <param name="file">A fully qualified file name of an assembly</param>
/// <param name="flags">0 for read, 1 for write</param>
/// <param name="iid">GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
/// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
/// <returns>The HRESULT from the COM method</returns>
int OpenScope([MarshalAs(UnmanagedType.LPWStr)] string file,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out Object scope);
/// <summary>Open a metadata scope on an existing set of metadata mapped into memory</summary>
/// <param name="data">The bytes of the assembly (i.e. base address of a mapped assembly dll file)</param>
/// <param name="size">Count of bytes in <paramref name="data"/></param>
/// <param name="flags">0 for read, 1 for write</param>
/// <param name="iid">GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
/// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
/// <returns>The HRESULT from the COM method</returns>
int OpenScopeOnMemory(IntPtr data,uint size,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out object scope);
/// <summary>Set an option for the metadata API behaviour</summary>
/// <param name="iid">GUID for the metadata option to set</param>
/// <param name="optValue">Option specific variant data. Note that this object must be convertable to a variant according to the rules in the topic "Default Marshaling for Objects" in the SDK help</param>
/// <returns>The HRESULT from the COM method</returns>
int SetOption(ref Guid iid,[MarshalAs(UnmanagedType.Struct)] object optValue);
/// <summary>Get an option for the metadata API behaviour</summary>
/// <param name="iid">GUID for the metadata option to set</param>
/// <param name="optValue">Option specific variant data. Note that this object must be convertable to a variant according to the rules in the topic "Default Marshaling for Objects" in the SDK help</param>
/// <returns>The HRESULT from the COM method</returns>
int GetOption(ref Guid iid,[MarshalAs(UnmanagedType.Struct)] out object optValue);
/// <summary>Open a metadata scope on an object description from a COM type library (I think)</summary>
/// <param name="info">A COM ITypeInfo interface pointer for a type in a type library</param>
/// <param name="flags">0 for read, 1 for write</param>
/// <param name="iid">GUID for the required interface, one of IID_IMetaDataEmit, IID_IMetadataImport, IID_IMetaDataAssemblyEmit or IID_IMetadataAssemblyImport</param>
/// <param name="scope">Output parameter which will be initialised to the new scope. Should be cast to the interface specified in <paramref name="iid"/></param>
/// <returns>The HRESULT from the COM method</returns>
int OpenScopeOnITypeInfo([MarshalAs(UnmanagedType.Interface)] UCOMITypeInfo info,uint flags,ref Guid iid,[MarshalAs(UnmanagedType.Interface)] out object scope);
/// <summary>Get the system directory for the CIL Runtime</summary>
/// <param name="dir">A char buffer big enough to hold the longest result</param>
/// <param name="size">Size of the buffer <paramref name="dir"/></param>
/// <param name="count">Number of chars written into <paramref name="dir"/> or number of required chars if larger than <paramref name="size"/></param>
/// <returns>The HRESULT from the COM method</returns>
int GetCORSystemDirectory([MarshalAs(UnmanagedType.LPArray,SizeParamIndex=1)] char[] dir,int size,out int count);
/// <summary>Find the best match for an assembly using the rules from the CIL Runtime</summary>
/// <returns>The HRESULT from the COM method</returns>
int FindAssembly([MarshalAs(UnmanagedType.LPWStr)] string appBase,[MarshalAs(UnmanagedType.LPWStr)] string privBin,[MarshalAs(UnmanagedType.LPWStr)] string globalBin,[MarshalAs(UnmanagedType.LPWStr)] string name,[MarshalAs(UnmanagedType.LPArray,SizeParamIndex=5)] char[] nameOut,int buffSize,out int nameLen);
/// <summary>Find the best match for an assembly module using the rules from the CIL Runtime</summary>
/// <returns>The HRESULT from the COM method</returns>
int FindAssemblyModule([MarshalAs(UnmanagedType.LPWStr)] string appBase,[MarshalAs(UnmanagedType.LPWStr)] string privBin,[MarshalAs(UnmanagedType.LPWStr)] string globalBin,[MarshalAs(UnmanagedType.LPWStr)] string name,[MarshalAs(UnmanagedType.LPArray,SizeParamIndex=5)]char[] nameOut,int buffSize,out int nameLen);
}
/// <summary>Alternate interface for IMetaDataDispenserEx. tlbimp.exe creates these, I don't know why so I copied it</summary>
/// <remarks>The GUID may be incorrect on this interface</remarks>
[ComImport,GuidAttribute("31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3"),CoClass(typeof(MetaDataDispenserExClass))]
public interface MetaDataDispenserEx: IMetaDataDispenserEx
{
}
/// <summary>Co class for the MetadataDispenserEx interface</summary>
[ComImport,GuidAttribute("E5CB7A31-7512-11D2-89CE-0080C792E5D8")]
public class MetaDataDispenserExClass
{
}
}
|