diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b76f8f..b9a08a30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [1.1x.x / 5.xx.x] - 2024-07-0x + +### Added +- added UI options for "ForceRestartAll" and "UseCreateToken" in OptionWindow +- added an optional context menu option to make folder/file forced quickly + - You can also use "Sandman.exe /add_force program_path" to do it ## [1.14.4 / 5.69.4] - 2024-07-13 @@ -16,9 +22,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). - added hwid display - - - ## [1.14.3 / 5.69.3] - 2024-07-01 ### Changed @@ -49,8 +52,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). - added template "BlockLocalConnect" to prevent sandboxed processes from sending network packets to localhost to breakout sandbox - added new option "AllowCoverTaskbar" for [#3975](https://github.com/sandboxie-plus/Sandboxie/issues/3975) - added RPC Port message filter mechanism to block unsafe RDP calls via the driver [#3930](https://github.com/sandboxie-plus/Sandboxie/issues/3930) - - usage: "RpcPortFilter=Port,ID,Label" label is optional -- added "Job Object" options page to collect all job object related options + - Usage: "RpcPortFilter=Port,ID,Label" label is optional +- added "Job Object" Options page to colelct all job object related options + ### Changed - extend "Temp Template" to make it could delete local template section diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.cpp b/SandboxiePlus/QSbieAPI/SbieUtils.cpp index 0466b92c..5f389338 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.cpp +++ b/SandboxiePlus/QSbieAPI/SbieUtils.cpp @@ -487,6 +487,42 @@ void CSbieUtils::RemoveContextMenu2() RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\unbox"); } +bool CSbieUtils::HasContextMenu3() +{ + const wchar_t* key = L"Software\\Classes\\*\\shell\\addforce\\command"; + //const wchar_t* key2 = L"Software\\Classes\\*\\Folder\\addforce\\command"; + HKEY hkey,hKey2; + LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey); + if (rc != 0) + return false; + + RegCloseKey(hkey); + + + /*rc = RegOpenKeyEx(HKEY_CURRENT_USER, key2, 0, KEY_READ, &hkey2); + if (rc != 0) + return false; + + RegCloseKey(hkey2);*/ + + return true; +} + +void CSbieUtils::AddContextMenu3(const QString& StartPath, const QString& RunStr, const QString& IconPath) +{ + std::wstring start_path = L"\"" + StartPath.toStdWString() + L"\""; + std::wstring icon_path = L"\"" + (IconPath.isEmpty() ? StartPath : IconPath).toStdWString() + L"\""; + + CreateShellEntry(L"*", L"addforce", RunStr.toStdWString(), icon_path, start_path + L" /add_force \"%1\" %*"); + CreateShellEntry(L"Folder", L"addforce", RunStr.toStdWString(), icon_path, start_path + L" /add_force \"%1\" %*"); +} + +void CSbieUtils::RemoveContextMenu3() +{ + RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\addforce"); + RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\addforce"); +} + ////////////////////////////////////////////////////////////////////////////// // Shortcuts diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.h b/SandboxiePlus/QSbieAPI/SbieUtils.h index c0c38933..c3e858f7 100644 --- a/SandboxiePlus/QSbieAPI/SbieUtils.h +++ b/SandboxiePlus/QSbieAPI/SbieUtils.h @@ -36,6 +36,10 @@ public: static void AddContextMenu2(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString()); static void RemoveContextMenu2(); + static bool HasContextMenu3(); + static void AddContextMenu3(const QString& StartPath, const QString& RunStr, const QString& IconPath = QString()); + static void RemoveContextMenu3(); + static bool CreateShortcut(const QString& StartExe, QString LinkPath, const QString &LinkName, const QString &boxname, const QString &arguments, const QString &iconPath = QString(), int iconIndex = 0, const QString &workdir = QString(), bool bRunElevated = false); static bool GetStartMenuShortcut(class CSbieAPI* pApi, QString &BoxName, QString &LinkPath, QString &IconPath, quint32& IconIndex, QString &WorkDir); diff --git a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui index f695af58..4b99832a 100644 --- a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui +++ b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui @@ -45,7 +45,7 @@ QTabWidget::North - 5 + 9 @@ -1095,7 +1095,7 @@ - 3 + 4 @@ -1739,7 +1739,7 @@ - + Qt::Horizontal @@ -1769,6 +1769,13 @@ + + + + Create a new sandboxed token instead of setting down default token + + + @@ -4089,7 +4096,14 @@ The process match level has a higher priority than the specificity and describes - + + + + Restart force process before they begin to execute + + + + Qt::Vertical @@ -4130,7 +4144,7 @@ The process match level has a higher priority than the specificity and describes - + Qt::Horizontal @@ -5079,8 +5093,8 @@ instead of "*". 0 0 - 98 - 28 + 75 + 16 diff --git a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui index 5adf1103..07c9ee6b 100644 --- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui +++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui @@ -6,8 +6,8 @@ 0 0 - 747 - 524 + 820 + 565 @@ -455,191 +455,194 @@ Windows Shell - + - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - Integrate with Host Start Menu - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Add 'Run Sandboxed' to the explorer context menu - - - - - - - Add 'Run Un-Sandboxed' to the context menu - - - - - - - Always use DefaultBox - - - - - - - - - - Integrate with Host Desktop - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Start UI when a sandboxed process is started - - - - - - - Scan shell folders and offer links in run menu - - - - - - - - - - Start UI with Windows - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - true - - - - Start Menu Integration - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - - 20 - 16777215 - - - - - - - - - - - - 75 - true - true - - - - Start Sandbox Manager - - - - - - - - 75 - true - true - - - - Run Sandboxed - Actions - - - - + + + + 75 + true + true + + + + Start Sandbox Manager + + + + + + + Start UI with Windows + + + + + + + Start UI when a sandboxed process is started + + + + + + + + 75 + true + true + + + + Run Sandboxed - Actions + + + + + + + + 20 + 16777215 + + + + + + + + + + + Qt::Horizontal + + + + 272 + 20 + + + + + + + + Qt::Horizontal + + + + 272 + 20 + + + + + + + + Add 'Run Sandboxed' to the explorer context menu + + + + + + + Always use DefaultBox + + + + + + + Add 'Run Un-Sandboxed' to the context menu + + + + + + + Add ‘Make Folder/File Forced' to the context menu + + + + + + + + 75 + true + true + + + + Start Menu Integration + + + + + + + Scan shell folders and offer links in run menu + + + + + + + Integrate with Host Start Menu + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + Integrate with Host Desktop + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 154 + + + + + + + + Qt::Horizontal + + + + 272 + 13 + + + diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 4e7937e9..fc68adc8 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -1636,6 +1636,30 @@ void CSandMan::OnMessage(const QString& MsgData) setWindowState(Qt::WindowActive); SetForegroundWindow(MainWndHandle); } + else if (Message.left(4) == "Add:") + { + + + QString respone = QInputDialog::getText(g_GUIParent, tr("Which box you want to add in?"), tr("Type the box name which you are going to set:")); + if(!respone.isEmpty()) + { + if (theAPI->GetBoxByName(respone) != NULL) { + if (Message.right(1)=="\\"||!Message.contains(".", Qt::CaseInsensitive)) { + theAPI->GetBoxByName(respone)->AppendText("ForceFolder", Message.mid(4).replace("\"","")); + } + else { + theAPI->GetBoxByName(respone)->AppendText("ForceProcess", Message.mid(4).replace("\"", "").mid(Message.mid(4).replace("\"", "").lastIndexOf("\\")+1)); + + } + } + else { + QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("You typed a wrong box name!Nothing was changed."), QMessageBox::Ok, 0); + } + } + else { + QMessageBox::warning(g_GUIParent, tr("Sandboxie-Plus Warning"), tr("Users canceled this operation."), QMessageBox::Yes, 0); + } + } else if (Message.left(4) == "Run:") { QString BoxName; diff --git a/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp b/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp index a726d435..3811b5d9 100644 --- a/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp +++ b/SandboxiePlus/SandMan/Windows/OptionsAdvanced.cpp @@ -30,6 +30,8 @@ void COptionsWindow::CreateAdvanced() connect(ui.chkOpenCOM, SIGNAL(clicked(bool)), this, SLOT(OnOpenCOM())); connect(ui.chkComTimeout, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged())); + connect(ui.chkForceRestart, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged())); + connect(ui.chkNoSecurityIsolation, SIGNAL(clicked(bool)), this, SLOT(OnIsolationChanged())); connect(ui.chkNoSecurityFiltering, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged())); @@ -39,7 +41,7 @@ void COptionsWindow::CreateAdvanced() connect(ui.chkOpenLsaEndpoint, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged())); connect(ui.chkSbieLogon, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged())); - + connect(ui.chkCreateToken, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged())); m_AdvOptions.insert("UseWin32kHooks", SAdvOption{eSpec, QStringList() << "y" << "n", tr("Enable the use of win32 hooks for selected processes. Note: You need to enable win32k syscall hook support globally first.")}); m_AdvOptions.insert("EnableMiniDump", SAdvOption{eSpec, QStringList() << "y" << "n", tr("Enable crash dump creation in the sandbox folder")}); @@ -142,6 +144,8 @@ void COptionsWindow::LoadAdvanced() ui.chkProtectSystem->setChecked(!m_pBox->GetBool("ExposeBoxedSystem", false)); ui.chkDropPrivileges->setChecked(m_pBox->GetBool("StripSystemPrivileges", true)); + ui.chkForceRestart->setChecked(m_pBox->GetBool("ForceRestartAll", false)); + CheckOpenCOM(); ui.chkComTimeout->setChecked(!m_pBox->GetBool("RpcMgmtSetComTimeout", true)); @@ -373,6 +377,8 @@ void COptionsWindow::SaveAdvanced() WriteAdvancedCheck(ui.chkComTimeout, "RpcMgmtSetComTimeout", "n", ""); + WriteAdvancedCheck(ui.chkForceRestart, "ForceRestartAll", "y", ""); + WriteAdvancedCheck(ui.chkNoSecurityIsolation, "NoSecurityIsolation", "y", ""); WriteAdvancedCheck(ui.chkNoSecurityFiltering, "NoSecurityFiltering", "y", ""); @@ -426,6 +432,9 @@ void COptionsWindow::SaveAdvanced() bool bGlobalSbieLogon = m_pBox->GetAPI()->GetGlobalSettings()->GetBool("SandboxieLogon", false); WriteAdvancedCheck(ui.chkSbieLogon, "SandboxieLogon", bGlobalSbieLogon ? "" : "y", bGlobalSbieLogon ? "n" : ""); + bool bGlobalSandboxGroup = m_pBox->GetAPI()->GetGlobalSettings()->GetBool("SandboxieAllGroup", false); + WriteAdvancedCheck(ui.chkCreateToken, "UseCreateToken", bGlobalSandboxGroup ? "" : "y", ""); + SaveOptionList(); bool bGlobalNoMon = m_pBox->GetAPI()->GetGlobalSettings()->GetBool("DisableResourceMonitor", false); @@ -595,14 +604,16 @@ void COptionsWindow::UpdateBoxIsolation() ui.chkNoOpenForBox->setEnabled(!ui.chkNoSecurityIsolation->isChecked()); ui.chkSbieLogon->setEnabled(!ui.chkNoSecurityIsolation->isChecked()); - + ui.chkCreateToken->setEnabled(!ui.chkNoSecurityIsolation->isChecked()); if (ui.chkNoSecurityIsolation->isChecked()) { ui.chkCloseForBox->setChecked(false); ui.chkNoOpenForBox->setChecked(false); ui.chkSbieLogon->setChecked(false); + ui.chkCreateToken->setChecked(false); } else { ReadGlobalCheck(ui.chkSbieLogon, "SandboxieLogon", false); + ReadGlobalCheck(ui.chkCreateToken, "UseCreateToken", false); } } diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index 91700bd7..c2f98f8e 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -331,7 +331,8 @@ CSettingsWindow::CSettingsWindow(QWidget* parent) connect(ui.chkShellMenu, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); connect(ui.chkAlwaysDefault, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); connect(ui.chkShellMenu2, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); - + connect(ui.chkShellMenu3, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); + connect(ui.chkScanMenu, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); connect(ui.cmbIntegrateMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged())); connect(ui.cmbIntegrateDesk, SIGNAL(currentIndexChanged(int)), this, SLOT(OnOptChanged())); @@ -891,6 +892,7 @@ void CSettingsWindow::LoadSettings() ui.chkShellMenu->setCheckState(IsContextMenu()); ui.chkShellMenu2->setChecked(CSbieUtils::HasContextMenu2()); + ui.chkShellMenu3->setChecked(CSbieUtils::HasContextMenu3()); ui.chkAlwaysDefault->setChecked(theConf->GetBool("Options/RunInDefaultBox", false)); ui.cmbDPI->setCurrentIndex(theConf->GetInt("Options/DPIScaling", 1)); @@ -1598,7 +1600,15 @@ void CSettingsWindow::SaveSettings() } else CSbieUtils::RemoveContextMenu2(); } - + if (ui.chkShellMenu3->isChecked() != CSbieUtils::HasContextMenu3()) { + if (ui.chkShellMenu3->isChecked()) { + CSbieUtils::AddContextMenu3(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe", + tr("Make Folder/File &Forced"), + QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe"); + } + else + CSbieUtils::RemoveContextMenu3(); + } theConf->SetValue("Options/RunInDefaultBox", ui.chkAlwaysDefault->isChecked()); theConf->SetValue("Options/CheckSilentMode", ui.chkSilentMode->isChecked()); diff --git a/SandboxiePlus/SandMan/main.cpp b/SandboxiePlus/SandMan/main.cpp index ce5d1baa..6d1f88c2 100644 --- a/SandboxiePlus/SandMan/main.cpp +++ b/SandboxiePlus/SandMan/main.cpp @@ -111,7 +111,14 @@ int main(int argc, char *argv[]) } } int DfpPos = Args.indexOf("/disable_force", Qt::CaseInsensitive); - // the first argument wins + int AfpPos = Args.indexOf("/add_force", Qt::CaseInsensitive); + + //Add_Force has the highest priority. + if (AfpPos != -1) { + DfpPos = -1; + BoxPos = -1; + }else + // the first argument wins if (BoxPos != -1 && DfpPos != -1) { if (BoxPos < DfpPos) DfpPos = -1; else BoxPos = -1; @@ -158,7 +165,13 @@ int main(int argc, char *argv[]) g_PendingMessage += "\nIn:*DFP*"; } + if (AfpPos != -1) { + LPWSTR cmdLine0 = wcsstr(GetCommandLineW(), L"/add_force"); + if (!cmdLine0) return -1; + LPWSTR cmdLine = cmdLine0 + 10; + g_PendingMessage = "Add:" + QString::fromWCharArray(cmdLine + 1); + } if (IsBoxed) { QMessageBox::critical(NULL, "Sandboxie-Plus", CSandMan::tr("Sandboxie Manager can not be run sandboxed!"));