QubesOS / qubes-issues

The Qubes OS Project issue tracker
https://www.qubes-os.org/doc/issue-tracking/
533 stars 46 forks source link

Restored Windows qube has no app menu entries; entries can't be added #8328

Open GWeck opened 1 year ago

GWeck commented 1 year ago

Qubes OS release

R4.2.0-rc1

Brief summary

If Windows Qubes (tested with Windows 7 and 10 templates and AppVMs) are restored from a backup, their Qubes application menus are empty or contain only the Start qube entry. The application refresh window of the Qube Manager may just contain Application missing in template entries or none at all. Refreshing the menu has no effect.

Steps to reproduce

Install a Windows Qube in R4.2, and try to populate its Qubes menu.

Expected behavior

Entries in the Windows menu should be available in the available pane of the application menu window, and it should be possible to move them to the show pane to select them for use in the Qubes menu. At least, after pushing the Refresh button, the Windows menu entries should be made available.

Actual behavior

The left pane stays empty, and no Windows menu entries can be selected for the Qubes menu. The CLI command qvm-sync-appmenus has no effect.

This may be caused by an incompatibility between the old Qubes menu and the new application menu of R4.2.

marmarek commented 1 year ago

This applies only to restoring from backup, right? On fresh Windows install it appears to work fine: https://openqa.qubes-os.org/tests/76774#step/windows_clipboard_and_filecopy/6

GWeck commented 1 year ago

I checked now with a new installation of Windows 10 Pro 21H2 and QWT 4.1.69, according to the documentation.

marmarek commented 1 year ago
  • It is possible to start a Windows qube by clicking on the Qubes menu entry for that qube, e.g. on Notepad, which is available.

Does the application start in this case?

marmarek commented 1 year ago
  • Their content is not identical to the Windows menu structure, however. Just some entries in the submenus are shown in Qubes

What is example difference? Some entry is missing?

GWeck commented 1 year ago

Does the application start in this case?

No - there is just the spinning wheel near the cursor, but nothing happens. After a few (5 or so) seconds, the wheel disappears. From within Windows, the application can be started.

What is example difference? Some entry is missing?

These are the menu entries that are available within Qubes:

:-Windows-system32-config-systemprofile-AppData-Roaming-Microsoft-Internet Explorer-Quick Launch Microsoft Edge
Accessibility Speech Recognition
Accessories Math Input Panel
Accessories Notepad
Accessories Paint
Accessories Quick Assist
Accessories Remote Desktop Connection
Accessories Snipping Tool
Accessories Steps Recorder
Accessories Windows Fax and Scan
Accessories Windows Media Player
Accessories Wordpad
Accessories-System Tools Character Map
Administrative Tools Component Services
Administrative Tools Computer Management
Administrative Tools dfrgui
Administrative Tools Disk Cleanup
Administrative Tools Event Viewer
Administrative Tools iSCSI Initiator
Administrative Tools Memory Diagnostics Tool
Administrative Tools Performance Monitor
Administrative Tools Print Management
Administrative Tools RecoveryDrive
Administrative Tools Registry Editor
Administrative Tools Resource Monitor
Administrative Tools Security Configuration Management
Administrative Tools services
Administrative Tools System Configuration
Administrative Tools System Information
Administrative Tools Task Scheduler
Administrative Tools Windows Defender Firewall with Advanced Security
Immersive Control Panel
Microsoft Edge
Start qube
System Tools Task Manager
Windows PowerShell 
Windows PowerShell ISE (x86)

This corresponds roughly to the last two submenus Accessories and Adminitrative Tools of the Windows menu. The rest of the Windows menu is completely missing.

I backed up my two Windows test qubes and restored them from the backup. The behavior stays the same, i.e. these menus are available after a refresh, and can be transferred to the Qubes menu, but have no effect on the Windows qube, with the exception that they start it if it is not running, but they start no apps.

GWeck commented 1 year ago

I repeated the test now with Windows 7 Professional SP1 fully updated, which I installed as new HVMs.

Here, Qubes shows the correct (as far as I could see) menu structure as available, and the menu items can be selected for the Qubes menu. The selected Qubes menu entries work as they should. and, in seamless mode, the Windows VM can be started, by e.g. selecting the Windows Explorer menu entry, whereupon the qube starts and shows the Windows Explorer - just as it should.

On the other hand, Windows 10 (and probably also W11) works correctly under Qubes R4.1.2. So the whole thing probably is caused by the menu interface between W10 and the new Qubes application menu, whereas a new installation of Windows 7 is not affected. With Windows 7, only VMs restored from R4.1.2 are affected.

marmarta commented 1 year ago

The menu doesn't really change much in the way programs are run, though. I wonder if it's not a difference in the way .desktop files for windows qubes are generated.

GWeck commented 1 year ago

That's plausible: Windows 10 may simply deliver wrong or insufficient information to create the .desktop files.

On the other hand, with respect to the broken menus on qubes restored from R4.1 backup, could it be that there some information needed to create the .desktop files is missing?

GWeck commented 1 year ago

Maybe I found a cause of the problems mentioned above: Creating the App menu desktop files from the Windows menus involves starting the Powershell script get-appmenus.ps1 in the Windows qube. In Qubes R4.2 (with QWT 4.1.68 or QWT 4.1.69), this script does not find/process the Windows menu entries. Instead, it throws errors like the following:

Script_Errors.txt

Consequently, the lists of .desktop files and icons are not filled, and the list of hashes in the registry key AppMenus stays empty. If you fill these lists manually, e.g. from an R4.1 system, the menus work as expected.

As I don't speak Powershell, I have no idea what went wrong there and what is the difference to R4.1.

DemiMarie commented 1 year ago

@GWeck Can you set the language of the Windows machine to English and retry? Those look like ArgumentNullException or NullReferenceException, but I can’t read enough German to understand it.

GWeck commented 1 year ago

I am not too sure how to install English in my Windows VM, but I am trying. It may take some time, however.

At least I tried to translate the log file using the DeepL translator, and it looks plausible. Here are the results:

Script_Errors_English.txt

I hope this helps a bit until I get the real text in English.

GWeck commented 10 months ago

The reason for these errors is that the COM-object WshShell is created with the wrong type. Executing $WshShell | Get-Member returns

   TypeName: System.__ComObject

Name                      MemberType Definition
----                      ---------- ----------
CreateObjRef              Method     System.Runtime.Remoting.ObjRef CreateOb...
Equals                    Method     bool Equals(System.Object obj)
GetHashCode               Method     int GetHashCode()
GetLifetimeService        Method     System.Object GetLifetimeService()
GetType                   Method     type GetType()
InitializeLifetimeService Method     System.Object InitializeLifetimeService()
ToString                  Method     string ToString()

while it should return

   TypeName: System.__ComObject#{41904400-be18-11d3-a28b-00104bd35090}

Name                     MemberType            Definition
----                     ----------            ----------
AppActivate              Method                bool AppActivate (Variant, Va...
CreateShortcut           Method                IDispatch CreateShortcut (str...
Exec                     Method                IWshExec Exec (string)
ExpandEnvironmentStrings Method                string ExpandEnvironmentStrin...
LogEvent                 Method                bool LogEvent (Variant, strin...
Popup                    Method                int Popup (string, Variant, V...
RegDelete                Method                void RegDelete (string)
RegRead                  Method                Variant RegRead (string)
RegWrite                 Method                void RegWrite (string, Varian...
Run                      Method                int Run (string, Variant, Var...
SendKeys                 Method                void SendKeys (string, Variant)
Environment              ParameterizedProperty IWshEnvironment Environment (...
CurrentDirectory         Property              string CurrentDirectory () {g...
SpecialFolders           Property              IWshCollection SpecialFolders...

So there is no method SpeicalFolders that could be invoked to retrieve the Windows menu structure. I suppose that the type of the COM-object to be created just does not exist. I checked that .NET 3.5.1 and 4.8 are both installed on a system returning the correct COM-Object and on the faulty VM under Qubes R4.2, so there must be something else missing.

I'll continue checking.

DemiMarie commented 10 months ago
  • The Qube Manager offers the actions to enable/disable seamless mode. As is to be expected for Windows 10, this has no effect on the display of the Windows qube, but the Qube Manager crashes.

Please report a bug for this @GWeck.

GWeck commented 10 months ago

Just created issue #8677

GWeck commented 10 months ago

Restoring a backup from Qubes R4.1 in R4.2 destroys the COM-Structure of the restored Windows 7 qube:

This looks as if the restore of Windows qubes from R4.1 is faulty under R4.2.

GWeck commented 10 months ago

Backup-restore seems to be innocent: I just copied root.img manually from R4.1.2 to R4.20.-rc4, and the behavior is the same: The qube under R4.2.0-rc4 has the faulty COM-Object WshShell.

DemiMarie commented 10 months ago

@GWeck How much is on root.img and how much is on private.img? I wonder if some COM stuff (registry?) wound up under private.img.

GWeck commented 10 months ago

No change if private.img is copied together with root.img. Anyhow, I suppose that the relevant parts are stored under HKLM and not under HKCU, which is kept in the private image.

The problem seems to come from the fact that Wscript.Shell is used to create a COM-object of the wrong type, as shown in the first lines of the listings above. This affects just the scripting host; other COM-objects like Shell.Application behave normally. On the other hand, the scripting host can be started normally, but this does not change the behavior.

GWeck commented 9 months ago

I did some more testing in order to locate the cause of the problems with transferring the Windows menus to the Qubes menu. All tests were performed on Qubes R4.2.0-rc5 fully updated.

The direct transfer of a Windows 7 template having Qubes Windows Tools on board from R4.1.2 to R4.2.0-rc5 showed a more difficult behavior:

I hope this helps somewhat to pinpoint the cause of the problems and will repeat the tests with a Windows 10 TemplateVM.

GWeck commented 9 months ago

For Windows 10, the results are similar, but, of course, without the Qubes GUI Agent, which is not yet available for this system. All tests were performed on Qubes R4.2.0-rc5 fully updated.

The direct transfer of a Windows 10 22H2 template from R4.1.2 to R4.2.0-rc5 showed a more difficult behavior:

Windows 11 will probably behave in the same way, as this system is basically just a somewhat more user-unfriendly version of Windows 10.

So, Windows 10 appears to be more robust than Windows 7, partially due to the lack of the Qubes GUI Agent. If the problems described in QSB-091 are solved, perhaps by including a new version of the Xen drivers, and a new version of the Qubes graphic driver is made available, as @marmarek has said at the Qubes Summit, then we might have an excellent integration of Windows into Qubes! I am looking forward to this and hope that Windows 7 - in my opinion the last usable version of this system - will still be supported.