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

Error when dialog opens when the Alt+Tab window switcher is open #8

Open
EchterAgo opened this issue Oct 3, 2024 · 9 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@EchterAgo
Copy link

I keep seeing this sometimes. I think it happens if the security key dialog opens when the Alt+Tab switcher is open.

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at MS.Internal.Automation.UiaCoreApi.CheckError(Int32 hr)
   at AuthenticatorChooser.SecurityKeyChooser.chooseUsbSecurityKey(SystemWindow fidoPrompt)
   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)


************** Loaded Assemblies **************
System.Private.CoreLib
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Private.CoreLib.dll
----------------------------------------
AuthenticatorChooser
    Assembly Version: 0.1.0.0
    Location: 
----------------------------------------
System.Runtime
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Runtime.dll
----------------------------------------
mwinapi
    Assembly Version: 0.3.0.5
    Location: 
----------------------------------------
System.Windows.Forms
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\System.Windows.Forms.dll
----------------------------------------
System.Windows.Forms.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\System.Windows.Forms.Primitives.dll
----------------------------------------
System.Console
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Console.dll
----------------------------------------
System.Diagnostics.TraceSource
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Diagnostics.TraceSource.dll
----------------------------------------
System.Collections
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Collections.dll
----------------------------------------
System.ComponentModel.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.ComponentModel.Primitives.dll
----------------------------------------
System.Drawing.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Drawing.Primitives.dll
----------------------------------------
System.Runtime.InteropServices
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Runtime.InteropServices.dll
----------------------------------------
System.Threading
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Threading.dll
----------------------------------------
System.Drawing.Common
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\System.Drawing.Common.dll
----------------------------------------
System.Collections.Specialized
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Collections.Specialized.dll
----------------------------------------
Microsoft.Win32.Primitives
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\Microsoft.Win32.Primitives.dll
----------------------------------------
System.ComponentModel.EventBasedAsync
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.ComponentModel.EventBasedAsync.dll
----------------------------------------
System.Threading.Thread
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Threading.Thread.dll
----------------------------------------
System.Numerics.Vectors
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Numerics.Vectors.dll
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\Accessibility.dll
----------------------------------------
Microsoft.Win32.SystemEvents
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\Microsoft.Win32.SystemEvents.dll
----------------------------------------
System.Memory
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Memory.dll
----------------------------------------
Workshell.PE.Resources
    Assembly Version: 3.0.0.130
    Location: 
----------------------------------------
Workshell.PE
    Assembly Version: 3.0.0.130
    Location: 
----------------------------------------
System.Linq
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Linq.dll
----------------------------------------
System.Text.Encoding.Extensions
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Text.Encoding.Extensions.dll
----------------------------------------
UIAutomationClient
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\UIAutomationClient.dll
----------------------------------------
UIAutomationTypes
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\UIAutomationTypes.dll
----------------------------------------
ThrottleDebounce
    Assembly Version: 2.0.0.0
    Location: 
----------------------------------------
netstandard
    Assembly Version: 2.1.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\netstandard.dll
----------------------------------------
PresentationCore
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\PresentationCore.dll
----------------------------------------
WindowsBase
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\WindowsBase.dll
----------------------------------------
DirectWriteForwarder
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\DirectWriteForwarder.dll
----------------------------------------
System.Runtime.Extensions
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Runtime.Extensions.dll
----------------------------------------
System.Diagnostics.Debug
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Diagnostics.Debug.dll
----------------------------------------
System.Runtime.CompilerServices.VisualC
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Runtime.CompilerServices.VisualC.dll
----------------------------------------
System.Collections.NonGeneric
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Collections.NonGeneric.dll
----------------------------------------
System.ComponentModel
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.ComponentModel.dll
----------------------------------------
System.Threading.ThreadPool
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Threading.ThreadPool.dll
----------------------------------------
UIAutomationProvider
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\UIAutomationProvider.dll
----------------------------------------
System.Diagnostics.StackTrace
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Diagnostics.StackTrace.dll
----------------------------------------
UIAutomationClientSideProviders
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\UIAutomationClientSideProviders.dll
----------------------------------------
System.ComponentModel.TypeConverter
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.ComponentModel.TypeConverter.dll
----------------------------------------
System.Runtime.Loader
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Runtime.Loader.dll
----------------------------------------
System.Reflection.Metadata
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Reflection.Metadata.dll
----------------------------------------
System.Collections.Immutable
    Assembly Version: 8.0.0.0
    Location: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Collections.Immutable.dll
----------------------------------------

************** JIT Debugging **************
@Aldaviva
Copy link
Owner

Aldaviva commented Oct 3, 2024

Interesting, I will try to reproduce that and figure out how to fix it.

@Aldaviva Aldaviva self-assigned this Oct 3, 2024
@Aldaviva Aldaviva added the bug Something isn't working label Oct 3, 2024
@EchterAgo
Copy link
Author

I noticed that I wasn't running the latest version yet, I have upgraded now and will see if the issue happens again. I noticed it occasionally with the version from June.

@Aldaviva
Copy link
Owner

Aldaviva commented Oct 3, 2024

So far I haven't gotten AuthenticatorChooser to crash, but I have gotten AuthenticatorChooser to move the dialog box to the top-left corner of the screen if the dialog opens while the Alt+Tab window is open. Even when AuthenticatorChooser isn't running, opening a credentials dialog while the Alt+Tab window is open seems to frequently cause both the credentials window and Alt+Tab windows to become invisible and frozen, requiring you to kill CredentialsUIHost.exe to proceed, but sometimes that's insufficient and Alt+Tab is still invisible and frozen after that, at which point you have to restart explorer.exe using Task Manager's Restart Task or by just killing it.

I will keep working on this and also send you a build that has logging and line numbers to get more detailed information.

Testing notes

To easily get a WebAuthn dialog box to appear when I want, I am following these steps.

  1. Go to https://webauthn.io
  2. In the browser Developer Tools console, run
    setTimeout(() => document.getElementById("login-button").click(), 1000);

@Aldaviva
Copy link
Owner

Aldaviva commented Oct 3, 2024

The Alt+Tab window has class XamlExplorerHostIslandWindow and title Task Switching from process explorer.exe. (The old 95/NT CoolSwitch is from csrss.exe and you can trigger it with Alt+Alt+Tab).

@Aldaviva
Copy link
Owner

Aldaviva commented Oct 3, 2024

To make issues easier to debug, I should also

  • Make the CI build include the PDB file in its output, and upload it as a separate file to the releases page, so that you don't have to recompile just to get symbols and line numbers
  • Add a text logging option that will write logs to a file or something, so that you don't have to set the output type to Exe and recompile

Aldaviva added a commit that referenced this issue Oct 4, 2024
…nto lots of small methods to make stack traces more useful, package PDB file in CI build artifacts, added more robust argument parsing, skip when foreground window is the Alt+Tab window
@Aldaviva
Copy link
Owner

Aldaviva commented Oct 4, 2024

Here is a development build with the following changes.

  • Skip interacting with Windows Security dialog box if the Alt+Tab window is open
  • Catch the COMException from your stacktrace
  • Included the PDB file, which will add line numbers to stack traces when this file is in the same directory as the EXE
  • Split one large method into several smaller ones to make stack traces more meaningful
  • Added ability to log debug messages to a file
    # log to %TEMP%\AuthenticatorChooser.log
    .\AuthenticatorChooser.exe --log
    
    # log to custom file path
    .\AuthenticatorChooser.exe --log="c:\users\ben\desktop\ac.log"

AuthenticatorChooser.zip

@EchterAgo
Copy link
Author

It seems that getUserLocaleId throws for me on startup:

---------------------------
AuthenticatorChooser
---------------------------
Uncaught exception: System.TypeInitializationException: The type initializer for 'AuthenticatorChooser.I18N' threw an exception.

 ---> System.Security.SecurityException: Requested registry access is not allowed.

   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)

   at Microsoft.Win32.Registry.GetValue(String keyName, String valueName, Object defaultValue)

   at AuthenticatorChooser.I18N.getUserLocaleId(Boolean currentUser) in /_/AuthenticatorChooser/I18N.cs:line 83

   at AuthenticatorChooser.I18N..cctor() in /_/AuthenticatorChooser/I18N.cs:line 30

   --- End of inner exception stack trace ---

   at AuthenticatorChooser.I18N.getUserLocaleId(Boolean currentUser) in /_/AuthenticatorChooser/I18N.cs:line 83

   at AuthenticatorChooser.Startup.OnExecute() in /_/AuthenticatorChooser/Startup.cs:line 52
---------------------------
OK   
---------------------------

I also see the same when using shell to query the value:

C:\Users\axel>reg query "HKEY_USERS\S-1-5-20\Control Panel\International"
ERROR: Access is denied.

@Aldaviva
Copy link
Owner

Aldaviva commented Oct 6, 2024

Thanks, I'll find another way to read that. I must not have tested with the right permissions.


Note to self: try https://learn.microsoft.com/en-us/powershell/module/international/get-winsystemlocale?view=windowsserver2022-ps

@Aldaviva
Copy link
Owner

Aldaviva commented Oct 7, 2024

Here is a fixed version that fetches the system locale using a Windows API call instead of a registry read on a different user's hive. Tested on Windows 11 23H2 with UAC turned all the way up.

AuthenticatorChooser.zip

Aldaviva added a commit that referenced this issue Oct 7, 2024
…istry read on a different user's hive, which fails with permission denied because it's a different user's registry hive. Inline methods because they were making the code less readable, and the debugging symbols should do this job instead. Log OS marketing version (like "23H2") on startup, in addition to the build number. Generate some native method calls at compile time instead of at runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants