diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f6b728..a34e1866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Usage: "RpcPortFilter=Port,ID,Label" label is optional - added "Job Object" Options page to colelct all job object related options - added UI options for "ForceRestartAll" and "UseCreateToken" in OptionWindow. +- added a optional context menu option to make folder/file forced quickly. + - You can also use "Sandman.exe /add_force program_path" to do it. ### Changed 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/SettingsWindow.ui b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui index 5adf1103..1d8f400c 100644 --- a/SandboxiePlus/SandMan/Forms/SettingsWindow.ui +++ b/SandboxiePlus/SandMan/Forms/SettingsWindow.ui @@ -6,8 +6,8 @@ 0 0 - 747 - 524 + 820 + 565 @@ -48,7 +48,7 @@ QTabWidget::North - 1 + 5 @@ -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 + + + @@ -1948,225 +1951,228 @@ Unlike the preview channel, it does not include untested, potentially breaking, - 1 + 0 Sandboxie Config - + - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Sandbox <a href="sbie://docs/keyrootpath">registry root</a>: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - - 75 - true - true - - - - Sandbox default - - - - - - - - - - - - - Sandbox <a href="sbie://docs/filerootpath">file system root</a>: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Default sandbox: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Activate Kernel Mode Object Filtering - - - - - - - - 75 - true - true - - - - Sandboxing features - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Hook selected Win32k system calls to enable GPU acceleration (experimental) - - - - - - - Use a Sandboxie login instead of an anonymous token - - - - - - - - - - Portable root folder - - - - - - - Sandbox <a href="sbie://docs/ipcrootpath">ipc root</a>: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 23 - 16777215 - - - - ... - - - - - - - Use Windows Filtering Platform to restrict network access - - - - - - - Add "Sandboxie\All Sandboxes" group to the sandboxed token (experimental) - - - - + + + + 75 + true + true + + + + Sandbox default + + + + + + + Default sandbox: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Portable root folder + + + + + + + Sandbox <a href="sbie://docs/filerootpath">file system root</a>: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + + 23 + 16777215 + + + + ... + + + + + + + Sandbox <a href="sbie://docs/keyrootpath">registry root</a>: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + Sandbox <a href="sbie://docs/ipcrootpath">ipc root</a>: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + + + 75 + true + true + + + + Sandboxing features + + + + + + + Qt::Horizontal + + + + 108 + 20 + + + + + + + + Use Windows Filtering Platform to restrict network access + + + + + + + Activate Kernel Mode Object Filtering + + + + + + + Hook selected Win32k system calls to enable GPU acceleration (experimental) + + + + + + + Use a Sandboxie login instead of an anonymous token + + + + + + + Add "Sandboxie\All Sandboxes" group to the sandboxed token (experimental) + + + + + + + Enhance the 3D gaming experience by releasing some system calls. + + + + + + + Qt::Horizontal + + + + 108 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 139 + + + + + + + + Qt::Horizontal + + + + 107 + 20 + + + + + + + + Qt::Horizontal + + + + 108 + 20 + + + 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/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index 91700bd7..11813784 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())); @@ -426,6 +427,7 @@ CSettingsWindow::CSettingsWindow(QWidget* parent) connect(ui.chkWin32k, SIGNAL(stateChanged(int)), this, SLOT(OnGeneralChanged())); connect(ui.chkSbieLogon, SIGNAL(stateChanged(int)), this, SLOT(OnGeneralChanged())); connect(ui.chkSbieAll, SIGNAL(stateChanged(int)), this, SLOT(OnGeneralChanged())); + connect(ui.chkImproveGame, SIGNAL(stateChanged(int)), this, SLOT(OnGeneralChanged())); m_GeneralChanged = false; connect(ui.chkWatchConfig, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged())); // not sbie ini @@ -891,6 +893,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)); @@ -1009,6 +1012,7 @@ void CSettingsWindow::LoadSettings() ui.chkWin32k->setChecked(theAPI->GetGlobalSettings()->GetBool("EnableWin32kHooks", true)); ui.chkSbieLogon->setChecked(theAPI->GetGlobalSettings()->GetBool("SandboxieLogon", false)); ui.chkSbieAll->setChecked(theAPI->GetGlobalSettings()->GetBool("SandboxieAllGroup", false)); + ui.chkImproveGame->setChecked(theAPI->GetGlobalSettings()->GetBool("Improve3DGameRate", false)); ui.chkAdminOnly->setChecked(theAPI->GetGlobalSettings()->GetBool("EditAdminOnly", false)); ui.chkAdminOnly->setEnabled(IsAdminUser()); @@ -1061,6 +1065,7 @@ void CSettingsWindow::LoadSettings() ui.chkWin32k->setEnabled(false); ui.chkSbieLogon->setEnabled(false); ui.chkSbieAll->setEnabled(false); + ui.chkImproveGame->setEnabled(false); ui.regRoot->setEnabled(false); ui.ipcRoot->setEnabled(false); ui.chkRamDisk->setEnabled(false); @@ -1598,7 +1603,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()); @@ -1703,6 +1716,7 @@ void CSettingsWindow::SaveSettings() WriteAdvancedCheck(ui.chkWin32k, "EnableWin32kHooks", "", "n"); WriteAdvancedCheck(ui.chkSbieLogon, "SandboxieLogon", "y", ""); WriteAdvancedCheck(ui.chkSbieAll, "SandboxieAllGroup", "y", ""); + WriteAdvancedCheck(ui.chkImproveGame, "Improve3DGameRate", "y", ""); if (m_FeaturesChanged) { m_FeaturesChanged = false; diff --git a/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp b/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp index 06f99ac3..63a13146 100644 --- a/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp +++ b/SandboxiePlus/SandMan/Wizards/SetupWizard.cpp @@ -135,6 +135,8 @@ bool CSetupWizard::ShowWizard(int iOldLevel) { if (wizard.field("editAdminOnly").toBool()) theAPI->GetGlobalSettings()->SetText("EditAdminOnly", "y"); + if (wizard.field("improveGame").toBool()) + theAPI->GetGlobalSettings()->SetText("Improve3DGameRate", "y"); } theConf->SetValue("Options/WizardLevel", SETUP_LVL_CURRENT); @@ -530,6 +532,11 @@ CShellPage::CShellPage(QWidget *parent) layout->addWidget(m_pEditOnlyAdmin); registerField("editAdminOnly", m_pEditOnlyAdmin); + m_pImproveGame = new QCheckBox(tr("Enhance the 3D gaming experience by releasing some system calls.")); + m_pImproveGame->setChecked(false); + layout->addWidget(m_pImproveGame); + registerField("improveGame", m_pImproveGame); + setLayout(layout); } diff --git a/SandboxiePlus/SandMan/Wizards/SetupWizard.h b/SandboxiePlus/SandMan/Wizards/SetupWizard.h index b3125f24..33a40879 100644 --- a/SandboxiePlus/SandMan/Wizards/SetupWizard.h +++ b/SandboxiePlus/SandMan/Wizards/SetupWizard.h @@ -123,6 +123,7 @@ private: QCheckBox *m_pContecxtMenu; QCheckBox *m_pBrowserIcon; QCheckBox* m_pEditOnlyAdmin; + QCheckBox* m_pImproveGame; }; ////////////////////////////////////////////////////////////////////////////////////////// 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!"));