From 5752f401101168e5b789505f4e51b48b3a77f373 Mon Sep 17 00:00:00 2001 From: Antoniojose Figueroa Date: Fri, 8 Nov 2024 12:33:34 -0300 Subject: [PATCH 1/2] chore: add rule to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f552cdd..1ca0f39 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ obj *.layout *.bak *.zip +.vscode \ No newline at end of file From 1345ed9d30980fa592dc3c30d58628a3a3b78c93 Mon Sep 17 00:00:00 2001 From: Antoniojose Figueroa Date: Thu, 14 Nov 2024 11:06:38 -0300 Subject: [PATCH 2/2] fix: Add fast switch user to fix write password after waking up the pc --- persistent.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/persistent.cpp b/persistent.cpp index e79ac54..c6cccbb 100644 --- a/persistent.cpp +++ b/persistent.cpp @@ -220,12 +220,14 @@ PersistentSystemOptions PersistentSystemOptions::ReadSystemSettings() std::string system = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; std::string explorer = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; std::string power = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power"; + std::string only_system = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; + PersistentSystemOptions retval; retval.hasChangePassword = !ReadRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableChangePassword"), false); retval.hasLockComputer = !ReadRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableLockWorkstation"), false); retval.hasLogOff = !ReadRegistryKey(HKEY_USERS, _T(sid + explorer), _T("NoLogoff"), false); - retval.hasSwitchUser = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(sid + system), _T("HideFastUserSwitching"), false); + retval.hasSwitchUser = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(only_system), _T("HideFastUserSwitching"), false); retval.hasTaskManager = !ReadRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableTaskMgr"), false); retval.hasPower = !ReadRegistryKey(HKEY_USERS, _T(sid + explorer), _T("NoClose"), false); retval.hasFilterKeysHotkey = ReadFilterKeysHotkey(); @@ -233,7 +235,7 @@ PersistentSystemOptions PersistentSystemOptions::ReadSystemSettings() retval.hasStickyKeysHotkey = ReadStickyKeysHotkey(); retval.hasToggleKeysHotkey = ReadToggleKeysHotkey(); retval.hasHighContrastHotkey = ReadHighContrastHotkey(); - retval.hasFastBootHotKey = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(sid + power), _T("HiberbootEnabled"), false); + retval.hasFastBootHotKey = !ReadRegistryKey(HKEY_LOCAL_MACHINE, _T(power), _T("HiberbootEnabled"), false); return retval; } @@ -242,6 +244,7 @@ bool PersistentSystemOptions::WriteSystemSettings() const bool allWorked = true; char* sid = getSid(); std::string system = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; + std::string only_system = "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; std::string explorer = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"; std::string power = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power"; @@ -255,6 +258,11 @@ bool PersistentSystemOptions::WriteSystemSettings() const Tcout << _T("Error NoLogoff") << std::endl; } + /* if(!WriteRegistryKey(HKEY_LOCAL_MACHINE, _T(only_system), _T("HideFastUserSwitching"), !hasSwitchUser)) { + allWorked = false; + Tcout << _T("Error HideFastUserSwitching") << std::endl; + } */ + #ifndef DEBUG if(!WriteRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableTaskMgr"), !hasTaskManager)) { @@ -294,6 +302,11 @@ bool PersistentSystemOptions::WriteSystemSettings() const Tcout << _T("Error HighContrastHotkey") << std::endl; } + if(!WriteRegistryKey(HKEY_LOCAL_MACHINE, _T(power), _T("HiberbootEnabled"), hasFastBootHotKey)) { + allWorked = false; + Tcout << _T("Error FastBootHotKey") << std::endl; + } + return allWorked; }