This commit is contained in:
DavidXanatos 2023-07-20 20:45:51 +02:00
parent e41c6f167e
commit 3dbf924ba2
4 changed files with 35 additions and 8 deletions

View File

@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- added UI option to change ini editor [#3116](https://github.com/sandboxie-plus/Sandboxie/issues/3116)
- added Separate protection against box removal and content deletion [#3104] (https://github.com/sandboxie-plus/Sandboxie/issues/3104)
### Changed
- reworked Nt Object Handle handling

View File

@ -290,9 +290,15 @@
</item>
<item row="6" column="1" colspan="5">
<widget class="QCheckBox" name="chkProtectBox">
<property name="toolTip">
<string>Partially checked means prevent box removal but not content deletion.</string>
</property>
<property name="text">
<string>Protect this sandbox from deletion or emptying</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1" colspan="5">

View File

@ -1354,17 +1354,20 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
bool bChanged = false;
foreach(const CSandBoxPtr& pBox, SandBoxes)
{
SB_STATUS Status = SB_OK;
if (!pBox->GetBool("IsShadow")) {
SB_STATUS Status = theGUI->DeleteBoxContent(pBox, CSandMan::eForDelete);
Status = theGUI->DeleteBoxContent(pBox, CSandMan::eForDelete);
if (Status.GetMsgCode() == SB_Canceled)
break;
if (Status.IsError())
continue;
}
if (pBox->GetBool("NeverRemove", false))
Status = SB_ERR(SB_DeleteProtect);
QString Name = pBox->GetName();
SB_STATUS Status = pBox->RemoveBox();
Results.append(Status);
if (!Status.IsError())
Status = pBox->RemoveBox();
if (!Status.IsError()) {
theConf->DelValue("SizeCache/" + Name);
@ -1377,6 +1380,8 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
}
}
}
Results.append(Status);
}
if(bChanged)

View File

@ -303,7 +303,12 @@ void COptionsWindow::LoadGeneral()
LoadCopyRules();
ui.chkProtectBox->setChecked(m_pBox->GetBool("NeverDelete", false));
if (m_pBox->GetBool("NeverDelete", false))
ui.chkProtectBox->setCheckState(Qt::Checked);
else if (m_pBox->GetBool("NeverRemove", false))
ui.chkProtectBox->setCheckState(Qt::PartiallyChecked);
else
ui.chkProtectBox->setCheckState(Qt::Unchecked);
ui.chkAutoEmpty->setChecked(m_pBox->GetBool("AutoDelete", false));
ui.chkRawDiskRead->setChecked(m_pBox->GetBool("AllowRawDiskRead", false));
@ -414,8 +419,18 @@ void COptionsWindow::SaveGeneral()
WriteAdvancedCheck(ui.chkDenyWrite, "CopyBlockDenyWrite", "y", "");
WriteAdvancedCheck(ui.chkNoCopyMsg, "NotifyNoCopy", "y", "");
WriteAdvancedCheck(ui.chkProtectBox, "NeverDelete", "y", "");
if (ui.chkProtectBox->checkState() == Qt::Checked) {
m_pBox->SetText("NeverDelete", "y");
m_pBox->SetText("NeverRemove", "y");
}
else if (ui.chkProtectBox->checkState() == Qt::PartiallyChecked) {
m_pBox->DelValue("NeverDelete");
m_pBox->SetText("NeverRemove", "y");
}
else {
m_pBox->DelValue("NeverDelete");
m_pBox->DelValue("NeverRemove");
}
WriteAdvancedCheck(ui.chkAutoEmpty, "AutoDelete", "y", "");
WriteAdvancedCheck(ui.chkRawDiskRead, "AllowRawDiskRead", "y", "");