Skip to content

Commit c4eba79

Browse files
committed
[ExplorerPatcher] Improved EP taskbar detection
EP changed their `ep_taskbar*.dll` naming scheme. We will look for module whose name starts with `ep_taskbar` which should be compatible with both old and new naming. Fixes #2474
1 parent 9518c3b commit c4eba79

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <dbghelp.h>
2323
#include <set>
2424
#include <Thumbcache.h>
25+
#include <tlhelp32.h>
2526

2627
#define HOOK_DROPTARGET // define this to replace the IDropTarget of the start button
2728
#define START_TOUCH // touch support for the start button
@@ -2936,6 +2937,35 @@ static void OpenCortana( void )
29362937
ShellExecute(NULL,NULL,L"shell:::{2559a1f8-21d7-11d4-bdaf-00c04f60b9f0}",NULL,NULL,SW_SHOWNORMAL);
29372938
}
29382939

2940+
HMODULE GetModuleHandleByPrefix(const WCHAR* prefix)
2941+
{
2942+
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
2943+
if (snapshot == INVALID_HANDLE_VALUE)
2944+
return nullptr;
2945+
2946+
size_t prefixLength = wcslen(prefix);
2947+
2948+
MODULEENTRY32 me{};
2949+
me.dwSize = sizeof(me);
2950+
2951+
HMODULE result = nullptr;
2952+
2953+
if (Module32First(snapshot, &me))
2954+
{
2955+
do
2956+
{
2957+
if (_wcsnicmp(me.szModule, prefix, prefixLength) == 0)
2958+
{
2959+
result = reinterpret_cast<HMODULE>(me.modBaseAddr);
2960+
break;
2961+
}
2962+
} while (Module32Next(snapshot, &me));
2963+
}
2964+
2965+
CloseHandle(snapshot);
2966+
return result;
2967+
}
2968+
29392969
static void InitStartMenuDLL( void )
29402970
{
29412971
static bool initCalled = false;
@@ -2979,10 +3009,7 @@ static void InitStartMenuDLL( void )
29793009
auto module=GetModuleHandle(L"taskbar.dll");
29803010
if (!module)
29813011
{
2982-
module = GetModuleHandle(L"ep_taskbar.5.dll");
2983-
if (!module)
2984-
module = GetModuleHandle(L"ep_taskbar.2.dll");
2985-
3012+
module = GetModuleHandleByPrefix(L"ep_taskbar");
29863013
if (module)
29873014
g_epTaskbar = true;
29883015
}

0 commit comments

Comments
 (0)