Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ResourceHelper.h"
#include "LogManager.h"
#include "TouchHelper.h"
#include "Win11StartButton.h"
#include "IatHookHelper.h"
#include "dllmain.h"
#include <uxtheme.h>
Expand Down Expand Up @@ -2643,6 +2644,7 @@ void UpdateTaskBars( TUpdateTaskbar update )
InvalidateRect(taskBar.taskBar,NULL,TRUE);
PostMessage(taskBar.taskBar,WM_THEMECHANGED,0,0);
}
UpdateWin11StartButtonMonitor();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3227,6 +3229,7 @@ if (!g_bTrimHooks)

UpdateTaskBars(TASKBAR_RECREATE_BUTTONS);
UpdateTaskBars(TASKBAR_UPDATE_TEXTURE);
StartWin11StartButtonMonitor();
}

static void RecreateStartButton( size_t taskbarId )
Expand Down Expand Up @@ -3288,6 +3291,8 @@ static DWORD WINAPI ExitThreadProc( void *param )

static void CleanStartMenuDLL( void )
{
StopWin11StartButtonMonitor();

ClearIatHook(g_DwmpBTRHook);
g_DwmpBTRHook=NULL;
ClearIatHook(g_DwmpTWWRHook);
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TouchHelper.cpp" />
<ClCompile Include="Win11StartButton.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Accessibility.h" />
Expand All @@ -110,6 +111,7 @@
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TouchHelper.h" />
<ClInclude Include="Win11StartButton.h" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\Setup\OpenShell.ico" />
Expand Down
6 changes: 6 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<ClCompile Include="TouchHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Win11StartButton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Accessibility.h">
Expand Down Expand Up @@ -128,6 +131,9 @@
<ClInclude Include="TouchHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Win11StartButton.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Resource Files</Filter>
</ClInclude>
Expand Down
113 changes: 113 additions & 0 deletions Src/StartMenu/StartMenuDLL/Win11StartButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Windows 11 native Start button suppression bridge.
//
// XAML Diagnostics retains its TAP site object for the diagnostics session.
// The TAP therefore lives in StartMenuHelper, which may remain resident in
// Explorer, while StartMenuDLL can still unload/reload on Exit.

#include "stdafx.h"
#include "Win11StartButton.h"
#include "Settings.h"
#include "LogManager.h"
#include "ResourceHelper.h"

typedef void (__cdecl *StartWin11StartButtonTap_t)( BOOL enabled, BOOL allTaskbars );
typedef void (__cdecl *UpdateWin11StartButtonTap_t)( BOOL enabled, BOOL allTaskbars );
typedef void (__cdecl *StopWin11StartButtonTap_t)( void );

static HMODULE g_StartButtonTapModule = NULL;
static StartWin11StartButtonTap_t g_StartButtonTapStart = NULL;
static UpdateWin11StartButtonTap_t g_StartButtonTapUpdate = NULL;
static StopWin11StartButtonTap_t g_StartButtonTapStop = NULL;

static bool LoadStartButtonTap( void )
{
if (g_StartButtonTapModule)
return true;

#ifdef _WIN64
const wchar_t helperName[] = L"StartMenuHelper64.dll";
#else
const wchar_t helperName[] = L"StartMenuHelper32.dll";
#endif

// Prefer a helper next to StartMenuDLL for local development builds, but
// installed Open-Shell keeps StartMenuHelper in System32.
HMODULE module = NULL;
wchar_t path[MAX_PATH];
DWORD pathLength = GetModuleFileName(g_Instance, path, _countof(path));
if (pathLength && pathLength < _countof(path))
{
wchar_t *name = wcsrchr(path, L'\\');
if (name)
{
name++;
const size_t remaining = path + _countof(path) - name;
if (_countof(helperName) <= remaining)
{
wcscpy_s(name, remaining, helperName);
module = LoadLibraryEx(path, NULL,
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
}
}
}

if (!module)
module = LoadLibraryEx(helperName, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);

if (!module)
{
LogToFile(STARTUP_LOG, L"Win11StartButton: unable to load TAP helper 0x%08X", GetLastError());
return false;
}

StartWin11StartButtonTap_t start =
(StartWin11StartButtonTap_t)GetProcAddress(module, "StartWin11StartButtonTap");
UpdateWin11StartButtonTap_t update =
(UpdateWin11StartButtonTap_t)GetProcAddress(module, "UpdateWin11StartButtonTap");
StopWin11StartButtonTap_t stop =
(StopWin11StartButtonTap_t)GetProcAddress(module, "StopWin11StartButtonTap");
if (!start || !update || !stop)
{
LogToFile(STARTUP_LOG, L"Win11StartButton: TAP helper exports are unavailable");
FreeLibrary(module);
return false;
}

g_StartButtonTapModule = module;
g_StartButtonTapStart = start;
g_StartButtonTapUpdate = update;
g_StartButtonTapStop = stop;
return true;
}

void StartWin11StartButtonMonitor( void )
{
if (!IsWin11() || !LoadStartButtonTap())
return;

g_StartButtonTapStart(GetSettingBool(L"EnableStartButton"), GetSettingBool(L"AllTaskbars"));
}

void UpdateWin11StartButtonMonitor( void )
{
if (!IsWin11() || !g_StartButtonTapModule)
return;

g_StartButtonTapUpdate(GetSettingBool(L"EnableStartButton"), GetSettingBool(L"AllTaskbars"));
}

void StopWin11StartButtonMonitor( void )
{
if (!IsWin11() || !g_StartButtonTapModule)
return;

g_StartButtonTapStop();

// Drop only StartMenuDLL's explicit reference. XAML Diagnostics owns the TAP
// module reference for the diagnostics session after a successful connection.
FreeLibrary(g_StartButtonTapModule);
g_StartButtonTapModule = NULL;
g_StartButtonTapStart = NULL;
g_StartButtonTapUpdate = NULL;
g_StartButtonTapStop = NULL;
}
8 changes: 8 additions & 0 deletions Src/StartMenu/StartMenuDLL/Win11StartButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// Windows 11 draws the native Start button in XAML. These helpers hide only
// the native glyph/hit target while Open-Shell's replacement button is active.
// They never move or resize either button.
void StartWin11StartButtonMonitor( void );
void UpdateWin11StartButtonMonitor( void );
void StopWin11StartButtonMonitor( void );
6 changes: 6 additions & 0 deletions Src/StartMenu/StartMenuHelper/StartMenuHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "resource.h"
#include "StartMenuHelper_h.h"
#include "dllmain.h"
#include "Win11StartButtonTap.h"
#include "ResourceHelper.h"
#include "Settings.h"
#include "StringUtils.h"
Expand Down Expand Up @@ -206,6 +207,11 @@ static void StartStartMenu( void )
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
WaitDllInitThread();

HRESULT tapResult = GetWin11StartButtonTapClassObject(rclsid, riid, ppv);
if (tapResult != CLASS_E_CLASSNOTAVAILABLE)
return tapResult;

if (rclsid==g_EmulationClsid)
{
LogToFile(STARTUP_LOG,L"StartMenuHelper: DllGetClassObject1");
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuHelper/StartMenuHelper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<ClCompile Include="ModernSettingsShellFolder.cpp" />
<ClCompile Include="StartMenuExt.cpp" />
<ClCompile Include="StartMenuHelper.cpp" />
<ClCompile Include="Win11StartButtonTap.cpp" />
<ClCompile Include="StartMenuHelper_i.c">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -138,6 +139,7 @@
<ClInclude Include="Resource.h" />
<ClInclude Include="StartMenuExt.h" />
<ClInclude Include="StartMenuHelper_h.h" />
<ClInclude Include="Win11StartButtonTap.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Src/StartMenu/StartMenuHelper/StartMenuHelper.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<ClCompile Include="ModernSettingsContextMenu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Win11StartButtonTap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="StartMenuHelper.idl">
Expand Down Expand Up @@ -100,6 +103,9 @@
<ClInclude Include="ModernSettingsContextMenu.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Win11StartButtonTap.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="StartMenuHelper.rc">
Expand Down
3 changes: 3 additions & 0 deletions Src/StartMenu/StartMenuHelper/StartMenuHelper32.def
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ EXPORTS
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllInstall PRIVATE
StartWin11StartButtonTap
UpdateWin11StartButtonTap
StopWin11StartButtonTap
3 changes: 3 additions & 0 deletions Src/StartMenu/StartMenuHelper/StartMenuHelper64.def
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ EXPORTS
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllInstall PRIVATE
StartWin11StartButtonTap
UpdateWin11StartButtonTap
StopWin11StartButtonTap
Loading