Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COFF header is changed #620

Closed
nxtn opened this issue Oct 15, 2019 · 4 comments · Fixed by #775
Closed

COFF header is changed #620

nxtn opened this issue Oct 15, 2019 · 4 comments · Fixed by #775

Comments

@nxtn
Copy link

nxtn commented Oct 15, 2019

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));
        }
    }
}
@jbevain
Copy link
Owner

jbevain commented Oct 15, 2019

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
Copy link
Author

nxtn commented Oct 16, 2019

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

Agree.

@shelllee
Copy link

shelllee commented Jun 2, 2021

two year?

@jbevain
Copy link
Owner

jbevain commented Jun 2, 2021

@shelllee I think you meant two years?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants