Skip to content

Commit 28b3cc6

Browse files
committed
bug fixes and optimizations
1 parent 883eccc commit 28b3cc6

File tree

4 files changed

+137
-43
lines changed

4 files changed

+137
-43
lines changed

ExplorerBlurMica/HookDef.cpp

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ void OnDocComplete(std::wstring path, DWORD threadID)
149149
//std::wcout << L"path[" << threadID << L"] " << path << L"\n";
150150
auto iter = m_DUIList.find(threadID);
151151
if (iter != m_DUIList.end())
152-
iter->second.path = path;
152+
{
153+
iter->second.path = std::move(path);
154+
}
153155
}
154156

155157

@@ -244,10 +246,12 @@ namespace Hook
244246
bool IsExcludePath()
245247
{
246248
auto iter = m_DUIList.find(GetCurrentThreadId());
247-
if (iter != m_DUIList.end())
249+
if (iter == m_DUIList.end()) return true;
250+
if (iter->second.mainWnd == nullptr)
248251
{
249-
if (iter->second.path.find(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}") != std::wstring::npos)
250-
return true;
252+
/*if (iter->second.path.find(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}") != std::wstring::npos)
253+
return true;*/
254+
return true;
251255
}
252256
return false;
253257
}
@@ -434,29 +438,29 @@ namespace Hook
434438
if (ClassName == L"DirectUIHWND" && GetWindowClassName(hWndParent) == L"SHELLDLL_DefView")
435439
{
436440
//继续查找父级
437-
HWND parent = GetParent(hWndParent);
438-
if (GetWindowClassName(parent) == L"ShellTabWindowClass")
441+
if (GetWindowClassName(hWndParent) == L"ShellTabWindowClass")
439442
{
440-
parent = GetParent(parent);
441-
442-
//设置Blur
443-
SetWindowBlur(parent);
444-
445-
//22H2
446-
if (g_sysBuildNumber >= 22500)
447-
{
448-
SetWindowSubclass(parent, MyWndSubProc, 0, (DWORD_PTR)0);
449-
}
450-
451443
//记录到列表中 Add to list
452444
DWORD tid = GetCurrentThreadId();
445+
m_DUIList[tid].hWnd = hWnd;
446+
}
447+
}
448+
//查找主窗口
449+
else if(ClassName == L"SHELLDLL_DefView" && GetWindowClassName(hWndParent) == L"ShellTabWindowClass")
450+
{
451+
HWND mainWnd = GetParent(hWndParent);
452+
//设置Blur
453+
SetWindowBlur(mainWnd);
453454

454-
DUIData data;
455-
data.hWnd = hWnd;
456-
data.mainWnd = parent;
457-
458-
m_DUIList[tid] = data;
455+
//22H2
456+
if (g_sysBuildNumber >= 22500)
457+
{
458+
SetWindowSubclass(mainWnd, MyWndSubProc, 0, (DWORD_PTR)0);
459459
}
460+
461+
//记录到列表中 Add to list
462+
DWORD tid = GetCurrentThreadId();
463+
m_DUIList[tid].mainWnd = mainWnd;
460464
}
461465
//导航树视图
462466
else if (ClassName == L"SysTreeView32")
@@ -567,10 +571,7 @@ namespace Hook
567571
}
568572
return ret;
569573
}
570-
else
571-
goto Next;
572574
}
573-
Next:
574575
//透明化 Windows 10 Ribbon 在Light模式
575576
auto ribiter = m_ribbonPaint.find(curThread);
576577
if (ribiter != m_ribbonPaint.end())
@@ -708,7 +709,7 @@ namespace Hook
708709

709710
thread_local bool isCurThread = false;
710711

711-
if (!IsExcludePath() && !(option & ETO_GLYPH_INDEX) && !(option & ETO_IGNORELANGUAGE)
712+
if (!IsExcludePath() && !(CheckCaller(L"msctf.dll")) && !(option & ETO_GLYPH_INDEX) && !(option & ETO_IGNORELANGUAGE)
712713
&& !isCurThread && !str.empty() && m_drawtextState.find(GetCurrentThreadId()) == m_drawtextState.end())
713714
{
714715
isCurThread = true;
@@ -732,17 +733,13 @@ namespace Hook
732733
IntersectClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom);
733734
}
734735

735-
HRESULT hr = S_OK;
736-
HDC hDC = 0;
737-
DTTOPTS dtop = { 0 };
738-
dtop.dwSize = sizeof(DTTOPTS);
739-
dtop.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR | DTT_CALLBACK;
740-
dtop.crText = GetTextColor(hdc);
741-
dtop.pfnDrawTextCallback = [](HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc, UINT format, LPARAM lParam)
736+
COLORREF crText = GetTextColor(hdc);
737+
auto callback = [](HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc, UINT format, LPARAM lParam)
742738
{
743739
return _DrawTextW_.Org(hdc, lpchText, cchText, lprc, format);
744740
};
745741

742+
HRESULT hr = S_OK;
746743
//合批绘制文本
747744
auto fun = [&](HDC hDC) {
748745
HTHEME hTheme = OpenThemeData((HWND)0, L"Menu");
@@ -771,7 +768,7 @@ namespace Hook
771768
{
772769
//先绘制上一批
773770
hr = DrawTextWithGlow(hDC, batchStr.c_str(), (int)batchStr.length(), &batchRc, DT_LEFT | DT_TOP | DT_SINGLELINE,
774-
dtop.crText, 0, 0, 0, 0, dtop.pfnDrawTextCallback, 0);
771+
crText, 0, 0, 0, 0, callback, 0);
775772
//hr = _DrawThemeTextEx_.Org(hTheme, hDC, 0, 0, batchStr.c_str(), batchStr.length(), DT_LEFT | DT_TOP | DT_SINGLELINE, &batchRc, &dtop);
776773

777774
batch = false;
@@ -785,7 +782,7 @@ namespace Hook
785782
if (i == c - 1)
786783
{
787784
hr = DrawTextWithGlow(hDC, batchStr.c_str(), (int)batchStr.length(), &batchRc, DT_LEFT | DT_TOP | DT_SINGLELINE,
788-
dtop.crText, 0, 0, 0, 0, dtop.pfnDrawTextCallback, 0);
785+
crText, 0, 0, 0, 0, callback, 0);
789786
//hr = _DrawThemeTextEx_.Org(hTheme, hDC, 0, 0, batchStr.c_str(), batchStr.length(), DT_LEFT | DT_TOP | DT_SINGLELINE, &batchRc, &dtop);
790787
}
791788

@@ -839,10 +836,11 @@ namespace Hook
839836
)
840837
{
841838
HRESULT ret = _GetThemeColor_.Org(hTheme, iPartId, iStateId, iPropId, pColor);
839+
842840
std::wstring kname = GetThemeClassName(hTheme);
843841

844842
//将主要控件的背景色设置为黑色 以供API透明化Blur效果
845-
if (iPropId == TMT_FILLCOLOR && !IsExcludePath())
843+
if (iPropId == TMT_FILLCOLOR)
846844
{
847845
//DUI视图、底部状态栏、导航栏
848846
if (((kname == L"ItemsView" || kname == L"ExplorerStatusBar" || kname == L"ExplorerNavPane")
@@ -907,13 +905,16 @@ namespace Hook
907905
LPCRECT pRect,
908906
LPCRECT pClipRect)
909907
{
910-
std::wstring kname = GetThemeClassName(hTheme);
911-
912-
if (kname == L"Rebar" && (iPartId == RP_BACKGROUND || iPartId == RP_BAND) && iStateId == 0)
908+
if (!IsExcludePath())
913909
{
914-
return S_OK;
915-
}
910+
std::wstring kname = GetThemeClassName(hTheme);
916911

912+
if (kname == L"Rebar" && (iPartId == RP_BACKGROUND || iPartId == RP_BAND) && iStateId == 0)
913+
{
914+
FillRect(hdc, pRect, m_clearBrush);
915+
return S_OK;
916+
}
917+
}
917918
return _DrawThemeBackground_.Org(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
918919
}
919920

@@ -926,9 +927,12 @@ namespace Hook
926927
const DTBGOPTS* pOptions
927928
)
928929
{
929-
std::wstring kname = GetThemeClassName(hTheme);
930930
if (!IsExcludePath())
931931
{
932+
std::wstring kname = GetThemeClassName(hTheme);
933+
934+
//std::wcout << kname << L" p:" << iPartId << L" s:" << iStateId << std::endl;
935+
932936
//Blur模式下 透明化 Header、Rebar、预览面板、命令模块
933937
if (kname == L"Header") {
934938
if ((iPartId == HP_HEADERITEM && iStateId == HIS_NORMAL)
@@ -940,6 +944,7 @@ namespace Hook
940944
{
941945
if ((iPartId == RP_BACKGROUND || iPartId == RP_BAND) && iStateId == 0)
942946
{
947+
FillRect(hdc, pRect, m_clearBrush);
943948
return S_OK;
944949
}
945950
}
@@ -952,12 +957,19 @@ namespace Hook
952957
{
953958
if (iPartId == 1 && iStateId == 0) {
954959

960+
FillRect(hdc, pRect, m_clearBrush);
961+
return S_OK;
962+
}
963+
}
964+
else if (kname == L"ControlPanel")
965+
{
966+
if (iPartId == 2 && iStateId == 0) {
967+
955968
FillRect(hdc, pRect, m_clearBrush);
956969
return S_OK;
957970
}
958971
}
959972
}
960-
End:
961973
return _DrawThemeBackgroundEx_.Org(hTheme, hdc, iPartId, iStateId, pRect, pOptions);
962974
}
963975
}

ExplorerBlurMica/ShellLoader.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ STDAPI DllRegisterServer()
259259
RegCloseKey(hkey);
260260

261261
//注册BHO组件
262+
//if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, (LR"(SOFTWARE\Classes\Drive\shellex\FolderExtensions\)"
263+
// + CLSID_SHELL_BHO_STR).c_str(), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL) != ERROR_SUCCESS)
264+
// return SELFREG_E_CLASS;
265+
266+
////注册文件对话框
267+
//DWORD value = 255;
268+
//RegSetValueExW(hkey, L"DriveMask", 0, REG_DWORD, (const BYTE*)&value, sizeof(DWORD));
269+
270+
//RegCloseKey(hkey);
271+
262272
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, (LR"(Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\)"
263273
+ CLSID_SHELL_BHO_STR).c_str(), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL) != ERROR_SUCCESS)
264274
return SELFREG_E_CLASS;
@@ -275,6 +285,8 @@ STDAPI DllUnregisterServer()
275285
//删除BHO组件注册
276286
RegDeleteKeyW(HKEY_LOCAL_MACHINE, (LR"(Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\\)"
277287
+ CLSID_SHELL_BHO_STR).c_str());
288+
/*RegDeleteKeyW(HKEY_LOCAL_MACHINE, (LR"(SOFTWARE\Classes\Drive\shellex\FolderExtensions\)"
289+
+ CLSID_SHELL_BHO_STR).c_str());*/
278290
//删除COM组件注册
279291
RegDeleteKeyW(HKEY_CLASSES_ROOT, (L"CLSID\\" + CLSID_SHELL_BHO_STR + L"\\InProcServer32").c_str());
280292
RegDeleteKeyW(HKEY_CLASSES_ROOT, (L"CLSID\\" + CLSID_SHELL_BHO_STR).c_str());

ExplorerBlurMica/dllmain.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ BOOL APIENTRY DllMain( HMODULE hModule,
1818
g_hModule = hModule;
1919
DisableThreadLibraryCalls(hModule);
2020

21+
if (GetModuleHandleW(L"SettingSyncHost.exe")
22+
|| GetModuleHandleW(L"SkyDrive.exe")
23+
|| GetModuleHandleW(L"FileManager.exe")
24+
|| GetModuleHandleW(L"vmtoolsd.exe")
25+
|| GetModuleHandleW(L"svchost.exe")
26+
|| GetModuleHandleW(L"SearchIndexer.exe")
27+
|| GetModuleHandleW(L"WSHost.exe")
28+
|| GetModuleHandleW(L"wmpnetwk.exe")
29+
|| GetModuleHandleW(L"svchost.exe")
30+
|| GetModuleHandleW(L"dllhost.exe")
31+
|| GetModuleHandleW(L"spoolsv.exe"))
32+
{
33+
//FreeLibraryAndExitThread(hModule, 0);
34+
return FALSE;
35+
}
36+
2137
//防止别的程序意外加载
2238
wchar_t pName[MAX_PATH];
2339
GetModuleFileNameW(NULL, pName, MAX_PATH);

build/x64/ReadMe.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
本软件是免费开源软件 使用LGPLv3许可证
2+
This software is free and open source software licensed under LGPLv3
3+
https://github.com/Maplespe/ExplorerBlurMica
4+
5+
更新日志(update log):
6+
7+
1.0.5 2023-4-29
8+
修复了与StartAllBack等软件调节导航栏相关的功能的兼容性问题 #17
9+
修复了控制面板的部分渲染问题和通过shell方式打开特定页面渲染效果异常的问题
10+
优化了程序效率和代码
11+
12+
Fixed the compatibility issue with the function of modifying the navigation bar with software such as StartAllBack #17
13+
Fixed some rendering issues in the control panel and the issue of rendering abnormalities when opening certain pages via shell.
14+
Optimized program efficiency and code.
15+
16+
--------------------------------------------------------------------------
17+
18+
1.0.4 2023-1-12
19+
修复了特定情况下可能出现背景渲染错误的问题 #10
20+
修复了控制面板命令模块和导航栏渲染错误的问题 #9
21+
修复了微软输入法文字颜色渲染错误的问题 #8
22+
23+
Fixed possible rendering errors in certain cases #10
24+
Fixed control panel's command module and navbar rendering errors #9
25+
Fixed Microsoft IME input text rendering error in edit box #8
26+
27+
--------------------------------------------------------------------------
28+
29+
1.0.3 2022-11-21
30+
修复了win10 dark 主题颜色下地址栏不透明的问题 #7
31+
修复了win10 配置文件 Blur效果和Acrylic效果参数ID相反的问题
32+
33+
Fixed the problem that the Win10 dark address bar was opaque #7
34+
Fixed the problem that the Blur effect of the win10 configuration file was opposite to the Acrylic effect parameter ID.
35+
36+
--------------------------------------------------------------------------
37+
38+
1.0.2 2022-10-22
39+
支持Windows 22H2系统 支持多标签页 #5
40+
修复了Windows11 最左边有白色竖条的问题
41+
修复了Windows11 暗色模式下地址栏不透明的问题
42+
增强了程序稳定性
43+
增加了Windows11的Acrylic支持 Mica效果现在为effect=2
44+
45+
Support Windows 22H2 system supports multiple tabs #5
46+
Fixed the problem of white vertical bar on the left of WIndows11
47+
Fixed the problem of opaque address bar in Windows 11 dark mode
48+
The program stability is enhanced
49+
Added Acrylic support for Windows 11, Mica effect is now effect=2
50+
51+
--------------------------------------------------------------------------
52+
53+
1.0.1 2022-8-27
54+
Fixed the bug of opaque ribbon bar in Windows 10 English language system

0 commit comments

Comments
 (0)