Skip to content

Browse mode is not available in some electron apps running on Windows 11 ARM #14397

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

Closed
rperez030 opened this issue Nov 24, 2022 · 11 comments · Fixed by #14449
Closed

Browse mode is not available in some electron apps running on Windows 11 ARM #14397

rperez030 opened this issue Nov 24, 2022 · 11 comments · Fixed by #14449
Labels
feature/browse-mode feature p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority platform/Windows11 Issues specific to Windows 11 triaged Has been triaged, issue is waiting for implementation.
Milestone

Comments

@rperez030
Copy link

I have observed this problem with the 64 version of 1Password 8, the RIM app by Pneuma solutions and the version of Slack that can be obtained from the Microsoft store running on a virtual machine with Windows 11 ARM. The problem does not occur with the 32 bits version of Slack, the ARM64 version of Visual Studio code or Teams. All the apps work as expected with Narrator. Executing the command focus.devInfo in the Python Console while focus is inside any of the non-working apps shows the IAccessible2 properties related to the object with focus.

Steps to reproduce:

  1. Download and run Slack from the Microsoft Store.
  2. While focus is on the app, try turning on browse mode by pressing NVDA +the space bar.

Actual behavior:

Nothing happens. The following gets added to the lock when the electron app receives focus:

DEBUGWARNING - virtualBuffers.VirtualBuffer.prepare (18:55:41.302) - MainThread (4072):
appModule has no binding handle to injected code, can't prepare virtualBuffer yet.

Expected behavior:

NVDA can switch between focus and browse mode.

NVDA logs, crash dumps and other attachments:

System configuration

NVDA installed/portable/running from source:

Installed

NVDA version:

2022.3.2

Windows version:

Edition Windows 11 Pro

Version 22H2

OS build 22621.819

Experience Windows Feature Experience Pack 1000.22636.1000.0

Name and version of other software in use when reproducing the issue:

N/a

Other information about your system:

Windows is running on a Parallels VM

Other questions

Does the issue still occur after restarting your computer?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

No

If NVDA add-ons are disabled, is your problem still occurring?

Yes

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

Yes

@josephsl
Copy link
Collaborator

Hi,

Can you report the results of:

  1. From the affected app, press Control+NVDA+F1 and see if says something.
  2. Again from the affected ap, press Control+NVDA+Z, then type "focus.appModule.appArchitecture" and see if it says "AMD64" or something similar.

If it says something other than "AMD64" for the app architecture, chances are that this is an emulation compatible (Arm64EC) application with a mixture of x64 and ARM64 code included. CC @michaelDCurran, do you think we should update our building logic to support injecting code into AMD64/Arm64EC processes in Windows 11 on ARM?

Thanks.

@rperez030
Copy link
Author

@josephsl Results from 1password:

1password module is loaded. 1Password.exe is currently running.

focus.appModule.appArchitecture: ARM64

Results from the RIM app:

Remote Incident Manager.exe is currently running.

focus.appModule.appArchitecture: ARM64

@rperez030
Copy link
Author

Looking at the devInfo output for 1Password I found the following:

appModule: <'1password' (appName '1password', process ID 4760) at address 80feef0>
appModule.productName: exception: processHandle is 0
appModule.productVersion: exception: processHandle is 0

@michaelDCurran
Copy link
Member

michaelDCurran commented Nov 24, 2022 via email

@josephsl
Copy link
Collaborator

Hi,

As for GetProcessInformation function call, I think it would be best to split this into a separate issue/PR pair (wish we can get Microsoft ARM development kit to test this scenario more fully).

Thanks.

@josephsl
Copy link
Collaborator

Hi,

Possible solution based on Mick's comment:

  1. Change the Remote Loader 64-bit class by adding a keyword argument to the constructor, taking lib64 directory. By default, it will use whatever lib64 variable gets set to.
  2. In the initialize function, run an additional remote loader executable for AMD64 processes if this is Windows 11 on ARM (cannot be done for Windows 10 on ARM because it does not support running AMD64 processes). Be sure to termiante BOTH processes in Windows 11 on ARM (to do this, define another variable just to hold a reference to the second remote loader executable class).

Ideally someone using a Windows 11 on ARM device should come up with a pull request.

Thanks.

@michaelDCurran
Copy link
Member

michaelDCurran commented Nov 27, 2022 via email

@rperez030
Copy link
Author

rperez030 commented Nov 27, 2022 via email

@josephsl
Copy link
Collaborator

josephsl commented Nov 27, 2022 via email

@michaelDCurran
Copy link
Member

michaelDCurran commented Nov 27, 2022 via email

@rperez030
Copy link
Author

Done. @josephsl i left a comment on #14404.

@seanbudd seanbudd added the platform/Windows11 Issues specific to Windows 11 label Dec 1, 2022
@feerrenrut feerrenrut added feature triaged Has been triaged, issue is waiting for implementation. feature/browse-mode labels Dec 1, 2022
@seanbudd seanbudd added the p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority label Dec 1, 2022
@nvaccessAuto nvaccessAuto added this to the 2023.1 milestone Dec 20, 2022
seanbudd added a commit that referenced this issue Dec 21, 2022
Closes #14439
Follow-up to #14397
Follow-up to #14403

Summary of the issue:
winVersion.WinVersion class should define processor architecture property to record machine architecture for the current Windows installation.

Description of user facing changes
At NVDA startup, processor architecture will be logged as part of Windows information.

Description of development approach
Add "processorArchitecture" property to winVersion.WinVersion class to record machine architecture (currently x86 (32-bit) AMD64 (x64), ARM64). From getWinVer() function, this value will be fetched via Python's platform.machine() function, which itself looks up processor architecture from environment variables. This means NVDA can read the new property instead of consulting environment variables every time it wishes to check machine architecture. Also, added a unit test to see if the processor architecture recorded is indeed the one Windows says.

Commits:

* winVersion.WinVersion: define processor architecture property. Re #14439.

Define 'processorArchitecture' property in WinVersion class to store machine arcthiecture for the Windows installation (x86/32-bit, AMD64, ARM64). This is useful in detecting 64-bit systems and different architectures for use for log output, 64-bit versus 32-bit differences, and testing and debugging.

* WinVersion.repr: print processor architecture if defined. Re #14439.

Print processor architecture for the Windows installation as part of Windows version output.

* winVersion.getWinVer: obtain processor architecture via platform.machine() function. Re #14439.

Python's platform module provides platform.machine() function, returning the processor architecture for the system. If Windows is detected, it internally retrieves PROCESSOR_ARCHITEW6432 and PROCESSOR_ARCHITECTURE environment variabls, in that order so it can detect WoW64 (such as x86 program running on an x64 processor). Because winVersion.getWinVer() function caches the current Windows installation, processor architecture string is always available and cached as part of the resulting WinVersion object. The practical implication is that NVDA no longer needs to consult environment variables every time it wants to detect processor architecture as the result is already known at program startup.

* Unit tets: add processor architecture test and update copyright header. Re #14439.

Add winVersion.getWinVer().processorArchitecture test to see if what it says matches processor architecture (and WoW64 version) environment variable. Python's platform.machine() function is not used because that function consults environment variables itself.

* update changes

Co-authored-by: Sean Budd <sean@nvaccess.org>
seanbudd added a commit that referenced this issue Dec 21, 2022
…ows 11 on ARM via kernel32.dll::GetProcessInformation (#14404)

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:

1. Defined a process information structure with three attributes: process machine (unsigned short), res0 (double word), machine attributes (double word.
2. Added 0xAA64 to represent ARM64 applications in app architecture property.
3. Refined app architecture property in AppModule class to call kernel32.dll::GetProcessInformation on Windows 11 21H2 (build 22000) or later, with WoW64 detection reserved for Windows 10 and earlier.
4. If GetProcessInformation fails (returns 0), report "unknown" as app architecture to prepare to handle cases where an app (perhaps hosted or an ARM64EC) may report wrong architecture information.
5. Added type information to app architecture property (return type: str). This should inspire efforts to add type information to app module handler odule and classes (later).

Commits:

* appModuleHandler.AppModule: define process information structure for use when detecting various ap architectures in Windows 11. Re #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.

* AppModule.appArchitecture: call kernel32::GetProcessInformation to obtain app architecture in Windows 11. Re #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.

* AppModule.appArchitecture: recognize 0xAA64 as ARM64 machine type. Re #14403

* AppModule.appArchitecture: winKernel -> ctypes.windll for consistency. Re #14403

* AppModule.appArchitecture: add type information (return type: str). Re #14403

* appModuleHandler.AppModule: handle kernel32.dll::GetProcessInformation returning 0 (error). Re #14403.

Comment from Mick Curran (NV Access): GetProcessInformation may say '0' (error) sometimes, therefore treat the app in question has targeting 'unknown' architecture.

* App module handler: refine get app module from NVDA object function to set process handle to a valid one if it is 0. Re #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.

* App module handler: catch atribute error of obj.processHandle is undefined. Re #14403.

When running unit tests, a placeholder NVDA object is created with process handle undefined. Therefore catch attribute error and move on.

* update changes
Co-authored-by: Sean Budd <sean@nvaccess.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/browse-mode feature p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority platform/Windows11 Issues specific to Windows 11 triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
6 participants