This commit is contained in:
DavidXanatos 2023-11-26 15:28:46 +01:00
parent beede4dbd1
commit affaba9b34
12 changed files with 223 additions and 25 deletions

View File

@ -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)

View File

@ -216,7 +216,7 @@ bool CArchive::Close()
return false;
}
bool CArchive::Update(QMap<int, QIODevice*> *FileList, bool bDelete, int Level)
bool CArchive::Update(QMap<int, QIODevice*> *FileList, bool bDelete, const SCompressParams* Params)
{
if(!theArc.IsOperational())
{
@ -263,8 +263,8 @@ bool CArchive::Update(QMap<int, QIODevice*> *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
(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)
};

View File

@ -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<int, QIODevice*> *FileList, bool bDelete = true);
bool Close();
bool Update(QMap<int, QIODevice*> *FileList, bool bDelete = true, int Level = 0);
bool Update(QMap<int, QIODevice*> *FileList, bool bDelete = true, const SCompressParams* Params = NULL);
int AddFile(QString Path);
int FileCount() {return m_Files.count();}

View File

@ -1,6 +1,5 @@
#pragma once
#include "../../MiscHelpers/Common/PanelView.h"
#include "../../MiscHelpers/Common/FlexError.h"
#include "../../QSbieAPI/SbieStatus.h"
class CMultiErrorDialog : public QDialog

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CompressDialog</class>
<widget class="QDialog" name="CompressDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>207</height>
</rect>
</property>
<property name="windowTitle">
<string>Compress Files</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QComboBox" name="cmbCompression"/>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Compression</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chkEncrypt">
<property name="toolTip">
<string>When sellected you will be prompted for a password after clicking OK</string>
</property>
<property name="text">
<string>Encrypt archive content</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkSolid">
<property name="toolTip">
<string>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.</string>
</property>
<property name="text">
<string>Create Solide Archive</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Export Sandbox to a 7z archive, Choose Your Compression Rate and Customize Additional Compression Settings.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -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 \

View File

@ -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);
}

View File

@ -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<QString, QList<QString>>& DeletedPaths);

View File

@ -1384,19 +1384,25 @@ void CSbieView::OnSandBoxAction(QAction* Action, const QList<CSandBoxPtr>& SandB
CSandBoxPtr pBox = SandBoxes.first();
auto pBoxEx = pBox.objectCast<CSandBoxPlus>();
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

View File

@ -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();
}

View File

@ -0,0 +1,23 @@
#pragma once
#include <QtWidgets/QMainWindow>
#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;
};

View File

@ -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)) {