From a41387ffe5fb971843afa9732944dba4fab69598 Mon Sep 17 00:00:00 2001 From: denis zolotoust Date: Wed, 10 Jul 2024 22:27:13 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrashFix.sln | 31 +++++++++ CrashFix.vcxproj | 135 +++++++++++++++++++++++++++++++++++++++ CrashFix.vcxproj.filters | 22 +++++++ Main.cpp | 57 +++++++++++++++++ 4 files changed, 245 insertions(+) create mode 100644 CrashFix.sln create mode 100644 CrashFix.vcxproj create mode 100644 CrashFix.vcxproj.filters create mode 100644 Main.cpp diff --git a/CrashFix.sln b/CrashFix.sln new file mode 100644 index 0000000..c729345 --- /dev/null +++ b/CrashFix.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35027.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrashFix", "CrashFix.vcxproj", "{03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Debug|x64.ActiveCfg = Debug|x64 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Debug|x64.Build.0 = Debug|x64 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Debug|x86.ActiveCfg = Debug|Win32 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Debug|x86.Build.0 = Debug|Win32 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Release|x64.ActiveCfg = Release|x64 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Release|x64.Build.0 = Release|x64 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Release|x86.ActiveCfg = Release|Win32 + {03DE769E-9E6D-4E39-8BA5-6D11CE3BAB97}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C586777F-2CD2-4A7B-8849-B4F2CA46E4F5} + EndGlobalSection +EndGlobal diff --git a/CrashFix.vcxproj b/CrashFix.vcxproj new file mode 100644 index 0000000..3be4578 --- /dev/null +++ b/CrashFix.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {03de769e-9e6d-4e39-8ba5-6d11ce3bab97} + CrashFix + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/CrashFix.vcxproj.filters b/CrashFix.vcxproj.filters new file mode 100644 index 0000000..63ea03e --- /dev/null +++ b/CrashFix.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..06b2aac --- /dev/null +++ b/Main.cpp @@ -0,0 +1,57 @@ +#include +#include +#include + +HHOOK hKeyboardHook; + +void RunExplorer() { + system("start explorer.exe"); +} + +void KillExplorer() { + system("taskkill /f /im explorer.exe"); +} + +LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { + if (nCode == HC_ACTION) { + KBDLLHOOKSTRUCT* pKeyboard = (KBDLLHOOKSTRUCT*)lParam; + + // + if (wParam == WM_KEYDOWN) { + // "+", Explorer.exe + if (pKeyboard->vkCode == VK_ADD) { + RunExplorer(); + } + // "-", Explorer.exe + else if (pKeyboard->vkCode == VK_SUBTRACT) { + KillExplorer(); + } + else if (((pKeyboard->vkCode == VK_RCONTROL) && (GetKeyState(VK_MULTIPLY) & 0x8000))) { + exit(0); + } + } + } + // + return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); +} + +int main() { + ShowWindow(GetConsoleWindow(), SW_HIDE); + // + hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0); + if (hKeyboardHook == NULL) { + return 1; + } + + // ( ) + MSG msg; + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + // + UnhookWindowsHookEx(hKeyboardHook); + + return 0; +}