Open-Shell takes over the right-click on the start button, which in
Windows opens the Win+X menu (Terminal (Admin), Device Manager, Disk
Management and so on). Shift+right-click still opens it, but nothing on
screen says so, and the Controls setting can only swap the two menus,
not offer both.
Win+X Menu is now in the context menu, in the section of Windows
Explorer and Open, on Windows 8 and later. It calls ShowWinX(), as
Shift+right-click does. EnableExplorer doesn't remove it: that setting
is about opening folders, and Win+X opens none. The help's Operation
section mentions Shift+right-click and the new item.
Menu.WinXMenu is a new string, in English only for now. A Start Menu
(Windows) item was in an earlier version and was dropped in review:
Open-Shell's own menu has that item by default.
* Add Reload to the start button's context menu
Reload exits the menu and starts it again, so it goes through startup
anew: settings, the item and icon caches in memory, and the hook into
Explorer. Useful after something the running menu does not notice, like a
Store app updating itself under a pinned shortcut. Until now that took Exit
and starting StartMenu.exe again by hand.
The item sits above Exit, shown and disabled under the same conditions
(EnableExit, CanShowMenu), since it exits first. It starts
"StartMenu.exe -reload" from the DLL's own folder, so it works for any
install location.
StartMenu.exe -reload is the new part. Like -exit it posts MSG_EXIT to the
running menu, but then it waits for that process to end (up to 20 s) and
carries on as a normal start, owning the single-instance mutex. It waits
for the process, not only the mutex: the old menu releases the mutex just
before it exits, and the new one should hook Explorer only once the old one
is gone. "-reloadsettings" also contains "-reload", so -reload counts only
when no other command matched.
The label is Menu.MenuReload, in English only for now; other languages fall
back to the English default until translated.
* Help: Reload on the start button's menu and StartMenu.exe -reload
The Operation section lists what the start button's right-click menu
does; it now includes reloading. The Settings section said a few settings
need the menu to be exited before they show; reloading is the direct way
now, so it says that. The Command Line section gets -reload, next to
-exit, including that it just starts the menu when none is running
(checked on the real machine).
It also no longer counts the parameters: "supports 5" was already short
of what StartMenu.exe accepts (for example -reloadsettings), and adding
one made it 6 of more.
* Move the reload steps into their own functions
The -reload handling sat inline in wWinMain, three levels deep, with two
bare timeouts. It is now TakeOverFromRunningMenu, with the timeouts named
and explained, and wWinMain keeps a three-line call. The start button's
Reload item calls ReloadStartMenu instead of building the path inline.
One difference, on purpose: if the running menu's window is found but its
process can't be opened, the old code still told the menu to exit, then
gave up waiting and left no menu running. Now it leaves the running menu
alone and returns, as when no menu is found.
---------
Co-authored-by: ge0rdi <ge0rdi@users.noreply.github.com>
CleanStartMenuDLL called CloseManagers() before CMenuContainer::CloseStartMenu().
When the start menu was still open at exit, destroying it ran
CMenuContainer::OnDestroy -> g_SearchManager.CloseMenu(), which locks the
search manager's critical section. CloseManagers had already deleted that
lock, so Explorer crashed with an access violation in
ntdll!RtlpWaitOnCriticalSection. This order dates back to at least the
Classic Shell -> Open-Shell rebrand and is in 4.4.198 and current master.
The menu, the settings window and the owner window are now closed before
the managers are shut down.
Found with a crash dump (WER LocalDumps + full page heap on explorer.exe):
StartMenuDLL!CSearchManager::CloseMenu+0x2d (SearchManager.cpp:139)
StartMenuDLL!CMenuContainer::OnDestroy+0x361
...
StartMenuDLL!CMenuContainer::CloseStartMenu+0xa0
StartMenuDLL!CleanStartMenuDLL+0x605
StartMenuDLL!HookDesktopThread+0x7e6
FAILURE_BUCKET_ID: NULL_CLASS_PTR_WRITE_AVRF_c0000005_StartMenuDLL.dll!CSearchManager::CloseMenu
Reproduce: start StartMenu.exe, run "StartMenu.exe -open", and while the
menu is visible run "StartMenu.exe -exit". Explorer restarts.
Verified on Windows 11 (26100): unmodified master crashed Explorer in every
run with the menu open at exit; with this change, 5 of 5 such runs exited
cleanly.