Skip to content

Commit

Permalink
Read the image earlier (dotnet#33576)
Browse files Browse the repository at this point in the history
  • Loading branch information
cshung committed Mar 14, 2020
1 parent caa1f1b commit 4e0671c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ private unsafe void Initialize(MetadataReader metadata)

PEReader = new PEReader(Unsafe.As<byte[], ImmutableArray<byte>>(ref image));
}
else
{
ImmutableArray<byte> content = PEReader.GetEntireImage().GetContent();
Image = Unsafe.As<ImmutableArray<byte>, byte[]>(ref content);
}

if (metadata == null && PEReader.HasMetadata)
{
Expand All @@ -392,9 +397,6 @@ private unsafe void Initialize(MetadataReader metadata)
{
throw new BadImageFormatException($"ECMA metadata / RTR_HEADER not found in file '{Filename}'");
}

ImmutableArray<byte> content = PEReader.GetEntireImage().GetContent();
Image = Unsafe.As<ImmutableArray<byte>, byte[]>(ref content);
}

private void EnsureMethods()
Expand Down

0 comments on commit 4e0671c

Please sign in to comment.