├── .gitignore
├── COPYING.LESSER
├── ExplorerBlurMica.sln
├── ExplorerBlurMica
├── .editorconfig
├── DirectUITweaker.h
├── ExplorerBlurMica.aps
├── ExplorerBlurMica.rc
├── ExplorerBlurMica.vcxproj
├── ExplorerBlurMica.vcxproj.filters
├── ExplorerBlurMica.vcxproj.user
├── Helper
│ ├── DllNotifyRoutine.h
│ ├── GraphicsHelper.h
│ ├── ThemeHelper.h
│ ├── VersionHelper.h
│ ├── Win32Helper.h
│ ├── WinRTHelper.h
│ └── comdef.h
├── HookDef.h
├── MenuToolBarTweaker.h
├── MiscTweaker.h
├── RibbonTweaker.h
├── Source.def
├── TranslucentImpl.h
├── WindowListener.h
├── dllmain.cpp
├── framework.h
├── minhook
│ ├── MinHook.h
│ ├── buffer.cpp
│ ├── buffer.h
│ ├── hde
│ │ ├── hde32.cpp
│ │ ├── hde32.h
│ │ ├── hde64.cpp
│ │ ├── hde64.h
│ │ ├── pstdint.h
│ │ ├── table32.h
│ │ └── table64.h
│ ├── hook.cpp
│ ├── trampoline.cpp
│ └── trampoline.h
├── module.h
├── packages.config
├── resource.h
├── tapsite.h
├── visualtreewatcher.h
└── xamldiagnostics.h
├── LICENSE
├── README.md
├── README_TR.md
├── README_ZH.md
├── program.py
├── screenshot
├── 012949.png
├── 013256.png
├── 152834.png
├── 152929.png
└── 230909.png
└── src
├── config.ini
├── register.cmd
└── uninstall.cmd
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
3 | ################################################################################
4 |
5 | /.vs/ExplorerBlurMica/FileContentIndex
6 | /.vs
7 | /ExplorerBlurMica/x64/Release
8 | /build/x64/Release/ExplorerBlurMica.dll
9 | /build/x64/Release/ExplorerBlurMica.exp
10 | /build/x64/Release/ExplorerBlurMica.lib
11 | /build/x64/Release/ExplorerBlurMica.pdb
12 | /ExplorerBlurMica/x64/Debug
13 | /build/x64/Debug
14 | /build/x64/Release_x64.zip
15 | *.cpp
16 | /packages
17 | /ExplorerBlurMica/HookHelper
18 | /ExplorerBlurMica/old
19 | /ExplorerBlurMica/Helper/DirectUIHelper.h
20 | /ExplorerBlurMica/dllmain.cpp
21 | /build/x64/Release/ExplorerBlurMica.pri
22 | /build/x64/Release/Microsoft.WindowsAppRuntime.Bootstrap.dll
23 | /screenshot/new
24 |
--------------------------------------------------------------------------------
/COPYING.LESSER:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
--------------------------------------------------------------------------------
/ExplorerBlurMica.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.2.32602.215
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplorerBlurMica", "ExplorerBlurMica\ExplorerBlurMica.vcxproj", "{51102466-CD35-4F4F-A1AD-2F08BD33E839}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Debug|x64.ActiveCfg = Debug|x64
17 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Debug|x64.Build.0 = Debug|x64
18 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Debug|x86.ActiveCfg = Debug|Win32
19 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Debug|x86.Build.0 = Debug|Win32
20 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Release|x64.ActiveCfg = Release|x64
21 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Release|x64.Build.0 = Release|x64
22 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Release|x86.ActiveCfg = Release|Win32
23 | {51102466-CD35-4F4F-A1AD-2F08BD33E839}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {D9595EE0-D936-4111-AF16-F9297F3171EB}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/.editorconfig:
--------------------------------------------------------------------------------
1 | # Visual Studio 生成了具有 C++ 设置的 .editorconfig 文件。
2 | root = true
3 |
4 | [*.{c++,cc,cpp,cppm,cu,cuh,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]
5 | end_of_line = lf # 行尾 UNIX 格式 LF
6 | charset = utf-8-bom
--------------------------------------------------------------------------------
/ExplorerBlurMica/DirectUITweaker.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: DirectUITWeaker.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "Helper/DirectUIHelper.h"
20 | #include "WindowListener.h"
21 |
22 | namespace MBox::DTweaker
23 | {
24 | void DUIRequireVerticalLine();
25 | void DUIRequireHorizontalLine();
26 | void DUIRequireOutline();
27 |
28 | void WINAPI My_DirectUI_Element_PaintBackground_Filter(
29 | DirectUI::Element* This,
30 | HDC hdc,
31 | DirectUI::Value* value,
32 | LPCRECT pRect,
33 | LPCRECT pClipRect,
34 | LPCRECT pExcludeRect,
35 | LPCRECT pTargetRect
36 | );
37 |
38 | void WINAPI My_DirectUI_Element_PaintBackground_CleanUp(
39 | DirectUI::Element* This,
40 | HDC hdc,
41 | DirectUI::Value* value,
42 | LPCRECT pRect,
43 | LPCRECT pClipRect,
44 | LPCRECT pExcludeRect,
45 | LPCRECT pTargetRect
46 | );
47 |
48 | class BlinkEraserListener : public IWindowListenerCallback
49 | {
50 | public:
51 | LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled) override;
52 | BlinkEraserListener() = default;
53 | ~BlinkEraserListener() = default;
54 | };
55 |
56 | class CabinetWClassListener : public IWindowListenerCallback
57 | {
58 | using BackdropEffectUpdateCallback = std::function;
59 | using BackdropEffectApplyCallback = std::function;
60 | BackdropEffectUpdateCallback m_callback1 = nullptr;
61 | BackdropEffectApplyCallback m_callback2 = nullptr;
62 | public:
63 | LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled) override;
64 | CabinetWClassListener(BackdropEffectUpdateCallback callback1, BackdropEffectApplyCallback callback2) : m_callback1(callback1), m_callback2(callback2) {}
65 | ~CabinetWClassListener() = default;
66 | };
67 |
68 | class BlackDesktopChildSiteBridgeListener : public IWindowListenerCallback
69 | {
70 | public:
71 | LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled) override;
72 | BlackDesktopChildSiteBridgeListener() = default;
73 | ~BlackDesktopChildSiteBridgeListener() = default;
74 | };
75 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/ExplorerBlurMica.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/ExplorerBlurMica/ExplorerBlurMica.aps
--------------------------------------------------------------------------------
/ExplorerBlurMica/ExplorerBlurMica.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/ExplorerBlurMica/ExplorerBlurMica.rc
--------------------------------------------------------------------------------
/ExplorerBlurMica/ExplorerBlurMica.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | Debug
11 | Win32
12 |
13 |
14 | Release
15 | Win32
16 |
17 |
18 | Debug
19 | x64
20 |
21 |
22 | Release
23 | x64
24 |
25 |
26 |
27 | 16.0
28 | Win32Proj
29 | {51102466-cd35-4f4f-a1ad-2f08bd33e839}
30 | ExplorerBlurMica
31 | 10.0
32 |
33 |
34 |
35 | DynamicLibrary
36 | true
37 | v143
38 | Unicode
39 |
40 |
41 | DynamicLibrary
42 | false
43 | v143
44 | true
45 | Unicode
46 |
47 |
48 | DynamicLibrary
49 | true
50 | v143
51 | Unicode
52 | true
53 | 10.0.10240.0
54 |
55 |
56 | DynamicLibrary
57 | false
58 | v143
59 | true
60 | Unicode
61 | true
62 | 10.0.10240.0
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | $(SolutionDir)build\$(Platform)\$(Configuration)\
84 |
85 |
86 | $(SolutionDir)build\$(Platform)\$(Configuration)\
87 |
88 |
89 | $(SolutionDir)build\$(Platform)\$(Configuration)\
90 |
91 |
92 | $(SolutionDir)build\$(Platform)\$(Configuration)\
93 |
94 |
95 |
96 | Level3
97 | true
98 | WIN32;_DEBUG;EXPLORERBLURMICA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
99 | true
100 | NotUsing
101 | pch.h
102 |
103 |
104 | Windows
105 | true
106 | false
107 | Source.def
108 |
109 |
110 |
111 |
112 | Level3
113 | true
114 | true
115 | true
116 | WIN32;NDEBUG;EXPLORERBLURMICA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
117 | true
118 | NotUsing
119 | pch.h
120 |
121 |
122 | Windows
123 | true
124 | true
125 | true
126 | false
127 | Source.def
128 |
129 |
130 |
131 |
132 | Level3
133 | true
134 | _DEBUG;EXPLORERBLURMICA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
135 | true
136 | NotUsing
137 | pch.h
138 | MultiThreadedDebug
139 | stdcpp20
140 |
141 |
142 | Windows
143 | true
144 | false
145 | Source.def
146 |
147 |
148 |
149 |
150 | Level3
151 | true
152 | true
153 | true
154 | NDEBUG;EXPLORERBLURMICA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
155 | true
156 | NotUsing
157 | pch.h
158 | MultiThreaded
159 | stdcpp20
160 |
161 |
162 | Windows
163 | true
164 | true
165 | false
166 | false
167 | Source.def
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/ExplorerBlurMica.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {2b9bb378-874e-4add-a43b-8c59d43d27d5}
18 |
19 |
20 | {c5cf282b-bde1-4a21-824c-d72735dc68dd}
21 |
22 |
23 | {8237ab45-b664-4135-aef9-2e995b5f8b7e}
24 |
25 |
26 | {f1b50e42-7b0e-4b98-9070-cc5071280c46}
27 |
28 |
29 | {aeaedad3-131a-43b2-affd-96e31008f50d}
30 |
31 |
32 | {14eb13aa-231d-4c06-8f15-4b84351e23ef}
33 |
34 |
35 |
36 |
37 | 头文件
38 |
39 |
40 | minhook
41 |
42 |
43 | minhook
44 |
45 |
46 | minhook\hde
47 |
48 |
49 | minhook\hde
50 |
51 |
52 | minhook\hde
53 |
54 |
55 | minhook\hde
56 |
57 |
58 | minhook\hde
59 |
60 |
61 | minhook
62 |
63 |
64 | 头文件
65 |
66 |
67 | 头文件
68 |
69 |
70 | 头文件
71 |
72 |
73 | 头文件\HookHelper
74 |
75 |
76 | 头文件\HookHelper
77 |
78 |
79 | 头文件\HookHelper
80 |
81 |
82 | 头文件\Helper
83 |
84 |
85 | 头文件\Helper
86 |
87 |
88 | 头文件\HookHelper
89 |
90 |
91 | 头文件
92 |
93 |
94 | 头文件
95 |
96 |
97 | 头文件
98 |
99 |
100 | 头文件\Helper
101 |
102 |
103 | 头文件
104 |
105 |
106 | 头文件\Helper
107 |
108 |
109 | 头文件
110 |
111 |
112 | 头文件
113 |
114 |
115 | 头文件\Helper
116 |
117 |
118 | 头文件
119 |
120 |
121 | 头文件
122 |
123 |
124 | 头文件\Helper
125 |
126 |
127 | 头文件\Helper
128 |
129 |
130 | 头文件
131 |
132 |
133 |
134 |
135 | 源文件
136 |
137 |
138 | minhook
139 |
140 |
141 | minhook
142 |
143 |
144 | minhook
145 |
146 |
147 | minhook\hde
148 |
149 |
150 | minhook\hde
151 |
152 |
153 | 源文件
154 |
155 |
156 | 源文件\HookHelper
157 |
158 |
159 | 源文件\HookHelper
160 |
161 |
162 | 源文件\Helper
163 |
164 |
165 | 源文件\HookHelper
166 |
167 |
168 | 源文件\HookHelper
169 |
170 |
171 | 源文件
172 |
173 |
174 | 源文件
175 |
176 |
177 | 源文件
178 |
179 |
180 | 源文件\Helper
181 |
182 |
183 | 源文件
184 |
185 |
186 | 源文件
187 |
188 |
189 | 源文件
190 |
191 |
192 | 源文件
193 |
194 |
195 | 源文件
196 |
197 |
198 | 源文件\Helper
199 |
200 |
201 | 源文件
202 |
203 |
204 |
205 |
206 | 资源文件
207 |
208 |
209 |
210 |
211 |
212 | 资源文件
213 |
214 |
215 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/ExplorerBlurMica.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WindowsLocalDebugger
5 | C:\Windows\explorer.exe
6 | C:\Users\None_Name\Desktop\Files\ExplorerBlurMica
7 | 192.168.188.128:4026
8 | RemoteWithoutAuthentication
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/DllNotifyRoutine.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: DllNotifyRoutine.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "../framework.h"
20 | #include
21 |
22 | namespace MBox
23 | {
24 | class DllNotifyRoutine
25 | {
26 | public:
27 | static DllNotifyRoutine& GetInstance();
28 | DllNotifyRoutine();
29 | ~DllNotifyRoutine() noexcept;
30 | DllNotifyRoutine(const DllNotifyRoutine&) = delete;
31 | DllNotifyRoutine& operator=(const DllNotifyRoutine&) = delete;
32 |
33 | struct DllInfo
34 | {
35 | PCUNICODE_STRING FullDllName; // The full path name of the DLL module.
36 | PCUNICODE_STRING BaseDllName; // The base file name of the DLL module.
37 | PVOID DllBase; // A pointer to the base address for the DLL in memory.
38 | ULONG SizeOfImage; // The size of the DLL image, in bytes.
39 | };
40 | using Callback = std::function;
41 |
42 | void AddCallback(Callback callback);
43 | void DeleteCallback(Callback callback);
44 | private:
45 | typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA
46 | {
47 | ULONG Flags; // Reserved.
48 | PCUNICODE_STRING FullDllName; // The full path name of the DLL module.
49 | PCUNICODE_STRING BaseDllName; // The base file name of the DLL module.
50 | PVOID DllBase; // A pointer to the base address for the DLL in memory.
51 | ULONG SizeOfImage; // The size of the DLL image, in bytes.
52 | } LDR_DLL_LOADED_NOTIFICATION_DATA, * PLDR_DLL_LOADED_NOTIFICATION_DATA;
53 | typedef struct _LDR_DLL_UNLOADED_NOTIFICATION_DATA
54 | {
55 | ULONG Flags; // Reserved.
56 | PCUNICODE_STRING FullDllName; // The full path name of the DLL module.
57 | PCUNICODE_STRING BaseDllName; // The base file name of the DLL module.
58 | PVOID DllBase; // A pointer to the base address for the DLL in memory.
59 | ULONG SizeOfImage; // The size of the DLL image, in bytes.
60 | } LDR_DLL_UNLOADED_NOTIFICATION_DATA, * PLDR_DLL_UNLOADED_NOTIFICATION_DATA;
61 | typedef union _LDR_DLL_NOTIFICATION_DATA
62 | {
63 | LDR_DLL_LOADED_NOTIFICATION_DATA Loaded;
64 | LDR_DLL_UNLOADED_NOTIFICATION_DATA Unloaded;
65 | } LDR_DLL_NOTIFICATION_DATA, * PLDR_DLL_NOTIFICATION_DATA;
66 | typedef LDR_DLL_NOTIFICATION_DATA* PCLDR_DLL_NOTIFICATION_DATA;
67 | typedef VOID(CALLBACK* PLDR_DLL_NOTIFICATION_FUNCTION)(
68 | ULONG NotificationReason,
69 | PCLDR_DLL_NOTIFICATION_DATA NotificationData,
70 | PVOID Context
71 | );
72 | static VOID CALLBACK LdrDllNotification(
73 | ULONG NotificationReason,
74 | PCLDR_DLL_NOTIFICATION_DATA NotificationData,
75 | PVOID Context
76 | );
77 | static constexpr UINT LDR_DLL_NOTIFICATION_REASON_LOADED{ 1 };
78 | static constexpr UINT LDR_DLL_NOTIFICATION_REASON_UNLOADED{ 2 };
79 |
80 | bool m_internalError{ false };
81 | PVOID m_cookie{ nullptr };
82 | NTSTATUS(NTAPI* m_actualLdrRegisterDllNotification)(ULONG, PLDR_DLL_NOTIFICATION_FUNCTION, PVOID, PVOID*);
83 | NTSTATUS(NTAPI* m_actualLdrUnregisterDllNotification)(PVOID);
84 | std::vector m_callbackList{};
85 | };
86 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/GraphicsHelper.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: GraphicsHelper.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "../framework.h"
20 | #ifdef GDIPVER
21 | #undef GDIPVER
22 | #define GDIPVER 0x0110
23 | #else
24 | #define GDIPVER 0x0110
25 | #endif
26 |
27 | #include
28 | #include
29 | #pragma comment(lib, "gdiplus.lib")
30 |
31 | namespace MBox
32 | {
33 | namespace Utils
34 | {
35 | extern constexpr HRESULT hresult_from_gpstatus(Gdiplus::GpStatus const status);
36 | }
37 |
38 | class LazyGdip
39 | {
40 | ULONG_PTR m_gdiplusToken{ 0 };
41 | Gdiplus::GdiplusStartupOutput m_gdiplusOutput{};
42 | public:
43 | static HRESULT EnsureInitialized();
44 | static LazyGdip& Instance();
45 | ~LazyGdip() noexcept;
46 | LazyGdip(const LazyGdip&) = delete;
47 | LazyGdip& operator=(const LazyGdip&) = delete;
48 |
49 | // 通过无占用的方式读取出位图
50 | Gdiplus::Bitmap* CreateBitmapFromFile(std::wstring_view fileName) const;
51 | Gdiplus::Bitmap* CreateBitmapFromMemory(const BYTE* pInit, UINT cbInit) const;
52 | private:
53 | LazyGdip() = default;
54 | HRESULT Startup();
55 | };
56 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/ThemeHelper.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: ThemeHelper.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "../framework.h"
20 |
21 | namespace MBox
22 | {
23 | extern const HMODULE g_uxthemeModule;
24 |
25 | enum class WINDOWCOMPOSITIONATTRIBUTE
26 | {
27 | WCA_UNDEFINED,
28 | WCA_NCRENDERING_ENABLED,
29 | WCA_NCRENDERING_POLICY,
30 | WCA_TRANSITIONS_FORCEDISABLED,
31 | WCA_ALLOW_NCPAINT,
32 | WCA_CAPTION_BUTTON_BOUNDS,
33 | WCA_NONCLIENT_RTL_LAYOUT,
34 | WCA_FORCE_ICONIC_REPRESENTATION,
35 | WCA_EXTENDED_FRAME_BOUNDS,
36 | WCA_HAS_ICONIC_BITMAP,
37 | WCA_THEME_ATTRIBUTES,
38 | WCA_NCRENDERING_EXILED,
39 | WCA_NCADORNMENTINFO,
40 | WCA_EXCLUDED_FROM_LIVEPREVIEW,
41 | WCA_VIDEO_OVERLAY_ACTIVE,
42 | WCA_FORCE_ACTIVEWINDOW_APPEARANCE,
43 | WCA_DISALLOW_PEEK,
44 | WCA_CLOAK,
45 | WCA_CLOAKED,
46 | WCA_ACCENT_POLICY,
47 | WCA_FREEZE_REPRESENTATION,
48 | WCA_EVER_UNCLOAKED,
49 | WCA_VISUAL_OWNER,
50 | WCA_HOLOGRAPHIC,
51 | WCA_EXCLUDED_FROM_DDA,
52 | WCA_PASSIVEUPDATEMODE,
53 | WCA_USEDARKMODECOLORS,
54 | WCA_CORNER_STYLE,
55 | WCA_PART_COLOR,
56 | WCA_DISABLE_MOVESIZE_FEEDBACK,
57 | WCA_LAST
58 | };
59 | struct WINDOWCOMPOSITIONATTRIBUTEDATA
60 | {
61 | DWORD dwAttribute;
62 | PVOID pvData;
63 | SIZE_T cbData;
64 | };
65 | enum class ACCENT_STATE
66 | {
67 | ACCENT_DISABLED,
68 | ACCENT_ENABLE_GRADIENT,
69 | ACCENT_ENABLE_TRANSPARENTGRADIENT,
70 | ACCENT_ENABLE_BLURBEHIND, // Removed in Windows 11 22H2+
71 | ACCENT_ENABLE_ACRYLICBLURBEHIND,
72 | ACCENT_ENABLE_HOSTBACKDROP,
73 | ACCENT_INVALID_STATE
74 | };
75 | enum class ACCENT_FLAG
76 | {
77 | ACCENT_NONE,
78 | ACCENT_ENABLE_MODERN_ACRYLIC_RECIPE = 1 << 1, // Windows 11 22H2+
79 | ACCENT_ENABLE_GRADIENT_COLOR = 1 << 1, // ACCENT_ENABLE_BLURBEHIND
80 | ACCENT_ENABLE_FULLSCREEN = 1 << 2,
81 | ACCENT_ENABLE_BORDER_LEFT = 1 << 5,
82 | ACCENT_ENABLE_BORDER_TOP = 1 << 6,
83 | ACCENT_ENABLE_BORDER_RIGHT = 1 << 7,
84 | ACCENT_ENABLE_BORDER_BOTTOM = 1 << 8,
85 | ACCENT_ENABLE_BLUR_RECT = 1 << 9, // DwmpUpdateAccentBlurRect, it is conflicted with ACCENT_ENABLE_GRADIENT_COLOR when using ACCENT_ENABLE_BLURBEHIND
86 | ACCENT_ENABLE_BORDER = ACCENT_ENABLE_BORDER_LEFT | ACCENT_ENABLE_BORDER_TOP | ACCENT_ENABLE_BORDER_RIGHT | ACCENT_ENABLE_BORDER_BOTTOM
87 | };
88 | struct ACCENT_POLICY
89 | {
90 | DWORD AccentState;
91 | DWORD AccentFlags;
92 | DWORD dwGradientColor;
93 | DWORD dwAnimationId;
94 | };
95 |
96 | namespace Utils
97 | {
98 | extern BOOL(WINAPI* g_pfnSetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBUTEDATA*);
99 |
100 | extern HRESULT DrawTextWithGlow(
101 | HDC hdc,
102 | LPCWSTR pszText,
103 | int cchText,
104 | LPRECT prc,
105 | UINT dwFlags,
106 | UINT crText,
107 | UINT crGlow,
108 | UINT nGlowRadius,
109 | UINT nGlowIntensity,
110 | BOOL bPreMultiply,
111 | DTT_CALLBACK_PROC pfnDrawTextCallback,
112 | LPARAM lParam
113 | );
114 |
115 | extern HRESULT DrawContentOffscreen(
116 | HDC hdc,
117 | LPCRECT paintRect,
118 | LPCRECT clipRect,
119 | LPCRECT excludeRect,
120 | std::function callback,
121 | UCHAR alpha = 0xFF,
122 | bool noClip = false,
123 | bool nonClient = false,
124 | bool useBlt = false,
125 | bool update = true,
126 | bool useCompatibleBitmap = false
127 | );
128 |
129 | extern bool ShouldAppsUseDarkMode();
130 |
131 | inline COLORREF M_RGBA(BYTE r, BYTE g, BYTE b, BYTE a)
132 | {
133 | return RGB(r, g, b) | (a << 24);
134 | }
135 |
136 | inline BYTE M_GetAValue(COLORREF rgba)
137 | {
138 | return BYTE(ULONG(rgba >> 24) & 0xff);
139 | }
140 |
141 | }
142 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/VersionHelper.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: VersionHelper.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "../framework.h"
20 |
21 | namespace MBox
22 | {
23 | struct KSYSTEM_TIME
24 | {
25 | ULONG LowPart;
26 | LONG High1Time;
27 | LONG High2Time;
28 | };
29 | enum class NT_PRODUCT_TYPE
30 | {
31 | NtProductWinNt = 1,
32 | NtProductLanManNt,
33 | NtProductServer
34 | };
35 | enum class ALTERNATIVE_ARCHITECTURE_TYPE
36 | {
37 | StandardDesign,
38 | NEC98x86,
39 | EndAlternatives
40 | };
41 | constexpr UINT PROCESSOR_FEATURE_MAX = 64;
42 | struct KUSER_SHARED_DATA
43 | {
44 | ULONG TickCountLowDeprecated;
45 | ULONG TickCountMultiplier;
46 | KSYSTEM_TIME InterruptTime;
47 | KSYSTEM_TIME SystemTime;
48 | KSYSTEM_TIME TimeZoneBias;
49 | USHORT ImageNumberLow;
50 | USHORT ImageNumberHigh;
51 | WCHAR NtSystemRoot[260];
52 | ULONG MaxStackTraceDepth;
53 | ULONG CryptoExponent;
54 | ULONG TimeZoneId;
55 | ULONG LargePageMinimum;
56 | ULONG AitSamplingValue;
57 | ULONG AppCompatFlag;
58 | ULONGLONG RNGSeedVersion;
59 | ULONG GlobalValidationRunlevel;
60 | LONG TimeZoneBiasStamp;
61 | ULONG NtBuildNumber;
62 | NT_PRODUCT_TYPE NtProductType;
63 | BOOLEAN ProductTypeIsValid;
64 | BOOLEAN Reserved0[1];
65 | USHORT NativeProcessorArchitecture;
66 | ULONG NtMajorVersion;
67 | ULONG NtMinorVersion;
68 | BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
69 | ULONG Reserved1;
70 | ULONG Reserved3;
71 | ULONG TimeSlip;
72 | ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
73 | ULONG BootId;
74 | LARGE_INTEGER SystemExpirationDate;
75 | ULONG SuiteMask;
76 | BOOLEAN KdDebuggerEnabled;
77 | union
78 | {
79 | UCHAR MitigationPolicies;
80 | struct
81 | {
82 | UCHAR NXSupportPolicy : 2;
83 | UCHAR SEHValidationPolicy : 2;
84 | UCHAR CurDirDevicesSkippedForDlls : 2;
85 | UCHAR Reserved : 2;
86 | };
87 | };
88 | USHORT CyclesPerYield;
89 | ULONG ActiveConsoleId;
90 | ULONG DismountCount;
91 | ULONG ComPlusPackage;
92 | ULONG LastSystemRITEventTickCount;
93 | ULONG NumberOfPhysicalPages;
94 | BOOLEAN SafeBootMode;
95 | union
96 | {
97 | UCHAR VirtualizationFlags;
98 | struct
99 | {
100 | UCHAR ArchStartedInEl2 : 1;
101 | UCHAR QcSlIsSupported : 1;
102 | };
103 | };
104 | UCHAR Reserved12[2];
105 | union
106 | {
107 | ULONG SharedDataFlags;
108 | struct
109 | {
110 | ULONG DbgErrorPortPresent : 1;
111 | ULONG DbgElevationEnabled : 1;
112 | ULONG DbgVirtEnabled : 1;
113 | ULONG DbgInstallerDetectEnabled : 1;
114 | ULONG DbgLkgEnabled : 1;
115 | ULONG DbgDynProcessorEnabled : 1;
116 | ULONG DbgConsoleBrokerEnabled : 1;
117 | ULONG DbgSecureBootEnabled : 1;
118 | ULONG DbgMultiSessionSku : 1;
119 | ULONG DbgMultiUsersInSessionSku : 1;
120 | ULONG DbgStateSeparationEnabled : 1;
121 | ULONG SpareBits : 21;
122 | } DUMMYSTRUCTNAME2;
123 | } DUMMYUNIONNAME2;
124 | ULONG DataFlagsPad[1];
125 | ULONGLONG TestRetInstruction;
126 | LONGLONG QpcFrequency;
127 | ULONG SystemCall;
128 | ULONG Reserved2;
129 | ULONGLONG SystemCallPad[2];
130 | union
131 | {
132 | KSYSTEM_TIME TickCount;
133 | ULONG64 TickCountQuad;
134 | struct
135 | {
136 | ULONG ReservedTickCountOverlay[3];
137 | ULONG TickCountPad[1];
138 | } DUMMYSTRUCTNAME;
139 | } DUMMYUNIONNAME3;
140 | ULONG Cookie;
141 | ULONG CookiePad[1];
142 | LONGLONG ConsoleSessionForegroundProcessId;
143 | ULONGLONG TimeUpdateLock;
144 | ULONGLONG BaselineSystemTimeQpc;
145 | ULONGLONG BaselineInterruptTimeQpc;
146 | ULONGLONG QpcSystemTimeIncrement;
147 | ULONGLONG QpcInterruptTimeIncrement;
148 | UCHAR QpcSystemTimeIncrementShift;
149 | UCHAR QpcInterruptTimeIncrementShift;
150 | USHORT UnparkedProcessorCount;
151 | ULONG EnclaveFeatureMask[4];
152 | ULONG TelemetryCoverageRound;
153 | USHORT UserModeGlobalLogger[16];
154 | ULONG ImageFileExecutionOptions;
155 | ULONG LangGenerationCount;
156 | ULONGLONG Reserved4;
157 | ULONGLONG InterruptTimeBias;
158 | ULONGLONG QpcBias;
159 | ULONG ActiveProcessorCount;
160 | UCHAR ActiveGroupCount;
161 | UCHAR Reserved9;
162 | union
163 | {
164 | USHORT QpcData;
165 | struct
166 | {
167 | UCHAR QpcBypassEnabled;
168 | UCHAR QpcShift;
169 | };
170 | };
171 | LARGE_INTEGER TimeZoneBiasEffectiveStart;
172 | LARGE_INTEGER TimeZoneBiasEffectiveEnd;
173 | XSTATE_CONFIGURATION XState;
174 | KSYSTEM_TIME FeatureConfigurationChangeStamp;
175 | ULONG Spare;
176 | ULONG64 UserPointerAuthMask;
177 | };
178 | using PKUSER_SHARED_DATA = KUSER_SHARED_DATA* const;
179 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/Win32Helper.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: Win32Helper.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "VersionHelper.h"
20 | #include
21 |
22 | namespace RAIIHelper
23 | {
24 | template
25 | class lambda_call
26 | {
27 | public:
28 | lambda_call(const lambda_call&) = delete;
29 | lambda_call& operator=(const lambda_call&) = delete;
30 | lambda_call& operator=(lambda_call&& other) = delete;
31 |
32 | inline explicit lambda_call(TLambda&& lambda) noexcept : m_lambda(std::move(lambda))
33 | {
34 | static_assert(std::is_same::value, "scope_exit的lambda函数一定不能有返回值");
35 | static_assert(!std::is_lvalue_reference::value && !std::is_rvalue_reference::value, "scope_exit只能直接与lambda函数一起使用");
36 | }
37 | inline lambda_call(lambda_call&& other) noexcept : m_lambda(std::move(other.m_lambda)), m_call(other.m_call)
38 | {
39 | other.m_call = false;
40 | }
41 | inline ~lambda_call() noexcept
42 | {
43 | reset();
44 | }
45 | // 确保scope_exit lambda不会被调用
46 | inline void release() noexcept
47 | {
48 | m_call = false;
49 | }
50 | // 立刻执行scope_exit lambda如果还没有运行的话;确保它不再次运行
51 | inline void reset() noexcept
52 | {
53 | if (m_call)
54 | {
55 | m_call = false;
56 | m_lambda();
57 | }
58 | }
59 | // 返回true如果scope_exit lambda仍要被执行
60 | [[nodiscard]] inline explicit operator bool() const noexcept
61 | {
62 | return m_call;
63 | }
64 | protected:
65 | TLambda m_lambda;
66 | bool m_call = true;
67 | };
68 | /*
69 | 返回一个对象,该对象在销毁时执行给定的lambda函数,请使用auto捕获返回的对象
70 | 使用reset()提前执行lambda或使用release()避免执行
71 | 在lambda中抛出的异常将引发快速失败
72 | 你可以认为这个对象的作用跟finally差不多
73 | */
74 | template
75 | [[nodiscard]] inline auto scope_exit(TLambda&& lambda) noexcept
76 | {
77 | return lambda_call(std::forward(lambda));
78 | }
79 | }
80 |
81 | EXTERN_C IMAGE_DOS_HEADER __ImageBase;
82 | namespace MBox
83 | {
84 | extern const HMODULE g_user32Module;
85 | extern const HMODULE g_comctl32Module;
86 |
87 | extern UINT MTBM_ATTACH;
88 | extern UINT MTBM_DETACH;
89 | extern const HINSTANCE this_inst;
90 |
91 | namespace Utils
92 | {
93 | inline PKUSER_SHARED_DATA get_kernel_shared_info()
94 | {
95 | return reinterpret_cast(0x7FFE0000);
96 | }
97 | extern std::string_view get_file_name_ansi(std::string_view path);
98 | extern HWND GetChildByClass(HWND hwnd, std::wstring_view className);
99 | extern HWND GetParentByClass(HWND hwnd, std::wstring_view className);
100 | extern HRESULT get_module_name(HMODULE moduleHandle, LPWSTR moduleName, DWORD size);
101 | extern HRESULT GetThemeClass(HTHEME hTheme, LPCWSTR pszClassIdList, int cchClass);
102 | extern HRESULT get_runtime_class_name(::IInspectable* inspectable, LPWSTR className, DWORD size);
103 | extern void RefreshExplorerTheme();
104 | }
105 |
106 | template
107 | class obj_name
108 | {
109 | public:
110 | obj_name(const obj_name&) = delete;
111 | obj_name& operator=(const obj_name&) = delete;
112 | obj_name& operator=(obj_name&& other) = delete;
113 | inline bool operator==(std::wstring str) const { return !_wcsicmp(m_name, str.c_str()); }
114 | inline bool operator==(std::wstring_view str) const { return !_wcsicmp(m_name, str.data()); }
115 | inline bool operator==(LPCWSTR str) const { return !_wcsicmp(m_name, str); }
116 | inline T operator=(T obj) { get_name_fn(obj, m_name, buffer_size - 1); return obj; }
117 | inline obj_name()
118 | {
119 | if constexpr (ignoreNullptr || defaultValue != nullptr)
120 | {
121 | if constexpr (std::is_same::value && defaultValue == nullptr)
122 | {
123 | obj_name::operator=(T(L""));
124 | }
125 | else
126 | {
127 | obj_name::operator=(T(defaultValue));
128 | }
129 | }
130 | }
131 | inline obj_name(T obj) { obj_name::operator=(obj); }
132 | ~obj_name() = default;
133 | [[nodiscard]] inline constexpr const wchar_t* const c_str() const { return m_name; }
134 | [[nodiscard]] inline constexpr const std::wstring_view get() const { return m_name; }
135 | [[nodiscard]] inline constexpr std::wstring make_wstring() const { return std::wstring(m_name); }
136 | void* operator new(size_t) = delete;
137 | void operator delete(void*) = delete;
138 | private:
139 | WCHAR m_name[buffer_size] = {};
140 | };
141 |
142 | template
143 | class obj_name_ansi
144 | {
145 | public:
146 | obj_name_ansi(const obj_name_ansi&) = delete;
147 | obj_name_ansi& operator=(const obj_name_ansi&) = delete;
148 | obj_name_ansi& operator=(obj_name_ansi&& other) = delete;
149 | inline bool operator==(std::string str) const { return !_stricmp(m_name, str.c_str()); }
150 | inline bool operator==(std::string_view str) const { return !_stricmp(m_name, str.data()); }
151 | inline bool operator==(LPCSTR str) const { return !_stricmp(m_name, str); }
152 | inline T operator=(T obj) { get_name_fn(obj, m_name, buffer_size - 1); return obj; }
153 | inline obj_name_ansi()
154 | {
155 | if constexpr (ignoreNullptr || defaultValue != nullptr)
156 | {
157 | if constexpr (std::is_same::value && defaultValue == nullptr)
158 | {
159 | obj_name_ansi::operator=(T(""));
160 | }
161 | else
162 | {
163 | obj_name_ansi::operator=(T(defaultValue));
164 | }
165 | }
166 | }
167 | inline obj_name_ansi(T obj) { obj_name_ansi::operator=(obj); }
168 | ~obj_name_ansi() = default;
169 | [[nodiscard]] inline constexpr const wchar_t* const c_str() const { return m_name; }
170 | [[nodiscard]] inline constexpr const std::string_view get() const { return m_name; }
171 | [[nodiscard]] inline constexpr std::string make_string() const { return std::string(m_name); }
172 | void* operator new(size_t) = delete;
173 | void operator delete(void*) = delete;
174 | private:
175 | CHAR m_name[buffer_size] = {};
176 | };
177 |
178 | using atom_name = obj_name;
179 | using window_class = obj_name;
180 | using hmodule_file_name = obj_name;
181 | using hmodule_file_name_ansi = obj_name_ansi;
182 | using hmodule_name = obj_name;
183 | using htheme_class_name = obj_name;
184 | using runtime_class_name = obj_name<::IInspectable*, false, nullptr, decltype(Utils::get_runtime_class_name), Utils::get_runtime_class_name>;
185 |
186 | namespace os
187 | {
188 | const ULONG buildNumber = Utils::get_kernel_shared_info()->NtBuildNumber;
189 | }
190 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/WinRTHelper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | // 该头文件主要用于引入WinRT组件相关的帮助函数,可放入预编译头
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #pragma push_macro("GetCurrentTime")
9 | #undef GetCurrentTime
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | #include
18 | #include
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 | #include
45 | #include
46 | #include
47 | #include
48 | #include
49 | #pragma pop_macro("GetCurrentTime")
50 |
51 | #include
52 |
53 | namespace MBox
54 | {
55 | namespace abi
56 | {
57 | using namespace ABI::Windows;
58 | namespace comp = ABI::Windows::UI::Composition;
59 | namespace desktop = ABI::Windows::UI::Composition::Desktop;
60 | namespace xaml = ABI::Windows::UI::Xaml;
61 | namespace media = ABI::Windows::UI::Xaml::Media;
62 | namespace controls = ABI::Windows::UI::Xaml::Controls;
63 | namespace dx = ABI::Windows::Graphics::DirectX;
64 | namespace fx = ABI::Windows::Graphics::Effects;
65 | namespace collections = ABI::Windows::Foundation::Collections;
66 | namespace streams = ABI::Windows::Storage::Streams;
67 | }
68 |
69 | namespace Utils
70 | {
71 | inline HSTRING abi_of(const winrt::hstring& str)
72 | {
73 | return reinterpret_cast(winrt::get_abi(str));
74 | }
75 |
76 | template
77 | struct SimpleFactory : winrt::implements, IClassFactory, winrt::non_agile>
78 | {
79 | HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
80 | REFIID riid,
81 | void** ppvObject
82 | ) override try
83 | {
84 | if (!pUnkOuter)
85 | {
86 | *ppvObject = nullptr;
87 | return winrt::make().as(riid, ppvObject);
88 | }
89 | else
90 | {
91 | return CLASS_E_NOAGGREGATION;
92 | }
93 | }
94 | catch (...)
95 | {
96 | return winrt::to_hresult();
97 | }
98 |
99 | HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock) noexcept override
100 | {
101 | if (fLock)
102 | {
103 | ++winrt::get_module_lock();
104 | }
105 | else
106 | {
107 | --winrt::get_module_lock();
108 | }
109 |
110 | return S_OK;
111 | }
112 | };
113 | }
114 |
115 | using winrt::hresult_error;
116 | using winrt::check_bool;
117 | using winrt::check_hresult;
118 | using winrt::check_bool;
119 | using winrt::check_pointer;
120 | using winrt::check_win32;
121 | using winrt::throw_hresult;
122 | using winrt::throw_last_error;
123 | using winrt::to_hresult;
124 | using winrt::to_hstring;
125 | using winrt::to_string;
126 |
127 | using winrt::get_module_lock;
128 | using winrt::implements;
129 | using winrt::hstring;
130 | using winrt::com_ptr;
131 | using winrt::get_activation_factory;
132 | using winrt::get_abi;
133 | using winrt::put_abi;
134 | using winrt::copy_from_abi;
135 | using winrt::copy_to_abi;
136 | using winrt::attach_abi;
137 | using winrt::detach_abi;
138 |
139 | using winrt::make;
140 | using winrt::make_self;
141 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Helper/comdef.h:
--------------------------------------------------------------------------------
1 | // 该头文件主要用于引入与COM组件密切相关的头文件
2 | // 可放入预编译头
3 | #pragma once
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #pragma comment(lib, "shlwapi.lib")
23 | #pragma comment(lib, "shcore.lib")
24 | #pragma comment(lib, "oleacc.lib")
25 | #pragma comment(lib, "taskschd.lib")
26 | #pragma comment(lib, "comsuppw.lib")
27 | #pragma comment(lib, "pathcch.lib")
--------------------------------------------------------------------------------
/ExplorerBlurMica/HookDef.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: HookDef.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "Helper/DirectUIHelper.h"
20 | #include "HookHelper/MHookHelper.h"
21 | #include "DirectUITweaker.h"
22 |
23 | namespace MBox
24 | {
25 | extern bool g_enableCustomScrollBar;
26 | extern bool g_enableClearAddress;
27 | extern bool g_enableClearWinUI;
28 | extern bool g_enableShowLine;
29 |
30 | void WINAPI My_DirectUI_Element_PaintBackground(
31 | DirectUI::Element* This,
32 | HDC hdc,
33 | DirectUI::Value* value,
34 | LPCRECT pRect,
35 | LPCRECT pClipRect,
36 | LPCRECT pExcludeRect,
37 | LPCRECT pTargetRect
38 | );
39 |
40 | inline MiniHookDispatcher g_DirectUI_Element_PaintBackground_hookDispatcher =
41 | {
42 | DirectUI::g_pfnElement_PaintBackground,
43 | std::array
44 | {
45 | detour_info(DTweaker::My_DirectUI_Element_PaintBackground_Filter, call_type::before),
46 | detour_info(DTweaker::My_DirectUI_Element_PaintBackground_CleanUp, call_type::final),
47 | detour_info(My_DirectUI_Element_PaintBackground, call_type::before)
48 | }
49 | };
50 |
51 | void WINAPI My_DirectUI_Element_Paint(
52 | DirectUI::Element* This,
53 | HDC hdc,
54 | LPCRECT pRect,
55 | LPCRECT pClipRect,
56 | LPCRECT pExcludeRect,
57 | LPCRECT pTargetRect
58 | );
59 |
60 | HRESULT WINAPI My_DwmExtendFrameIntoClientArea(
61 | HWND hWnd,
62 | const MARGINS* pMarInset
63 | );
64 |
65 | HRESULT WINAPI My_DwmExtendFrameIntoClientArea_startallback(
66 | HWND hWnd,
67 | const MARGINS* pMarInset
68 | );
69 |
70 | HRESULT WINAPI MyDwmSetWindowAttribute(
71 | HWND hwnd,
72 | DWORD dwAttribute,
73 | LPCVOID pvAttribute,
74 | DWORD cbAttribute
75 | );
76 |
77 | HWND WINAPI My_CreateWindowExW_explorerframe(
78 | DWORD dwExStyle,
79 | LPCWSTR lpClassName,
80 | LPCWSTR lpWindowName,
81 | DWORD dwStyle,
82 | int X,
83 | int Y,
84 | int nWidth,
85 | int nHeight,
86 | HWND hWndParent,
87 | HMENU hMenu,
88 | HINSTANCE hInstance,
89 | LPVOID lpParam
90 | );
91 |
92 | HWND WINAPI My_CreateWindowExW_dui70(
93 | DWORD dwExStyle,
94 | LPCWSTR lpClassName,
95 | LPCWSTR lpWindowName,
96 | DWORD dwStyle,
97 | int X,
98 | int Y,
99 | int nWidth,
100 | int nHeight,
101 | HWND hWndParent,
102 | HMENU hMenu,
103 | HINSTANCE hInstance,
104 | LPVOID lpParam
105 | );
106 |
107 | int WINAPI My_DrawTextW(
108 | HDC hdc,
109 | LPCWSTR lpchText,
110 | int cchText,
111 | LPRECT lprc,
112 | UINT format
113 | );
114 |
115 | BOOL WINAPI My_ExtTextOutW(
116 | HDC hdc,
117 | int x,
118 | int y,
119 | UINT options,
120 | const RECT* lprect,
121 | LPCWSTR lpString,
122 | UINT c,
123 | const INT* lpDx
124 | );
125 |
126 | HRESULT WINAPI My_DrawThemeText(
127 | HTHEME hTheme,
128 | HDC hdc,
129 | int iPartId,
130 | int iStateId,
131 | LPCWSTR pszText,
132 | int cchText,
133 | DWORD dwTextFlags,
134 | DWORD dwTextFlags2,
135 | LPCRECT pRect
136 | );
137 |
138 | HRESULT WINAPI My_DrawThemeTextEx(
139 | HTHEME hTheme,
140 | HDC hdc,
141 | int iPartId,
142 | int iStateId,
143 | LPCWSTR pszText,
144 | int cchText,
145 | DWORD dwTextFlags,
146 | LPRECT pRect,
147 | const DTTOPTS* pOptions
148 | );
149 |
150 | BOOL WINAPI My_InflateRect(
151 | LPRECT lprc,
152 | int dx,
153 | int dy
154 | );
155 |
156 | HWND WINAPI My_CreateWindowExW_shell32(
157 | DWORD dwExStyle,
158 | LPCWSTR lpClassName,
159 | LPCWSTR lpWindowName,
160 | DWORD dwStyle,
161 | int X,
162 | int Y,
163 | int nWidth,
164 | int nHeight,
165 | HWND hWndParent,
166 | HMENU hMenu,
167 | HINSTANCE hInstance,
168 | LPVOID lpParam
169 | );
170 |
171 | //RibbonTweaker
172 | namespace RibbonTweaker
173 | {
174 | HDC WINAPI My_BeginPaint(
175 | HWND hWnd,
176 | LPPAINTSTRUCT lpPaint
177 | );
178 | int WINAPI My_FillRect(
179 | HDC hDC,
180 | const RECT* lprc,
181 | HBRUSH hbr
182 | );
183 | int WINAPI My_DrawTextW(
184 | HDC hdc,
185 | LPCWSTR lpchText,
186 | int cchText,
187 | LPRECT lprc,
188 | UINT format
189 | );
190 | BOOL WINAPI My_StretchBlt(
191 | HDC hdcDest,
192 | int xDest,
193 | int yDest,
194 | int wDest,
195 | int hDest,
196 | HDC hdcSrc,
197 | int xSrc,
198 | int ySrc,
199 | int wSrc,
200 | int hSrc,
201 | DWORD rop
202 | );
203 | BOOL WINAPI My_BitBlt(
204 | HDC hdc,
205 | int x,
206 | int y,
207 | int cx,
208 | int cy,
209 | HDC hdcSrc,
210 | int x1,
211 | int y1,
212 | DWORD rop
213 | );
214 | BOOL WINAPI My_GdiAlphaBlend(
215 | HDC hdcDest,
216 | int xoriginDest,
217 | int yoriginDest,
218 | int wDest,
219 | int hDest,
220 | HDC hdcSrc,
221 | int xoriginSrc,
222 | int yoriginSrc,
223 | int wSrc,
224 | int hSrc,
225 | BLENDFUNCTION ftn
226 | );
227 | }
228 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/MenuToolBarTweaker.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: MenuToolBarTweaker.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "WindowListener.h"
20 |
21 | namespace MBox
22 | {
23 | class BlackListener : public IWindowListenerCallback
24 | {
25 | public:
26 | LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled) override;
27 | BlackListener() = default;
28 | ~BlackListener() = default;
29 | };
30 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/MiscTweaker.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: MiscTweaker.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "HookDef.h"
20 | #include "visualtreewatcher.h"
21 |
22 | namespace MBox::MiscTweaker
23 | {
24 | void Startup();
25 | void Shutdown();
26 |
27 | extern LRESULT WINAPI MyDefWindowProcW(
28 | HWND hWnd,
29 | UINT Msg,
30 | WPARAM wParam,
31 | LPARAM lParam
32 | );
33 |
34 | extern HRESULT WINAPI MyDrawThemeBackground(
35 | HTHEME hTheme,
36 | HDC hdc,
37 | int iPartId,
38 | int iStateId,
39 | LPCRECT pRect,
40 | LPCRECT pClipRect
41 | );
42 |
43 | extern HRESULT WINAPI MyDrawThemeBackground_Address(
44 | HTHEME hTheme,
45 | HDC hdc,
46 | int iPartId,
47 | int iStateId,
48 | LPCRECT pRect,
49 | LPCRECT pClipRect
50 | );
51 |
52 | extern HRESULT __stdcall MyCoCreateInstance(
53 | REFCLSID rclsid,
54 | LPUNKNOWN pUnkOuter,
55 | DWORD dwClsContext,
56 | REFIID riid,
57 | LPVOID* ppv
58 | );
59 |
60 | extern HRESULT WINAPI MyGetThemeColor_WinUI(
61 | HTHEME hTheme,
62 | int iPartId,
63 | int iStateId,
64 | int iPropId,
65 | COLORREF* pColor
66 | );
67 |
68 | extern HRESULT WINAPI MyGetThemeColor_WASDK(
69 | HTHEME hTheme,
70 | int iPartId,
71 | int iStateId,
72 | int iPropId,
73 | COLORREF* pColor
74 | );
75 |
76 | void OnVisualTreeChange(
77 | com_ptr visualTreeWatcher,
78 | const ParentChildRelation& parentChildRelation,
79 | const VisualElement& element,
80 | VisualMutationType mutationType
81 | );
82 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/RibbonTweaker.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | namespace MBox::RibbonTweaker
4 | {
5 | void Startup();
6 | void Shutdown();
7 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/Source.def:
--------------------------------------------------------------------------------
1 | LIBRARY "ExplorerBlurMica"
2 | EXPORTS
3 | DllGetClassObject PRIVATE
4 | DllCanUnloadNow PRIVATE
5 | DllRegisterServer PRIVATE
6 | DllUnregisterServer PRIVATE
--------------------------------------------------------------------------------
/ExplorerBlurMica/TranslucentImpl.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "framework.h"
3 |
4 | namespace MBox
5 | {
6 | void Startup();
7 | void StartupPart();
8 | void Shutdown();
9 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/WindowListener.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: WindowListener.h
3 | *
4 | * Copyright (C) 2022-2023 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "framework.h"
20 |
21 | namespace MBox
22 | {
23 | struct IWindowListenerCallback
24 | {
25 | virtual LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool& handled) = 0;
26 | };
27 |
28 | class WindowListenerImpl
29 | {
30 | protected:
31 | HWND m_hwnd = nullptr;
32 | mutable std::shared_ptr m_listener = nullptr;
33 |
34 | WindowListenerImpl(HWND hwnd);
35 | ~WindowListenerImpl();
36 |
37 | static LRESULT CALLBACK s_SubclassProc(
38 | HWND hWnd,
39 | UINT uMsg,
40 | WPARAM wParam,
41 | LPARAM lParam,
42 | UINT_PTR uIdSubclass,
43 | DWORD_PTR dwRefData
44 | );
45 | public:
46 | HWND GetHwnd() const { return m_hwnd; }
47 | template
48 | std::shared_ptr GetListener() const
49 | {
50 | return std::dynamic_pointer_cast(m_listener);
51 | }
52 |
53 | static void Detach(HWND hwnd);
54 | static WindowListenerImpl* Get(HWND hwnd);
55 | };
56 |
57 | class WindowListener : public WindowListenerImpl
58 | {
59 | static std::unordered_map> s_windowList;
60 | ULONG_PTR m_token = 0;
61 | public:
62 | WindowListener(HWND hwnd, ULONG_PTR token) : WindowListenerImpl(hwnd), m_token(token)
63 | {
64 | s_windowList[token].push_back(hwnd);
65 | }
66 | ~WindowListener()
67 | {
68 | for (auto it = s_windowList[m_token].begin(); it != s_windowList[m_token].end(); it++) if (*it == m_hwnd) { it = s_windowList[m_token].erase(it); break; }
69 | }
70 |
71 | static void DetachAll(ULONG_PTR token)
72 | {
73 | for (const auto& window : s_windowList[token])
74 | {
75 | WindowListenerImpl::Detach(window);
76 | }
77 | s_windowList.erase(token);
78 | }
79 | static WindowListener* Attach(HWND hwnd, ULONG_PTR token, std::function& listener)> callback)
80 | {
81 | WindowListener* windowListener = static_cast(WindowListenerImpl::Get(hwnd));
82 | if (windowListener)
83 | {
84 | if (callback)
85 | {
86 | callback(windowListener, false, windowListener->m_listener);
87 | }
88 | }
89 | else
90 | {
91 | auto ptr = std::make_unique(hwnd, token);
92 | if (callback)
93 | {
94 | callback(ptr.get(), true, ptr->m_listener);
95 | }
96 | windowListener = ptr.release();
97 | }
98 |
99 | return windowListener;
100 | }
101 | static WindowListener* Get(HWND hwnd)
102 | {
103 | return static_cast(WindowListenerImpl::Get(hwnd));
104 | }
105 | };
106 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : 定义 DLL 应用程序的入口点。
2 | #include "framework.h"
3 | #include "module.h"
4 |
5 | BOOL APIENTRY DllMain( HMODULE hModule,
6 | DWORD ul_reason_for_call,
7 | LPVOID lpReserved
8 | )
9 | {
10 | return MBox::OnDllMain(hModule, ul_reason_for_call);
11 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/framework.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //从 Windows 头文件中排除极少使用的内容
3 | #define WIN32_LEAN_AND_MEAN
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #pragma comment(lib, "dwmapi.lib")
18 | #pragma comment(lib, "Comctl32.lib")
19 | #pragma comment(lib, "Shlwapi.lib")
20 | #pragma comment(lib, "uxtheme.lib")
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/MinHook.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MinHook - The Minimalistic API Hooking Library for x64/x86
3 | * Copyright (C) 2009-2017 Tsuda Kageyu.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #pragma once
30 |
31 | #if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__)
32 | #error MinHook supports only x86 and x64 systems.
33 | #endif
34 |
35 | #include
36 |
37 | // MinHook Error Codes.
38 | typedef enum MH_STATUS
39 | {
40 | // Unknown error. Should not be returned.
41 | MH_UNKNOWN = -1,
42 |
43 | // Successful.
44 | MH_OK = 0,
45 |
46 | // MinHook is already initialized.
47 | MH_ERROR_ALREADY_INITIALIZED,
48 |
49 | // MinHook is not initialized yet, or already uninitialized.
50 | MH_ERROR_NOT_INITIALIZED,
51 |
52 | // The hook for the specified target function is already created.
53 | MH_ERROR_ALREADY_CREATED,
54 |
55 | // The hook for the specified target function is not created yet.
56 | MH_ERROR_NOT_CREATED,
57 |
58 | // The hook for the specified target function is already enabled.
59 | MH_ERROR_ENABLED,
60 |
61 | // The hook for the specified target function is not enabled yet, or already
62 | // disabled.
63 | MH_ERROR_DISABLED,
64 |
65 | // The specified pointer is invalid. It points the address of non-allocated
66 | // and/or non-executable region.
67 | MH_ERROR_NOT_EXECUTABLE,
68 |
69 | // The specified target function cannot be hooked.
70 | MH_ERROR_UNSUPPORTED_FUNCTION,
71 |
72 | // Failed to allocate memory.
73 | MH_ERROR_MEMORY_ALLOC,
74 |
75 | // Failed to change the memory protection.
76 | MH_ERROR_MEMORY_PROTECT,
77 |
78 | // The specified module is not loaded.
79 | MH_ERROR_MODULE_NOT_FOUND,
80 |
81 | // The specified function is not found.
82 | MH_ERROR_FUNCTION_NOT_FOUND,
83 |
84 | // Failed to create, or to wait for the main mutex.
85 | MH_ERROR_MUTEX_FAILURE
86 | } MH_STATUS;
87 |
88 | // The method of suspending and resuming threads.
89 | //
90 | // It's possible to add an additional method using PssCaptureSnapshot.
91 | // Pros: Documented, fast.
92 | // Cons: Available from Windows 8.1, less reliable.
93 | typedef enum MH_THREAD_FREEZE_METHOD
94 | {
95 | // The original MinHook method, using CreateToolhelp32Snapshot. Documented
96 | // and supported on all Windows versions, but very slow and less reliable.
97 | MH_FREEZE_METHOD_ORIGINAL = 0,
98 |
99 | // A much faster and more reliable, but undocumented method, using
100 | // NtGetNextThread. Supported since Windows Vista, on older versions falls
101 | // back to MH_ORIGINAL.
102 | MH_FREEZE_METHOD_FAST_UNDOCUMENTED,
103 |
104 | // Threads are not suspended and instruction pointer registers are not
105 | // adjusted. Don't use this method unless you understand the implications
106 | // and know that it's safe.
107 | MH_FREEZE_METHOD_NONE_UNSAFE
108 | } MH_THREAD_FREEZE_METHOD;
109 |
110 | // Can be passed as a parameter to MH_EnableHook, MH_DisableHook,
111 | // MH_QueueEnableHook or MH_QueueDisableHook.
112 | #define MH_ALL_HOOKS NULL
113 |
114 | #ifdef __cplusplus
115 | extern "C" {
116 | #endif
117 |
118 | // Initialize the MinHook library. You must call this function EXACTLY ONCE
119 | // at the beginning of your program.
120 | MH_STATUS WINAPI MH_Initialize(VOID);
121 |
122 | // Uninitialize the MinHook library. You must call this function EXACTLY
123 | // ONCE at the end of your program.
124 | MH_STATUS WINAPI MH_Uninitialize(VOID);
125 |
126 | // Set the method of suspending and resuming threads.
127 | MH_STATUS WINAPI MH_SetThreadFreezeMethod(MH_THREAD_FREEZE_METHOD method);
128 |
129 | // Creates a hook for the specified target function, in disabled state.
130 | // Parameters:
131 | // hookIdent [in] A hook identifier, can be set to different values for
132 | // different hooks to hook the same function more than
133 | // once. Default value: 0.
134 | // pTarget [in] A pointer to the target function, which will be
135 | // overridden by the detour function.
136 | // pDetour [in] A pointer to the detour function, which will override
137 | // the target function.
138 | // ppOriginal [out] A pointer to the trampoline function, which will be
139 | // used to call the original target function.
140 | // This parameter can be NULL.
141 | MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal);
142 | MH_STATUS WINAPI MH_CreateHookEx(ULONG_PTR hookIdent, LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal);
143 |
144 | // Creates a hook for the specified API function, in disabled state.
145 | // Parameters:
146 | // pszModule [in] A pointer to the loaded module name which contains the
147 | // target function.
148 | // pszProcName [in] A pointer to the target function name, which will be
149 | // overridden by the detour function.
150 | // pDetour [in] A pointer to the detour function, which will override
151 | // the target function.
152 | // ppOriginal [out] A pointer to the trampoline function, which will be
153 | // used to call the original target function.
154 | // This parameter can be NULL.
155 | MH_STATUS WINAPI MH_CreateHookApi(
156 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal);
157 |
158 | // Creates a hook for the specified API function, in disabled state.
159 | // Parameters:
160 | // pszModule [in] A pointer to the loaded module name which contains the
161 | // target function.
162 | // pszProcName [in] A pointer to the target function name, which will be
163 | // overridden by the detour function.
164 | // pDetour [in] A pointer to the detour function, which will override
165 | // the target function.
166 | // ppOriginal [out] A pointer to the trampoline function, which will be
167 | // used to call the original target function.
168 | // This parameter can be NULL.
169 | // ppTarget [out] A pointer to the target function, which will be used
170 | // with other functions.
171 | // This parameter can be NULL.
172 | MH_STATUS WINAPI MH_CreateHookApiEx(
173 | LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget);
174 |
175 | // Removes an already created hook.
176 | // Parameters:
177 | // hookIdent [in] A hook identifier, can be set to different values for
178 | // different hooks to hook the same function more than
179 | // once. Default value: 0.
180 | // pTarget [in] A pointer to the target function.
181 | // If this parameter is MH_ALL_HOOKS, all created hooks are
182 | // removed in one go.
183 | MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget);
184 | MH_STATUS WINAPI MH_RemoveHookEx(ULONG_PTR hookIdent, LPVOID pTarget);
185 |
186 | // Enables an already created hook.
187 | // Parameters:
188 | // hookIdent [in] A hook identifier, can be set to different values for
189 | // different hooks to hook the same function more than
190 | // once. Default value: 0.
191 | // pTarget [in] A pointer to the target function.
192 | // If this parameter is MH_ALL_HOOKS, all created hooks are
193 | // enabled in one go.
194 | MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget);
195 | MH_STATUS WINAPI MH_EnableHookEx(ULONG_PTR hookIdent, LPVOID pTarget);
196 |
197 | // Disables an already created hook.
198 | // Parameters:
199 | // hookIdent [in] A hook identifier, can be set to different values for
200 | // different hooks to hook the same function more than
201 | // once. Default value: 0.
202 | // pTarget [in] A pointer to the target function.
203 | // If this parameter is MH_ALL_HOOKS, all created hooks are
204 | // disabled in one go.
205 | MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget);
206 | MH_STATUS WINAPI MH_DisableHookEx(ULONG_PTR hookIdent, LPVOID pTarget);
207 |
208 | // Queues to enable an already created hook.
209 | // Parameters:
210 | // hookIdent [in] A hook identifier, can be set to different values for
211 | // different hooks to hook the same function more than
212 | // once. Default value: 0.
213 | // pTarget [in] A pointer to the target function.
214 | // If this parameter is MH_ALL_HOOKS, all created hooks are
215 | // queued to be enabled.
216 | MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget);
217 | MH_STATUS WINAPI MH_QueueEnableHookEx(ULONG_PTR hookIdent, LPVOID pTarget);
218 |
219 | // Queues to disable an already created hook.
220 | // Parameters:
221 | // hookIdent [in] A hook identifier, can be set to different values for
222 | // different hooks to hook the same function more than
223 | // once. Default value: 0.
224 | // pTarget [in] A pointer to the target function.
225 | // If this parameter is MH_ALL_HOOKS, all created hooks are
226 | // queued to be disabled.
227 | MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget);
228 | MH_STATUS WINAPI MH_QueueDisableHookEx(ULONG_PTR hookIdent, LPVOID pTarget);
229 |
230 | // Applies all queued changes in one go.
231 | MH_STATUS WINAPI MH_ApplyQueued(VOID);
232 |
233 | // Translates the MH_STATUS to its name as a string.
234 | const char * WINAPI MH_StatusToString(MH_STATUS status);
235 |
236 | #ifdef __cplusplus
237 | }
238 | #endif
239 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/buffer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * MinHook - The Minimalistic API Hooking Library for x64/x86
3 | * Copyright (C) 2009-2017 Tsuda Kageyu.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #include
30 | #include "buffer.h"
31 |
32 | // Size of each memory block. (= page size of VirtualAlloc)
33 | #define MEMORY_BLOCK_SIZE 0x1000
34 |
35 | // Max range for seeking a memory block. (= 1024MB)
36 | #define MAX_MEMORY_RANGE 0x40000000
37 |
38 | // Memory protection flags to check the executable address.
39 | #define PAGE_EXECUTE_FLAGS \
40 | (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)
41 |
42 | // Memory slot.
43 | typedef struct _MEMORY_SLOT
44 | {
45 | union
46 | {
47 | struct _MEMORY_SLOT *pNext;
48 | UINT8 buffer[MEMORY_SLOT_SIZE];
49 | };
50 | } MEMORY_SLOT, *PMEMORY_SLOT;
51 |
52 | // Memory block info. Placed at the head of each block.
53 | typedef struct _MEMORY_BLOCK
54 | {
55 | struct _MEMORY_BLOCK *pNext;
56 | PMEMORY_SLOT pFree; // First element of the free slot list.
57 | UINT usedCount;
58 | } MEMORY_BLOCK, *PMEMORY_BLOCK;
59 |
60 | //-------------------------------------------------------------------------
61 | // Global Variables:
62 | //-------------------------------------------------------------------------
63 |
64 | // First element of the memory block list.
65 | PMEMORY_BLOCK g_pMemoryBlocks;
66 |
67 | //-------------------------------------------------------------------------
68 | VOID InitializeBuffer(VOID)
69 | {
70 | // Nothing to do for now.
71 | }
72 |
73 | //-------------------------------------------------------------------------
74 | VOID UninitializeBuffer(VOID)
75 | {
76 | PMEMORY_BLOCK pBlock = g_pMemoryBlocks;
77 | g_pMemoryBlocks = NULL;
78 |
79 | while (pBlock)
80 | {
81 | PMEMORY_BLOCK pNext = pBlock->pNext;
82 | VirtualFree(pBlock, 0, MEM_RELEASE);
83 | pBlock = pNext;
84 | }
85 | }
86 |
87 | //-------------------------------------------------------------------------
88 | #if defined(_M_X64) || defined(__x86_64__)
89 | static LPVOID FindPrevFreeRegion(LPVOID pAddress, LPVOID pMinAddr, DWORD dwAllocationGranularity)
90 | {
91 | ULONG_PTR tryAddr = (ULONG_PTR)pAddress;
92 |
93 | // Round down to the allocation granularity.
94 | tryAddr -= tryAddr % dwAllocationGranularity;
95 |
96 | // Start from the previous allocation granularity multiply.
97 | tryAddr -= dwAllocationGranularity;
98 |
99 | while (tryAddr >= (ULONG_PTR)pMinAddr)
100 | {
101 | MEMORY_BASIC_INFORMATION mbi;
102 | if (VirtualQuery((LPVOID)tryAddr, &mbi, sizeof(mbi)) == 0)
103 | break;
104 |
105 | if (mbi.State == MEM_FREE)
106 | return (LPVOID)tryAddr;
107 |
108 | if ((ULONG_PTR)mbi.AllocationBase < dwAllocationGranularity)
109 | break;
110 |
111 | tryAddr = (ULONG_PTR)mbi.AllocationBase - dwAllocationGranularity;
112 | }
113 |
114 | return NULL;
115 | }
116 | #endif
117 |
118 | //-------------------------------------------------------------------------
119 | #if defined(_M_X64) || defined(__x86_64__)
120 | static LPVOID FindNextFreeRegion(LPVOID pAddress, LPVOID pMaxAddr, DWORD dwAllocationGranularity)
121 | {
122 | ULONG_PTR tryAddr = (ULONG_PTR)pAddress;
123 |
124 | // Round down to the allocation granularity.
125 | tryAddr -= tryAddr % dwAllocationGranularity;
126 |
127 | // Start from the next allocation granularity multiply.
128 | tryAddr += dwAllocationGranularity;
129 |
130 | while (tryAddr <= (ULONG_PTR)pMaxAddr)
131 | {
132 | MEMORY_BASIC_INFORMATION mbi;
133 | if (VirtualQuery((LPVOID)tryAddr, &mbi, sizeof(mbi)) == 0)
134 | break;
135 |
136 | if (mbi.State == MEM_FREE)
137 | return (LPVOID)tryAddr;
138 |
139 | tryAddr = (ULONG_PTR)mbi.BaseAddress + mbi.RegionSize;
140 |
141 | // Round up to the next allocation granularity.
142 | tryAddr += dwAllocationGranularity - 1;
143 | tryAddr -= tryAddr % dwAllocationGranularity;
144 | }
145 |
146 | return NULL;
147 | }
148 | #endif
149 |
150 | //-------------------------------------------------------------------------
151 | static PMEMORY_BLOCK GetMemoryBlock(LPVOID pOrigin)
152 | {
153 | PMEMORY_BLOCK pBlock;
154 | #if defined(_M_X64) || defined(__x86_64__)
155 | ULONG_PTR minAddr;
156 | ULONG_PTR maxAddr;
157 |
158 | SYSTEM_INFO si;
159 | GetSystemInfo(&si);
160 | minAddr = (ULONG_PTR)si.lpMinimumApplicationAddress;
161 | maxAddr = (ULONG_PTR)si.lpMaximumApplicationAddress;
162 |
163 | // pOrigin ± 512MB
164 | if ((ULONG_PTR)pOrigin > MAX_MEMORY_RANGE && minAddr < (ULONG_PTR)pOrigin - MAX_MEMORY_RANGE)
165 | minAddr = (ULONG_PTR)pOrigin - MAX_MEMORY_RANGE;
166 |
167 | if (maxAddr > (ULONG_PTR)pOrigin + MAX_MEMORY_RANGE)
168 | maxAddr = (ULONG_PTR)pOrigin + MAX_MEMORY_RANGE;
169 |
170 | // Make room for MEMORY_BLOCK_SIZE bytes.
171 | maxAddr -= MEMORY_BLOCK_SIZE - 1;
172 | #endif
173 |
174 | // Look the registered blocks for a reachable one.
175 | for (pBlock = g_pMemoryBlocks; pBlock != NULL; pBlock = pBlock->pNext)
176 | {
177 | #if defined(_M_X64) || defined(__x86_64__)
178 | // Ignore the blocks too far.
179 | if ((ULONG_PTR)pBlock < minAddr || (ULONG_PTR)pBlock >= maxAddr)
180 | continue;
181 | #endif
182 | // The block has at least one unused slot.
183 | if (pBlock->pFree != NULL)
184 | return pBlock;
185 | }
186 |
187 | #if defined(_M_X64) || defined(__x86_64__)
188 | // Alloc a new block above if not found.
189 | {
190 | LPVOID pAlloc = pOrigin;
191 | while ((ULONG_PTR)pAlloc >= minAddr)
192 | {
193 | pAlloc = FindPrevFreeRegion(pAlloc, (LPVOID)minAddr, si.dwAllocationGranularity);
194 | if (pAlloc == NULL)
195 | break;
196 |
197 | pBlock = (PMEMORY_BLOCK)VirtualAlloc(
198 | pAlloc, MEMORY_BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
199 | if (pBlock != NULL)
200 | break;
201 | }
202 | }
203 |
204 | // Alloc a new block below if not found.
205 | if (pBlock == NULL)
206 | {
207 | LPVOID pAlloc = pOrigin;
208 | while ((ULONG_PTR)pAlloc <= maxAddr)
209 | {
210 | pAlloc = FindNextFreeRegion(pAlloc, (LPVOID)maxAddr, si.dwAllocationGranularity);
211 | if (pAlloc == NULL)
212 | break;
213 |
214 | pBlock = (PMEMORY_BLOCK)VirtualAlloc(
215 | pAlloc, MEMORY_BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
216 | if (pBlock != NULL)
217 | break;
218 | }
219 | }
220 | #else
221 | // In x86 mode, a memory block can be placed anywhere.
222 | pBlock = (PMEMORY_BLOCK)VirtualAlloc(
223 | NULL, MEMORY_BLOCK_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
224 | #endif
225 |
226 | if (pBlock != NULL)
227 | {
228 | // Build a linked list of all the slots.
229 | PMEMORY_SLOT pSlot = (PMEMORY_SLOT)pBlock + 1;
230 | pBlock->pFree = NULL;
231 | pBlock->usedCount = 0;
232 | do
233 | {
234 | pSlot->pNext = pBlock->pFree;
235 | pBlock->pFree = pSlot;
236 | pSlot++;
237 | } while ((ULONG_PTR)pSlot - (ULONG_PTR)pBlock <= MEMORY_BLOCK_SIZE - MEMORY_SLOT_SIZE);
238 |
239 | pBlock->pNext = g_pMemoryBlocks;
240 | g_pMemoryBlocks = pBlock;
241 | }
242 |
243 | return pBlock;
244 | }
245 |
246 | //-------------------------------------------------------------------------
247 | LPVOID AllocateBuffer(LPVOID pOrigin)
248 | {
249 | PMEMORY_SLOT pSlot;
250 | PMEMORY_BLOCK pBlock = GetMemoryBlock(pOrigin);
251 | if (pBlock == NULL)
252 | return NULL;
253 |
254 | // Remove an unused slot from the list.
255 | pSlot = pBlock->pFree;
256 | pBlock->pFree = pSlot->pNext;
257 | pBlock->usedCount++;
258 | #ifdef _DEBUG
259 | // Fill the slot with INT3 for debugging.
260 | memset(pSlot, 0xCC, sizeof(MEMORY_SLOT));
261 | #endif
262 | return pSlot;
263 | }
264 |
265 | //-------------------------------------------------------------------------
266 | VOID FreeBuffer(LPVOID pBuffer)
267 | {
268 | PMEMORY_BLOCK pBlock = g_pMemoryBlocks;
269 | PMEMORY_BLOCK pPrev = NULL;
270 | ULONG_PTR pTargetBlock = ((ULONG_PTR)pBuffer / MEMORY_BLOCK_SIZE) * MEMORY_BLOCK_SIZE;
271 |
272 | while (pBlock != NULL)
273 | {
274 | if ((ULONG_PTR)pBlock == pTargetBlock)
275 | {
276 | PMEMORY_SLOT pSlot = (PMEMORY_SLOT)pBuffer;
277 | #ifdef _DEBUG
278 | // Clear the released slot for debugging.
279 | memset(pSlot, 0x00, sizeof(MEMORY_SLOT));
280 | #endif
281 | // Restore the released slot to the list.
282 | pSlot->pNext = pBlock->pFree;
283 | pBlock->pFree = pSlot;
284 | pBlock->usedCount--;
285 |
286 | // Free if unused.
287 | if (pBlock->usedCount == 0)
288 | {
289 | if (pPrev)
290 | pPrev->pNext = pBlock->pNext;
291 | else
292 | g_pMemoryBlocks = pBlock->pNext;
293 |
294 | VirtualFree(pBlock, 0, MEM_RELEASE);
295 | }
296 |
297 | break;
298 | }
299 |
300 | pPrev = pBlock;
301 | pBlock = pBlock->pNext;
302 | }
303 | }
304 |
305 | //-------------------------------------------------------------------------
306 | BOOL IsExecutableAddress(LPVOID pAddress)
307 | {
308 | MEMORY_BASIC_INFORMATION mi;
309 | VirtualQuery(pAddress, &mi, sizeof(mi));
310 |
311 | return (mi.State == MEM_COMMIT && (mi.Protect & PAGE_EXECUTE_FLAGS));
312 | }
313 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/buffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MinHook - The Minimalistic API Hooking Library for x64/x86
3 | * Copyright (C) 2009-2017 Tsuda Kageyu.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #pragma once
30 |
31 | // Size of each memory slot.
32 | #if defined(_M_X64) || defined(__x86_64__)
33 | #define MEMORY_SLOT_SIZE 64
34 | #else
35 | #define MEMORY_SLOT_SIZE 64
36 | #endif
37 |
38 | VOID InitializeBuffer(VOID);
39 | VOID UninitializeBuffer(VOID);
40 | LPVOID AllocateBuffer(LPVOID pOrigin);
41 | VOID FreeBuffer(LPVOID pBuffer);
42 | BOOL IsExecutableAddress(LPVOID pAddress);
43 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/hde32.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Hacker Disassembler Engine 32 C
3 | * Copyright (c) 2008-2009, Vyacheslav Patkov.
4 | * All rights reserved.
5 | *
6 | */
7 |
8 | #if defined(_M_IX86) || defined(__i386__)
9 |
10 | #include
11 | #include "hde32.h"
12 | #include "table32.h"
13 |
14 | unsigned int hde32_disasm(const void *code, hde32s *hs)
15 | {
16 | uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0;
17 | uint8_t *ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0;
18 |
19 | memset(hs, 0, sizeof(hde32s));
20 |
21 | for (x = 16; x; x--)
22 | switch (c = *p++) {
23 | case 0xf3:
24 | hs->p_rep = c;
25 | pref |= PRE_F3;
26 | break;
27 | case 0xf2:
28 | hs->p_rep = c;
29 | pref |= PRE_F2;
30 | break;
31 | case 0xf0:
32 | hs->p_lock = c;
33 | pref |= PRE_LOCK;
34 | break;
35 | case 0x26: case 0x2e: case 0x36:
36 | case 0x3e: case 0x64: case 0x65:
37 | hs->p_seg = c;
38 | pref |= PRE_SEG;
39 | break;
40 | case 0x66:
41 | hs->p_66 = c;
42 | pref |= PRE_66;
43 | break;
44 | case 0x67:
45 | hs->p_67 = c;
46 | pref |= PRE_67;
47 | break;
48 | default:
49 | goto pref_done;
50 | }
51 | pref_done:
52 |
53 | hs->flags = (uint32_t)pref << 23;
54 |
55 | if (!pref)
56 | pref |= PRE_NONE;
57 |
58 | if ((hs->opcode = c) == 0x0f) {
59 | hs->opcode2 = c = *p++;
60 | ht += DELTA_OPCODES;
61 | } else if (c >= 0xa0 && c <= 0xa3) {
62 | if (pref & PRE_67)
63 | pref |= PRE_66;
64 | else
65 | pref &= ~PRE_66;
66 | }
67 |
68 | opcode = c;
69 | cflags = ht[ht[opcode / 4] + (opcode % 4)];
70 |
71 | if (cflags == C_ERROR) {
72 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
73 | cflags = 0;
74 | if ((opcode & -3) == 0x24)
75 | cflags++;
76 | }
77 |
78 | x = 0;
79 | if (cflags & C_GROUP) {
80 | uint16_t t;
81 | t = *(uint16_t *)(ht + (cflags & 0x7f));
82 | cflags = (uint8_t)t;
83 | x = (uint8_t)(t >> 8);
84 | }
85 |
86 | if (hs->opcode2) {
87 | ht = hde32_table + DELTA_PREFIXES;
88 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref)
89 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
90 | }
91 |
92 | if (cflags & C_MODRM) {
93 | hs->flags |= F_MODRM;
94 | hs->modrm = c = *p++;
95 | hs->modrm_mod = m_mod = c >> 6;
96 | hs->modrm_rm = m_rm = c & 7;
97 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3;
98 |
99 | if (x && ((x << m_reg) & 0x80))
100 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
101 |
102 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) {
103 | uint8_t t = opcode - 0xd9;
104 | if (m_mod == 3) {
105 | ht = hde32_table + DELTA_FPU_MODRM + t*8;
106 | t = ht[m_reg] << m_rm;
107 | } else {
108 | ht = hde32_table + DELTA_FPU_REG;
109 | t = ht[t] << m_reg;
110 | }
111 | if (t & 0x80)
112 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
113 | }
114 |
115 | if (pref & PRE_LOCK) {
116 | if (m_mod == 3) {
117 | hs->flags |= F_ERROR | F_ERROR_LOCK;
118 | } else {
119 | uint8_t *table_end, op = opcode;
120 | if (hs->opcode2) {
121 | ht = hde32_table + DELTA_OP2_LOCK_OK;
122 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK;
123 | } else {
124 | ht = hde32_table + DELTA_OP_LOCK_OK;
125 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK;
126 | op &= -2;
127 | }
128 | for (; ht != table_end; ht++)
129 | if (*ht++ == op) {
130 | if (!((*ht << m_reg) & 0x80))
131 | goto no_lock_error;
132 | else
133 | break;
134 | }
135 | hs->flags |= F_ERROR | F_ERROR_LOCK;
136 | no_lock_error:
137 | ;
138 | }
139 | }
140 |
141 | if (hs->opcode2) {
142 | switch (opcode) {
143 | case 0x20: case 0x22:
144 | m_mod = 3;
145 | if (m_reg > 4 || m_reg == 1)
146 | goto error_operand;
147 | else
148 | goto no_error_operand;
149 | case 0x21: case 0x23:
150 | m_mod = 3;
151 | if (m_reg == 4 || m_reg == 5)
152 | goto error_operand;
153 | else
154 | goto no_error_operand;
155 | }
156 | } else {
157 | switch (opcode) {
158 | case 0x8c:
159 | if (m_reg > 5)
160 | goto error_operand;
161 | else
162 | goto no_error_operand;
163 | case 0x8e:
164 | if (m_reg == 1 || m_reg > 5)
165 | goto error_operand;
166 | else
167 | goto no_error_operand;
168 | }
169 | }
170 |
171 | if (m_mod == 3) {
172 | uint8_t *table_end;
173 | if (hs->opcode2) {
174 | ht = hde32_table + DELTA_OP2_ONLY_MEM;
175 | table_end = ht + sizeof(hde32_table) - DELTA_OP2_ONLY_MEM;
176 | } else {
177 | ht = hde32_table + DELTA_OP_ONLY_MEM;
178 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM;
179 | }
180 | for (; ht != table_end; ht += 2)
181 | if (*ht++ == opcode) {
182 | if ((*ht++ & pref) && !((*ht << m_reg) & 0x80))
183 | goto error_operand;
184 | else
185 | break;
186 | }
187 | goto no_error_operand;
188 | } else if (hs->opcode2) {
189 | switch (opcode) {
190 | case 0x50: case 0xd7: case 0xf7:
191 | if (pref & (PRE_NONE | PRE_66))
192 | goto error_operand;
193 | break;
194 | case 0xd6:
195 | if (pref & (PRE_F2 | PRE_F3))
196 | goto error_operand;
197 | break;
198 | case 0xc5:
199 | goto error_operand;
200 | }
201 | goto no_error_operand;
202 | } else
203 | goto no_error_operand;
204 |
205 | error_operand:
206 | hs->flags |= F_ERROR | F_ERROR_OPERAND;
207 | no_error_operand:
208 |
209 | c = *p++;
210 | if (m_reg <= 1) {
211 | if (opcode == 0xf6)
212 | cflags |= C_IMM8;
213 | else if (opcode == 0xf7)
214 | cflags |= C_IMM_P66;
215 | }
216 |
217 | switch (m_mod) {
218 | case 0:
219 | if (pref & PRE_67) {
220 | if (m_rm == 6)
221 | disp_size = 2;
222 | } else
223 | if (m_rm == 5)
224 | disp_size = 4;
225 | break;
226 | case 1:
227 | disp_size = 1;
228 | break;
229 | case 2:
230 | disp_size = 2;
231 | if (!(pref & PRE_67))
232 | disp_size <<= 1;
233 | break;
234 | }
235 |
236 | if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) {
237 | hs->flags |= F_SIB;
238 | p++;
239 | hs->sib = c;
240 | hs->sib_scale = c >> 6;
241 | hs->sib_index = (c & 0x3f) >> 3;
242 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1))
243 | disp_size = 4;
244 | }
245 |
246 | p--;
247 | switch (disp_size) {
248 | case 1:
249 | hs->flags |= F_DISP8;
250 | hs->disp.disp8 = *p;
251 | break;
252 | case 2:
253 | hs->flags |= F_DISP16;
254 | hs->disp.disp16 = *(uint16_t *)p;
255 | break;
256 | case 4:
257 | hs->flags |= F_DISP32;
258 | hs->disp.disp32 = *(uint32_t *)p;
259 | break;
260 | }
261 | p += disp_size;
262 | } else if (pref & PRE_LOCK)
263 | hs->flags |= F_ERROR | F_ERROR_LOCK;
264 |
265 | if (cflags & C_IMM_P66) {
266 | if (cflags & C_REL32) {
267 | if (pref & PRE_66) {
268 | hs->flags |= F_IMM16 | F_RELATIVE;
269 | hs->imm.imm16 = *(uint16_t *)p;
270 | p += 2;
271 | goto disasm_done;
272 | }
273 | goto rel32_ok;
274 | }
275 | if (pref & PRE_66) {
276 | hs->flags |= F_IMM16;
277 | hs->imm.imm16 = *(uint16_t *)p;
278 | p += 2;
279 | } else {
280 | hs->flags |= F_IMM32;
281 | hs->imm.imm32 = *(uint32_t *)p;
282 | p += 4;
283 | }
284 | }
285 |
286 | if (cflags & C_IMM16) {
287 | if (hs->flags & F_IMM32) {
288 | hs->flags |= F_IMM16;
289 | hs->disp.disp16 = *(uint16_t *)p;
290 | } else if (hs->flags & F_IMM16) {
291 | hs->flags |= F_2IMM16;
292 | hs->disp.disp16 = *(uint16_t *)p;
293 | } else {
294 | hs->flags |= F_IMM16;
295 | hs->imm.imm16 = *(uint16_t *)p;
296 | }
297 | p += 2;
298 | }
299 | if (cflags & C_IMM8) {
300 | hs->flags |= F_IMM8;
301 | hs->imm.imm8 = *p++;
302 | }
303 |
304 | if (cflags & C_REL32) {
305 | rel32_ok:
306 | hs->flags |= F_IMM32 | F_RELATIVE;
307 | hs->imm.imm32 = *(uint32_t *)p;
308 | p += 4;
309 | } else if (cflags & C_REL8) {
310 | hs->flags |= F_IMM8 | F_RELATIVE;
311 | hs->imm.imm8 = *p++;
312 | }
313 |
314 | disasm_done:
315 |
316 | if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) {
317 | hs->flags |= F_ERROR | F_ERROR_LENGTH;
318 | hs->len = 15;
319 | }
320 |
321 | return (unsigned int)hs->len;
322 | }
323 |
324 | #endif // defined(_M_IX86) || defined(__i386__)
325 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/hde32.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Hacker Disassembler Engine 32
3 | * Copyright (c) 2006-2009, Vyacheslav Patkov.
4 | * All rights reserved.
5 | *
6 | * hde32.h: C/C++ header file
7 | *
8 | */
9 |
10 | #ifndef _HDE32_H_
11 | #define _HDE32_H_
12 |
13 | /* stdint.h - C99 standard header
14 | * http://en.wikipedia.org/wiki/stdint.h
15 | *
16 | * if your compiler doesn't contain "stdint.h" header (for
17 | * example, Microsoft Visual C++), you can download file:
18 | * http://www.azillionmonkeys.com/qed/pstdint.h
19 | * and change next line to:
20 | * #include "pstdint.h"
21 | */
22 | #include "pstdint.h"
23 |
24 | #define F_MODRM 0x00000001
25 | #define F_SIB 0x00000002
26 | #define F_IMM8 0x00000004
27 | #define F_IMM16 0x00000008
28 | #define F_IMM32 0x00000010
29 | #define F_DISP8 0x00000020
30 | #define F_DISP16 0x00000040
31 | #define F_DISP32 0x00000080
32 | #define F_RELATIVE 0x00000100
33 | #define F_2IMM16 0x00000800
34 | #define F_ERROR 0x00001000
35 | #define F_ERROR_OPCODE 0x00002000
36 | #define F_ERROR_LENGTH 0x00004000
37 | #define F_ERROR_LOCK 0x00008000
38 | #define F_ERROR_OPERAND 0x00010000
39 | #define F_PREFIX_REPNZ 0x01000000
40 | #define F_PREFIX_REPX 0x02000000
41 | #define F_PREFIX_REP 0x03000000
42 | #define F_PREFIX_66 0x04000000
43 | #define F_PREFIX_67 0x08000000
44 | #define F_PREFIX_LOCK 0x10000000
45 | #define F_PREFIX_SEG 0x20000000
46 | #define F_PREFIX_ANY 0x3f000000
47 |
48 | #define PREFIX_SEGMENT_CS 0x2e
49 | #define PREFIX_SEGMENT_SS 0x36
50 | #define PREFIX_SEGMENT_DS 0x3e
51 | #define PREFIX_SEGMENT_ES 0x26
52 | #define PREFIX_SEGMENT_FS 0x64
53 | #define PREFIX_SEGMENT_GS 0x65
54 | #define PREFIX_LOCK 0xf0
55 | #define PREFIX_REPNZ 0xf2
56 | #define PREFIX_REPX 0xf3
57 | #define PREFIX_OPERAND_SIZE 0x66
58 | #define PREFIX_ADDRESS_SIZE 0x67
59 |
60 | #pragma pack(push,1)
61 |
62 | typedef struct {
63 | uint8_t len;
64 | uint8_t p_rep;
65 | uint8_t p_lock;
66 | uint8_t p_seg;
67 | uint8_t p_66;
68 | uint8_t p_67;
69 | uint8_t opcode;
70 | uint8_t opcode2;
71 | uint8_t modrm;
72 | uint8_t modrm_mod;
73 | uint8_t modrm_reg;
74 | uint8_t modrm_rm;
75 | uint8_t sib;
76 | uint8_t sib_scale;
77 | uint8_t sib_index;
78 | uint8_t sib_base;
79 | union {
80 | uint8_t imm8;
81 | uint16_t imm16;
82 | uint32_t imm32;
83 | } imm;
84 | union {
85 | uint8_t disp8;
86 | uint16_t disp16;
87 | uint32_t disp32;
88 | } disp;
89 | uint32_t flags;
90 | } hde32s;
91 |
92 | #pragma pack(pop)
93 |
94 | #ifdef __cplusplus
95 | extern "C" {
96 | #endif
97 |
98 | /* __cdecl */
99 | unsigned int hde32_disasm(const void *code, hde32s *hs);
100 |
101 | #ifdef __cplusplus
102 | }
103 | #endif
104 |
105 | #endif /* _HDE32_H_ */
106 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/hde64.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Hacker Disassembler Engine 64 C
3 | * Copyright (c) 2008-2009, Vyacheslav Patkov.
4 | * All rights reserved.
5 | *
6 | */
7 |
8 | #if defined(_M_X64) || defined(__x86_64__)
9 |
10 | #include
11 | #include "hde64.h"
12 | #include "table64.h"
13 |
14 | unsigned int hde64_disasm(const void *code, hde64s *hs)
15 | {
16 | uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0;
17 | uint8_t *ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0;
18 | uint8_t op64 = 0;
19 |
20 | memset(hs, 0, sizeof(hde64s));
21 |
22 | for (x = 16; x; x--)
23 | switch (c = *p++) {
24 | case 0xf3:
25 | hs->p_rep = c;
26 | pref |= PRE_F3;
27 | break;
28 | case 0xf2:
29 | hs->p_rep = c;
30 | pref |= PRE_F2;
31 | break;
32 | case 0xf0:
33 | hs->p_lock = c;
34 | pref |= PRE_LOCK;
35 | break;
36 | case 0x26: case 0x2e: case 0x36:
37 | case 0x3e: case 0x64: case 0x65:
38 | hs->p_seg = c;
39 | pref |= PRE_SEG;
40 | break;
41 | case 0x66:
42 | hs->p_66 = c;
43 | pref |= PRE_66;
44 | break;
45 | case 0x67:
46 | hs->p_67 = c;
47 | pref |= PRE_67;
48 | break;
49 | default:
50 | goto pref_done;
51 | }
52 | pref_done:
53 |
54 | hs->flags = (uint32_t)pref << 23;
55 |
56 | if (!pref)
57 | pref |= PRE_NONE;
58 |
59 | if ((c & 0xf0) == 0x40) {
60 | hs->flags |= F_PREFIX_REX;
61 | if ((hs->rex_w = (c & 0xf) >> 3) && (*p & 0xf8) == 0xb8)
62 | op64++;
63 | hs->rex_r = (c & 7) >> 2;
64 | hs->rex_x = (c & 3) >> 1;
65 | hs->rex_b = c & 1;
66 | if (((c = *p++) & 0xf0) == 0x40) {
67 | opcode = c;
68 | goto error_opcode;
69 | }
70 | }
71 |
72 | if ((hs->opcode = c) == 0x0f) {
73 | hs->opcode2 = c = *p++;
74 | ht += DELTA_OPCODES;
75 | } else if (c >= 0xa0 && c <= 0xa3) {
76 | op64++;
77 | if (pref & PRE_67)
78 | pref |= PRE_66;
79 | else
80 | pref &= ~PRE_66;
81 | }
82 |
83 | opcode = c;
84 | cflags = ht[ht[opcode / 4] + (opcode % 4)];
85 |
86 | if (cflags == C_ERROR) {
87 | error_opcode:
88 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
89 | cflags = 0;
90 | if ((opcode & -3) == 0x24)
91 | cflags++;
92 | }
93 |
94 | x = 0;
95 | if (cflags & C_GROUP) {
96 | uint16_t t;
97 | t = *(uint16_t *)(ht + (cflags & 0x7f));
98 | cflags = (uint8_t)t;
99 | x = (uint8_t)(t >> 8);
100 | }
101 |
102 | if (hs->opcode2) {
103 | ht = hde64_table + DELTA_PREFIXES;
104 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref)
105 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
106 | }
107 |
108 | if (cflags & C_MODRM) {
109 | hs->flags |= F_MODRM;
110 | hs->modrm = c = *p++;
111 | hs->modrm_mod = m_mod = c >> 6;
112 | hs->modrm_rm = m_rm = c & 7;
113 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3;
114 |
115 | if (x && ((x << m_reg) & 0x80))
116 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
117 |
118 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) {
119 | uint8_t t = opcode - 0xd9;
120 | if (m_mod == 3) {
121 | ht = hde64_table + DELTA_FPU_MODRM + t*8;
122 | t = ht[m_reg] << m_rm;
123 | } else {
124 | ht = hde64_table + DELTA_FPU_REG;
125 | t = ht[t] << m_reg;
126 | }
127 | if (t & 0x80)
128 | hs->flags |= F_ERROR | F_ERROR_OPCODE;
129 | }
130 |
131 | if (pref & PRE_LOCK) {
132 | if (m_mod == 3) {
133 | hs->flags |= F_ERROR | F_ERROR_LOCK;
134 | } else {
135 | uint8_t *table_end, op = opcode;
136 | if (hs->opcode2) {
137 | ht = hde64_table + DELTA_OP2_LOCK_OK;
138 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK;
139 | } else {
140 | ht = hde64_table + DELTA_OP_LOCK_OK;
141 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK;
142 | op &= -2;
143 | }
144 | for (; ht != table_end; ht++)
145 | if (*ht++ == op) {
146 | if (!((*ht << m_reg) & 0x80))
147 | goto no_lock_error;
148 | else
149 | break;
150 | }
151 | hs->flags |= F_ERROR | F_ERROR_LOCK;
152 | no_lock_error:
153 | ;
154 | }
155 | }
156 |
157 | if (hs->opcode2) {
158 | switch (opcode) {
159 | case 0x20: case 0x22:
160 | m_mod = 3;
161 | if (m_reg > 4 || m_reg == 1)
162 | goto error_operand;
163 | else
164 | goto no_error_operand;
165 | case 0x21: case 0x23:
166 | m_mod = 3;
167 | if (m_reg == 4 || m_reg == 5)
168 | goto error_operand;
169 | else
170 | goto no_error_operand;
171 | }
172 | } else {
173 | switch (opcode) {
174 | case 0x8c:
175 | if (m_reg > 5)
176 | goto error_operand;
177 | else
178 | goto no_error_operand;
179 | case 0x8e:
180 | if (m_reg == 1 || m_reg > 5)
181 | goto error_operand;
182 | else
183 | goto no_error_operand;
184 | }
185 | }
186 |
187 | if (m_mod == 3) {
188 | uint8_t *table_end;
189 | if (hs->opcode2) {
190 | ht = hde64_table + DELTA_OP2_ONLY_MEM;
191 | table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM;
192 | } else {
193 | ht = hde64_table + DELTA_OP_ONLY_MEM;
194 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM;
195 | }
196 | for (; ht != table_end; ht += 2)
197 | if (*ht++ == opcode) {
198 | if (*ht++ & pref && !((*ht << m_reg) & 0x80))
199 | goto error_operand;
200 | else
201 | break;
202 | }
203 | goto no_error_operand;
204 | } else if (hs->opcode2) {
205 | switch (opcode) {
206 | case 0x50: case 0xd7: case 0xf7:
207 | if (pref & (PRE_NONE | PRE_66))
208 | goto error_operand;
209 | break;
210 | case 0xd6:
211 | if (pref & (PRE_F2 | PRE_F3))
212 | goto error_operand;
213 | break;
214 | case 0xc5:
215 | goto error_operand;
216 | }
217 | goto no_error_operand;
218 | } else
219 | goto no_error_operand;
220 |
221 | error_operand:
222 | hs->flags |= F_ERROR | F_ERROR_OPERAND;
223 | no_error_operand:
224 |
225 | c = *p++;
226 | if (m_reg <= 1) {
227 | if (opcode == 0xf6)
228 | cflags |= C_IMM8;
229 | else if (opcode == 0xf7)
230 | cflags |= C_IMM_P66;
231 | }
232 |
233 | switch (m_mod) {
234 | case 0:
235 | if (pref & PRE_67) {
236 | if (m_rm == 6)
237 | disp_size = 2;
238 | } else
239 | if (m_rm == 5)
240 | disp_size = 4;
241 | break;
242 | case 1:
243 | disp_size = 1;
244 | break;
245 | case 2:
246 | disp_size = 2;
247 | if (!(pref & PRE_67))
248 | disp_size <<= 1;
249 | }
250 |
251 | if (m_mod != 3 && m_rm == 4) {
252 | hs->flags |= F_SIB;
253 | p++;
254 | hs->sib = c;
255 | hs->sib_scale = c >> 6;
256 | hs->sib_index = (c & 0x3f) >> 3;
257 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1))
258 | disp_size = 4;
259 | }
260 |
261 | p--;
262 | switch (disp_size) {
263 | case 1:
264 | hs->flags |= F_DISP8;
265 | hs->disp.disp8 = *p;
266 | break;
267 | case 2:
268 | hs->flags |= F_DISP16;
269 | hs->disp.disp16 = *(uint16_t *)p;
270 | break;
271 | case 4:
272 | hs->flags |= F_DISP32;
273 | hs->disp.disp32 = *(uint32_t *)p;
274 | }
275 | p += disp_size;
276 | } else if (pref & PRE_LOCK)
277 | hs->flags |= F_ERROR | F_ERROR_LOCK;
278 |
279 | if (cflags & C_IMM_P66) {
280 | if (cflags & C_REL32) {
281 | if (pref & PRE_66) {
282 | hs->flags |= F_IMM16 | F_RELATIVE;
283 | hs->imm.imm16 = *(uint16_t *)p;
284 | p += 2;
285 | goto disasm_done;
286 | }
287 | goto rel32_ok;
288 | }
289 | if (op64) {
290 | hs->flags |= F_IMM64;
291 | hs->imm.imm64 = *(uint64_t *)p;
292 | p += 8;
293 | } else if (!(pref & PRE_66)) {
294 | hs->flags |= F_IMM32;
295 | hs->imm.imm32 = *(uint32_t *)p;
296 | p += 4;
297 | } else
298 | goto imm16_ok;
299 | }
300 |
301 |
302 | if (cflags & C_IMM16) {
303 | imm16_ok:
304 | hs->flags |= F_IMM16;
305 | hs->imm.imm16 = *(uint16_t *)p;
306 | p += 2;
307 | }
308 | if (cflags & C_IMM8) {
309 | hs->flags |= F_IMM8;
310 | hs->imm.imm8 = *p++;
311 | }
312 |
313 | if (cflags & C_REL32) {
314 | rel32_ok:
315 | hs->flags |= F_IMM32 | F_RELATIVE;
316 | hs->imm.imm32 = *(uint32_t *)p;
317 | p += 4;
318 | } else if (cflags & C_REL8) {
319 | hs->flags |= F_IMM8 | F_RELATIVE;
320 | hs->imm.imm8 = *p++;
321 | }
322 |
323 | disasm_done:
324 |
325 | if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) {
326 | hs->flags |= F_ERROR | F_ERROR_LENGTH;
327 | hs->len = 15;
328 | }
329 |
330 | return (unsigned int)hs->len;
331 | }
332 |
333 | #endif // defined(_M_X64) || defined(__x86_64__)
334 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/hde64.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Hacker Disassembler Engine 64
3 | * Copyright (c) 2008-2009, Vyacheslav Patkov.
4 | * All rights reserved.
5 | *
6 | * hde64.h: C/C++ header file
7 | *
8 | */
9 |
10 | #ifndef _HDE64_H_
11 | #define _HDE64_H_
12 |
13 | /* stdint.h - C99 standard header
14 | * http://en.wikipedia.org/wiki/stdint.h
15 | *
16 | * if your compiler doesn't contain "stdint.h" header (for
17 | * example, Microsoft Visual C++), you can download file:
18 | * http://www.azillionmonkeys.com/qed/pstdint.h
19 | * and change next line to:
20 | * #include "pstdint.h"
21 | */
22 | #include "pstdint.h"
23 |
24 | #define F_MODRM 0x00000001
25 | #define F_SIB 0x00000002
26 | #define F_IMM8 0x00000004
27 | #define F_IMM16 0x00000008
28 | #define F_IMM32 0x00000010
29 | #define F_IMM64 0x00000020
30 | #define F_DISP8 0x00000040
31 | #define F_DISP16 0x00000080
32 | #define F_DISP32 0x00000100
33 | #define F_RELATIVE 0x00000200
34 | #define F_ERROR 0x00001000
35 | #define F_ERROR_OPCODE 0x00002000
36 | #define F_ERROR_LENGTH 0x00004000
37 | #define F_ERROR_LOCK 0x00008000
38 | #define F_ERROR_OPERAND 0x00010000
39 | #define F_PREFIX_REPNZ 0x01000000
40 | #define F_PREFIX_REPX 0x02000000
41 | #define F_PREFIX_REP 0x03000000
42 | #define F_PREFIX_66 0x04000000
43 | #define F_PREFIX_67 0x08000000
44 | #define F_PREFIX_LOCK 0x10000000
45 | #define F_PREFIX_SEG 0x20000000
46 | #define F_PREFIX_REX 0x40000000
47 | #define F_PREFIX_ANY 0x7f000000
48 |
49 | #define PREFIX_SEGMENT_CS 0x2e
50 | #define PREFIX_SEGMENT_SS 0x36
51 | #define PREFIX_SEGMENT_DS 0x3e
52 | #define PREFIX_SEGMENT_ES 0x26
53 | #define PREFIX_SEGMENT_FS 0x64
54 | #define PREFIX_SEGMENT_GS 0x65
55 | #define PREFIX_LOCK 0xf0
56 | #define PREFIX_REPNZ 0xf2
57 | #define PREFIX_REPX 0xf3
58 | #define PREFIX_OPERAND_SIZE 0x66
59 | #define PREFIX_ADDRESS_SIZE 0x67
60 |
61 | #pragma pack(push,1)
62 |
63 | typedef struct {
64 | uint8_t len;
65 | uint8_t p_rep;
66 | uint8_t p_lock;
67 | uint8_t p_seg;
68 | uint8_t p_66;
69 | uint8_t p_67;
70 | uint8_t rex;
71 | uint8_t rex_w;
72 | uint8_t rex_r;
73 | uint8_t rex_x;
74 | uint8_t rex_b;
75 | uint8_t opcode;
76 | uint8_t opcode2;
77 | uint8_t modrm;
78 | uint8_t modrm_mod;
79 | uint8_t modrm_reg;
80 | uint8_t modrm_rm;
81 | uint8_t sib;
82 | uint8_t sib_scale;
83 | uint8_t sib_index;
84 | uint8_t sib_base;
85 | union {
86 | uint8_t imm8;
87 | uint16_t imm16;
88 | uint32_t imm32;
89 | uint64_t imm64;
90 | } imm;
91 | union {
92 | uint8_t disp8;
93 | uint16_t disp16;
94 | uint32_t disp32;
95 | } disp;
96 | uint32_t flags;
97 | } hde64s;
98 |
99 | #pragma pack(pop)
100 |
101 | #ifdef __cplusplus
102 | extern "C" {
103 | #endif
104 |
105 | /* __cdecl */
106 | unsigned int hde64_disasm(const void *code, hde64s *hs);
107 |
108 | #ifdef __cplusplus
109 | }
110 | #endif
111 |
112 | #endif /* _HDE64_H_ */
113 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/pstdint.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MinHook - The Minimalistic API Hooking Library for x64/x86
3 | * Copyright (C) 2009-2017 Tsuda Kageyu. All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | *
9 | * 1. Redistributions of source code must retain the above copyright
10 | * notice, this list of conditions and the following disclaimer.
11 | * 2. Redistributions in binary form must reproduce the above copyright
12 | * notice, this list of conditions and the following disclaimer in the
13 | * documentation and/or other materials provided with the distribution.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | */
26 |
27 | #pragma once
28 |
29 | #include
30 |
31 | // Integer types for HDE.
32 | typedef INT8 int8_t;
33 | typedef INT16 int16_t;
34 | typedef INT32 int32_t;
35 | typedef INT64 int64_t;
36 | typedef UINT8 uint8_t;
37 | typedef UINT16 uint16_t;
38 | typedef UINT32 uint32_t;
39 | typedef UINT64 uint64_t;
40 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/table32.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Hacker Disassembler Engine 32 C
3 | * Copyright (c) 2008-2009, Vyacheslav Patkov.
4 | * All rights reserved.
5 | *
6 | */
7 |
8 | #define C_NONE 0x00
9 | #define C_MODRM 0x01
10 | #define C_IMM8 0x02
11 | #define C_IMM16 0x04
12 | #define C_IMM_P66 0x10
13 | #define C_REL8 0x20
14 | #define C_REL32 0x40
15 | #define C_GROUP 0x80
16 | #define C_ERROR 0xff
17 |
18 | #define PRE_ANY 0x00
19 | #define PRE_NONE 0x01
20 | #define PRE_F2 0x02
21 | #define PRE_F3 0x04
22 | #define PRE_66 0x08
23 | #define PRE_67 0x10
24 | #define PRE_LOCK 0x20
25 | #define PRE_SEG 0x40
26 | #define PRE_ALL 0xff
27 |
28 | #define DELTA_OPCODES 0x4a
29 | #define DELTA_FPU_REG 0xf1
30 | #define DELTA_FPU_MODRM 0xf8
31 | #define DELTA_PREFIXES 0x130
32 | #define DELTA_OP_LOCK_OK 0x1a1
33 | #define DELTA_OP2_LOCK_OK 0x1b9
34 | #define DELTA_OP_ONLY_MEM 0x1cb
35 | #define DELTA_OP2_ONLY_MEM 0x1da
36 |
37 | unsigned char hde32_table[] = {
38 | 0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,
39 | 0xa8,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xac,0xaa,0xb2,0xaa,0x9f,0x9f,
40 | 0x9f,0x9f,0xb5,0xa3,0xa3,0xa4,0xaa,0xaa,0xba,0xaa,0x96,0xaa,0xa8,0xaa,0xc3,
41 | 0xc3,0x96,0x96,0xb7,0xae,0xd6,0xbd,0xa3,0xc5,0xa3,0xa3,0x9f,0xc3,0x9c,0xaa,
42 | 0xaa,0xac,0xaa,0xbf,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0x90,
43 | 0x82,0x7d,0x97,0x59,0x59,0x59,0x59,0x59,0x7f,0x59,0x59,0x60,0x7d,0x7f,0x7f,
44 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x9a,0x88,0x7d,
45 | 0x59,0x50,0x50,0x50,0x50,0x59,0x59,0x59,0x59,0x61,0x94,0x61,0x9e,0x59,0x59,
46 | 0x85,0x59,0x92,0xa3,0x60,0x60,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,
47 | 0x59,0x59,0x9f,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xcc,0x01,0xbc,0x03,0xf0,
48 | 0x10,0x10,0x10,0x10,0x50,0x50,0x50,0x50,0x14,0x20,0x20,0x20,0x20,0x01,0x01,
49 | 0x01,0x01,0xc4,0x02,0x10,0x00,0x00,0x00,0x00,0x01,0x01,0xc0,0xc2,0x10,0x11,
50 | 0x02,0x03,0x11,0x03,0x03,0x04,0x00,0x00,0x14,0x00,0x02,0x00,0x00,0xc6,0xc8,
51 | 0x02,0x02,0x02,0x02,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xca,
52 | 0x01,0x01,0x01,0x00,0x06,0x00,0x04,0x00,0xc0,0xc2,0x01,0x01,0x03,0x01,0xff,
53 | 0xff,0x01,0x00,0x03,0xc4,0xc4,0xc6,0x03,0x01,0x01,0x01,0xff,0x03,0x03,0x03,
54 | 0xc8,0x40,0x00,0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00,
55 | 0x00,0x00,0x00,0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,
56 | 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
57 | 0x00,0xff,0xff,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
58 | 0x7f,0x00,0x00,0xff,0x4a,0x4a,0x4a,0x4a,0x4b,0x52,0x4a,0x4a,0x4a,0x4a,0x4f,
59 | 0x4c,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x55,0x45,0x40,0x4a,0x4a,0x4a,
60 | 0x45,0x59,0x4d,0x46,0x4a,0x5d,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,
61 | 0x4a,0x4a,0x4a,0x4a,0x4a,0x61,0x63,0x67,0x4e,0x4a,0x4a,0x6b,0x6d,0x4a,0x4a,
62 | 0x45,0x6d,0x4a,0x4a,0x44,0x45,0x4a,0x4a,0x00,0x00,0x00,0x02,0x0d,0x06,0x06,
63 | 0x06,0x06,0x0e,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x00,0x06,0x06,0x02,0x06,
64 | 0x00,0x0a,0x0a,0x07,0x07,0x06,0x02,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04,
65 | 0x04,0x04,0x00,0x00,0x00,0x0e,0x05,0x06,0x06,0x06,0x01,0x06,0x00,0x00,0x08,
66 | 0x00,0x10,0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01,
67 | 0x86,0x00,0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba,
68 | 0xf8,0xbb,0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00,
69 | 0xc4,0xff,0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00,
70 | 0x13,0x09,0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07,
71 | 0xb2,0xff,0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,
72 | 0xe7,0x08,0x00,0xf0,0x02,0x00
73 | };
74 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/hde/table64.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Hacker Disassembler Engine 64 C
3 | * Copyright (c) 2008-2009, Vyacheslav Patkov.
4 | * All rights reserved.
5 | *
6 | */
7 |
8 | #define C_NONE 0x00
9 | #define C_MODRM 0x01
10 | #define C_IMM8 0x02
11 | #define C_IMM16 0x04
12 | #define C_IMM_P66 0x10
13 | #define C_REL8 0x20
14 | #define C_REL32 0x40
15 | #define C_GROUP 0x80
16 | #define C_ERROR 0xff
17 |
18 | #define PRE_ANY 0x00
19 | #define PRE_NONE 0x01
20 | #define PRE_F2 0x02
21 | #define PRE_F3 0x04
22 | #define PRE_66 0x08
23 | #define PRE_67 0x10
24 | #define PRE_LOCK 0x20
25 | #define PRE_SEG 0x40
26 | #define PRE_ALL 0xff
27 |
28 | #define DELTA_OPCODES 0x4a
29 | #define DELTA_FPU_REG 0xfd
30 | #define DELTA_FPU_MODRM 0x104
31 | #define DELTA_PREFIXES 0x13c
32 | #define DELTA_OP_LOCK_OK 0x1ae
33 | #define DELTA_OP2_LOCK_OK 0x1c6
34 | #define DELTA_OP_ONLY_MEM 0x1d8
35 | #define DELTA_OP2_ONLY_MEM 0x1e7
36 |
37 | unsigned char hde64_table[] = {
38 | 0xa5,0xaa,0xa5,0xb8,0xa5,0xaa,0xa5,0xaa,0xa5,0xb8,0xa5,0xb8,0xa5,0xb8,0xa5,
39 | 0xb8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xac,0xc0,0xcc,0xc0,0xa1,0xa1,
40 | 0xa1,0xa1,0xb1,0xa5,0xa5,0xa6,0xc0,0xc0,0xd7,0xda,0xe0,0xc0,0xe4,0xc0,0xea,
41 | 0xea,0xe0,0xe0,0x98,0xc8,0xee,0xf1,0xa5,0xd3,0xa5,0xa5,0xa1,0xea,0x9e,0xc0,
42 | 0xc0,0xc2,0xc0,0xe6,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0xab,
43 | 0x8b,0x90,0x64,0x5b,0x5b,0x5b,0x5b,0x5b,0x92,0x5b,0x5b,0x76,0x90,0x92,0x92,
44 | 0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x6a,0x73,0x90,
45 | 0x5b,0x52,0x52,0x52,0x52,0x5b,0x5b,0x5b,0x5b,0x77,0x7c,0x77,0x85,0x5b,0x5b,
46 | 0x70,0x5b,0x7a,0xaf,0x76,0x76,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,
47 | 0x5b,0x5b,0x86,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xd5,0x03,0xcc,0x01,0xbc,
48 | 0x03,0xf0,0x03,0x03,0x04,0x00,0x50,0x50,0x50,0x50,0xff,0x20,0x20,0x20,0x20,
49 | 0x01,0x01,0x01,0x01,0xc4,0x02,0x10,0xff,0xff,0xff,0x01,0x00,0x03,0x11,0xff,
50 | 0x03,0xc4,0xc6,0xc8,0x02,0x10,0x00,0xff,0xcc,0x01,0x01,0x01,0x00,0x00,0x00,
51 | 0x00,0x01,0x01,0x03,0x01,0xff,0xff,0xc0,0xc2,0x10,0x11,0x02,0x03,0x01,0x01,
52 | 0x01,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x10,
53 | 0x10,0x10,0x10,0x02,0x10,0x00,0x00,0xc6,0xc8,0x02,0x02,0x02,0x02,0x06,0x00,
54 | 0x04,0x00,0x02,0xff,0x00,0xc0,0xc2,0x01,0x01,0x03,0x03,0x03,0xca,0x40,0x00,
55 | 0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00,0x00,0x00,0x00,
56 | 0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xff,0x00,
57 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
58 | 0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,
59 | 0xff,0x40,0x40,0x40,0x40,0x41,0x49,0x40,0x40,0x40,0x40,0x4c,0x42,0x40,0x40,
60 | 0x40,0x40,0x40,0x40,0x40,0x40,0x4f,0x44,0x53,0x40,0x40,0x40,0x44,0x57,0x43,
61 | 0x5c,0x40,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
62 | 0x40,0x40,0x64,0x66,0x6e,0x6b,0x40,0x40,0x6a,0x46,0x40,0x40,0x44,0x46,0x40,
63 | 0x40,0x5b,0x44,0x40,0x40,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x01,0x06,
64 | 0x06,0x02,0x06,0x06,0x00,0x06,0x00,0x0a,0x0a,0x00,0x00,0x00,0x02,0x07,0x07,
65 | 0x06,0x02,0x0d,0x06,0x06,0x06,0x0e,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04,
66 | 0x04,0x04,0x05,0x06,0x06,0x06,0x00,0x00,0x00,0x0e,0x00,0x00,0x08,0x00,0x10,
67 | 0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01,0x86,0x00,
68 | 0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba,0xf8,0xbb,
69 | 0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00,0xc4,0xff,
70 | 0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00,0x13,0x09,
71 | 0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07,0xb2,0xff,
72 | 0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,0xe7,0x08,
73 | 0x00,0xf0,0x02,0x00
74 | };
75 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/trampoline.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * MinHook - The Minimalistic API Hooking Library for x64/x86
3 | * Copyright (C) 2009-2017 Tsuda Kageyu.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #include
30 |
31 | #ifdef _MSC_VER
32 | #include
33 | #endif
34 |
35 | #ifndef ARRAYSIZE
36 | #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
37 | #endif
38 |
39 | #if defined(_M_X64) || defined(__x86_64__)
40 | #include "./hde/hde64.h"
41 | typedef hde64s HDE;
42 | #define HDE_DISASM(code, hs) hde64_disasm(code, hs)
43 | #else
44 | #include "./hde/hde32.h"
45 | typedef hde32s HDE;
46 | #define HDE_DISASM(code, hs) hde32_disasm(code, hs)
47 | #endif
48 |
49 | #include "trampoline.h"
50 | #include "buffer.h"
51 |
52 | //-------------------------------------------------------------------------
53 | static BOOL IsCodePadding(LPBYTE pInst, UINT size)
54 | {
55 | UINT i;
56 |
57 | if (pInst[0] != 0x00 && pInst[0] != 0x90 && pInst[0] != 0xCC)
58 | return FALSE;
59 |
60 | for (i = 1; i < size; ++i)
61 | {
62 | if (pInst[i] != pInst[0])
63 | return FALSE;
64 | }
65 | return TRUE;
66 | }
67 |
68 | //-------------------------------------------------------------------------
69 | VOID CreateRelayFunction(PJMP_RELAY pJmpRelay, LPVOID pDetour)
70 | {
71 | #if defined(_M_X64) || defined(__x86_64__)
72 | JMP_ABS jmp = {
73 | 0xFF, 0x25, 0x00000000, // FF25 00000000: JMP [RIP+6]
74 | 0x0000000000000000ULL // Absolute destination address
75 | };
76 |
77 | jmp.address = (ULONG_PTR)pDetour;
78 | #else
79 | JMP_REL jmp = {
80 | 0xE9, // E9 xxxxxxxx: JMP +5+xxxxxxxx
81 | 0x00000000 // Relative destination address
82 | };
83 |
84 | jmp.operand = (UINT32)((LPBYTE)pDetour - ((LPBYTE)pJmpRelay + sizeof(jmp)));
85 | #endif
86 |
87 | memcpy(pJmpRelay, &jmp, sizeof(jmp));
88 | }
89 |
90 | //-------------------------------------------------------------------------
91 | BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
92 | {
93 | #if defined(_M_X64) || defined(__x86_64__)
94 | CALL_ABS call = {
95 | 0xFF, 0x15, 0x00000002, // FF15 00000002: CALL [RIP+8]
96 | 0xEB, 0x08, // EB 08: JMP +10
97 | 0x0000000000000000ULL // Absolute destination address
98 | };
99 | JMP_ABS jmp = {
100 | 0xFF, 0x25, 0x00000000, // FF25 00000000: JMP [RIP+6]
101 | 0x0000000000000000ULL // Absolute destination address
102 | };
103 | JCC_ABS jcc = {
104 | 0x70, 0x0E, // 7* 0E: J** +16
105 | 0xFF, 0x25, 0x00000000, // FF25 00000000: JMP [RIP+6]
106 | 0x0000000000000000ULL // Absolute destination address
107 | };
108 | #else
109 | CALL_REL call = {
110 | 0xE8, // E8 xxxxxxxx: CALL +5+xxxxxxxx
111 | 0x00000000 // Relative destination address
112 | };
113 | JMP_REL jmp = {
114 | 0xE9, // E9 xxxxxxxx: JMP +5+xxxxxxxx
115 | 0x00000000 // Relative destination address
116 | };
117 | JCC_REL jcc = {
118 | 0x0F, 0x80, // 0F8* xxxxxxxx: J** +6+xxxxxxxx
119 | 0x00000000 // Relative destination address
120 | };
121 | #endif
122 |
123 | UINT8 oldPos = 0;
124 | UINT8 newPos = 0;
125 | ULONG_PTR jmpDest = 0; // Destination address of an internal jump.
126 | BOOL finished = FALSE; // Is the function completed?
127 | #if defined(_M_X64) || defined(__x86_64__)
128 | UINT8 instBuf[16];
129 | #endif
130 |
131 | ct->patchAbove = FALSE;
132 | ct->nIP = 0;
133 |
134 | do
135 | {
136 | HDE hs;
137 | UINT copySize;
138 | LPVOID pCopySrc;
139 | ULONG_PTR pOldInst = (ULONG_PTR)ct->pTarget + oldPos;
140 | ULONG_PTR pNewInst = (ULONG_PTR)ct->pTrampoline + newPos;
141 |
142 | copySize = HDE_DISASM((LPVOID)pOldInst, &hs);
143 | if (hs.flags & F_ERROR)
144 | return FALSE;
145 |
146 | pCopySrc = (LPVOID)pOldInst;
147 | if (oldPos >= sizeof(JMP_REL))
148 | {
149 | // The trampoline function is long enough.
150 | // Complete the function with the jump to the target function.
151 | #if defined(_M_X64) || defined(__x86_64__)
152 | jmp.address = pOldInst;
153 | #else
154 | jmp.operand = (UINT32)(pOldInst - (pNewInst + sizeof(jmp)));
155 | #endif
156 | pCopySrc = &jmp;
157 | copySize = sizeof(jmp);
158 |
159 | finished = TRUE;
160 | }
161 | #if defined(_M_X64) || defined(__x86_64__)
162 | else if ((hs.modrm & 0xC7) == 0x05)
163 | {
164 | // Instructions using RIP relative addressing. (ModR/M = 00???101B)
165 |
166 | // Modify the RIP relative address.
167 | PUINT32 pRelAddr;
168 |
169 | // Avoid using memcpy to reduce the footprint.
170 | #ifndef _MSC_VER
171 | memcpy(instBuf, (LPBYTE)pOldInst, copySize);
172 | #else
173 | __movsb(instBuf, (LPBYTE)pOldInst, copySize);
174 | #endif
175 | pCopySrc = instBuf;
176 |
177 | // Relative address is stored at (instruction length - immediate value length - 4).
178 | pRelAddr = (PUINT32)(instBuf + hs.len - ((hs.flags & 0x3C) >> 2) - 4);
179 | *pRelAddr
180 | = (UINT32)((pOldInst + hs.len + (INT32)hs.disp.disp32) - (pNewInst + hs.len));
181 |
182 | // Complete the function if JMP (FF /4).
183 | if (hs.opcode == 0xFF && hs.modrm_reg == 4)
184 | finished = TRUE;
185 | }
186 | #endif
187 | else if (hs.opcode == 0xE8)
188 | {
189 | // Direct relative CALL
190 | ULONG_PTR dest = pOldInst + hs.len + (INT32)hs.imm.imm32;
191 | #if defined(_M_X64) || defined(__x86_64__)
192 | call.address = dest;
193 | #else
194 | call.operand = (UINT32)(dest - (pNewInst + sizeof(call)));
195 | #endif
196 | pCopySrc = &call;
197 | copySize = sizeof(call);
198 | }
199 | else if ((hs.opcode & 0xFD) == 0xE9)
200 | {
201 | // Direct relative JMP (EB or E9)
202 | ULONG_PTR dest = pOldInst + hs.len;
203 |
204 | if (hs.opcode == 0xEB) // isShort jmp
205 | dest += (INT8)hs.imm.imm8;
206 | else
207 | dest += (INT32)hs.imm.imm32;
208 |
209 | // Simply copy an internal jump.
210 | if ((ULONG_PTR)ct->pTarget <= dest
211 | && dest < ((ULONG_PTR)ct->pTarget + sizeof(JMP_REL)))
212 | {
213 | if (jmpDest < dest)
214 | jmpDest = dest;
215 | }
216 | else
217 | {
218 | #if defined(_M_X64) || defined(__x86_64__)
219 | jmp.address = dest;
220 | #else
221 | jmp.operand = (UINT32)(dest - (pNewInst + sizeof(jmp)));
222 | #endif
223 | pCopySrc = &jmp;
224 | copySize = sizeof(jmp);
225 |
226 | // Exit the function if it is not in the branch.
227 | finished = (pOldInst >= jmpDest);
228 | }
229 | }
230 | else if ((hs.opcode & 0xF0) == 0x70
231 | || (hs.opcode & 0xFC) == 0xE0
232 | || (hs.opcode2 & 0xF0) == 0x80)
233 | {
234 | // Direct relative Jcc
235 | ULONG_PTR dest = pOldInst + hs.len;
236 |
237 | if ((hs.opcode & 0xF0) == 0x70 // Jcc
238 | || (hs.opcode & 0xFC) == 0xE0) // LOOPNZ/LOOPZ/LOOP/JECXZ
239 | dest += (INT8)hs.imm.imm8;
240 | else
241 | dest += (INT32)hs.imm.imm32;
242 |
243 | // Simply copy an internal jump.
244 | if ((ULONG_PTR)ct->pTarget <= dest
245 | && dest < ((ULONG_PTR)ct->pTarget + sizeof(JMP_REL)))
246 | {
247 | if (jmpDest < dest)
248 | jmpDest = dest;
249 | }
250 | else if ((hs.opcode & 0xFC) == 0xE0)
251 | {
252 | // LOOPNZ/LOOPZ/LOOP/JCXZ/JECXZ to the outside are not supported.
253 | return FALSE;
254 | }
255 | else
256 | {
257 | UINT8 cond = ((hs.opcode != 0x0F ? hs.opcode : hs.opcode2) & 0x0F);
258 | #if defined(_M_X64) || defined(__x86_64__)
259 | // Invert the condition in x64 mode to simplify the conditional jump logic.
260 | jcc.opcode = 0x71 ^ cond;
261 | jcc.address = dest;
262 | #else
263 | jcc.opcode1 = 0x80 | cond;
264 | jcc.operand = (UINT32)(dest - (pNewInst + sizeof(jcc)));
265 | #endif
266 | pCopySrc = &jcc;
267 | copySize = sizeof(jcc);
268 | }
269 | }
270 | else if ((hs.opcode & 0xFE) == 0xC2)
271 | {
272 | // RET (C2 or C3)
273 |
274 | // Complete the function if not in a branch.
275 | finished = (pOldInst >= jmpDest);
276 | }
277 |
278 | // Can't alter the instruction length in a branch.
279 | if (pOldInst < jmpDest && copySize != hs.len)
280 | return FALSE;
281 |
282 | // Trampoline function is too large.
283 | if ((newPos + copySize) > ct->trampolineSize)
284 | return FALSE;
285 |
286 | // Trampoline function has too many instructions.
287 | if (ct->nIP >= ARRAYSIZE(ct->oldIPs))
288 | return FALSE;
289 |
290 | ct->oldIPs[ct->nIP] = oldPos;
291 | ct->newIPs[ct->nIP] = newPos;
292 | ct->nIP++;
293 |
294 | // Avoid using memcpy to reduce the footprint.
295 | #ifndef _MSC_VER
296 | memcpy((LPBYTE)ct->pTrampoline + newPos, pCopySrc, copySize);
297 | #else
298 | __movsb((LPBYTE)ct->pTrampoline + newPos, (LPBYTE)pCopySrc, copySize);
299 | #endif
300 | newPos += copySize;
301 | oldPos += hs.len;
302 | }
303 | while (!finished);
304 |
305 | // Is there enough place for a long jump?
306 | if (oldPos < sizeof(JMP_REL)
307 | && !IsCodePadding((LPBYTE)ct->pTarget + oldPos, sizeof(JMP_REL) - oldPos))
308 | {
309 | // Is there enough place for a short jump?
310 | if (oldPos < sizeof(JMP_REL_SHORT)
311 | && !IsCodePadding((LPBYTE)ct->pTarget + oldPos, sizeof(JMP_REL_SHORT) - oldPos))
312 | {
313 | return FALSE;
314 | }
315 |
316 | // Can we place the long jump above the function?
317 | if (!IsExecutableAddress((LPBYTE)ct->pTarget - sizeof(JMP_REL)))
318 | return FALSE;
319 |
320 | if (!IsCodePadding((LPBYTE)ct->pTarget - sizeof(JMP_REL), sizeof(JMP_REL)))
321 | return FALSE;
322 |
323 | ct->patchAbove = TRUE;
324 | }
325 |
326 | return TRUE;
327 | }
328 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/minhook/trampoline.h:
--------------------------------------------------------------------------------
1 | /*
2 | * MinHook - The Minimalistic API Hooking Library for x64/x86
3 | * Copyright (C) 2009-2017 Tsuda Kageyu.
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
20 | * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 | */
28 |
29 | #pragma once
30 |
31 | #pragma pack(push, 1)
32 |
33 | // Structs for writing x86/x64 instructions.
34 |
35 | // 8-bit relative jump.
36 | typedef struct _JMP_REL_SHORT
37 | {
38 | UINT8 opcode; // EB xx: JMP +2+xx
39 | UINT8 operand; // Relative destination address
40 | } JMP_REL_SHORT, *PJMP_REL_SHORT;
41 |
42 | // 32-bit direct relative jump/call.
43 | typedef struct _JMP_REL
44 | {
45 | UINT8 opcode; // E9/E8 xxxxxxxx: JMP/CALL +5+xxxxxxxx
46 | UINT32 operand; // Relative destination address
47 | } JMP_REL, *PJMP_REL, CALL_REL;
48 |
49 | // 64-bit indirect absolute jump.
50 | typedef struct _JMP_ABS
51 | {
52 | UINT8 opcode0; // FF25 00000000: JMP [+6]
53 | UINT8 opcode1;
54 | UINT32 dummy;
55 | UINT64 address; // Absolute destination address
56 | } JMP_ABS, *PJMP_ABS;
57 |
58 | // 64-bit indirect absolute call.
59 | typedef struct _CALL_ABS
60 | {
61 | UINT8 opcode0; // FF15 00000002: CALL [+6]
62 | UINT8 opcode1;
63 | UINT32 dummy0;
64 | UINT8 dummy1; // EB 08: JMP +10
65 | UINT8 dummy2;
66 | UINT64 address; // Absolute destination address
67 | } CALL_ABS;
68 |
69 | // 32-bit direct relative conditional jumps.
70 | typedef struct _JCC_REL
71 | {
72 | UINT8 opcode0; // 0F8* xxxxxxxx: J** +6+xxxxxxxx
73 | UINT8 opcode1;
74 | UINT32 operand; // Relative destination address
75 | } JCC_REL;
76 |
77 | // 64bit indirect absolute conditional jumps that x64 lacks.
78 | typedef struct _JCC_ABS
79 | {
80 | UINT8 opcode; // 7* 0E: J** +16
81 | UINT8 dummy0;
82 | UINT8 dummy1; // FF25 00000000: JMP [+6]
83 | UINT8 dummy2;
84 | UINT32 dummy3;
85 | UINT64 address; // Absolute destination address
86 | } JCC_ABS;
87 |
88 | #pragma pack(pop)
89 |
90 | #if defined(_M_X64) || defined(__x86_64__)
91 | typedef JMP_ABS JMP_RELAY;
92 | typedef PJMP_ABS PJMP_RELAY;
93 | #else
94 | typedef JMP_REL JMP_RELAY;
95 | typedef PJMP_REL PJMP_RELAY;
96 | #endif
97 |
98 | typedef struct _TRAMPOLINE
99 | {
100 | LPVOID pTarget; // [In] Address of the target function.
101 | LPVOID pTrampoline; // [In] Buffer address for the trampoline function.
102 | UINT trampolineSize; // [In] The size of the trampoline function buffer.
103 |
104 | BOOL patchAbove; // [Out] Should use the hot patch area?
105 | UINT nIP; // [Out] Number of the instruction boundaries.
106 | UINT8 oldIPs[8]; // [Out] Instruction boundaries of the target function.
107 | UINT8 newIPs[8]; // [Out] Instruction boundaries of the trampoline function.
108 | } TRAMPOLINE, *PTRAMPOLINE;
109 |
110 | VOID CreateRelayFunction(PJMP_RELAY pJmpRelay, LPVOID pDetour);
111 | BOOL CreateTrampolineFunction(PTRAMPOLINE ct);
112 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/module.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "framework.h"
3 |
4 | namespace MBox
5 | {
6 | // {887D3A6A-502E-4AF5-9CE6-D515E12AFE89}
7 | static constexpr CLSID CLSID_FolderExtension = { 0x887d3a6a, 0x502e, 0x4af5, { 0x9c, 0xe6, 0xd5, 0x15, 0xe1, 0x2a, 0xfe, 0x89 } };
8 | static constexpr auto CLSID_FolderExtension_STR = L"{887D3A6A-502E-4AF5-9CE6-D515E12AFE89}";
9 | static constexpr std::wstring_view regPath = LR"(SOFTWARE\Classes\Drive\shellex\FolderExtensions\{887D3A6A-502E-4AF5-9CE6-D515E12AFE89})";
10 |
11 | BOOL OnDllMain(HMODULE hModule, DWORD ul_reason_for_call);
12 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ExplorerBlurMica/resource.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/ExplorerBlurMica/resource.h
--------------------------------------------------------------------------------
/ExplorerBlurMica/tapsite.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: tapsite.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "framework.h"
20 | #include "Helper/comdef.h"
21 | #include "Helper/WinRTHelper.h"
22 | #include "visualtreewatcher.h"
23 |
24 | namespace MBox
25 | {
26 | // {233A5395-98B8-40C9-8DEE-1BD9158B34CA}
27 | constexpr CLSID CLSID_TAPSite =
28 | { 0x233a5395, 0x98b8, 0x40c9, { 0x8d, 0xee, 0x1b, 0xd9, 0x15, 0x8b, 0x34, 0xca } };
29 |
30 | struct TAPSite : implements
31 | {
32 | public:
33 | HRESULT STDMETHODCALLTYPE SetSite(IUnknown* pUnkSite) override;
34 | HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void** ppvSite) noexcept override;
35 | static HRESULT ShutdownVisualTreeWatcher();
36 | private:
37 | static com_ptr s_VisualTreeWatcher;
38 |
39 | com_ptr m_site = nullptr;
40 | };
41 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/visualtreewatcher.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: visualtreewatcher.h
3 | *
4 | * Copyright (C) 2022-2024 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "framework.h"
20 | #include "Helper/comdef.h"
21 | #include "Helper/WinRTHelper.h"
22 |
23 | namespace MBox
24 | {
25 | struct VisualTreeWatcher : implements
26 | {
27 | public:
28 | VisualTreeWatcher(com_ptr site);
29 | VisualTreeWatcher(const VisualTreeWatcher&) = delete;
30 | VisualTreeWatcher& operator=(const VisualTreeWatcher&) = delete;
31 | VisualTreeWatcher(VisualTreeWatcher&&) = delete;
32 | VisualTreeWatcher& operator=(VisualTreeWatcher&&) = delete;
33 | ~VisualTreeWatcher();
34 |
35 | template
36 | auto FromHandle(InstanceHandle handle)
37 | {
38 | com_ptr<::IInspectable> obj = nullptr;
39 | m_xamlDiagnostics->GetIInspectableFromHandle(
40 | handle, obj.put()
41 | );
42 | return obj.as();
43 | }
44 | template
45 | auto FromIInspectable(com_ptr obj)
46 | {
47 | InstanceHandle handle = 0;
48 | check_hresult(
49 | m_xamlDiagnostics->GetHandleFromIInspectable(obj.get(), &handle)
50 | );
51 |
52 | return handle;
53 | }
54 | auto FromIInspectable(::IInspectable* obj)
55 | {
56 | InstanceHandle handle = 0;
57 | check_hresult(
58 | m_xamlDiagnostics->GetHandleFromIInspectable(obj, &handle)
59 | );
60 |
61 | return handle;
62 | }
63 | auto GetXamlDiagnostics() const { return m_xamlDiagnostics; }
64 |
65 | using PropertyCallback = std::function;
66 | using PropertySourceCallback = std::function;
67 | IFACEMETHODIMP WalkInstanceHandle(InstanceHandle handle, PropertyCallback propertyCallback, PropertySourceCallback sourceCallback = nullptr);
68 | private:
69 | HRESULT STDMETHODCALLTYPE OnVisualTreeChange(
70 | ParentChildRelation relation,
71 | VisualElement element,
72 | VisualMutationType mutationType
73 | ) override;
74 | HRESULT STDMETHODCALLTYPE OnElementStateChanged(
75 | InstanceHandle element,
76 | VisualElementState elementState,
77 | LPCWSTR context
78 | ) noexcept override;
79 |
80 | com_ptr m_xamlDiagnostics = nullptr;
81 | };
82 | }
--------------------------------------------------------------------------------
/ExplorerBlurMica/xamldiagnostics.h:
--------------------------------------------------------------------------------
1 | /**
2 | * FileName: xamldiagnostics.h
3 | *
4 | * Copyright (C) 2022-2023 Maplespe、ALTaleX
5 | *
6 | * This file is part of MToolBox and ExplorerBlurMica.
7 | * ExplorerBlurMica is free software: you can redistribute it and/or modify it under the terms of the
8 | * GNU Lesser General Public License as published by the Free Software Foundation, either version 3
9 | * of the License, or any later version.
10 | *
11 | * ExplorerBlurMica is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 | * See the GNU Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public License along with Foobar.
16 | * If not, see .
17 | */
18 | #pragma once
19 | #include "tapsite.h"
20 |
21 | namespace MBox
22 | {
23 | HRESULT InitializeUWPXamlDiagnostics();
24 | HRESULT InitializeWinUIXamlDiagnostics();
25 |
26 | void EnableXamlDiagnostics(bool uwp);
27 | void FreeXamlDiagnostics();
28 |
29 | void RunDiagnostics(bool uwp);
30 |
31 | bool ProcessIsWinUI();
32 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ExplorerBlurMica
2 | Add background Blur effect or Acrylic or Mica effect to explorer for win10 and win11
3 |
4 | 给文件资源管理器添加背景模糊效果或Acrylic、Mica效果 适用于win10和win11
5 | #
6 | | [中文](/README_ZH.md) | [English](/README.md) | [Türkçe](/README_TR.md)
7 | This project uses [LGNU V3 license](/COPYING.LESSER).
8 |
9 | [](https://www.gnu.org/licenses/lgpl-3.0.en.html)
10 | [](https://github.com/Maplespe/ExplorerBlurMica/releases)
11 | [](https://github.com/Maplespe/ExplorerBlurMica/releases/latest)
12 |
13 |
14 |
15 | ## Effects
16 | * Blur or Acrylic, Mica effects are available.
17 | * Custom blend colors are available.
18 | * Light/Dark Mode Adaptive.
19 |
20 | This project is for Explorer only, if you want to apply the effect globally, take a look at our other project [DWMBlurGlass](https://github.com/Maplespe/DWMBlurGlass).
21 |
22 | ## Compatibility
23 | Compatible with StartAllBack, OldNewExplorer and other software that modifies window styles.
24 |
25 | It is also compatible with third-party themes.
26 |
27 | ## Catalog
28 | - [Overview](#overview)
29 | - [How to use](#how-to-use)
30 | - [Config](#config)
31 | - [Other](#other)
32 |
33 | ## Overview
34 | Windows 11
35 |
36 | 23H2 WinUI3
37 | ```ini
38 | [config]
39 | effect=1
40 | clearBarBg=true
41 | clearAddress=true
42 | clearWinUIBg=true
43 | [light]
44 | r=255
45 | g=255
46 | b=255
47 | a=200
48 | ....
49 | ```
50 | 
51 |
52 | Dark Mode
53 | ```ini
54 | [config]
55 | effect=2
56 | clearBarBg=true
57 | clearAddress=true
58 | clearWinUIBg=true
59 | ```
60 | 
61 |
62 | 22H2 XamlIslands
63 | ```ini
64 | [config]
65 | effect=1
66 | clearBarBg=true
67 | clearAddress=true
68 | clearWinUIBg=true
69 | [light]
70 | r=255
71 | g=255
72 | b=255
73 | a=200
74 | ....
75 | ```
76 | 
77 |
78 | ```ini
79 | [config]
80 | effect=1
81 | clearBarBg=true
82 | clearAddress=true
83 | clearWinUIBg=false
84 | [light]
85 | r=255
86 | g=255
87 | b=255
88 | a=200
89 | ....
90 | ```
91 | 
92 |
93 |
94 |
95 | Windows 10
96 |
97 | ```ini
98 | [config]
99 | effect=1
100 | clearBarBg=true
101 | clearAddress=true
102 | clearWinUIBg=false
103 | [light]
104 | r=222
105 | g=222
106 | b=222
107 | a=200
108 | ```
109 | 
110 |
111 |
112 |
113 | ## How to use
114 |
115 | ### Install
116 | 1. Download the compiled program archive from the [Release](https://github.com/Maplespe/ExplorerBlurMica/releases) page.
117 | 2. Unzip it to a location such as "`C:\Program Files`".
118 | 3. Run "`register.cmd`" as administrator.
119 | 4. Reopen the Explorer window to take effect.
120 |
121 | cmd: `regsvr32 "you path/ExplorerBlurMica.dll"`
122 |
123 | ### Uninstall
124 | 1. Run "`uninstall.cmd`" as administrator.
125 | 2. Delete the remaining files.
126 |
127 | cmd: `regsvr32 /u "you path/ExplorerBlurMica.dll"`
128 |
129 | #
130 | Note: If something happens that crashes Explorer, press and hold the `ESC` key to open Explorer and uninstall the program.
131 |
132 | ## Config
133 | ``` ini
134 | [config]
135 | #Effect type 0=Blur 1=Acrylic 2=Mica 3=Blur(Clear) 4=MicaAlt
136 | #Blur is only available until win11 22h2, Blur (Clear) is available in both win10 and win11, Mica is win11 only.
137 | effect=1
138 | #Clear the background of the address bar.
139 | clearAddress=true
140 | #Clear the background color of the scrollbar.
141 | #(Note: Since the system scrollbar itself has a background color that cannot be removed,
142 | # when this option is turned on, the scrollbar is drawn by the program and the style may be different from the system).
143 | clearBarBg=true
144 | #Remove the toolbar background color from the WinUI or XamlIslands section of Windows 11.
145 | clearWinUIBg=true
146 | #Show split line between TreeView and DUIView.
147 | showLine=true
148 | [light]
149 | #The system color scheme is the color in Light mode.
150 | #RGBA component of background blend color
151 | r=220
152 | g=220
153 | b=220
154 | a=160
155 | [dark]
156 | #The system color scheme is the color in Dark mode.
157 | r=0
158 | g=0
159 | b=0
160 | a=120
161 | ```
162 |
163 | Save the configuration after modification and reopen the File Explorer window to take effect.
164 |
165 | ## Other
166 | The GUI running on Python.
167 | Dependent on [minhook](https://github.com/m417z/minhook) and [customtkinter](https://github.com/TomSchimansky/CustomTkinter).
168 |
169 | This project is an independent component based on the code in the [MToolBox](https://winmoes.com/tools/12948.html).
170 |
--------------------------------------------------------------------------------
/README_TR.md:
--------------------------------------------------------------------------------
1 | # ExplorerBlurMica
2 | Windows 10 ve 11 için Dosya Gezginine Bulanık, Akrilik veya Mika arka plan efekti ekleyin
3 |
4 | 给文件资源管理器添加背景模糊效果或Acrylic、Mica效果 适用于win10和win11
5 | #
6 | | [中文](/README_ZH.md) | [English](/README.md) | [Türkçe](/README_TR.md)
7 | Bu proje [LGNU V3 lisansı](/COPYING.LESSER) kullanmaktadır.
8 |
9 | [](https://www.gnu.org/licenses/lgpl-3.0.en.html)
10 | [](https://github.com/Maplespe/ExplorerBlurMica/releases)
11 | [](https://github.com/Maplespe/ExplorerBlurMica/releases/latest)
12 |
13 |
14 |
15 | ## Efektler
16 | * Bulanık, Akrilik ve Mika efektleri mevcuttur.
17 | * Özel karışım renkleri mevcuttur.
18 | * Açık/Koyu mod ile uyumlu.
19 |
20 | Bu proje sadece Dosya Gezgini içindir. Eğer efekti küresel olarak uygulamak isterseniz diğer projemiz olan [DWMBlurGlass](https://github.com/Maplespe/DWMBlurGlass)'a bir göz atın.
21 |
22 | ## Uyumluluk
23 | StartAllBack, OldNewExplorer ve diğer pencere stillerini düzenleyen yazılımlarla uyumludur.
24 |
25 | Ayrıca üçüncü parti temalarla da uyumludur.
26 |
27 | ## Katalog
28 | - [Genel bakış](#overview)
29 | - [Nasıl kullanılır](#how-to-use)
30 | - [Yapılandırma](#config)
31 | - [Diğer](#other)
32 |
33 | ## Genel bakış
34 | Windows 11
35 |
36 | 23H2 WinUI3
37 | ```ini
38 | [config]
39 | effect=1
40 | clearBarBg=true
41 | clearAddress=true
42 | clearWinUIBg=true
43 | [light]
44 | r=255
45 | g=255
46 | b=255
47 | a=200
48 | ....
49 | ```
50 | 
51 |
52 | Koyu Mod
53 | ```ini
54 | [config]
55 | effect=2
56 | clearBarBg=true
57 | clearAddress=true
58 | clearWinUIBg=true
59 | ```
60 | 
61 |
62 | 22H2 XamlIslands
63 | ```ini
64 | [config]
65 | effect=1
66 | clearBarBg=true
67 | clearAddress=true
68 | clearWinUIBg=true
69 | [light]
70 | r=255
71 | g=255
72 | b=255
73 | a=200
74 | ....
75 | ```
76 | 
77 |
78 | ```ini
79 | [config]
80 | effect=1
81 | clearBarBg=true
82 | clearAddress=true
83 | clearWinUIBg=false
84 | [light]
85 | r=255
86 | g=255
87 | b=255
88 | a=200
89 | ....
90 | ```
91 | 
92 |
93 |
94 |
95 | Windows 10
96 |
97 | ```ini
98 | [config]
99 | effect=1
100 | clearBarBg=true
101 | clearAddress=true
102 | clearWinUIBg=false
103 | [light]
104 | r=222
105 | g=222
106 | b=222
107 | a=200
108 | ```
109 | 
110 |
111 |
112 |
113 | ## Nasıl kullanılır
114 |
115 | ### Yükle
116 | 1. Derlenmiş program arşivini [Yayın](https://github.com/Maplespe/ExplorerBlurMica/releases) sayfasından indirin.
117 | 2. "`C:\Program Files`" gibi bir dizinde arşivden çıkarın.
118 | 3. "`register.cmd`" dosyasını yönetici olarak çalıştırın.
119 | 4. Efektler için Dosya Gezgini penceresini yeniden açın.
120 |
121 | Komut İstemi komutu: `regsvr32 "dizininiz/ExplorerBlurMica.dll"`
122 |
123 | ### Kaldır
124 | 1. "`uninstall.cmd`" dosyasını yönetici olarak çalıştırın.
125 | 2. Geri kalan dosyaları silin.
126 |
127 | Komut İstemi komutu: `regsvr32 /u "dizininiz/ExplorerBlurMica.dll"`
128 |
129 | #
130 | Not: Eğer Dosya Gezginini çökerten bir şey olursa, Dosya Gezginini açmak ve programı kaldırmak için `ESC` tuşunu basılı tutun.
131 |
132 | ## Yapılandırma
133 | ``` ini
134 | [config]
135 | #Etki türü 0=Bulanık 1=Akrilik 2=Mika 3=Bulanık(Açık) 4=MikaAlt
136 | #Bulanık efekti yalnızca Windows 11 22H2'ye kadar mevcuttur. Bulanık (Açık) hem Windows 10 hem de Windows 11'de
137 | #mevcuttur. Mika yalnızca Windows 11'de mevcuttur.
138 | effect=1
139 | #Adres çubuğunun arka planını kaldır.
140 | clearAddress=true
141 | #Kaydırma çubuğunun arka planını kaldır.
142 | #(Not: Sistem kaydırma çubuğunun kendi kaldırılamayan bir arka plan rengine sahip olduğundan,
143 | # bu seçenek açıldığında, kaydırma çubuğu program tarafından çizilir ve stil sistemden farklı olabilir).
144 | clearBarBg=true
145 | #Araç çubuğu arka plan rengini Windows 11'in WinUI veya XamlIslands bölümünden kaldır.
146 | clearWinUIBg=true
147 | #TreeView ve DUIView arasında bölünmüş çizgiyi göster.
148 | showLine=true
149 | [light]
150 | #Sistem renk düzeni Açık moddaki renktir.
151 | #Arka plan karışım renginin #RGBA bileşeni
152 | r=220
153 | g=220
154 | b=220
155 | a=160
156 | [dark]
157 | #Sistem renk düzeni Koyu moddaki renktir.
158 | r=0
159 | g=0
160 | b=0
161 | a=120
162 | ```
163 |
164 | Değişiklikten sonra yapılandırmayı kaydedin ve etkili olması için Dosya Gezgini penceresini yeniden açın.
165 |
166 | ## Diğer
167 | Grafik kullanıcı arayüzü Python'da çalışmaktadır.
168 | [minhook](https://github.com/m417z/minhook) ve [customtkinter](https://github.com/TomSchimansky/CustomTkinter) öğelerine bağlıdır.
169 |
170 | Bu proje [MToolBox](https://winmoes.com/tools/12948.html) içindeki kodu temel alan bağımsız bir bileşendir.
171 |
--------------------------------------------------------------------------------
/README_ZH.md:
--------------------------------------------------------------------------------
1 | # ExplorerBlurMica
2 | Add background Blur effect or Acrylic or Mica effect to explorer for win10 and win11
3 |
4 | 给文件资源管理器添加背景模糊效果或Acrylic、Mica效果 适用于win10和win11
5 | #
6 | | [中文](/README_ZH.md) | [English](/README.md) |
7 | 本项目使用 [LGNU V3 license](/COPYING.LESSER).
8 |
9 | [](https://www.gnu.org/licenses/lgpl-3.0.en.html)
10 | [](https://github.com/Maplespe/ExplorerBlurMica/releases)
11 | [](https://github.com/Maplespe/ExplorerBlurMica/releases/latest)
12 |
13 |
14 |
15 | ## 效果
16 | * 可选Blur、Acrylic或者Mica效果
17 | * 可自定义混合颜色
18 | * 亮/暗 颜色模式自适应
19 |
20 | 此项目仅针对Explorer,如果您想将效果应用到全局,请看看我们的另一个项目[DWMBlurGlass](https://github.com/Maplespe/DWMBlurGlass).
21 |
22 | ## 兼容性
23 | 与 StartAllBack、OldNewExplorer等修改窗口样式的软件兼容.
24 |
25 | 也与第三方主题兼容
26 |
27 | ## 目录
28 | - [预览](#预览)
29 | - [如何使用](#如何使用)
30 | - [配置文件](#配置文件)
31 | - [其他](#其他)
32 |
33 | ## 预览
34 | Windows 11
35 |
36 | 23H2 WinUI3
37 | ```ini
38 | [config]
39 | effect=1
40 | clearBarBg=true
41 | clearAddress=true
42 | clearWinUIBg=true
43 | [light]
44 | r=255
45 | g=255
46 | b=255
47 | a=200
48 | ....
49 | ```
50 | 
51 |
52 | Dark Mode
53 | ```ini
54 | [config]
55 | effect=2
56 | clearBarBg=true
57 | clearAddress=true
58 | clearWinUIBg=true
59 | ```
60 | 
61 |
62 | 22H2 XamlIslands
63 | ```ini
64 | [config]
65 | effect=1
66 | clearBarBg=true
67 | clearAddress=true
68 | clearWinUIBg=true
69 | [light]
70 | r=255
71 | g=255
72 | b=255
73 | a=200
74 | ....
75 | ```
76 | 
77 |
78 | ```ini
79 | [config]
80 | effect=1
81 | clearBarBg=true
82 | clearAddress=true
83 | clearWinUIBg=false
84 | [light]
85 | r=255
86 | g=255
87 | b=255
88 | a=200
89 | ....
90 | ```
91 | 
92 |
93 |
94 |
95 | Windows 10
96 |
97 | ```ini
98 | [config]
99 | effect=1
100 | clearBarBg=true
101 | clearAddress=true
102 | clearWinUIBg=false
103 | [light]
104 | r=222
105 | g=222
106 | b=222
107 | a=200
108 | ```
109 | 
110 |
111 |
112 |
113 | ## 如何使用
114 |
115 | ### 安装
116 | 1. 从 [Release](https://github.com/Maplespe/ExplorerBlurMica/releases) 页面下载压缩文档
117 | 2. 解压到一个地方,例如 "`C:\Program Files`"
118 | 3. 以管理员身份运行 "`register.cmd`"
119 | 4. 程序打开文件资源管理器窗口即可生效
120 |
121 | cmd: `regsvr32 "你的路径/ExplorerBlurMica.dll"`
122 |
123 | ### 卸载
124 | 1. 以管理员身份运行 "`uninstall.cmd`"
125 | 2. 删除剩余文件
126 |
127 | cmd: `regsvr32 /u "你的路径/ExplorerBlurMica.dll"`
128 |
129 | #
130 | 注意:如果出现文件资源管理器异常崩溃请按住`ESC`键打开资源管理器并卸载该程序。
131 |
132 | ## 配置文件
133 | ``` ini
134 | [config]
135 | #效果类型: 0=Blur 1=Acrylic 2=Mica 3=Blur(Clear) 4=MicaAlt
136 | #Blur仅在win11 22H2之前版本可用; Blur(Clear)在win10和win11都可用; Mica仅限win11可用
137 | effect=1
138 | #清除地址栏背景颜色
139 | clearAddress=true
140 | #清除滚动条背景颜色
141 | #(注意:由于系统滚动条本身不透明 因此为了去除背景色 滚动条是由本程序自绘的 它可能和系统样式有所差别)
142 | clearBarBg=true
143 | #清除Windows11文件资源管理器的WinUI或XamlIslands部分的工具栏背景色
144 | clearWinUIBg=true
145 | #显示TreeView和DUIView之间的分隔线
146 | showLine=true
147 | [light]
148 | #系统颜色模式为Light(亮色)时的颜色
149 | #RGBA 颜色分量
150 | r=220
151 | g=220
152 | b=220
153 | a=160
154 | [dark]
155 | #系统颜色模式为Dark(暗色)时的颜色
156 | r=0
157 | g=0
158 | b=0
159 | a=120
160 |
161 | ```
162 |
163 | 修改完保存文件重新打开文件资源管理器窗口即可生效。
164 |
165 | ## 其他
166 | 依赖: [minhook](https://github.com/m417z/minhook).
167 |
168 | 此项目是基于枫の美化工具箱独立出来的组件 [MToolBox](https://winmoes.com/tools/12948.html).
169 |
--------------------------------------------------------------------------------
/program.py:
--------------------------------------------------------------------------------
1 | import tkinter
2 | import customtkinter
3 | import subprocess
4 |
5 | customtkinter.set_default_color_theme("blue")
6 | clearAddress="false"
7 | clearBarBg="false"
8 | clearWinUIBg= "false"
9 | showLine="false"
10 | mode="0"
11 | alpha="200"
12 | r="255"
13 | g="255"
14 | b="255"
15 |
16 | class App(customtkinter.CTk):
17 | def __init__(self):
18 | super().__init__()
19 |
20 | # configure window
21 | self.title("ExplorerBlurMica GUI")
22 | self.geometry(f"{800}x{550}")
23 | self.resizable(False, False)
24 |
25 | # configure grid layout (4x4)
26 | self.grid_columnconfigure(1, weight=1)
27 | self.grid_columnconfigure((2, 3), weight=0)
28 | self.grid_rowconfigure((0, 1, 2), weight=1)
29 |
30 | # create sidebar frame with widgets
31 | self.sidebar_frame = customtkinter.CTkFrame(self, width=140, corner_radius=0)
32 | self.sidebar_frame.grid(row=0, column=0, rowspan=4, sticky="nsew")
33 | self.sidebar_frame.grid_rowconfigure(4, weight=1)
34 | self.logo_label = customtkinter.CTkLabel(self.sidebar_frame, text="ExplorerBlurMica", font=customtkinter.CTkFont(size=18, weight="bold"))
35 | self.logo_label.grid(row=0, column=0, padx=20, pady=(20, 10))
36 | self.sidebar_button_1 = customtkinter.CTkButton(self.sidebar_frame, command=self.install)
37 | self.sidebar_button_1.grid(row=1, column=0, padx=20, pady=10)
38 | self.sidebar_button_2 = customtkinter.CTkButton(self.sidebar_frame, command=self.remove)
39 | self.sidebar_button_2.grid(row=2, column=0, padx=20, pady=10)
40 | self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="GUI by lengoc-quang", anchor="w")
41 | self.appearance_mode_label.grid(row=5, column=0, padx=10, pady=(10, 10))
42 |
43 | # create radiobutton frame
44 | self.radiobutton_frame = customtkinter.CTkFrame(self)
45 | self.label_radio_group = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Mode")
46 | self.label_radio_group.grid(row=0, column=2, columnspan=1, padx=30, pady=(20, 20), sticky="")
47 | self.radiobutton_frame.grid(row=0, column=2, padx=30, pady=(20, 20), sticky="nsew")
48 | self.radio_var = tkinter.IntVar(value=0)
49 | self.radio_button_1 = customtkinter.CTkRadioButton(master=self.radiobutton_frame, variable=self.radio_var, value=0, command=self.changeMode0)
50 | self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n")
51 | self.radio_button_2 = customtkinter.CTkRadioButton(master=self.radiobutton_frame, variable=self.radio_var, value=1, command=self.changeMode1)
52 | self.radio_button_2.grid(row=2, column=2, pady=10, padx=20, sticky="n")
53 | self.radio_button_3 = customtkinter.CTkRadioButton(master=self.radiobutton_frame, variable=self.radio_var, value=2, command=self.changeMode2)
54 | self.radio_button_3.grid(row=3, column=2, pady=10, padx=20, sticky="n")
55 | self.radio_button_4 = customtkinter.CTkRadioButton(master=self.radiobutton_frame, variable=self.radio_var, value=3, command=self.changeMode3)
56 | self.radio_button_4.grid(row=4, column=2, pady=10, padx=20, sticky="n")
57 | self.radio_button_5 = customtkinter.CTkRadioButton(master=self.radiobutton_frame, variable=self.radio_var, value=4, command=self.changeMode4)
58 | self.radio_button_5.grid(row=5, column=2, pady=10, padx=20, sticky="n")
59 |
60 | # create checkbox and switch frame
61 | self.checkbox_slider_frame = customtkinter.CTkFrame(self)
62 | self.checkbox_slider_frame = customtkinter.CTkLabel(master=self.radiobutton_frame, text="Option")
63 | self.checkbox_slider_frame.grid(row=0, column=2, columnspan=1, padx=30, pady=(20, 50), sticky="nsew")
64 | self.checkbox_1 = customtkinter.CTkCheckBox(master=self.checkbox_slider_frame, command=self.clrAddressBar)
65 | self.checkbox_1.grid(row=1, column=0, pady=(20, 0), padx=(18, 20), sticky="n")
66 | self.checkbox_2 = customtkinter.CTkCheckBox(master=self.checkbox_slider_frame, command=self.clrToolbar)
67 | self.checkbox_2.grid(row=2, column=0, pady=(20, 0), padx=(3, 20), sticky="n")
68 | self.checkbox_3 = customtkinter.CTkCheckBox(master=self.checkbox_slider_frame, command=self.clrBackground)
69 | self.checkbox_3.grid(row=3, column=0, pady=(20, 0), padx=20, sticky="n")
70 | self.checkbox_4 = customtkinter.CTkCheckBox(master=self.checkbox_slider_frame, command=self.showLn)
71 | self.checkbox_4.grid(row=4, column=0, pady=20, padx=(21, 20), sticky="n")
72 |
73 | # create slider
74 | self.slider_frame = customtkinter.CTkFrame(self)
75 | self.slider_frame.grid(row=0, column=3, padx=(0, 20), pady=(20, 20), sticky="nsew")
76 | self.slider_frame.grid_columnconfigure(3, weight=1)
77 | self.slider_frame.grid_rowconfigure(6, weight=1)
78 | self.label_slider_group = customtkinter.CTkLabel(master=self.slider_frame, text="Settings")
79 | self.label_slider_group.grid(row=1, column=0, padx=(20, 20), pady=(30, 10), sticky="ew")
80 | self.label_slider_group_a = customtkinter.CTkLabel(master=self.slider_frame, text="Alpha")
81 | self.label_slider_group_a.grid(row=2, column=0, padx=(20, 20), pady=(0, 10), sticky="ew")
82 | self.label_slider_group_r = customtkinter.CTkLabel(master=self.slider_frame, text="Red")
83 | self.label_slider_group_r.grid(row=3, column=0, padx=(20, 20), pady=(10, 10), sticky="ew")
84 | self.label_slider_group_g = customtkinter.CTkLabel(master=self.slider_frame, text="Green")
85 | self.label_slider_group_g.grid(row=4, column=0, padx=(20, 20), pady=(20, 0), sticky="ew")
86 | self.label_slider_group_b = customtkinter.CTkLabel(master=self.slider_frame, text="Blue")
87 | self.label_slider_group_b.grid(row=5, column=0, padx=(20, 20), pady=(10, 60), sticky="ew")
88 | self.slider_1 = customtkinter.CTkSlider(self.slider_frame, from_=0, to=255, number_of_steps=256, progress_color="white", command=self.changeAlpha)
89 | self.slider_1.grid(row=2, column=0, padx=(20, 10), pady=(40, 10), sticky="ew")
90 | self.slider_2 = customtkinter.CTkSlider(self.slider_frame, from_=0, to=255, number_of_steps=256, progress_color="red", command=self.changeRed)
91 | self.slider_2.grid(row=3, column=0, padx=(20, 10), pady=(60, 10), sticky="ew")
92 | self.slider_3 = customtkinter.CTkSlider(self.slider_frame, from_=0, to=255, number_of_steps=256, progress_color="green", command=self.changeGreen)
93 | self.slider_3.grid(row=4, column=0, padx=(20, 10), pady=(80, 0), sticky="ew")
94 | self.slider_4 = customtkinter.CTkSlider(self.slider_frame, from_=0, to=255, number_of_steps=256, progress_color="blue", command=self.changeBlue)
95 | self.slider_4.grid(row=5, column=0, padx=(20, 10), pady=(80, 50), sticky="ew")
96 | self.note_slider_group = customtkinter.CTkLabel(master=self.slider_frame, text='''NOTE:
97 | This settings combines dark and light settings!''')
98 | self.note_slider_group.grid(row=6, column=0, padx=(5, 5), pady=(0, 5), sticky="ew")
99 |
100 | # set default values
101 | self.sidebar_button_1.configure(text="Install")
102 | self.sidebar_button_2.configure(text="Remove")
103 | self.checkbox_1.configure(text="Clear address bar ")
104 | self.checkbox_2.configure(text="Clear toolbar ")
105 | self.checkbox_3.configure(text="Clear background ")
106 | self.checkbox_4.configure(text="Show seperate line")
107 | self.radio_button_1.configure(text="Blur ")
108 | self.radio_button_2.configure(text="Acrylic ")
109 | self.radio_button_3.configure(text="Mica ")
110 | self.radio_button_4.configure(text="Clear ")
111 | self.radio_button_5.configure(text="Mica Alt ")
112 | self.slider_1.set(200)
113 | self.slider_2.set(255)
114 | self.slider_3.set(255)
115 | self.slider_4.set(255)
116 | customtkinter.set_appearance_mode("Light")
117 |
118 | def clrAddressBar(a):
119 | global clearAddress
120 | if clearAddress=="false":
121 | clearAddress="true"
122 | else:
123 | clearAddress="false"
124 |
125 | def clrToolbar(a):
126 | global clearBarBg
127 | if clearBarBg=="false":
128 | clearBarBg="true"
129 | else:
130 | clearBarBg="false"
131 |
132 | def clrBackground(a):
133 | global clearWinUIBg
134 | if clearWinUIBg=="false":
135 | clearWinUIBg="true"
136 | else:
137 | clearWinUIBg="false"
138 |
139 | def showLn(a):
140 | global showLine
141 | if showLine=="false":
142 | showLine="true"
143 | else:
144 | showLine="false"
145 |
146 | def changeMode0(a):
147 | global mode
148 | mode = "0"
149 | def changeMode1(a):
150 | global mode
151 | mode = "1"
152 | def changeMode2(a):
153 | global mode
154 | mode = "2"
155 | def changeMode3(a):
156 | global mode
157 | mode = "3"
158 | def changeMode4(a):
159 | global mode
160 | mode = "4"
161 |
162 | def changeAlpha(a, value):
163 | global alpha
164 | alpha = str(int(value // 1))
165 | print("A: " + alpha)
166 | def changeRed(a, value):
167 | global r
168 | r = str(int(value // 1))
169 | print("R: " + r)
170 | def changeGreen(a, value):
171 | global g
172 | g = str(int(value // 1))
173 | print("G: " + g)
174 | def changeBlue(a, value):
175 | global b
176 | b = str(int(value // 1))
177 | print("B: " + b)
178 |
179 | def install(a):
180 | print(mode, clearAddress, clearBarBg, clearWinUIBg, showLine)
181 | f = open('src\\config.ini', "w")
182 | f.write("[config]\n")
183 | f.write("effect=" + mode + "\n")
184 | f.write("clearAddress=" + clearAddress + "\n")
185 | f.write("clearBarBg=" + clearBarBg + "\n")
186 | f.write("clearWinUIBg=" + clearWinUIBg + "\n")
187 | f.write("showLine=" + showLine + "\n")
188 | f.write("[light]\n")
189 | f.write("r="+ r + "\n")
190 | f.write("g="+ g + "\n")
191 | f.write("b="+ b + "\n")
192 | f.write("a="+ alpha + "\n")
193 | f.write("[dark]\n")
194 | f.write("r="+ r + "\n")
195 | f.write("g="+ g + "\n")
196 | f.write("b="+ b + "\n")
197 | f.write("a="+ alpha + "\n")
198 | f.close()
199 | subprocess.Popen(".\\src\\register.cmd", shell=True)
200 | return
201 | def remove(a):
202 | subprocess.Popen(".\\src\\uninstall.cmd", shell=True)
203 | return
204 |
205 | if __name__ == "__main__":
206 | app = App()
207 | app.mainloop()
208 |
--------------------------------------------------------------------------------
/screenshot/012949.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/screenshot/012949.png
--------------------------------------------------------------------------------
/screenshot/013256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/screenshot/013256.png
--------------------------------------------------------------------------------
/screenshot/152834.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/screenshot/152834.png
--------------------------------------------------------------------------------
/screenshot/152929.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/screenshot/152929.png
--------------------------------------------------------------------------------
/screenshot/230909.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Maplespe/ExplorerBlurMica/6359b669c60cd47dfbaf010a5ccf4835e3e7f1e5/screenshot/230909.png
--------------------------------------------------------------------------------
/src/config.ini:
--------------------------------------------------------------------------------
1 | [config]
2 | effect=0
3 | clearAddress=false
4 | clearBarBg=false
5 | clearWinUIBg=false
6 | showLine=false
7 | [light]
8 | r=255
9 | g=255
10 | b=255
11 | a=255
12 | [dark]
13 | r=255
14 | g=255
15 | b=255
16 | a=255
17 |
--------------------------------------------------------------------------------
/src/register.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | title Asking for administrator access
4 | mode CON COLS=37 LINES=3
5 | color F0
6 | echo :::::::::::::::::::::::::::::::::::::
7 | echo :: Requesting administrator access ::
8 | echo :::::::::::::::::::::::::::::::::::::
9 | cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && ""%~s0"" %Apply%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
10 | color
11 | cls
12 |
13 | title Applying
14 | call :isAdmin
15 | if %errorlevel% == 0 (
16 | echo Applying effects
17 | regsvr32 "%~dp0ExplorerBlurMica.dll"
18 | echo.
19 | ) else (
20 | echo Please run as Administrator
21 | )
22 |
23 | echo Restarting explorer
24 | taskkill /F /IM explorer.exe >nul
25 | start explorer.exe
26 | echo .
27 | echo title Success
28 | echo Changes applied successfully
29 | echo You can now close this window, it will close automatically in 5 seconds
30 | timeout /t 5 >nul
31 | exit /b 0
32 |
33 | :isAdmin
34 | fsutil dirty query %systemdrive% >nul
35 | exit /b %errorlevel%
--------------------------------------------------------------------------------
/src/uninstall.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | title Asking for administrator access
4 | mode CON COLS=37 LINES=3
5 | color F0
6 | echo :::::::::::::::::::::::::::::::::::::
7 | echo :: Requesting administrator access ::
8 | echo :::::::::::::::::::::::::::::::::::::
9 | cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && ""%~s0"" %Apply%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )
10 | color
11 | cls
12 |
13 | title Uninstalling
14 | call :isAdmin
15 | if %errorlevel% == 0 (
16 | regsvr32 /u "%~dp0ExplorerBlurMica.dll"
17 | echo.
18 | ) else (
19 | echo Please run as Administrator
20 | )
21 |
22 | echo Restarting explorer
23 | taskkill /F /IM explorer.exe >nul
24 | start explorer.exe
25 | echo .
26 | echo title Success
27 | echo Changes applied successfully
28 | echo You can now close this window, it will close automatically in 5 seconds
29 | timeout /t 5 >nul
30 | exit /b 0
31 |
32 | :isAdmin
33 | fsutil dirty query %systemdrive% >nul
34 | exit /b %errorlevel%
--------------------------------------------------------------------------------