Skip to content

Commit

Permalink
1.11.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Sep 25, 2023
1 parent 290da81 commit 0a288b5
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 19 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion SandboxiePlus/SandMan/Forms/OptionsWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
<widget class="QComboBox" name="cmbVersion"/>
</item>
<item row="5" column="5">
<widget class="QPushButton" name="btnPassword">
<widget class="QToolButton" name="btnPassword">
<property name="text">
<string>Set Password</string>
</property>
Expand Down
80 changes: 63 additions & 17 deletions SandboxiePlus/SandMan/Windows/OptionsGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,17 @@ void COptionsWindow::LoadGeneral()
if (ui.chkRamBox->isEnabled())
ui.chkEncrypt->setEnabled(!ui.chkRamBox->isChecked());
CSandBoxPlus* pBoxEx = qobject_cast<CSandBoxPlus*>(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);
Expand Down Expand Up @@ -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<CSandBoxPlus*>(m_pBox.data());
Expand All @@ -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);

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);
}
Arguments.append("new_key=" + window.GetNewPassword());

if (RunImBox(Arguments))
QMessageBox::information(this, "Sandboxie-Plus", tr("Image Password Changed"));
}
}
}

void COptionsWindow::OnBackupHeader()
{
CSandBoxPlus* pBoxEx = qobject_cast<CSandBoxPlus*>(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<CSandBoxPlus*>(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"));
}
4 changes: 4 additions & 0 deletions SandboxiePlus/SandMan/Windows/OptionsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ private slots:

void OnDiskChanged();
void OnSetPassword();
void OnBackupHeader();
void OnRestoreHeader();

void OnAddGroup();
void OnAddProg();
Expand Down Expand Up @@ -362,6 +364,8 @@ private slots:
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();
Expand Down

0 comments on commit 0a288b5

Please sign in to comment.