Skip to content

Conversation

@jandupej
Copy link
Contributor

This fixes the second pass of #89429 when trying to read DLLs that have no metadata. The first pass was addressed in #89430.

@jandupej jandupej added this to the 8.0.0 milestone Jul 27, 2023
@jandupej jandupej self-assigned this Jul 27, 2023
Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!


using FileStream file = new FileStream(assyPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using PEReader peReader = new PEReader(file);
if (!peReader.HasMetadata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: May be good to encapsulate this, so we don't forget to check peReader.HasMetadata each time it is created, but I think it is nice to have.

@kotlarmilos
Copy link
Member

/azp run runtime-ioslike

@azure-pipelines
Copy link

No commit pushedDate could be found for PR 89555 in repo dotnet/runtime

@kotlarmilos
Copy link
Member

/azp run runtime-ioslike

@azure-pipelines
Copy link

No commit pushedDate could be found for PR 89555 in repo dotnet/runtime

@kotlarmilos
Copy link
Member

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@kotlarmilos
Copy link
Member

kotlarmilos commented Jul 27, 2023

The failure looks related. The scanner invokes GetAssemblyName which ends up with:

peReader = new PEReader((byte*)safeBuffer.DangerousGetHandle(), (int)safeBuffer.ByteLength);
MetadataReader mdReader = peReader.GetMetadataReader(MetadataReaderOptions.None);
AssemblyName assemblyName = mdReader.GetAssemblyDefinition().GetAssemblyName();

@kotlarmilos
Copy link
Member

/azp run runtime-ioslike

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@kotlarmilos
Copy link
Member

The failures shouldn't be related. Thanks!

@jandupej jandupej merged commit 1da23b1 into dotnet:main Jul 28, 2023
@jandupej jandupej deleted the issue89429-part-deux branch July 28, 2023 09:24
@ghost ghost locked as resolved and limited conversation to collaborators Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

3 participants