/// <summary>
 /// Creates a new managed PE file builder context.
 /// </summary>
 /// <param name="image">The image to build.</param>
 public ManagedPEBuilderContext(IPEImage image)
 {
     ImportDirectory      = new ImportDirectoryBuffer(image.PEKind == OptionalHeaderMagic.Pe32);
     ExportDirectory      = new ExportDirectoryBuffer();
     DotNetSegment        = new DotNetSegmentBuffer(image.DotNetDirectory);
     ResourceDirectory    = new ResourceDirectoryBuffer();
     RelocationsDirectory = new RelocationsDirectoryBuffer();
     FieldRvaDataReader   = new FieldRvaDataReader();
     Bootstrapper         = CreateBootstrapper(image);
 }
Ejemplo n.º 2
0
        private void CreateResourceSection()
        {
            var resourcesBuffer = new ResourceDirectoryBuffer(Assembly);

            _rsrcSectionHeader = new ImageSectionHeader
            {
                Name       = ".rsrc",
                Attributes = ImageSectionAttributes.MemoryRead |
                             ImageSectionAttributes.ContentInitializedData,
                Section =
                {
                    Segments = { resourcesBuffer.DirectoryTable, resourcesBuffer.DataDirectoryTable, resourcesBuffer.DataTable }
                }
            };
        }