From 5ea9da147b9b82c9ccc9381bca506c12a130abe4 Mon Sep 17 00:00:00 2001 From: love-code-yeyixiao <188240888@qq.com> Date: Fri, 17 May 2024 22:09:04 +0800 Subject: [PATCH] 1.14.0 --- SandboxiePlus/QSbieAPI/SbieAPI.cpp | 63 ++++---- SandboxiePlus/QSbieAPI/SbieAPI.h | 1 + .../SandMan/Forms/SelectBoxWindow.ui | 149 +++++++++--------- SandboxiePlus/SandMan/SandMan.cpp | 9 +- SandboxiePlus/SandMan/SandMan.h | 1 + SandboxiePlus/SandMan/SbiePlusAPI.cpp | 5 + SandboxiePlus/SandMan/SbiePlusAPI.h | 4 +- .../SandMan/Windows/SelectBoxWindow.cpp | 18 ++- 8 files changed, 139 insertions(+), 111 deletions(-) diff --git a/SandboxiePlus/QSbieAPI/SbieAPI.cpp b/SandboxiePlus/QSbieAPI/SbieAPI.cpp index 8974e888..0fd2b49c 100644 --- a/SandboxiePlus/QSbieAPI/SbieAPI.cpp +++ b/SandboxiePlus/QSbieAPI/SbieAPI.cpp @@ -1030,15 +1030,21 @@ QString CSbieAPI::GetUserSection(QString* pUserName, bool* pIsAdmin) const } SB_RESULT(quint32) CSbieAPI::RunStart(const QString& BoxName, const QString& Command, bool Elevated, const QString& WorkingDir, QProcess* pProcess) +{ + return RunStart(BoxName, Command, Elevated, WorkingDir, false, pProcess); +} +SB_RESULT(quint32) CSbieAPI::RunStart(const QString& BoxName, const QString& Command, bool Elevated, const QString& WorkingDir,bool isFCP, QProcess* pProcess) { if (m_SbiePath.isEmpty()) return SB_ERR(SB_PathFail); QString StartArgs; - if(Elevated) + if (Elevated) StartArgs += "/elevated "; if (!BoxName.isEmpty()) StartArgs += "/box:" + BoxName + " "; + if (isFCP) + StartArgs += "/fcp "; else StartArgs += "/disable_force "; @@ -1055,7 +1061,7 @@ SB_RESULT(quint32) CSbieAPI::RunStart(const QString& BoxName, const QString& Com pProcess->setNativeArguments(StartArgs); pProcess->start(); pid = pProcess->processId(); - } + } else { QProcess process; //process.setWorkingDirectory(QString::fromWCharArray(sysPath)); @@ -1069,42 +1075,41 @@ SB_RESULT(quint32) CSbieAPI::RunStart(const QString& BoxName, const QString& Com /* QString CommandLine = "\"" + GetStartPath() + "\" " + StartArgs; - STARTUPINFO si; - PROCESS_INFORMATION pi; - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); + STARTUPINFO si; + PROCESS_INFORMATION pi; + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); - // Start the child process. - if( !CreateProcessW( NULL, // No module name (use command line) - (wchar_t*)CommandLine.toStdWString().c_str(), // Command line - NULL, // Process handle not inheritable - NULL, // Thread handle not inheritable - FALSE, // Set handle inheritance to FALSE - 0, // No creation flags - NULL, // Use parent's environment block - NULL, // Use parent's starting directory - &si, // Pointer to STARTUPINFO structure - &pi ) // Pointer to PROCESS_INFORMATION structure - ) - { - printf( "CreateProcess failed (%d).\n", GetLastError() ); + // Start the child process. + if( !CreateProcessW( NULL, // No module name (use command line) + (wchar_t*)CommandLine.toStdWString().c_str(), // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi ) // Pointer to PROCESS_INFORMATION structure + ) + { + printf( "CreateProcess failed (%d).\n", GetLastError() ); return SB_ERR(); - } + } - // Wait until child process exits. - //WaitForSingleObject( pi.hProcess, INFINITE ); + // Wait until child process exits. + //WaitForSingleObject( pi.hProcess, INFINITE ); - // Close process and thread handles. - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); + // Close process and thread handles. + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); */ - if(pid == 0) + if (pid == 0) return SB_ERR(); return CSbieResult((quint32)pid); } - QString CSbieAPI::GetStartPath() const { return m_SbiePath + "\\" + QString::fromWCharArray(SBIESTART_EXE); diff --git a/SandboxiePlus/QSbieAPI/SbieAPI.h b/SandboxiePlus/QSbieAPI/SbieAPI.h index 9287befa..9ed161c3 100644 --- a/SandboxiePlus/QSbieAPI/SbieAPI.h +++ b/SandboxiePlus/QSbieAPI/SbieAPI.h @@ -152,6 +152,7 @@ public: virtual QString GetSbieMsgStr(quint32 code, quint32 Lang = 1033); virtual SB_RESULT(quint32) RunStart(const QString& BoxName, const QString& Command, bool Elevated = false, const QString& WorkingDir = QString(), QProcess* pProcess = NULL); + virtual SB_RESULT(quint32) RunStart(const QString& BoxName, const QString& Command, bool Elevated = false, const QString& WorkingDir = QString(), bool isFCP,QProcess* pProcess = NULL); virtual QString GetStartPath() const; virtual quint32 GetSessionID() const; diff --git a/SandboxiePlus/SandMan/Forms/SelectBoxWindow.ui b/SandboxiePlus/SandMan/Forms/SelectBoxWindow.ui index 0f31c89a..7034a91d 100644 --- a/SandboxiePlus/SandMan/Forms/SelectBoxWindow.ui +++ b/SandboxiePlus/SandMan/Forms/SelectBoxWindow.ui @@ -6,8 +6,8 @@ 0 0 - 263 - 430 + 278 + 475 @@ -31,77 +31,80 @@ SandboxiePlus select box - - - - - - - Qt::Horizontal - - - - - - - Run Sandboxed - - - true - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - Sandbox - - - - - - - - Run Outside the Sandbox - - - - - - - Run As UAC Administrator - - - - - - - Select the sandbox in which to start the program, installer or document. - - - true - - - - - - - Run in a new Sandbox - - - false - - - - + + + + + + Sandbox + + + + + + + + Run Outside the Sandbox + + + + + + + Qt::Horizontal + + + + + + + Select the sandbox in which to start the program, installer or document. + + + true + + + + + + + Run in a new Sandbox + + + false + + + + + + + Run As UAC Administrator + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Run Sandboxed + + + true + + + + + + + Run Unsandboxed with ForceChildProcess + + diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 92fbb5f6..aef36318 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -1696,18 +1696,21 @@ bool CSandMan::RunSandboxed(const QStringList& Commands, QString BoxName, const } SB_RESULT(quint32) CSandMan::RunStart(const QString& BoxName, const QString& Command, bool Elevated, const QString& WorkingDir, QProcess* pProcess) +{ + return RunStart(BoxName, Command, Elevated, WorkingDir, false, pProcess); +} +SB_RESULT(quint32) CSandMan::RunStart(const QString& BoxName, const QString& Command, bool Elevated, const QString& WorkingDir,bool isFCP, QProcess* pProcess) { auto pBoxEx = theAPI->GetBoxByName(BoxName).objectCast(); - if (pBoxEx && pBoxEx->UseImageFile() && pBoxEx->GetMountRoot().isEmpty()){ + if (pBoxEx && pBoxEx->UseImageFile() && pBoxEx->GetMountRoot().isEmpty()) { SB_STATUS Status = ImBoxMount(pBoxEx, true); if (Status.IsError()) return Status; } - return theAPI->RunStart(BoxName, Command, Elevated, WorkingDir, pProcess); + return theAPI->RunStart(BoxName, Command, Elevated, WorkingDir,isFCP, pProcess); } - SB_STATUS CSandMan::ImBoxMount(const CSandBoxPtr& pBox, bool bAutoUnmount) { auto pBoxEx = pBox.objectCast(); diff --git a/SandboxiePlus/SandMan/SandMan.h b/SandboxiePlus/SandMan/SandMan.h index c5f84d00..2c2c7d11 100644 --- a/SandboxiePlus/SandMan/SandMan.h +++ b/SandboxiePlus/SandMan/SandMan.h @@ -92,6 +92,7 @@ public: bool RunSandboxed(const QStringList& Commands, QString BoxName = QString(), const QString& WrkDir = QString()); SB_RESULT(quint32) RunStart(const QString& BoxName, const QString& Command, bool Elevated = false, const QString& WorkingDir = QString(), QProcess* pProcess = NULL); + SB_RESULT(quint32) RunStart(const QString& BoxName, const QString& Command, bool Elevated = false, const QString& WorkingDir = QString(), bool isFCP,QProcess* pProcess = NULL); SB_STATUS ImBoxMount(const CSandBoxPtr& pBox, bool bAutoUnmount = false); void EditIni(const QString& IniPath, bool bPlus = false); diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.cpp b/SandboxiePlus/SandMan/SbiePlusAPI.cpp index 7d0d4239..190cfe39 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.cpp +++ b/SandboxiePlus/SandMan/SbiePlusAPI.cpp @@ -93,6 +93,11 @@ void CSbiePlusAPI::StopMonitor() } SB_RESULT(quint32) CSbiePlusAPI::RunStart(const QString& BoxName, const QString& Command, bool Elevated, const QString& WorkingDir, QProcess* pProcess) +{ + + return RunStart(BoxName,Command,Elevated,WorkingDir,false,pProcess); +} +SB_RESULT(quint32) CSbiePlusAPI::RunStart(const QString& BoxName, const QString& Command, bool Elevated, const QString& WorkingDir, bool isFCP,QProcess* pProcess) { if (!pProcess) pProcess = new QProcess(this); diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.h b/SandboxiePlus/SandMan/SbiePlusAPI.h index 87c9404b..2a6e44c6 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.h +++ b/SandboxiePlus/SandMan/SbiePlusAPI.h @@ -32,7 +32,7 @@ public: virtual void StopMonitor(); virtual SB_RESULT(quint32) RunStart(const QString& BoxName, const QString& Command, bool Elevated = false, const QString& WorkingDir = QString(), QProcess* pProcess = NULL); - + virtual SB_RESULT(quint32) RunStart(const QString& BoxName, const QString& Command, bool Elevated = false, const QString& WorkingDir = QString(), bool isFCP,QProcess* pProcess = NULL); virtual bool IsStarting(qint64 pid) const { return m_PendingStarts.contains(pid); } private slots: @@ -280,4 +280,4 @@ protected: void CollectUpdates(); QList m_Updates; -}; \ No newline at end of file +}; diff --git a/SandboxiePlus/SandMan/Windows/SelectBoxWindow.cpp b/SandboxiePlus/SandMan/Windows/SelectBoxWindow.cpp index 2a8b5df6..a34f461a 100644 --- a/SandboxiePlus/SandMan/Windows/SelectBoxWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SelectBoxWindow.cpp @@ -186,6 +186,7 @@ CSelectBoxWindow::CSelectBoxWindow(const QStringList& Commands, const QString& B connect(ui.radBoxed, SIGNAL(clicked(bool)), this, SLOT(OnBoxType())); connect(ui.radBoxedNew, SIGNAL(clicked(bool)), this, SLOT(OnBoxType())); connect(ui.radUnBoxed, SIGNAL(clicked(bool)), this, SLOT(OnBoxType())); + connect(ui.radFCPRuned, SIGNAL(clicked(bool)), this, SLOT(OnBoxType())); connect(ui.buttonBox, SIGNAL(accepted()), SLOT(OnRun())); connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject())); @@ -213,13 +214,13 @@ void CSelectBoxWindow::closeEvent(QCloseEvent *e) void CSelectBoxWindow::OnBoxType() { - m_pBoxPicker->setEnabled(ui.radBoxed->isChecked()); + m_pBoxPicker->setEnabled(ui.radBoxed->isChecked()||ui.radFCPRuned->isChecked()); } void CSelectBoxWindow::OnRun() { QString BoxName; - + bool isFCP = false; if (ui.radUnBoxed->isChecked()) { if (QMessageBox("Sandboxie-Plus", tr("Are you sure you want to run the program outside the sandbox?"), QMessageBox::Question, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape, QMessageBox::NoButton, this).exec() != QMessageBox::Yes) @@ -233,6 +234,15 @@ void CSelectBoxWindow::OnRun() return; } } + else if (ui.radFCPRuned->isChecked()) + { + isFCP = true; + BoxName = m_pBoxPicker->GetBoxName(); + if (BoxName.isEmpty()) { + QMessageBox("Sandboxie-Plus", tr("Please select a sandbox."), QMessageBox::Information, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton, this).exec(); + return; + } + } else { BoxName = m_pBoxPicker->GetBoxName(); @@ -243,8 +253,8 @@ void CSelectBoxWindow::OnRun() } foreach(const QString & Command, m_Commands) - theGUI->RunStart(BoxName, Command, ui.chkAdmin->isChecked(), m_WrkDir); + theGUI->RunStart(BoxName, Command, ui.chkAdmin->isChecked(), m_WrkDir,isFCP,0); setResult(1); close(); -} \ No newline at end of file +}