builtbybel / SuperMSConfig

MSConfig of our dreams...
MIT License
111 stars 9 forks source link

Unhandled exception when scanning for Copilot #1

Closed Zagrthos closed 2 weeks ago

Zagrthos commented 2 weeks ago

Version

1.0

OS Version

Windows 11 22635.4145 x64

Description

After initiating the scan with the default profile (no configuration selected) the app runs into an unhandled exception. When continuing the runtime of the app it just says "checking..." and nothing happens.

Stacktrace

************** Ausnahmetext **************
System.UnauthorizedAccessException: Der Zugriff auf den Registrierungsschlüssel "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\WindowsCopilot" wurde verweigert.
   bei Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   bei Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions)
   bei Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck)
   bei SuperMSConfig.RegistryHabit.OpenRegistryKey(Boolean writable)
   bei SuperMSConfig.RegistryHabit.GetCurrentValue()
   bei SuperMSConfig.RegistryHabit.GetDetails()
   bei SuperMSConfig.MainForm.<ProcessHabit>d__10.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   bei SuperMSConfig.MainForm.<LoadHabits>d__13.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   bei SuperMSConfig.MainForm.<btnCheck_Click>d__12.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Additional context

I have activated the local group policy of disabling Windows Copilot. Also I checked the registry key and found out that it doesn't even exist on my system.

Belim commented 2 weeks ago

could you please reload the release with build 112? There was still something enabled for logging purposes that should've been removed. sry about that!

Zagrthos commented 2 weeks ago

Same issue with new build.

Stacktrace:

************** Ausnahmetext **************
System.UnauthorizedAccessException: Der Zugriff auf den Registrierungsschlüssel "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\WindowsCopilot" wurde verweigert.
   bei Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   bei Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions)
   bei Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck)
   bei SuperMSConfig.RegistryHabit.OpenRegistryKey(Boolean writable)
   bei SuperMSConfig.RegistryHabit.GetCurrentValue()
   bei SuperMSConfig.RegistryHabit.GetDetails()
   bei SuperMSConfig.MainForm.<ProcessHabit>d__10.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   bei SuperMSConfig.MainForm.<LoadHabits>d__13.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   bei SuperMSConfig.MainForm.<btnCheck_Click>d__12.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Belim commented 2 weeks ago

damn Sunday, I just threw in way too many this.logger = logger ?? throw new ArgumentNullException(nameof(logger)) and didn’t take them out again .please try again with build 114

Zagrthos commented 2 weeks ago

Didn't fixed it sadly, same Stacktrace as before.

But being honest there is no NRE thrown but an UnauthorizedAccessException. Somehow your app doesn't have the permission to write into HKCU (which is weird because IMHO it should just read when checking instead of writing the key).

I start the app without administrative permissions so maybe that's a helpful indicator what the issue could be. 🙂

Belim commented 2 weeks ago

😨 that's impossible.please test it with the attached dev version dev_SuperMSConfig.zip

Zagrthos commented 2 weeks ago

Sadly not again.

I looked at the specific reg key (HKCU\SOFTWARE\Policies...) now and a regular user does not has write but only read permissions. Administrators at the other side have full permissions.

For fixing this I'd either request administrative perms when checking that key (which would undermine the concept of checking things at current user side) or to disable the creation of the reg key in situations where the user is unable to write.

Belim commented 2 weeks ago

the key should now only be created if RegistryKeyPermissionCheck is set to writable. also threw in a SecurityException. tested it with a non-admin user and it’s working now dev_SuperMSConfig.zip

Belim commented 2 weeks ago

thanks for the support on that too. i’m really bummed that i let it slide like that :grimacing:

Zagrthos commented 2 weeks ago

Confirming it working, thanks for the fix! 🙂 Closing that one now.