-
Notifications
You must be signed in to change notification settings - Fork 325
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
Fix get process architecture #3726
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/Microsoft.TestPlatform.PlatformAbstractions/net451/System/ProcessHelper.cs
Show resolved
Hide resolved
// A pointer to a value that is set to TRUE if the process is running under WOW64. | ||
// If the process is running under 32-bit Windows, the value is set to FALSE. | ||
// If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE. | ||
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add CallingConvention = CallingConvention.Winapi
and the return annotation also above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
if (_currentProcess.Id == processId) | ||
{ | ||
// If we already cached the current process architecture, no need to figure it out again. | ||
if (_currentProcessArchitecture != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (_currentProcessArchitecture != null) | |
if (_currentProcessArchitecture is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
Description
Fix code in GetProcessArchitecture that assumed that the process is the current process, and checked IntPtr to figure out the architecture quickly. Instead we rely on intPtr only when we know we are looking at the current process, and in other cases we use the native api.
There is also more caching and fallback added when IsWow64Process2 fails because that api is not available on the system yet.
Related issue
Related dotnet/sdk#25421
It fixes part of the issue, but it looks like the DumpMinidump is recompiled somehow in dotnet sdk, and end up being unusable.