Fix runtime architecture detection logic in ANCM #63652
Draft
+88
−36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #63650
A recent change (#61894) inadvertently regressed a scenario that was working by accident.
That change switched us away from using
GetBinaryTypeW
to determine the architecture of a binary, because that method actually loads the binary into the process and we wanted to avoid that. However, what was missed there is that in some cases (e.g. x64 process running on arm64) the function fails entirely (since it can't even load the binary), which used to lead us to skip that binary when doing our probing and instead rely on fallback methods.After #61894, we started to correctly determine that both x64 and arm64 binaries are 64-bit, but since we weren't distinguishing between the two, we could end up attempting to load the wrong one.
This fixes that by actually determining the specific architecture and ensuring a match. There's some nearby code that needs to be rethought as well, but I'm trying to keep this change minimal so we can minimize risk late in .NET 10.