appModuleHandler.AppModule.appArchitecture: detect AMD64 apps in Windows 11 on ARM via kernel32.dll::GetProcessInformation#14404
Conversation
…use when detecting various ap architectures in Windows 11. Re nvaccess#14403. In Windows 11 on ARM, 64-bit x86 (AMD64) apps are identified as ARM64 when it should say AMD64, traced to a flaw in AppModule.appArchitecture property that relied on WoW64 detection. As part of resolving this, define a process machine info structure to be used in the refined app architecture property getter.
…tain app architecture in Windows 11. Re nvaccess#14403. Rather than relying on WoW64 detection, call kernel32.dll::GetProcessInformation in Windows 11 (21H2 build 22000 and later) to obtain app architecture. This uses a constant defined in process information class enumeration to obtain machine info (9). The WoW64 method is used if this is Windows 10 or earlier.
See test results for failed build of commit 1ab3d408f1 |
|
Tested using a Windows on ARM VM. X86, AMD64 and ARM64 where reported correctly for Slack (X86), Remote Incident Manager (AMD64) and Visual Studio code (ARM64), however, when tested with 1Password 8 which should have been reported as AMD64, NVDA generated the following error: Traceback (most recent call last): NVDA 2022.3.2 incorrectly reports ARM64 for the same app. |
|
Hi, sounds like it is saying “machine unknown” for this particular app. We might as well say “ARM64” for this case unless this is truly an AMD64 app and/or is an EC app. CC @michaelDCurran both for your comment and a review please.
|
|
I believe it is an AMD64, or maybe EC. I'm going by their website where they indicate that it requires Windows 11 64-bit or Windows 10 64-bit |
|
I'm indeed pretty sure that 1Password is AMD64 only. |
| processMachineInfo = _PROCESS_MACHINE_INFORMATION() | ||
| # Constant comes from PROCESS_INFORMATION_CLASS enumeration. | ||
| ProcessMachineTypeInfo = 9 | ||
| ctypes.windll.kernel32.GetProcessInformation( |
There was a problem hiding this comment.
Definitely should check the return value here. If false then we should report as unknown.
My hypothesis is that for 1Password this function fails due to process handle permissions.
However, if this is not the case, then at very least, using get or catching KeyError on the arch dictionary will obviously be necessary.
…n returning 0 (error). Re nvaccess#14403. Comment from Mick Curran (NV Access): GetProcessInformation may say '0' (error) sometimes, therefore treat the app in question has targeting 'unknown' architecture.
|
Having tested this on ARM64 now: |
|
It is also worth noting that in the 1password case, the appModule is also staying alive for ever, as passing a processHandle of 0 to WaitForSingleObject is returning a True value. (WAIT_FAIL). We should consider improving the isAlive property to only return True for WAIT_TIMEOUT, False for WAIT_0, and anything else should be logged as n error and probably return False. |
|
Hi, I'll incorporate Mick's suggestion this week after merging latest master commit on AMD64 support on Windows 11 ARM64. Thanks. |
…o set process handle to a valid one if it is 0. Re nvaccess#14403. Comment from ick Curran (NV Access): GetProcessInformation fials for some apps because process handle is 0 but the handle reported by NVDA object is valid. Therefore, after obtaining app module based on object process Id, see if process handle for the app is 0, and if so, replace process handle with that of the one reported by NVDA object. Also added type information for getAppModuleFromNVDAObject function.
f1b49c9 to
3deb7ed
Compare
…fined. Re nvaccess#14403. When running unit tests, a placeholder NVDA object is created with process handle undefined. Therefore catch attribute error and move on.
|
Hi, Perhaps a follow-up work: when running unit tests, process handle is undefined for placeholder NVDA object. For now NVDA will ignore it via attribute error. Thanks. |
|
Hi, Pull request build: https://ci.appveyor.com/api/buildjobs/x6a2kw2muycblho7/artifacts/output%2Fnvda_snapshot_pr14404-27340%2C5a08f6a6.exe While running this build, see if 1password is recognized as an AMD64 application under ARM64 (open NVDA Pyhton Console, type focus.appModule.appArchitecture). Thanks. |
Link to issue number:
Closes #14403
Stems from #14397
Summary of the issue:
In Windows 11 on ARM, AMD64 apps are seen as ARM64 apps.
Description of user facing changes
Entering "focus.appModule.appArchitecture" in Python Console will say "AMD64" if focused on AMD64 application.
Description of development approach
In app module handler:
Testing strategy:
Manual testing (ARM64 machine is ideal but also works on x64 machines):
Known issues with pull request:
None, although it might be possible that some x64 apps may continue to be seen as ARM64, in which case the development approach may need to be refined.
Change log entries:
Bug fixes (and changes for developers):
In Windows 11 on ARM, x64 apps are no longer identified as ARM64 applications. (#14403)
Code Review Checklist: