Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove fastboot and switchuser #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ obj
*.layout
*.bak
*.zip
.vscode
17 changes: 15 additions & 2 deletions persistent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,22 @@ 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();
retval.hasMouseKeysHotkey = ReadMouseKeysHotkey();
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;
}

Expand All @@ -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";

Expand All @@ -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)) {
Expand Down Expand Up @@ -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;
}

Expand Down