diff --git a/CHANGELOG.md b/CHANGELOG.md
index 74d94daf..14c504d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,9 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
-## [1.11.3 / 5.66.3] - 2023-09-
+## [1.11.3 / 5.66.3] - 2023-09-26
### Added
+added container header backup/restore option to the option windows
### Changed
- updated 7z library to version 23.01 [4ee1464](https://github.com/sandboxie-plus/Sandboxie/commit/4ee146430f70c91917fbcbfb77909b5b0b84a78c)
diff --git a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
index 920ab5f7..26571fb0 100644
--- a/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
+++ b/SandboxiePlus/SandMan/Forms/OptionsWindow.ui
@@ -457,7 +457,7 @@
-
-
+
Set Password
diff --git a/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp b/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp
index 560ccc0d..e256d5fe 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp
+++ b/SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp
@@ -328,8 +328,17 @@ void COptionsWindow::LoadGeneral()
if (ui.chkRamBox->isEnabled())
ui.chkEncrypt->setEnabled(!ui.chkRamBox->isChecked());
CSandBoxPlus* pBoxEx = qobject_cast(m_pBox.data());
- if (pBoxEx && QFile::exists(pBoxEx->GetBoxImagePath()))
+ if (pBoxEx && QFile::exists(pBoxEx->GetBoxImagePath()))
+ {
+ if (!ui.btnPassword->menu()) {
+ QMenu* pCryptoMenu = new QMenu();
+ pCryptoMenu->addAction(tr("Backup Image Header"), this, SLOT(OnBackupHeader()));
+ pCryptoMenu->addAction(tr("Restore Image Header"), this, SLOT(OnRestoreHeader()));
+ ui.btnPassword->setPopupMode(QToolButton::MenuButtonPopup);
+ ui.btnPassword->setMenu(pCryptoMenu);
+ }
ui.btnPassword->setText(tr("Change Password"));
+ }
ui.btnPassword->setEnabled(!ui.chkRamBox->isChecked() && ui.chkEncrypt->isChecked() && pBoxEx && pBoxEx->GetMountRoot().isEmpty());
int iLimit = m_pBox->GetNum("CopyLimitKb", 80 * 1024);
@@ -1121,6 +1130,25 @@ void COptionsWindow::OnDiskChanged()
OnGeneralChanged();
}
+bool COptionsWindow::RunImBox(const QStringList& Arguments)
+{
+ QProcess Process;
+ Process.start(theAPI->GetSbiePath() + "\\ImBox.exe", Arguments);
+ Process.waitForFinished();
+ int ret = Process.exitCode();
+ if (ret != ERR_OK) {
+ QString Message;
+ switch (ret) {
+ case ERR_FILE_NOT_OPENED: Message = tr("The image file does not exist"); break;
+ case ERR_WRONG_PASSWORD: Message = tr("The password is wrong"); break;
+ default: Message = tr("Unexpected error: %1").arg(ret); break;
+ }
+ QMessageBox::critical(this, "Sandboxie-Plus", Message);
+ return false;
+ }
+ return true;
+}
+
void COptionsWindow::OnSetPassword()
{
CSandBoxPlus* pBoxEx = qobject_cast(m_pBox.data());
@@ -1134,27 +1162,45 @@ void COptionsWindow::OnSetPassword()
OnGeneralChanged();
}
else {
- QString m_NewPassword = window.GetNewPassword();
QStringList Arguments;
Arguments.append("type=image");
Arguments.append("image=" + pBoxEx->GetBoxImagePath());
Arguments.append("key=" + m_Password);
- Arguments.append("new_key=" + m_NewPassword);
+ Arguments.append("new_key=" + window.GetNewPassword());
- QProcess Process;
- Process.start(theAPI->GetSbiePath() + "\\ImBox.exe", Arguments);
- Process.waitForFinished();
- int ret = Process.exitCode();
- if (ret != ERR_OK) {
- QString Message;
- switch (ret) {
- case ERR_FILE_NOT_OPENED: Message = tr("The image file does not exist"); break;
- case ERR_WRONG_PASSWORD: Message = tr("The password is wrong"); break;
- default: Message = tr("Unexpected error: %1").arg(ret); break;
- }
- QMessageBox::critical(this, "Sandboxie-Plus", Message);
- }
+ if (RunImBox(Arguments))
+ QMessageBox::information(this, "Sandboxie-Plus", tr("Image Password Changed"));
}
}
+}
+
+void COptionsWindow::OnBackupHeader()
+{
+ CSandBoxPlus* pBoxEx = qobject_cast(m_pBox.data());
+
+ QString FileName = QFileDialog::getSaveFileName(theGUI, tr("Backup Image Header for %1").arg(m_pBox->GetName()), "", QString("Image Header File (*.hdr)")).replace("/", "\\");
+
+ QStringList Arguments;
+ Arguments.append("type=image");
+ Arguments.append("image=" + pBoxEx->GetBoxImagePath());
+ Arguments.append("backup=" + FileName);
+
+ if (RunImBox(Arguments))
+ QMessageBox::information(this, "Sandboxie-Plus", tr("Image Header Backuped"));
+}
+
+void COptionsWindow::OnRestoreHeader()
+{
+ CSandBoxPlus* pBoxEx = qobject_cast(m_pBox.data());
+
+ QString FileName = QFileDialog::getOpenFileName(theGUI, tr("Backup Image Header for %1").arg(m_pBox->GetName()), "", QString("Image Header File (*.hdr)")).replace("/", "\\");
+
+ QStringList Arguments;
+ Arguments.append("type=image");
+ Arguments.append("image=" + pBoxEx->GetBoxImagePath());
+ Arguments.append("restore=" + FileName);
+
+ if (RunImBox(Arguments))
+ QMessageBox::information(this, "Sandboxie-Plus", tr("Image Header Restored"));
}
\ No newline at end of file
diff --git a/SandboxiePlus/SandMan/Windows/OptionsWindow.h b/SandboxiePlus/SandMan/Windows/OptionsWindow.h
index 802076ed..e80fb26e 100644
--- a/SandboxiePlus/SandMan/Windows/OptionsWindow.h
+++ b/SandboxiePlus/SandMan/Windows/OptionsWindow.h
@@ -74,6 +74,8 @@ private slots:
void OnDiskChanged();
void OnSetPassword();
+ void OnBackupHeader();
+ void OnRestoreHeader();
void OnAddGroup();
void OnAddProg();
@@ -362,6 +364,8 @@ protected:
void SetAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
void DelAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
+ bool RunImBox(const QStringList& Arguments);
+
void LoadConfig();
void SaveConfig();
void UpdateCurrentTab();