Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of the <see cref="DotNetDirectoryFactory"/> class.
 /// </summary>
 /// <param name="metadataBuilderFlags">
 /// The flags defining the behaviour of the .NET metadata directory builder regarding the
 /// construction of the .NET metadata directory.
 /// </param>
 public DotNetDirectoryFactory(MetadataBuilderFlags metadataBuilderFlags)
 {
     MetadataBuilderFlags = metadataBuilderFlags;
     MethodBodySerializer = new MultiMethodBodySerializer(
         new CilMethodBodySerializer(),
         new NativeMethodBodySerializer());
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of the <see cref="ManagedPEImageBuilder"/> class, and initializes a new
 /// .NET data directory factory using the provided metadata builder flags.
 /// </summary>
 public ManagedPEImageBuilder(MetadataBuilderFlags metadataBuilderFlags)
     : this(new DotNetDirectoryFactory(metadataBuilderFlags))
 {
 }
        protected static ModuleDefinition RebuildAndReloadModule(ModuleDefinition module, MetadataBuilderFlags builderFlags)
        {
            var builder = new ManagedPEImageBuilder
            {
                DotNetDirectoryFactory = new DotNetDirectoryFactory(builderFlags)
            };

            var newImage = builder.CreateImage(module).ConstructedImage;

            return(ModuleDefinition.FromImage(newImage));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of the <see cref="DotNetDirectoryFactory"/> class.
 /// </summary>
 /// <param name="metadataBuilderFlags">
 /// The flags defining the behaviour of the .NET metadata directory builder regarding the
 /// construction of the .NET metadata directory.
 /// </param>
 public DotNetDirectoryFactory(MetadataBuilderFlags metadataBuilderFlags)
 {
     MetadataBuilderFlags = metadataBuilderFlags;
 }
Ejemplo n.º 5
0
        protected static ModuleDefinition RebuildAndReloadModule(ModuleDefinition module, MetadataBuilderFlags builderFlags)
        {
            var builder = new ManagedPEImageBuilder
            {
                DotNetDirectoryFactory = new DotNetDirectoryFactory(builderFlags)
            };

            var result = builder.CreateImage(module);

            if (result.DiagnosticBag.HasErrors)
            {
                throw new AggregateException(result.DiagnosticBag.Exceptions);
            }

            var newImage = result.ConstructedImage;

            return(ModuleDefinition.FromImage(newImage));
        }