Skip to content

Commit

Permalink
bug fixes and optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Maplespe committed Apr 29, 2023
1 parent 883eccc commit 28b3cc6
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 43 deletions.
98 changes: 55 additions & 43 deletions ExplorerBlurMica/HookDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ void OnDocComplete(std::wstring path, DWORD threadID)
//std::wcout << L"path[" << threadID << L"] " << path << L"\n";
auto iter = m_DUIList.find(threadID);
if (iter != m_DUIList.end())
iter->second.path = path;
{
iter->second.path = std::move(path);
}
}


Expand Down Expand Up @@ -244,10 +246,12 @@ namespace Hook
bool IsExcludePath()
{
auto iter = m_DUIList.find(GetCurrentThreadId());
if (iter != m_DUIList.end())
if (iter == m_DUIList.end()) return true;
if (iter->second.mainWnd == nullptr)
{
if (iter->second.path.find(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}") != std::wstring::npos)
return true;
/*if (iter->second.path.find(L"::{26EE0668-A00A-44D7-9371-BEB064C98683}") != std::wstring::npos)
return true;*/
return true;
}
return false;
}
Expand Down Expand Up @@ -434,29 +438,29 @@ namespace Hook
if (ClassName == L"DirectUIHWND" && GetWindowClassName(hWndParent) == L"SHELLDLL_DefView")
{
//继续查找父级
HWND parent = GetParent(hWndParent);
if (GetWindowClassName(parent) == L"ShellTabWindowClass")
if (GetWindowClassName(hWndParent) == L"ShellTabWindowClass")
{
parent = GetParent(parent);

//设置Blur
SetWindowBlur(parent);

//22H2
if (g_sysBuildNumber >= 22500)
{
SetWindowSubclass(parent, MyWndSubProc, 0, (DWORD_PTR)0);
}

//记录到列表中 Add to list
DWORD tid = GetCurrentThreadId();
m_DUIList[tid].hWnd = hWnd;
}
}
//查找主窗口
else if(ClassName == L"SHELLDLL_DefView" && GetWindowClassName(hWndParent) == L"ShellTabWindowClass")
{
HWND mainWnd = GetParent(hWndParent);
//设置Blur
SetWindowBlur(mainWnd);

DUIData data;
data.hWnd = hWnd;
data.mainWnd = parent;

m_DUIList[tid] = data;
//22H2
if (g_sysBuildNumber >= 22500)
{
SetWindowSubclass(mainWnd, MyWndSubProc, 0, (DWORD_PTR)0);
}

//记录到列表中 Add to list
DWORD tid = GetCurrentThreadId();
m_DUIList[tid].mainWnd = mainWnd;
}
//导航树视图
else if (ClassName == L"SysTreeView32")
Expand Down Expand Up @@ -567,10 +571,7 @@ namespace Hook
}
return ret;
}
else
goto Next;
}
Next:
//透明化 Windows 10 Ribbon 在Light模式
auto ribiter = m_ribbonPaint.find(curThread);
if (ribiter != m_ribbonPaint.end())
Expand Down Expand Up @@ -708,7 +709,7 @@ namespace Hook

thread_local bool isCurThread = false;

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

HRESULT hr = S_OK;
HDC hDC = 0;
DTTOPTS dtop = { 0 };
dtop.dwSize = sizeof(DTTOPTS);
dtop.dwFlags = DTT_COMPOSITED | DTT_TEXTCOLOR | DTT_CALLBACK;
dtop.crText = GetTextColor(hdc);
dtop.pfnDrawTextCallback = [](HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc, UINT format, LPARAM lParam)
COLORREF crText = GetTextColor(hdc);
auto callback = [](HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc, UINT format, LPARAM lParam)
{
return _DrawTextW_.Org(hdc, lpchText, cchText, lprc, format);
};

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

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

Expand Down Expand Up @@ -839,10 +836,11 @@ namespace Hook
)
{
HRESULT ret = _GetThemeColor_.Org(hTheme, iPartId, iStateId, iPropId, pColor);

std::wstring kname = GetThemeClassName(hTheme);

//将主要控件的背景色设置为黑色 以供API透明化Blur效果
if (iPropId == TMT_FILLCOLOR && !IsExcludePath())
if (iPropId == TMT_FILLCOLOR)
{
//DUI视图、底部状态栏、导航栏
if (((kname == L"ItemsView" || kname == L"ExplorerStatusBar" || kname == L"ExplorerNavPane")
Expand Down Expand Up @@ -907,13 +905,16 @@ namespace Hook
LPCRECT pRect,
LPCRECT pClipRect)
{
std::wstring kname = GetThemeClassName(hTheme);

if (kname == L"Rebar" && (iPartId == RP_BACKGROUND || iPartId == RP_BAND) && iStateId == 0)
if (!IsExcludePath())
{
return S_OK;
}
std::wstring kname = GetThemeClassName(hTheme);

if (kname == L"Rebar" && (iPartId == RP_BACKGROUND || iPartId == RP_BAND) && iStateId == 0)
{
FillRect(hdc, pRect, m_clearBrush);
return S_OK;
}
}
return _DrawThemeBackground_.Org(hTheme, hdc, iPartId, iStateId, pRect, pClipRect);
}

Expand All @@ -926,9 +927,12 @@ namespace Hook
const DTBGOPTS* pOptions
)
{
std::wstring kname = GetThemeClassName(hTheme);
if (!IsExcludePath())
{
std::wstring kname = GetThemeClassName(hTheme);

//std::wcout << kname << L" p:" << iPartId << L" s:" << iStateId << std::endl;

//Blur模式下 透明化 Header、Rebar、预览面板、命令模块
if (kname == L"Header") {
if ((iPartId == HP_HEADERITEM && iStateId == HIS_NORMAL)
Expand All @@ -940,6 +944,7 @@ namespace Hook
{
if ((iPartId == RP_BACKGROUND || iPartId == RP_BAND) && iStateId == 0)
{
FillRect(hdc, pRect, m_clearBrush);
return S_OK;
}
}
Expand All @@ -952,12 +957,19 @@ namespace Hook
{
if (iPartId == 1 && iStateId == 0) {

FillRect(hdc, pRect, m_clearBrush);
return S_OK;
}
}
else if (kname == L"ControlPanel")
{
if (iPartId == 2 && iStateId == 0) {

FillRect(hdc, pRect, m_clearBrush);
return S_OK;
}
}
}
End:
return _DrawThemeBackgroundEx_.Org(hTheme, hdc, iPartId, iStateId, pRect, pOptions);
}
}
12 changes: 12 additions & 0 deletions ExplorerBlurMica/ShellLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,16 @@ STDAPI DllRegisterServer()
RegCloseKey(hkey);

//注册BHO组件
//if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, (LR"(SOFTWARE\Classes\Drive\shellex\FolderExtensions\)"
// + CLSID_SHELL_BHO_STR).c_str(), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL) != ERROR_SUCCESS)
// return SELFREG_E_CLASS;

////注册文件对话框
//DWORD value = 255;
//RegSetValueExW(hkey, L"DriveMask", 0, REG_DWORD, (const BYTE*)&value, sizeof(DWORD));

//RegCloseKey(hkey);

if (RegCreateKeyExW(HKEY_LOCAL_MACHINE, (LR"(Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\)"
+ CLSID_SHELL_BHO_STR).c_str(), 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL) != ERROR_SUCCESS)
return SELFREG_E_CLASS;
Expand All @@ -275,6 +285,8 @@ STDAPI DllUnregisterServer()
//删除BHO组件注册
RegDeleteKeyW(HKEY_LOCAL_MACHINE, (LR"(Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\\)"
+ CLSID_SHELL_BHO_STR).c_str());
/*RegDeleteKeyW(HKEY_LOCAL_MACHINE, (LR"(SOFTWARE\Classes\Drive\shellex\FolderExtensions\)"
+ CLSID_SHELL_BHO_STR).c_str());*/
//删除COM组件注册
RegDeleteKeyW(HKEY_CLASSES_ROOT, (L"CLSID\\" + CLSID_SHELL_BHO_STR + L"\\InProcServer32").c_str());
RegDeleteKeyW(HKEY_CLASSES_ROOT, (L"CLSID\\" + CLSID_SHELL_BHO_STR).c_str());
Expand Down
16 changes: 16 additions & 0 deletions ExplorerBlurMica/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ BOOL APIENTRY DllMain( HMODULE hModule,
g_hModule = hModule;
DisableThreadLibraryCalls(hModule);

if (GetModuleHandleW(L"SettingSyncHost.exe")
|| GetModuleHandleW(L"SkyDrive.exe")
|| GetModuleHandleW(L"FileManager.exe")
|| GetModuleHandleW(L"vmtoolsd.exe")
|| GetModuleHandleW(L"svchost.exe")
|| GetModuleHandleW(L"SearchIndexer.exe")
|| GetModuleHandleW(L"WSHost.exe")
|| GetModuleHandleW(L"wmpnetwk.exe")
|| GetModuleHandleW(L"svchost.exe")
|| GetModuleHandleW(L"dllhost.exe")
|| GetModuleHandleW(L"spoolsv.exe"))
{
//FreeLibraryAndExitThread(hModule, 0);
return FALSE;
}

//防止别的程序意外加载
wchar_t pName[MAX_PATH];
GetModuleFileNameW(NULL, pName, MAX_PATH);
Expand Down
54 changes: 54 additions & 0 deletions build/x64/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
本软件是免费开源软件 使用LGPLv3许可证
This software is free and open source software licensed under LGPLv3
https://github.com/Maplespe/ExplorerBlurMica

更新日志(update log):

1.0.5 2023-4-29
修复了与StartAllBack等软件调节导航栏相关的功能的兼容性问题 #17
修复了控制面板的部分渲染问题和通过shell方式打开特定页面渲染效果异常的问题
优化了程序效率和代码

Fixed the compatibility issue with the function of modifying the navigation bar with software such as StartAllBack #17
Fixed some rendering issues in the control panel and the issue of rendering abnormalities when opening certain pages via shell.
Optimized program efficiency and code.

--------------------------------------------------------------------------

1.0.4 2023-1-12
修复了特定情况下可能出现背景渲染错误的问题 #10
修复了控制面板命令模块和导航栏渲染错误的问题 #9
修复了微软输入法文字颜色渲染错误的问题 #8

Fixed possible rendering errors in certain cases #10
Fixed control panel's command module and navbar rendering errors #9
Fixed Microsoft IME input text rendering error in edit box #8

--------------------------------------------------------------------------

1.0.3 2022-11-21
修复了win10 dark 主题颜色下地址栏不透明的问题 #7
修复了win10 配置文件 Blur效果和Acrylic效果参数ID相反的问题

Fixed the problem that the Win10 dark address bar was opaque #7
Fixed the problem that the Blur effect of the win10 configuration file was opposite to the Acrylic effect parameter ID.

--------------------------------------------------------------------------

1.0.2 2022-10-22
支持Windows 22H2系统 支持多标签页 #5
修复了Windows11 最左边有白色竖条的问题
修复了Windows11 暗色模式下地址栏不透明的问题
增强了程序稳定性
增加了Windows11的Acrylic支持 Mica效果现在为effect=2

Support Windows 22H2 system supports multiple tabs #5
Fixed the problem of white vertical bar on the left of WIndows11
Fixed the problem of opaque address bar in Windows 11 dark mode
The program stability is enhanced
Added Acrylic support for Windows 11, Mica effect is now effect=2

--------------------------------------------------------------------------

1.0.1 2022-8-27
Fixed the bug of opaque ribbon bar in Windows 10 English language system

0 comments on commit 28b3cc6

Please sign in to comment.