├── .gitattributes
├── .gitignore
├── DetoursHelpers
├── DetoursHelpers.h
├── DetoursHelpers.vcxitems
└── DetoursHelpers.vcxitems.filters
├── FileUtils
├── FileUtils.h
├── FileUtils.vcxitems
└── FileUtils.vcxitems.filters
├── HookLib
├── HookLib.def
├── HookLib.h
├── HookLib.rc
├── HookLib.vcxproj
├── HookLib.vcxproj.filters
├── README.md
├── dllmain.cpp
├── packages.config
└── resource.h
├── LICENSE
├── Process Protector.sln
├── ProcessUtils
├── ProcessProtector.h
├── ProcessUtils.vcxitems
├── ProcessUtils.vcxitems.filters
└── README.md
├── README.md
├── Test
├── Test.vcxproj
├── Test.vcxproj.filters
└── main.cpp
└── std_container_helpers
├── set_helper.h
├── std_container_helpers.vcxitems
└── std_container_helpers.vcxitems.filters
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | [Aa][Rr][Mm]/
24 | [Aa][Rr][Mm]64/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Visual Studio 2015/2017 cache/options directory
31 | .vs/
32 | # Uncomment if you have tasks that create the project's static files in wwwroot
33 | #wwwroot/
34 |
35 | # Visual Studio 2017 auto generated files
36 | Generated\ Files/
37 |
38 | # MSTest test Results
39 | [Tt]est[Rr]esult*/
40 | [Bb]uild[Ll]og.*
41 |
42 | # NUNIT
43 | *.VisualState.xml
44 | TestResult.xml
45 |
46 | # Build Results of an ATL Project
47 | [Dd]ebugPS/
48 | [Rr]eleasePS/
49 | dlldata.c
50 |
51 | # Benchmark Results
52 | BenchmarkDotNet.Artifacts/
53 |
54 | # .NET Core
55 | project.lock.json
56 | project.fragment.lock.json
57 | artifacts/
58 |
59 | # StyleCop
60 | StyleCopReport.xml
61 |
62 | # Files built by Visual Studio
63 | *_i.c
64 | *_p.c
65 | *_h.h
66 | *.ilk
67 | *.meta
68 | *.obj
69 | *.iobj
70 | *.pch
71 | *.pdb
72 | *.ipdb
73 | *.pgc
74 | *.pgd
75 | *.rsp
76 | *.sbr
77 | *.tlb
78 | *.tli
79 | *.tlh
80 | *.tmp
81 | *.tmp_proj
82 | *_wpftmp.csproj
83 | *.log
84 | *.vspscc
85 | *.vssscc
86 | .builds
87 | *.pidb
88 | *.svclog
89 | *.scc
90 |
91 | # Chutzpah Test files
92 | _Chutzpah*
93 |
94 | # Visual C++ cache files
95 | ipch/
96 | *.aps
97 | *.ncb
98 | *.opendb
99 | *.opensdf
100 | *.sdf
101 | *.cachefile
102 | *.VC.db
103 | *.VC.VC.opendb
104 |
105 | # Visual Studio profiler
106 | *.psess
107 | *.vsp
108 | *.vspx
109 | *.sap
110 |
111 | # Visual Studio Trace Files
112 | *.e2e
113 |
114 | # TFS 2012 Local Workspace
115 | $tf/
116 |
117 | # Guidance Automation Toolkit
118 | *.gpState
119 |
120 | # ReSharper is a .NET coding add-in
121 | _ReSharper*/
122 | *.[Rr]e[Ss]harper
123 | *.DotSettings.user
124 |
125 | # JustCode is a .NET coding add-in
126 | .JustCode
127 |
128 | # TeamCity is a build add-in
129 | _TeamCity*
130 |
131 | # DotCover is a Code Coverage Tool
132 | *.dotCover
133 |
134 | # AxoCover is a Code Coverage Tool
135 | .axoCover/*
136 | !.axoCover/settings.json
137 |
138 | # Visual Studio code coverage results
139 | *.coverage
140 | *.coveragexml
141 |
142 | # NCrunch
143 | _NCrunch_*
144 | .*crunch*.local.xml
145 | nCrunchTemp_*
146 |
147 | # MightyMoose
148 | *.mm.*
149 | AutoTest.Net/
150 |
151 | # Web workbench (sass)
152 | .sass-cache/
153 |
154 | # Installshield output folder
155 | [Ee]xpress/
156 |
157 | # DocProject is a documentation generator add-in
158 | DocProject/buildhelp/
159 | DocProject/Help/*.HxT
160 | DocProject/Help/*.HxC
161 | DocProject/Help/*.hhc
162 | DocProject/Help/*.hhk
163 | DocProject/Help/*.hhp
164 | DocProject/Help/Html2
165 | DocProject/Help/html
166 |
167 | # Click-Once directory
168 | publish/
169 |
170 | # Publish Web Output
171 | *.[Pp]ublish.xml
172 | *.azurePubxml
173 | # Note: Comment the next line if you want to checkin your web deploy settings,
174 | # but database connection strings (with potential passwords) will be unencrypted
175 | *.pubxml
176 | *.publishproj
177 |
178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
179 | # checkin your Azure Web App publish settings, but sensitive information contained
180 | # in these scripts will be unencrypted
181 | PublishScripts/
182 |
183 | # NuGet Packages
184 | *.nupkg
185 | # The packages folder can be ignored because of Package Restore
186 | **/[Pp]ackages/*
187 | # except build/, which is used as an MSBuild target.
188 | !**/[Pp]ackages/build/
189 | # Uncomment if necessary however generally it will be regenerated when needed
190 | #!**/[Pp]ackages/repositories.config
191 | # NuGet v3's project.json files produces more ignorable files
192 | *.nuget.props
193 | *.nuget.targets
194 |
195 | # Microsoft Azure Build Output
196 | csx/
197 | *.build.csdef
198 |
199 | # Microsoft Azure Emulator
200 | ecf/
201 | rcf/
202 |
203 | # Windows Store app package directories and files
204 | AppPackages/
205 | BundleArtifacts/
206 | Package.StoreAssociation.xml
207 | _pkginfo.txt
208 | *.appx
209 |
210 | # Visual Studio cache files
211 | # files ending in .cache can be ignored
212 | *.[Cc]ache
213 | # but keep track of directories ending in .cache
214 | !?*.[Cc]ache/
215 |
216 | # Others
217 | ClientBin/
218 | ~$*
219 | *~
220 | *.dbmdl
221 | *.dbproj.schemaview
222 | *.jfm
223 | *.pfx
224 | *.publishsettings
225 | orleans.codegen.cs
226 |
227 | # Including strong name files can present a security risk
228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
229 | #*.snk
230 |
231 | # Since there are multiple workflows, uncomment next line to ignore bower_components
232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
233 | #bower_components/
234 |
235 | # RIA/Silverlight projects
236 | Generated_Code/
237 |
238 | # Backup & report files from converting an old project file
239 | # to a newer Visual Studio version. Backup files are not needed,
240 | # because we have git ;-)
241 | _UpgradeReport_Files/
242 | Backup*/
243 | UpgradeLog*.XML
244 | UpgradeLog*.htm
245 | ServiceFabricBackup/
246 | *.rptproj.bak
247 |
248 | # SQL Server files
249 | *.mdf
250 | *.ldf
251 | *.ndf
252 |
253 | # Business Intelligence projects
254 | *.rdl.data
255 | *.bim.layout
256 | *.bim_*.settings
257 | *.rptproj.rsuser
258 | *- Backup*.rdl
259 |
260 | # Microsoft Fakes
261 | FakesAssemblies/
262 |
263 | # GhostDoc plugin setting file
264 | *.GhostDoc.xml
265 |
266 | # Node.js Tools for Visual Studio
267 | .ntvs_analysis.dat
268 | node_modules/
269 |
270 | # Visual Studio 6 build log
271 | *.plg
272 |
273 | # Visual Studio 6 workspace options file
274 | *.opt
275 |
276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
277 | *.vbw
278 |
279 | # Visual Studio LightSwitch build output
280 | **/*.HTMLClient/GeneratedArtifacts
281 | **/*.DesktopClient/GeneratedArtifacts
282 | **/*.DesktopClient/ModelManifest.xml
283 | **/*.Server/GeneratedArtifacts
284 | **/*.Server/ModelManifest.xml
285 | _Pvt_Extensions
286 |
287 | # Paket dependency manager
288 | .paket/paket.exe
289 | paket-files/
290 |
291 | # FAKE - F# Make
292 | .fake/
293 |
294 | # JetBrains Rider
295 | .idea/
296 | *.sln.iml
297 |
298 | # CodeRush personal settings
299 | .cr/personal
300 |
301 | # Python Tools for Visual Studio (PTVS)
302 | __pycache__/
303 | *.pyc
304 |
305 | # Cake - Uncomment if you are using it
306 | # tools/**
307 | # !tools/packages.config
308 |
309 | # Tabs Studio
310 | *.tss
311 |
312 | # Telerik's JustMock configuration file
313 | *.jmconfig
314 |
315 | # BizTalk build output
316 | *.btp.cs
317 | *.btm.cs
318 | *.odx.cs
319 | *.xsd.cs
320 |
321 | # OpenCover UI analysis results
322 | OpenCover/
323 |
324 | # Azure Stream Analytics local run output
325 | ASALocalRun/
326 |
327 | # MSBuild Binary and Structured Log
328 | *.binlog
329 |
330 | # NVidia Nsight GPU debugger configuration file
331 | *.nvuser
332 |
333 | # MFractors (Xamarin productivity tool) working folder
334 | .mfractor/
335 |
336 | # Local History for Visual Studio
337 | .localhistory/
338 |
339 | # BeatPulse healthcheck temp database
340 | healthchecksdb
--------------------------------------------------------------------------------
/DetoursHelpers/DetoursHelpers.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Heade File: DetoursHelpers.h
3 | * Last Update: 2020/10/13
4 | *
5 | * Copyright (C) Hydr10n@GitHub. All Rights Reserved.
6 | */
7 |
8 | #pragma once
9 |
10 | #include "detours.h"
11 |
12 | namespace Hydr10n {
13 | namespace DetoursHelpers {
14 | LONG WINAPI ChangeProcAddr(PVOID* ppPointer, PVOID pDetour, BOOL bRestore) {
15 | LONG ret = DetourTransactionBegin();
16 | if (ret != NO_ERROR
17 | || (ret = DetourUpdateThread(GetCurrentThread())) != NO_ERROR
18 | || (ret = (bRestore ? DetourDetach(ppPointer, pDetour) : DetourAttach(ppPointer, pDetour))) != NO_ERROR)
19 | return ret;
20 | return DetourTransactionCommit();
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/DetoursHelpers/DetoursHelpers.vcxitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {0491bc94-cb78-42d3-b8ca-3016322b416f}
7 |
8 |
9 |
10 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/DetoursHelpers/DetoursHelpers.vcxitems.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {adcdeaab-b3fc-488e-8b8e-41c5777f2bb6}
6 |
7 |
8 |
9 |
10 | Header Files
11 |
12 |
13 |
--------------------------------------------------------------------------------
/FileUtils/FileUtils.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Heade File: FileUtils.h
3 | * Last Update: 2020/10/15
4 | *
5 | * Copyright (C) Hydr10n@GitHub. All Rights Reserved.
6 | */
7 |
8 | #pragma once
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #pragma comment(lib, "Shlwapi")
15 |
16 | namespace Hydr10n {
17 | namespace FileUtils {
18 | LPCWSTR WINAPI SkipUnicodeLongPathPrefix(LPCWSTR lpcwPath) {
19 | constexpr WCHAR lpcwPrefix[] = L"\\\\?\\";
20 | const LPCWSTR ret = StrStrW(lpcwPath, lpcwPrefix);
21 | return ret == NULL || ret != lpcwPath ? lpcwPath : ret + ARRAYSIZE(lpcwPrefix) - 1;
22 | }
23 |
24 | template
25 | DWORD WINAPI GetFileName(std::wstring& fileName, const Lambda& lambda) {
26 | DWORD ret;
27 | try {
28 | fileName.resize(UNICODE_STRING_MAX_CHARS);
29 | fileName.resize(ret = lambda());
30 | fileName.shrink_to_fit();
31 | }
32 | catch (...) { ret = 0; }
33 | return ret;
34 | }
35 |
36 | DWORD WINAPI GetModuleFileNameW(std::wstring& fileName, HMODULE hModule = NULL) { return GetFileName(fileName, [&]() { return GetModuleFileNameW(hModule, &fileName[0], (DWORD)fileName.size()); }); }
37 |
38 | DWORD WINAPI GetFinalPathNameByHandleW(std::wstring& fileName, HANDLE hFile, DWORD dwFlags = FILE_NAME_NORMALIZED | VOLUME_NAME_DOS) { return GetFileName(fileName, [&]() { return ::GetFinalPathNameByHandleW(hFile, &fileName[0], (DWORD)fileName.size(), dwFlags); }); }
39 | }
40 | }
--------------------------------------------------------------------------------
/FileUtils/FileUtils.vcxitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {c2e0c70e-a40f-4c72-8bf1-b1eba63626ed}
7 |
8 |
9 |
10 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/FileUtils/FileUtils.vcxitems.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {c097c2f6-051e-4633-b678-0bb66f82d61d}
6 |
7 |
8 |
9 |
10 | Header Files
11 |
12 |
13 |
--------------------------------------------------------------------------------
/HookLib/HookLib.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 |
3 | EXPORTS
4 | SetGlobalWindowsHook
5 | UnhookGlobalWindowsHook
--------------------------------------------------------------------------------
/HookLib/HookLib.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Header Files: HookLib.h
3 | * Last Update: 2020/10/07
4 | *
5 | * Copyright (C) Hydr10n@GitHub. All Rights Reserved.
6 | */
7 |
8 | #pragma once
9 |
10 | #include
11 |
12 | BOOL WINAPI SetGlobalWindowsHook();
13 | BOOL WINAPI UnhookGlobalWindowsHook();
--------------------------------------------------------------------------------
/HookLib/HookLib.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 |
5 | #include "resource.h"
6 |
7 | #define APSTUDIO_READONLY_SYMBOLS
8 | /////////////////////////////////////////////////////////////////////////////
9 | //
10 | // Generated from the TEXTINCLUDE 2 resource.
11 | //
12 | #include "winres.h"
13 |
14 | /////////////////////////////////////////////////////////////////////////////
15 | #undef APSTUDIO_READONLY_SYMBOLS
16 |
17 | /////////////////////////////////////////////////////////////////////////////
18 | // English (United States) resources
19 |
20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
21 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22 |
23 | #ifdef APSTUDIO_INVOKED
24 | /////////////////////////////////////////////////////////////////////////////
25 | //
26 | // TEXTINCLUDE
27 | //
28 |
29 | 1 TEXTINCLUDE
30 | BEGIN
31 | "resource.h\0"
32 | END
33 |
34 | 2 TEXTINCLUDE
35 | BEGIN
36 | "#include ""winres.h""\r\n"
37 | "\0"
38 | END
39 |
40 | 3 TEXTINCLUDE
41 | BEGIN
42 | "\r\n"
43 | "\0"
44 | END
45 |
46 | #endif // APSTUDIO_INVOKED
47 |
48 |
49 | /////////////////////////////////////////////////////////////////////////////
50 | //
51 | // Version
52 | //
53 |
54 | VS_VERSION_INFO VERSIONINFO
55 | FILEVERSION 1,0,0,1
56 | PRODUCTVERSION 1,0,0,1
57 | FILEFLAGSMASK 0x3fL
58 | #ifdef _DEBUG
59 | FILEFLAGS 0x1L
60 | #else
61 | FILEFLAGS 0x0L
62 | #endif
63 | FILEOS 0x40004L
64 | FILETYPE 0x2L
65 | FILESUBTYPE 0x0L
66 | BEGIN
67 | BLOCK "StringFileInfo"
68 | BEGIN
69 | BLOCK "040904b0"
70 | BEGIN
71 | VALUE "CompanyName", "Hydr10n"
72 | VALUE "FileVersion", "1.0.0.1"
73 | VALUE "InternalName", "HookLib.dll"
74 | VALUE "LegalCopyright", "© 2020 Hydr10n@GitHub"
75 | VALUE "OriginalFilename", "HookLib.dll"
76 | VALUE "ProductName", "HookLib"
77 | VALUE "ProductVersion", "1.0.0.1"
78 | END
79 | END
80 | BLOCK "VarFileInfo"
81 | BEGIN
82 | VALUE "Translation", 0x409, 1200
83 | END
84 | END
85 |
86 | #endif // English (United States) resources
87 | /////////////////////////////////////////////////////////////////////////////
88 |
89 |
90 |
91 | #ifndef APSTUDIO_INVOKED
92 | /////////////////////////////////////////////////////////////////////////////
93 | //
94 | // Generated from the TEXTINCLUDE 3 resource.
95 | //
96 |
97 |
98 | /////////////////////////////////////////////////////////////////////////////
99 | #endif // not APSTUDIO_INVOKED
100 |
101 |
--------------------------------------------------------------------------------
/HookLib/HookLib.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {ee16152f-396e-4cec-8490-4b074c9efa89}
25 | HookLib
26 | 10.0
27 |
28 |
29 |
30 | DynamicLibrary
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | DynamicLibrary
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | DynamicLibrary
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | DynamicLibrary
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | true
76 | HookLib
77 |
78 |
79 | false
80 | HookLib
81 |
82 |
83 | true
84 | HookLib
85 |
86 |
87 | false
88 | HookLib
89 |
90 |
91 |
92 | Level3
93 | true
94 | WIN32;_DEBUG;HOOKLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
95 | true
96 |
97 |
98 | Windows
99 | true
100 | false
101 | HookLib.def
102 |
103 |
104 |
105 |
106 | Level3
107 | true
108 | true
109 | true
110 | WIN32;NDEBUG;HOOKLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
111 | true
112 |
113 |
114 | Windows
115 | true
116 | true
117 | true
118 | false
119 | HookLib.def
120 |
121 |
122 |
123 |
124 | Level3
125 | true
126 | _DEBUG;HOOKLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
127 | true
128 |
129 |
130 | Windows
131 | true
132 | false
133 | HookLib.def
134 |
135 |
136 |
137 |
138 | Level3
139 | true
140 | true
141 | true
142 | NDEBUG;HOOKLIB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
143 | true
144 |
145 |
146 | Windows
147 | true
148 | true
149 | true
150 | false
151 | HookLib.def
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
175 |
176 |
177 |
178 |
--------------------------------------------------------------------------------
/HookLib/HookLib.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 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 | Header Files
28 |
29 |
30 |
31 |
32 | Source Files
33 |
34 |
35 |
36 |
37 |
38 | Resource Files
39 |
40 |
41 |
--------------------------------------------------------------------------------
/HookLib/README.md:
--------------------------------------------------------------------------------
1 | # HookLib.h Header
2 | The header is used by HookLib.
3 |
4 | ### Functions
5 | |Title|Description|
6 | |-----|-----------|
7 | |```SetGlobalWindowsHook```|Installs a hook procedure into a hook chain, applying to all GUI applications.|
8 | |```UnhookGlobalWindowsHook```|Removes a hook procedure installed in a hook chain by the ```SetGlobalWindowsHook``` function.|
--------------------------------------------------------------------------------
/HookLib/dllmain.cpp:
--------------------------------------------------------------------------------
1 | #include "HookLib.h"
2 | #include "ProcessProtector.h"
3 |
4 | #pragma data_seg("SharedData")
5 | struct {
6 | HHOOK hHook;
7 | DWORD dwHookCallerProcessId;
8 | } sharedData{};
9 | #pragma data_seg()
10 | #pragma comment(linker, "/SECTION:SharedData,RWS")
11 |
12 | HINSTANCE hInstance;
13 |
14 | BOOL WINAPI SetGlobalWindowsHook() {
15 | BOOL ret = sharedData.hHook == NULL;
16 | if (ret) {
17 | sharedData.dwHookCallerProcessId = GetCurrentProcessId();
18 | ret = (sharedData.hHook = SetWindowsHookExW(WH_GETMESSAGE, [](int nCode, WPARAM wParam, LPARAM lParam) { return CallNextHookEx(NULL, nCode, wParam, lParam); }, hInstance, 0)) != NULL;
19 | }
20 | return ret;
21 | }
22 |
23 | BOOL WINAPI UnhookGlobalWindowsHook() {
24 | const BOOL ret = UnhookWindowsHookEx(sharedData.hHook);
25 | if (ret)
26 | sharedData.hHook = NULL;
27 | return ret;
28 | }
29 |
30 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved) {
31 | using Hydr10n::ProcessUtils::ProcessProtector;
32 | switch (dwReason) {
33 | case DLL_PROCESS_ATTACH: {
34 | if (sharedData.hHook != NULL) {
35 | ProcessProtector::Hide(sharedData.dwHookCallerProcessId);
36 | ProcessProtector::Protect(sharedData.dwHookCallerProcessId);
37 | }
38 | hInstance = hModule;
39 | } break;
40 | }
41 | return TRUE;
42 | }
--------------------------------------------------------------------------------
/HookLib/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/HookLib/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by HookLib.rc
4 |
5 | // Next default values for new objects
6 | //
7 | #ifdef APSTUDIO_INVOKED
8 | #ifndef APSTUDIO_READONLY_SYMBOLS
9 | #define _APS_NEXT_RESOURCE_VALUE 101
10 | #define _APS_NEXT_COMMAND_VALUE 40001
11 | #define _APS_NEXT_CONTROL_VALUE 1001
12 | #define _APS_NEXT_SYMED_VALUE 101
13 | #endif
14 | #endif
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Xun Yang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Process Protector.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30406.217
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcessUtils", "ProcessUtils\ProcessUtils.vcxitems", "{5CC106A1-6209-45F1-B5F5-B0E6696218D0}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HookLib", "HookLib\HookLib.vcxproj", "{EE16152F-396E-4CEC-8490-4B074C9EFA89}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DetoursHelpers", "DetoursHelpers\DetoursHelpers.vcxitems", "{0491BC94-CB78-42D3-B8CA-3016322B416F}"
13 | EndProject
14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileUtils", "FileUtils\FileUtils.vcxitems", "{C2E0C70E-A40F-4C72-8BF1-B1EBA63626ED}"
15 | EndProject
16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "std_container_helpers", "std_container_helpers\std_container_helpers.vcxitems", "{192E25ED-926C-4C70-9D6A-700CF60712E6}"
17 | EndProject
18 | Global
19 | GlobalSection(SharedMSBuildProjectFiles) = preSolution
20 | DetoursHelpers\DetoursHelpers.vcxitems*{0491bc94-cb78-42d3-b8ca-3016322b416f}*SharedItemsImports = 9
21 | std_container_helpers\std_container_helpers.vcxitems*{192e25ed-926c-4c70-9d6a-700cf60712e6}*SharedItemsImports = 9
22 | ProcessUtils\ProcessUtils.vcxitems*{5cc106a1-6209-45f1-b5f5-b0e6696218d0}*SharedItemsImports = 9
23 | FileUtils\FileUtils.vcxitems*{c2e0c70e-a40f-4c72-8bf1-b1eba63626ed}*SharedItemsImports = 9
24 | ProcessUtils\ProcessUtils.vcxitems*{ee16152f-396e-4cec-8490-4b074c9efa89}*SharedItemsImports = 4
25 | FileUtils\FileUtils.vcxitems*{f3f4dcd6-2bc3-4700-b2f9-0020e9e18dda}*SharedItemsImports = 4
26 | ProcessUtils\ProcessUtils.vcxitems*{f3f4dcd6-2bc3-4700-b2f9-0020e9e18dda}*SharedItemsImports = 4
27 | EndGlobalSection
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|x64 = Debug|x64
30 | Debug|x86 = Debug|x86
31 | Release|x64 = Release|x64
32 | Release|x86 = Release|x86
33 | EndGlobalSection
34 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
35 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Debug|x64.ActiveCfg = Debug|x64
36 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Debug|x64.Build.0 = Debug|x64
37 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Debug|x86.ActiveCfg = Debug|Win32
38 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Debug|x86.Build.0 = Debug|Win32
39 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Release|x64.ActiveCfg = Release|x64
40 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Release|x64.Build.0 = Release|x64
41 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Release|x86.ActiveCfg = Release|Win32
42 | {EE16152F-396E-4CEC-8490-4B074C9EFA89}.Release|x86.Build.0 = Release|Win32
43 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Debug|x64.ActiveCfg = Debug|x64
44 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Debug|x64.Build.0 = Debug|x64
45 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Debug|x86.ActiveCfg = Debug|Win32
46 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Debug|x86.Build.0 = Debug|Win32
47 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Release|x64.ActiveCfg = Release|x64
48 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Release|x64.Build.0 = Release|x64
49 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Release|x86.ActiveCfg = Release|Win32
50 | {F3F4DCD6-2BC3-4700-B2F9-0020E9E18DDA}.Release|x86.Build.0 = Release|Win32
51 | EndGlobalSection
52 | GlobalSection(SolutionProperties) = preSolution
53 | HideSolutionNode = FALSE
54 | EndGlobalSection
55 | GlobalSection(ExtensibilityGlobals) = postSolution
56 | SolutionGuid = {183C3A3B-98B0-403D-A3B2-027B16F187BC}
57 | EndGlobalSection
58 | EndGlobal
59 |
--------------------------------------------------------------------------------
/ProcessUtils/ProcessProtector.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Heade File: ProcessProtector.h
3 | * Last Update: 2020/10/16
4 | *
5 | * Copyright (C) Hydr10n@GitHub. All Rights Reserved.
6 | */
7 |
8 | #pragma once
9 |
10 | #pragma warning(disable:4005)
11 | #pragma warning(disable:4302)
12 | #pragma warning(disable:4311)
13 |
14 | #include
15 | #include
16 | #include
17 | #include "../DetoursHelpers/DetoursHelpers.h"
18 | #include "../std_container_helpers/set_helper.h"
19 |
20 | #pragma comment(lib, "ntdll")
21 |
22 | namespace Hydr10n {
23 | namespace ProcessUtils {
24 | class ProcessProtector final {
25 | public:
26 | static bool Hide(DWORD dwProcessId) { return std_container_helpers::set_helper::modify(m_HiddenProcessIds, dwProcessId, false); }
27 |
28 | static bool Unhide(DWORD dwProcessId) { return std_container_helpers::set_helper::modify(m_HiddenProcessIds, dwProcessId, true); }
29 |
30 | static bool Protect(DWORD dwProcessId) { return std_container_helpers::set_helper::modify(m_ProtectedProcessIds, dwProcessId, false); }
31 |
32 | static bool Unprotect(DWORD dwProcessId) { return std_container_helpers::set_helper::modify(m_ProtectedProcessIds, dwProcessId, true); }
33 |
34 | private:
35 | using PCLIENT_ID = struct { HANDLE UniqueProcess, UniqueThread; }*;
36 |
37 | static std::set m_HiddenProcessIds, m_ProtectedProcessIds;
38 | static decltype(NtQuerySystemInformation)* m_NtQuerySystemInformation;
39 | static NTSTATUS(NTAPI* m_NtOpenProcess)(PHANDLE ProcessHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PCLIENT_ID ClientId);
40 |
41 | static const struct static_constructor {
42 | static_constructor() {
43 | using DetoursHelpers::ChangeProcAddr;
44 | m_NtQuerySystemInformation = NtQuerySystemInformation;
45 | m_NtOpenProcess = (decltype(m_NtOpenProcess))DetourFindFunction("ntdll", "NtOpenProcess");
46 | ChangeProcAddr((PVOID*)&m_NtQuerySystemInformation, MyNtQuerySystemInformation, FALSE);
47 | ChangeProcAddr((PVOID*)&m_NtOpenProcess, MyNtOpenProcess, FALSE);
48 | }
49 |
50 | ~static_constructor() {
51 | using DetoursHelpers::ChangeProcAddr;
52 | ChangeProcAddr((PVOID*)&m_NtQuerySystemInformation, MyNtQuerySystemInformation, TRUE);
53 | ChangeProcAddr((PVOID*)&m_NtOpenProcess, MyNtOpenProcess, TRUE);
54 | }
55 | } m_static_constructor;
56 |
57 | static NTSTATUS NTAPI MyNtQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength) {
58 | const NTSTATUS ret = m_NtQuerySystemInformation(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
59 | if (NT_SUCCESS(ret) && SystemInformationClass == SYSTEM_INFORMATION_CLASS::SystemProcessInformation)
60 | for (PSYSTEM_PROCESS_INFORMATION pCurrent = (PSYSTEM_PROCESS_INFORMATION)SystemInformation, pPrevious = NULL; pCurrent != NULL; pCurrent = (PSYSTEM_PROCESS_INFORMATION)((PBYTE)pCurrent + pCurrent->NextEntryOffset)) {
61 | if (!std_container_helpers::set_helper::contains(m_HiddenProcessIds, (DWORD)pCurrent->UniqueProcessId))
62 | pPrevious = pCurrent;
63 | else if (pPrevious != NULL)
64 | pPrevious->NextEntryOffset = pCurrent->NextEntryOffset ? pPrevious->NextEntryOffset + pCurrent->NextEntryOffset : 0;
65 | if (!pCurrent->NextEntryOffset)
66 | break;
67 | }
68 | return ret;
69 | }
70 |
71 | static NTSTATUS NTAPI MyNtOpenProcess(PHANDLE ProcessHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PCLIENT_ID ClientId) {
72 | NTSTATUS ret = m_NtOpenProcess(ProcessHandle, DesiredAccess, ObjectAttributes, ClientId);
73 | if (NT_SUCCESS(ret) && std_container_helpers::set_helper::contains(m_ProtectedProcessIds, (DWORD)ClientId->UniqueProcess)) {
74 | CloseHandle(*ProcessHandle);
75 | *ProcessHandle = NULL;
76 | ret = STATUS_ACCESS_DENIED;
77 | }
78 | return ret;
79 | }
80 | };
81 |
82 | decltype(ProcessProtector::m_static_constructor) ProcessProtector::m_static_constructor;
83 | decltype(ProcessProtector::m_HiddenProcessIds) ProcessProtector::m_HiddenProcessIds;
84 | decltype(ProcessProtector::m_ProtectedProcessIds) ProcessProtector::m_ProtectedProcessIds;
85 | decltype(ProcessProtector::m_NtQuerySystemInformation) ProcessProtector::m_NtQuerySystemInformation;
86 | decltype(ProcessProtector::m_NtOpenProcess) ProcessProtector::m_NtOpenProcess;
87 | }
88 | }
--------------------------------------------------------------------------------
/ProcessUtils/ProcessUtils.vcxitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {5cc106a1-6209-45f1-b5f5-b0e6696218d0}
7 |
8 |
9 |
10 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ProcessUtils/ProcessUtils.vcxitems.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4ced6d6a-3eef-4f10-a70b-8243c5c6a0de}
6 |
7 |
8 |
9 |
10 | Header Files
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ProcessUtils/README.md:
--------------------------------------------------------------------------------
1 | # ProcessProtector Class
2 | Protects and hides processes.
3 |
4 | ## Members
5 | ### Public Methods
6 | |Name|Description|
7 | |----|-----------|
8 | |```ProcessProtector::Hide```|Hides a process (static function).|
9 | |```ProcessProtector::Unhide```|Unhides a process hidden by the function ```ProcessProtector::Hide``` (static function).|
10 | |```ProcessProtector::Protect```|Protects a process (static function).|
11 | |```ProcessProtector::Unprotect```|Unprotects a process protected by the function ```ProcessProtector::Protect``` (static function).|
12 |
13 | ## Requirements
14 | |||
15 | |-|-|
16 | |Target Platform|Windows|
17 | |Namespace|Hydr10n::ProcessUtils|
18 | |Header|ProcessProtector.h|
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Process Protector
2 |
3 | This project is a demonstration of how to protect and hide processes by using Microsoft Detours library and other techniques such as DLL injection and windows hook on Windows platform. Intercepting the Windows functions ```NtQuerySystemInformation``` and ```NtOpenProcess``` is the key.
4 |
5 | A simple library is provided to make the task above easier. See README.md files in HookLib and ProcessUtils directories for details.
--------------------------------------------------------------------------------
/Test/Test.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {f3f4dcd6-2bc3-4700-b2f9-0020e9e18dda}
25 | Test
26 | 10.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v142
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v142
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v142
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v142
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | true
77 |
78 |
79 | false
80 |
81 |
82 | true
83 |
84 |
85 | false
86 |
87 |
88 |
89 | Level3
90 | true
91 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
92 | true
93 |
94 |
95 | Console
96 | true
97 | RequireAdministrator
98 |
99 |
100 |
101 |
102 | Level3
103 | true
104 | true
105 | true
106 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
107 | true
108 |
109 |
110 | Console
111 | true
112 | true
113 | true
114 | RequireAdministrator
115 |
116 |
117 |
118 |
119 | Level3
120 | true
121 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
122 | true
123 |
124 |
125 | Console
126 | true
127 | RequireAdministrator
128 |
129 |
130 |
131 |
132 | Level3
133 | true
134 | true
135 | true
136 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
137 | true
138 |
139 |
140 | Console
141 | true
142 | true
143 | true
144 | RequireAdministrator
145 |
146 |
147 |
148 |
149 | {ee16152f-396e-4cec-8490-4b074c9efa89}
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
--------------------------------------------------------------------------------
/Test/Test.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 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Test/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * ATTENTION: The test must be running as administrator. Besides, Visual Studio [Solution Platforms] must be set correctly before building ("Release" mode is recommended) (for example, if the test is going to be running on Windows x64 platform, change [Solution Platforms] to "x64" so that the test program can inject its DLL into 64-bit Task Manager).
3 | */
4 |
5 | #include
6 | #include
7 | #include "FileUtils.h"
8 | #include "../HookLib/HookLib.h"
9 |
10 | using namespace std;
11 |
12 | int wmain() {
13 | wstring moduleFileName;
14 | Hydr10n::FileUtils::GetModuleFileNameW(moduleFileName);
15 | ShellExecuteW(NULL, NULL, L"taskmgr", NULL, NULL, SW_SHOWNORMAL);
16 | wcout << "Test: view current process \"" << moduleFileName << "\" in Task Manager." << endl << endl
17 | << "Test ready. Waiting for a key to start..." << endl;
18 | (void)_getwch();
19 |
20 | SetGlobalWindowsHook();
21 | wcout << "Test started. Waiting for a key to stop..." << endl;
22 | (void)_getwch();
23 |
24 | UnhookGlobalWindowsHook();
25 | wcout << "Test stopped. Waiting for a key to quit..." << endl;
26 | (void)_getwch();
27 | }
--------------------------------------------------------------------------------
/std_container_helpers/set_helper.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Heade File: set_helper.h
3 | * Last Update: 2020/10/16
4 | *
5 | * Copyright (C) Hydr10n@GitHub. All Rights Reserved.
6 | */
7 |
8 | #pragma once
9 |
10 | #include
11 |
12 | namespace Hydr10n {
13 | namespace std_container_helpers {
14 | struct set_helper final {
15 | template ::key_compare, class Allocator = class std::set::allocator_type>
16 | static bool contains(const std::set& container, const T2& item) { return container.find(item) != container.cend(); }
17 |
18 | template ::key_compare, class Allocator = class std::set::allocator_type>
19 | static bool modify(std::set& container, const T2& item, bool remove) {
20 | const bool ret = contains(container, item) == remove;
21 | if (ret)
22 | if (remove)
23 | container.erase(item);
24 | else
25 | container.insert(item);
26 | return ret;
27 | }
28 | };
29 | }
30 | }
--------------------------------------------------------------------------------
/std_container_helpers/std_container_helpers.vcxitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | {192e25ed-926c-4c70-9d6a-700cf60712e6}
7 |
8 |
9 |
10 | %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/std_container_helpers/std_container_helpers.vcxitems.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {7180c36d-a6fd-472d-adff-6bf88bcf9a46}
6 |
7 |
8 |
9 |
10 | Header Files
11 |
12 |
13 |
--------------------------------------------------------------------------------