COFF header is changed #620

Closed
opened 2019-10-15 00:58:45 -05:00 by nxtn · 4 comments
nxtn commented 2019-10-15 00:58:45 -05:00 (Migrated from github.com)

Steps to reproduce

using System.Diagnostics;
using System.IO;
using System.Reflection.PortableExecutable;
using Mono.Cecil;

public class Program
{
    public static void Main()
    {
        const string Path = "executable.dll";

        using (var reader = new PEReader(new FileStream(Path, FileMode.Open)))
        {
            Debug.Assert(reader.PEHeaders.CoffHeader.Characteristics ==
                (Characteristics.ExecutableImage | Characteristics.LargeAddressAware));
        }

        using (var module = ModuleDefinition.ReadModule(Path, new ReaderParameters { ReadWrite = true }))
        {
            module.Write();
        }

        using (var reader = new PEReader(new FileStream(Path, FileMode.Open)))
        {
            Debug.Assert(reader.PEHeaders.CoffHeader.Characteristics ==
                (Characteristics.ExecutableImage | Characteristics.Bit32Machine));
        }
    }
}
Steps to reproduce ```cs using System.Diagnostics; using System.IO; using System.Reflection.PortableExecutable; using Mono.Cecil; public class Program { public static void Main() { const string Path = "executable.dll"; using (var reader = new PEReader(new FileStream(Path, FileMode.Open))) { Debug.Assert(reader.PEHeaders.CoffHeader.Characteristics == (Characteristics.ExecutableImage | Characteristics.LargeAddressAware)); } using (var module = ModuleDefinition.ReadModule(Path, new ReaderParameters { ReadWrite = true })) { module.Write(); } using (var reader = new PEReader(new FileStream(Path, FileMode.Open))) { Debug.Assert(reader.PEHeaders.CoffHeader.Characteristics == (Characteristics.ExecutableImage | Characteristics.Bit32Machine)); } } } ```
jbevain commented 2019-10-15 13:32:01 -05:00 (Migrated from github.com)

Thanks for reporting this.

Cecil is recomputing the headers, it might produce a difference after round tripping.

The issue is that we're losing the LargeAddressAware flag here?

Thanks for reporting this. Cecil is recomputing the headers, it might produce a difference after round tripping. The issue is that we're losing the LargeAddressAware flag here?
nxtn commented 2019-10-15 21:06:18 -05:00 (Migrated from github.com)

The issue is that we're losing the LargeAddressAware flag here?

Agree.

> The issue is that we're losing the LargeAddressAware flag here? Agree.
shelllee commented 2021-06-02 10:38:53 -05:00 (Migrated from github.com)

two year?

two year?
jbevain commented 2021-06-02 12:29:47 -05:00 (Migrated from github.com)

@shelllee I think you meant two years?

@shelllee I think you meant `two years?`
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil#620
No description provided.