From affaba9b341f3ec612bb54afa4cbae4bd8f0b198 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Sun, 26 Nov 2023 15:28:46 +0100 Subject: [PATCH] 1.12.2 --- CHANGELOG.md | 3 + SandboxiePlus/MiscHelpers/Archive/Archive.cpp | 10 +-- SandboxiePlus/MiscHelpers/Archive/Archive.h | 8 +- .../SandMan/Dialogs/MultiErrorDialog.h | 1 - SandboxiePlus/SandMan/Forms/CompressDialog.ui | 85 +++++++++++++++++++ SandboxiePlus/SandMan/SandMan.pri | 5 +- SandboxiePlus/SandMan/SbiePlusAPI.cpp | 14 ++- SandboxiePlus/SandMan/SbiePlusAPI.h | 4 +- SandboxiePlus/SandMan/Views/SbieView.cpp | 24 ++++-- .../SandMan/Windows/CompressDialog.cpp | 63 ++++++++++++++ .../SandMan/Windows/CompressDialog.h | 23 +++++ .../SandMan/Wizards/BoxAssistant.cpp | 8 +- 12 files changed, 223 insertions(+), 25 deletions(-) create mode 100644 SandboxiePlus/SandMan/Forms/CompressDialog.ui create mode 100644 SandboxiePlus/SandMan/Windows/CompressDialog.cpp create mode 100644 SandboxiePlus/SandMan/Windows/CompressDialog.h diff --git a/CHANGELOG.md b/CHANGELOG.md index e8812ea9..84031d93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [1.12.2 / 5.67.2] - 2023-11- +### Added +- added options dialog when exporting a box [#3409](https://github.com/sandboxie-plus/Sandboxie/issues/3409) + ### Fixed - FIXED SECURITY ISSUE ID-23 SeManageVolumePrivilege is now blocked, as it allowed to read MFT data (thanks Diversenok) - fixed issue with Microsoft Edge when using AutoDelete option [#post-3173507](https://www.wilderssecurity.com/threads/sandboxie-plus-v1-12-1-pre-release.452939/#post-3173507) diff --git a/SandboxiePlus/MiscHelpers/Archive/Archive.cpp b/SandboxiePlus/MiscHelpers/Archive/Archive.cpp index c2df134c..ef186b1f 100644 --- a/SandboxiePlus/MiscHelpers/Archive/Archive.cpp +++ b/SandboxiePlus/MiscHelpers/Archive/Archive.cpp @@ -216,7 +216,7 @@ bool CArchive::Close() return false; } -bool CArchive::Update(QMap *FileList, bool bDelete, int Level) +bool CArchive::Update(QMap *FileList, bool bDelete, const SCompressParams* Params) { if(!theArc.IsOperational()) { @@ -263,10 +263,10 @@ bool CArchive::Update(QMap *FileList, bool bDelete, int Level) const int kNumProps = sizeof(names) / sizeof(names[0]); NWindows::NCOM::CPropVariant values[kNumProps] = { - false, // solid mode OFF - (UInt32)Level, // compression level = 9 - ultra - //(UInt32)8, // set number of CPU threads - true // file name encryption (7z only) + (Params ? Params->bSolid : false), // solid mode OFF + (UInt32)(Params ? Params->iLevel : 5), // compression level = 9 - ultra + //(UInt32)8, // set number of CPU threads + true // file name encryption (7z only) }; if(setProperties->SetProperties(names, values, kNumProps) != S_OK) diff --git a/SandboxiePlus/MiscHelpers/Archive/Archive.h b/SandboxiePlus/MiscHelpers/Archive/Archive.h index 68af16d5..cf4cc29f 100644 --- a/SandboxiePlus/MiscHelpers/Archive/Archive.h +++ b/SandboxiePlus/MiscHelpers/Archive/Archive.h @@ -16,6 +16,12 @@ #define ERR_7Z_PASSWORD_REQUIRED 5 #define ERR_7Z_UNSUPPORTED_FORMAT 6 +struct SCompressParams +{ + int iLevel = 0; + bool bSolid = false; +}; + class MISCHELPERS_EXPORT CArchive { public: @@ -34,7 +40,7 @@ public: bool Extract(QMap *FileList, bool bDelete = true); bool Close(); - bool Update(QMap *FileList, bool bDelete = true, int Level = 0); + bool Update(QMap *FileList, bool bDelete = true, const SCompressParams* Params = NULL); int AddFile(QString Path); int FileCount() {return m_Files.count();} diff --git a/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h b/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h index 6442e9fc..d9bde152 100644 --- a/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h +++ b/SandboxiePlus/SandMan/Dialogs/MultiErrorDialog.h @@ -1,6 +1,5 @@ #pragma once #include "../../MiscHelpers/Common/PanelView.h" -#include "../../MiscHelpers/Common/FlexError.h" #include "../../QSbieAPI/SbieStatus.h" class CMultiErrorDialog : public QDialog diff --git a/SandboxiePlus/SandMan/Forms/CompressDialog.ui b/SandboxiePlus/SandMan/Forms/CompressDialog.ui new file mode 100644 index 00000000..03ba9553 --- /dev/null +++ b/SandboxiePlus/SandMan/Forms/CompressDialog.ui @@ -0,0 +1,85 @@ + + + CompressDialog + + + + 0 + 0 + 424 + 207 + + + + Compress Files + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Compression + + + + + + + When sellected you will be prompted for a password after clicking OK + + + Encrypt archive content + + + + + + + Solid archiving improves compression ratios by treating multiple files as a single continuous data block. Ideal for a large number of small files, it makes the archive more compact but may increase the time required for extracting individual files. + + + Create Solide Archive + + + + + + + Export Sandbox to a 7z archive, Choose Your Compression Rate and Customize Additional Compression Settings. + + + true + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/SandboxiePlus/SandMan/SandMan.pri b/SandboxiePlus/SandMan/SandMan.pri index 4df95b21..52243e4a 100644 --- a/SandboxiePlus/SandMan/SandMan.pri +++ b/SandboxiePlus/SandMan/SandMan.pri @@ -37,6 +37,7 @@ HEADERS += ./stdafx.h \ ./Wizards/SetupWizard.h \ ./Wizards/BoxAssistant.h \ ./Windows/BoxImageWindow.h \ + ./Windows/CompressDialog.h \ ./Engine/BoxEngine.h \ ./Engine/ScriptManager.h \ ./Engine/BoxObject.h \ @@ -86,6 +87,7 @@ SOURCES += ./main.cpp \ ./Wizards/SetupWizard.cpp \ ./Wizards/BoxAssistant.cpp \ ./Windows/BoxImageWindow.cpp \ + ./Windows/CompressDialog.cpp \ ./Engine/BoxEngine.cpp \ ./Engine/ScriptManager.cpp \ ./Engine/BoxObject.cpp \ @@ -101,7 +103,8 @@ FORMS += ./Forms/SelectBoxWindow.ui \ ./Forms/RecoveryWindow.ui \ ./Forms/SettingsWindow.ui \ ./Forms/SnapshotsWindow.ui \ - ./Forms/BoxImageWindow.ui + ./Forms/BoxImageWindow.ui \ + ./Forms/CompressDialog.ui TRANSLATIONS += sandman_de.ts \ sandman_en.ts \ diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.cpp b/SandboxiePlus/SandMan/SbiePlusAPI.cpp index 2d7530a1..2ce8c1d5 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.cpp +++ b/SandboxiePlus/SandMan/SbiePlusAPI.cpp @@ -189,7 +189,7 @@ protected: CArchive* m_pArchive; }; -void CSandBoxPlus::ExportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ExportPath, const QString& RootPath, const QString& Section, const QString& Password) +void CSandBoxPlus::ExportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ExportPath, const QString& RootPath, const QString& Section, const QString& Password, struct SCompressParams* Params) { //CArchive Archive(ExportPath + ".tmp"); CArchive Archive(ExportPath); @@ -233,7 +233,7 @@ void CSandBoxPlus::ExportBoxAsync(const CSbieProgressPtr& pProgress, const QStri Archive.SetPassword(Password); SB_STATUS Status = SB_OK; - if (!Archive.Update(&Files, true, theConf->GetInt("Options/ExportCompression", 3))) // 0, 1 - 9 + if (!Archive.Update(&Files, true, Params)) // 0, 1 - 9 Status = SB_ERR((ESbieMsgCodes)SBX_7zCreateFailed); //if(!Status.IsError() && !pProgress->IsCanceled()) @@ -243,10 +243,12 @@ void CSandBoxPlus::ExportBoxAsync(const CSbieProgressPtr& pProgress, const QStri File.remove(); + delete Params; + pProgress->Finish(Status); } -SB_PROGRESS CSandBoxPlus::ExportBox(const QString& FileName, const QString& Password) +SB_PROGRESS CSandBoxPlus::ExportBox(const QString& FileName, const QString& Password, int Level, bool Solid) { if (!CArchive::IsInit()) return SB_ERR((ESbieMsgCodes)SBX_7zNotReady); @@ -259,8 +261,12 @@ SB_PROGRESS CSandBoxPlus::ExportBox(const QString& FileName, const QString& Pass QString Section = theAPI->SbieIniGetEx(m_Name, ""); + SCompressParams* Params = new SCompressParams(); + Params->iLevel = Level; + Params->bSolid = Solid; + CSbieProgressPtr pProgress = CSbieProgressPtr(new CSbieProgress()); - QtConcurrent::run(CSandBoxPlus::ExportBoxAsync, pProgress, FileName, m_FilePath, Section, Password); + QtConcurrent::run(CSandBoxPlus::ExportBoxAsync, pProgress, FileName, m_FilePath, Section, Password, Params); return SB_PROGRESS(OP_ASYNC, pProgress); } diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.h b/SandboxiePlus/SandMan/SbiePlusAPI.h index c3352de2..5111eda1 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.h +++ b/SandboxiePlus/SandMan/SbiePlusAPI.h @@ -72,7 +72,7 @@ public: CSandBoxPlus(const QString& BoxName, class CSbieAPI* pAPI); virtual ~CSandBoxPlus(); - SB_PROGRESS ExportBox(const QString& FileName, const QString& Password = ""); + SB_PROGRESS ExportBox(const QString& FileName, const QString& Password = "", int Level = 5, bool Solid = false); SB_PROGRESS ImportBox(const QString& FileName, const QString& Password = ""); virtual void UpdateDetails(); @@ -220,7 +220,7 @@ protected: void AddJobToQueue(CBoxJob* pJob); void StartNextJob(); - static void ExportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ExportPath, const QString& RootPath, const QString& Section, const QString& Password = ""); + static void ExportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ExportPath, const QString& RootPath, const QString& Section, const QString& Password = "", struct SCompressParams* Params = NULL); static void ImportBoxAsync(const CSbieProgressPtr& pProgress, const QString& ImportPath, const QString& RootPath, const QString& BoxName, const QString& Password = ""); bool IsFileDeleted(const QString& RealPath, const QString& Snapshot, const QStringList& SnapshotList, const QMap>& DeletedPaths); diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index 298d0beb..55d318d2 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -1384,19 +1384,25 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList& SandB CSandBoxPtr pBox = SandBoxes.first(); auto pBoxEx = pBox.objectCast(); + CCompressDialog optWnd(this); + if (pBoxEx->UseImageFile()) + optWnd.SetMustEncrypt(); + if (!theGUI->SafeExec(&optWnd) == 1) + return; + + QString Password; + if (optWnd.UseEncryption()) { + CBoxImageWindow pwWnd(CBoxImageWindow::eExport, this); + if (!theGUI->SafeExec(&pwWnd) == 1) + return; + Password = pwWnd.GetPassword(); + } + QString Path = QFileDialog::getSaveFileName(this, tr("Select file name"), SandBoxes.first()->GetName() + ".7z", tr("7-zip Archive (*.7z)")); if (Path.isEmpty()) return; - QString Password; - if (pBoxEx->UseImageFile()) { - CBoxImageWindow window(CBoxImageWindow::eExport, this); - if (!theGUI->SafeExec(&window) == 1) - return; - Password = window.GetPassword(); - } - - SB_PROGRESS Status = pBoxEx->ExportBox(Path, Password); + SB_PROGRESS Status = pBoxEx->ExportBox(Path, Password, optWnd.GetLevel(), optWnd.MakeSolid()); if (Status.GetStatus() == OP_ASYNC) theGUI->AddAsyncOp(Status.GetValue(), false, tr("Exporting: %1").arg(Path)); else diff --git a/SandboxiePlus/SandMan/Windows/CompressDialog.cpp b/SandboxiePlus/SandMan/Windows/CompressDialog.cpp new file mode 100644 index 00000000..0e2e9eb0 --- /dev/null +++ b/SandboxiePlus/SandMan/Windows/CompressDialog.cpp @@ -0,0 +1,63 @@ +#include "stdafx.h" +#include "CompressDialog.h" +#include "SandMan.h" +#include "../MiscHelpers/Common/Settings.h" +#include "../MiscHelpers/Common/Common.h" + + +CCompressDialog::CCompressDialog(QWidget *parent) + : QDialog(parent) +{ + Qt::WindowFlags flags = windowFlags(); + flags |= Qt::CustomizeWindowHint; + //flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + //flags &= ~Qt::WindowMinMaxButtonsHint; + //flags |= Qt::WindowMinimizeButtonHint; + //flags &= ~Qt::WindowCloseButtonHint; + flags &= ~Qt::WindowContextHelpButtonHint; + //flags &= ~Qt::WindowSystemMenuHint; + setWindowFlags(flags); + + ui.setupUi(this); + this->setWindowTitle(tr("Sandboxie-Plus - Sandbox Export")); + + ui.cmbCompression->addItem(tr("Store"), 0); + ui.cmbCompression->addItem(tr("Fastest"), 1); + ui.cmbCompression->addItem(tr("Fast"), 3); + ui.cmbCompression->addItem(tr("Normal"), 5); + ui.cmbCompression->addItem(tr("Maximum"), 7); + ui.cmbCompression->addItem(tr("Ultra"), 9); + ui.cmbCompression->setCurrentIndex(ui.cmbCompression->findData(theConf->GetInt("Options/ExportCompression", 3))); + + connect(ui.buttonBox, SIGNAL(accepted()), SLOT(accept())); + connect(ui.buttonBox, SIGNAL(rejected()), SLOT(reject())); + + //restoreGeometry(theConf->GetBlob("CompressDialog/Window_Geometry")); +} + +CCompressDialog::~CCompressDialog() +{ + //theConf->SetBlob("CompressDialog/Window_Geometry", saveGeometry()); +} + +int CCompressDialog::GetLevel() +{ + return ui.cmbCompression->currentData().toInt(); +} + +bool CCompressDialog::MakeSolid() +{ + return ui.chkSolid->isChecked(); +} + +void CCompressDialog::SetMustEncrypt() +{ + ui.chkEncrypt->setChecked(true); + ui.chkEncrypt->setEnabled(false); +} + +bool CCompressDialog::UseEncryption() +{ + return ui.chkEncrypt->isChecked(); +} \ No newline at end of file diff --git a/SandboxiePlus/SandMan/Windows/CompressDialog.h b/SandboxiePlus/SandMan/Windows/CompressDialog.h new file mode 100644 index 00000000..84a05fe5 --- /dev/null +++ b/SandboxiePlus/SandMan/Windows/CompressDialog.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include "ui_CompressDialog.h" +#include "SbiePlusAPI.h" + +class CCompressDialog : public QDialog +{ + Q_OBJECT + +public: + CCompressDialog(QWidget *parent = Q_NULLPTR); + ~CCompressDialog(); + + int GetLevel(); + bool MakeSolid(); + + void SetMustEncrypt(); + bool UseEncryption(); + +private: + Ui::CompressDialog ui; +}; diff --git a/SandboxiePlus/SandMan/Wizards/BoxAssistant.cpp b/SandboxiePlus/SandMan/Wizards/BoxAssistant.cpp index a9735f16..a38512c9 100644 --- a/SandboxiePlus/SandMan/Wizards/BoxAssistant.cpp +++ b/SandboxiePlus/SandMan/Wizards/BoxAssistant.cpp @@ -966,7 +966,9 @@ bool CSubmitPage::validatePage() } m_pUploadProgress->ShowMessage(tr("Compressing Logs")); - Archive.Update(&Files, true, 9); + SCompressParams Params; + Params.iLevel = 9; + Archive.Update(&Files, true, &Params); if (pSbieLogs->open(QIODevice::ReadOnly)) { @@ -998,7 +1000,9 @@ bool CSubmitPage::validatePage() } m_pUploadProgress->ShowMessage(tr("Compressing Dumps")); - Archive.Update(&Files, true, 9); + SCompressParams Params; + Params.iLevel = 9; + Archive.Update(&Files, true, &Params); if (pSbieDumps->open(QIODevice::ReadOnly)) {