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

Fix get process architecture #3726

Merged
merged 7 commits into from
Jun 8, 2022

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented Jun 8, 2022

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.

@nohwnd nohwnd requested a review from MarcoRossignoli June 8, 2022 09:47
Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

LGTM

// 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)]
Copy link
Contributor

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

Copy link
Member Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (_currentProcessArchitecture != null)
if (_currentProcessArchitecture is not null)

Copy link
Member Author

Choose a reason for hiding this comment

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

added.

@nohwnd nohwnd enabled auto-merge (squash) June 8, 2022 11:03
@nohwnd nohwnd disabled auto-merge June 8, 2022 15:07
@nohwnd nohwnd merged commit 87cfa7a into microsoft:main Jun 8, 2022
@nohwnd nohwnd deleted the fix-get-process-architecture branch June 8, 2022 15:07
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 this pull request may close these issues.

3 participants