Обновление первой версии: https://lolz.live/threads/9031810/ Сделал список папок доступным везде, чтобы можно было менять их права не только в главном коде, но и при нажатии клавиш. Добавил функцию для возврата прав на папки — теперь можно снять блокировку и снова открыть доступ. Изменил обработку клавиш: Нажал Q + W + E → программа перестаёт блокировать и возвращает доступ к папкам. Нажал R + T + Y → программа снова начинает блокировать всё. Теперь при отключении (QWE) всё сразу разблокируется, а не просто перестаёт блокироваться дальше CODE #include <windows.h> #include <tlhelp32.h> #include <psapi.h> #include <string> #include <vector> #include <aclapi.h> #include <shlobj.h> #include <conio.h> #pragma comment(lib, "Advapi32.lib") #pragma comment(lib, "Psapi.lib") #pragma comment(lib, "Shell32.lib") #pragma comment(lib, "Version.lib") bool active = true; std::vector<std::wstring> blockPaths; bool KillProcessByName(const std::wstring &processName) { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return false; PROCESSENTRY32W pe; pe.dwSize = sizeof(pe); if (Process32FirstW(hSnapshot, &pe)) { do { if (_wcsicmp(pe.szExeFile, processName.c_str()) == 0) { HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID); if (hProcess) { TerminateProcess(hProcess, 1); CloseHandle(hProcess); } } } while (Process32NextW(hSnapshot, &pe)); } CloseHandle(hSnapshot); return true; } bool KillProcessByDescription(const std::wstring &descKeyword) { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return false; PROCESSENTRY32W pe; pe.dwSize = sizeof(pe); if (Process32FirstW(hSnapshot, &pe)) { do { HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, pe.th32ProcessID); if (hProcess) { WCHAR exePath[MAX_PATH]; if (GetModuleFileNameExW(hProcess, NULL, exePath, MAX_PATH)) { DWORD verHandle = 0; DWORD verSize = GetFileVersionInfoSizeW(exePath, &verHandle); if (verSize) { std::vector<BYTE> verData(verSize); if (GetFileVersionInfoW(exePath, verHandle, verSize, verData.data())) { LPVOID lpBuffer = NULL; UINT size = 0; if (VerQueryValueW(verData.data(), L"\\StringFileInfo\\040904b0\\FileDescription", &lpBuffer, &size)) { std::wstring fileDesc((wchar_t*)lpBuffer, size); if (fileDesc.find(descKeyword) != std::wstring::npos) { TerminateProcess(hProcess, 1); } } } } } CloseHandle(hProcess); } } while (Process32NextW(hSnapshot, &pe)); } CloseHandle(hSnapshot); return true; } bool DenyAllAccess(const std::wstring &path) { EXPLICIT_ACCESSW ea{}; PACL pACL = NULL; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; PSID pEveryoneSID = NULL; AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID); ZeroMemory(&ea, sizeof(EXPLICIT_ACCESSW)); ea.grfAccessPermissions = GENERIC_ALL; ea.grfAccessMode = DENY_ACCESS; ea.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT; ea.Trustee.TrusteeForm = TRUSTEE_IS_SID; ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; ea.Trustee.ptstrName = (LPWSTR)pEveryoneSID; SetEntriesInAclW(1, &ea, NULL, &pACL); SetNamedSecurityInfoW((LPWSTR)path.c_str(), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pACL, NULL); if (pACL) LocalFree(pACL); if (pEveryoneSID) FreeSid(pEveryoneSID); return true; } bool AllowAllAccess(const std::wstring &path) { EXPLICIT_ACCESSW ea{}; PACL pACL = NULL; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; PSID pEveryoneSID = NULL; AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID); ZeroMemory(&ea, sizeof(EXPLICIT_ACCESSW)); ea.grfAccessPermissions = GENERIC_ALL; ea.grfAccessMode = GRANT_ACCESS; ea.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT; ea.Trustee.TrusteeForm = TRUSTEE_IS_SID; ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; ea.Trustee.ptstrName = (LPWSTR)pEveryoneSID; SetEntriesInAclW(1, &ea, NULL, &pACL); SetNamedSecurityInfoW((LPWSTR)path.c_str(), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pACL, NULL); if (pACL) LocalFree(pACL); if (pEveryoneSID) FreeSid(pEveryoneSID); return true; } void CloseAccessDeniedWindows() { HWND hwnd = FindWindowW(NULL, L"Отказано в доступе"); if (hwnd) { PostMessage(hwnd, WM_CLOSE, 0, 0); } } std::wstring GetRecentFolderPath() { wchar_t path[MAX_PATH]; if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_RECENT, NULL, 0, path))) { return std::wstring(path); } return L""; } DWORD WINAPI KeyMonitorThread(LPVOID) { while (true) { // Disable blocking + restore access if (GetAsyncKeyState('Q') & 0x8000 && GetAsyncKeyState('W') & 0x8000 && GetAsyncKeyState('E') & 0x8000) { active = false; for (const auto &p : blockPaths) { if (!p.empty()) AllowAllAccess(p); } } if (GetAsyncKeyState('R') & 0x8000 && GetAsyncKeyState('T') & 0x8000 && GetAsyncKeyState('Y') & 0x8000) { active = true; } Sleep(100); } return 0; } int main() { HWND hwnd = GetConsoleWindow(); ShowWindow(hwnd, SW_HIDE); blockPaths = { L"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive", L"C:\\Program Files (x86)\\Steam\\steamapps\\common", L"C:\\Program Files (x86)\\Steam\\userdata", L"C:\\Program Files (x86)\\Steam\\config", GetRecentFolderPath() }; CreateThread(NULL, 0, KeyMonitorThread, NULL, 0, NULL); std::vector<std::wstring> blockProcesses = { L"ProcessHacker.exe", L"SystemInformer.exe", L"AnyDesk.exe", L"Everything.exe", L"ExecutedProgramsList.exe", L"LastActivityView.exe", L"USBDeview.exe", L"USBDeview32.exe", L"USBDriveLog.exe", L"USBDeview64.exe", L"UserAssistView.exe", L"CheatChecker.exe", L"regedit.exe" }; while (true) { if (active) { for (const auto &p : blockPaths) { if (!p.empty()) DenyAllAccess(p); } for (const auto &proc : blockProcesses) { KillProcessByName(proc); } KillProcessByDescription(L"ShellBag AnalyZer & Cleaner"); KillProcessByDescription(L"CheatChecker"); HWND h = FindWindowW(L"CabinetWClass", NULL); if (h) { wchar_t title[260]; GetWindowTextW(h, title, 260); if (wcsstr(title, L"Recent") || wcsstr(title, L"Недавние")) { PostMessage(h, WM_CLOSE, 0, 0); } } CloseAccessDeniedWindows(); } Sleep(1000); } return 0; } Код #include <windows.h> #include <tlhelp32.h> #include <psapi.h> #include <string> #include <vector> #include <aclapi.h> #include <shlobj.h> #include <conio.h> #pragma comment(lib, "Advapi32.lib") #pragma comment(lib, "Psapi.lib") #pragma comment(lib, "Shell32.lib") #pragma comment(lib, "Version.lib") bool active = true; std::vector<std::wstring> blockPaths; bool KillProcessByName(const std::wstring &processName) { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return false; PROCESSENTRY32W pe; pe.dwSize = sizeof(pe); if (Process32FirstW(hSnapshot, &pe)) { do { if (_wcsicmp(pe.szExeFile, processName.c_str()) == 0) { HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID); if (hProcess) { TerminateProcess(hProcess, 1); CloseHandle(hProcess); } } } while (Process32NextW(hSnapshot, &pe)); } CloseHandle(hSnapshot); return true; } bool KillProcessByDescription(const std::wstring &descKeyword) { HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return false; PROCESSENTRY32W pe; pe.dwSize = sizeof(pe); if (Process32FirstW(hSnapshot, &pe)) { do { HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, pe.th32ProcessID); if (hProcess) { WCHAR exePath[MAX_PATH]; if (GetModuleFileNameExW(hProcess, NULL, exePath, MAX_PATH)) { DWORD verHandle = 0; DWORD verSize = GetFileVersionInfoSizeW(exePath, &verHandle); if (verSize) { std::vector<BYTE> verData(verSize); if (GetFileVersionInfoW(exePath, verHandle, verSize, verData.data())) { LPVOID lpBuffer = NULL; UINT size = 0; if (VerQueryValueW(verData.data(), L"\\StringFileInfo\\040904b0\\FileDescription", &lpBuffer, &size)) { std::wstring fileDesc((wchar_t*)lpBuffer, size); if (fileDesc.find(descKeyword) != std::wstring::npos) { TerminateProcess(hProcess, 1); } } } } } CloseHandle(hProcess); } } while (Process32NextW(hSnapshot, &pe)); } CloseHandle(hSnapshot); return true; } bool DenyAllAccess(const std::wstring &path) { EXPLICIT_ACCESSW ea{}; PACL pACL = NULL; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; PSID pEveryoneSID = NULL; AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID); ZeroMemory(&ea, sizeof(EXPLICIT_ACCESSW)); ea.grfAccessPermissions = GENERIC_ALL; ea.grfAccessMode = DENY_ACCESS; ea.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT; ea.Trustee.TrusteeForm = TRUSTEE_IS_SID; ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; ea.Trustee.ptstrName = (LPWSTR)pEveryoneSID; SetEntriesInAclW(1, &ea, NULL, &pACL); SetNamedSecurityInfoW((LPWSTR)path.c_str(), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pACL, NULL); if (pACL) LocalFree(pACL); if (pEveryoneSID) FreeSid(pEveryoneSID); return true; } bool AllowAllAccess(const std::wstring &path) { EXPLICIT_ACCESSW ea{}; PACL pACL = NULL; SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY; PSID pEveryoneSID = NULL; AllocateAndInitializeSid(&SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pEveryoneSID); ZeroMemory(&ea, sizeof(EXPLICIT_ACCESSW)); ea.grfAccessPermissions = GENERIC_ALL; ea.grfAccessMode = GRANT_ACCESS; ea.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT; ea.Trustee.TrusteeForm = TRUSTEE_IS_SID; ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; ea.Trustee.ptstrName = (LPWSTR)pEveryoneSID; SetEntriesInAclW(1, &ea, NULL, &pACL); SetNamedSecurityInfoW((LPWSTR)path.c_str(), SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pACL, NULL); if (pACL) LocalFree(pACL); if (pEveryoneSID) FreeSid(pEveryoneSID); return true; } void CloseAccessDeniedWindows() { HWND hwnd = FindWindowW(NULL, L"Отказано в доступе"); if (hwnd) { PostMessage(hwnd, WM_CLOSE, 0, 0); } } std::wstring GetRecentFolderPath() { wchar_t path[MAX_PATH]; if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_RECENT, NULL, 0, path))) { return std::wstring(path); } return L""; } DWORD WINAPI KeyMonitorThread(LPVOID) { while (true) { // Disable blocking + restore access if (GetAsyncKeyState('Q') & 0x8000 && GetAsyncKeyState('W') & 0x8000 && GetAsyncKeyState('E') & 0x8000) { active = false; for (const auto &p : blockPaths) { if (!p.empty()) AllowAllAccess(p); } } if (GetAsyncKeyState('R') & 0x8000 && GetAsyncKeyState('T') & 0x8000 && GetAsyncKeyState('Y') & 0x8000) { active = true; } Sleep(100); } return 0; } int main() { HWND hwnd = GetConsoleWindow(); ShowWindow(hwnd, SW_HIDE); blockPaths = { L"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive", L"C:\\Program Files (x86)\\Steam\\steamapps\\common", L"C:\\Program Files (x86)\\Steam\\userdata", L"C:\\Program Files (x86)\\Steam\\config", GetRecentFolderPath() }; CreateThread(NULL, 0, KeyMonitorThread, NULL, 0, NULL); std::vector<std::wstring> blockProcesses = { L"ProcessHacker.exe", L"SystemInformer.exe", L"AnyDesk.exe", L"Everything.exe", L"ExecutedProgramsList.exe", L"LastActivityView.exe", L"USBDeview.exe", L"USBDeview32.exe", L"USBDriveLog.exe", L"USBDeview64.exe", L"UserAssistView.exe", L"CheatChecker.exe", L"regedit.exe" }; while (true) { if (active) { for (const auto &p : blockPaths) { if (!p.empty()) DenyAllAccess(p); } for (const auto &proc : blockProcesses) { KillProcessByName(proc); } KillProcessByDescription(L"ShellBag AnalyZer & Cleaner"); KillProcessByDescription(L"CheatChecker"); HWND h = FindWindowW(L"CabinetWClass", NULL); if (h) { wchar_t title[260]; GetWindowTextW(h, title, 260); if (wcsstr(title, L"Recent") || wcsstr(title, L"Недавние")) { PostMessage(h, WM_CLOSE, 0, 0); } } CloseAccessDeniedWindows(); } Sleep(1000); } return 0; }