Build 0.3.5 / 5.42.1

This commit is contained in:
DavidXanatos 2020-07-19 22:09:02 +02:00
parent a2fa7739fc
commit de57cdedc5
42 changed files with 4077 additions and 149 deletions

View File

@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.5 / 5.42.1] - 2020-07-19
### Added
- Added settings window
- added translationsupport
- added dark theme
- added auto start option
- added sandbox options
- added debug option "NoAddProcessToJob=y"
### Changed
- improved empty sandbox tray icon
- improved message parsing
- updated homepage links
### Fixed
- fixed ini issue with sandman.exe when renaming sandboxes
- fixed ini auto reload bug introduced in the last build
- fixed issue when hooking delayd loaded libraries
## [0.3 / 5.42] - 2020-07-04
### Added

View File

@ -134,7 +134,7 @@ void CRunBrowser::OnNo()
CString CRunBrowser::GetTopicUrl(const CString &topic)
{
return L"https://www.sandboxie.com/index.php?" + topic;
return L"https://xanasoft.com/Sandboxie/" + topic;
}
@ -155,5 +155,5 @@ void CRunBrowser::OpenHelp(CWnd *pParentWnd, const CString &topic)
void CRunBrowser::OpenForum(CWnd *pParentWnd)
{
CRunBrowser x(pParentWnd, L"http://forums.sandboxie.com/phpBB3/");
CRunBrowser x(pParentWnd, L"https://forum.xanasoft.com/");
}

View File

@ -246,11 +246,11 @@ void CLockConfigDialog::OnOK()
ini.SetRestrictions(
isEditAdminOnly, isForceDisableAdminOnly, isForgetPassword);
if ((*m_NewPassword) || isEditAdminOnly) {
int rv = CMyApp::MsgBox(this, MSG_4269, MB_YESNO);
if (rv == IDYES)
CRunBrowser::OpenHelp(this, L"ConfigurationProtection");
}
//if ((*m_NewPassword) || isEditAdminOnly) {
// int rv = CMyApp::MsgBox(this, MSG_4269, MB_YESNO);
// if (rv == IDYES)
// CRunBrowser::OpenHelp(this, L"ConfigurationProtection");
//}
EndDialog(0);
}

View File

@ -223,7 +223,8 @@ CMyFrame::CMyFrame(BOOL ForceVisible, BOOL ForceSync)
AdjustSizePosition(left, top, width, height);
ULONG exStyle = (CMyApp::m_LayoutRTL) ? WS_EX_LAYOUTRTL : 0;
CreateEx( exStyle, (LPCTSTR)CMyApp::m_atom, CMyApp::m_appTitle,
CString strTitle = CMyApp::m_appTitle + " - xanasoft.com";
CreateEx( exStyle, (LPCTSTR)CMyApp::m_atom, strTitle,
WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_SYSMENU,
left, top, width, height,
NULL, NULL, NULL);

View File

@ -20,8 +20,8 @@
#ifndef _MY_VERSION_H
#define _MY_VERSION_H
#define MY_VERSION_BINARY 5,42,0
#define MY_VERSION_STRING "5.42.0"
#define MY_VERSION_BINARY 5,42,1
#define MY_VERSION_STRING "5.42.1"
#define MY_VERSION_COMPAT "5.42"
// These #defines are used by either Resource Compiler, or by NSIC installer

View File

@ -27,7 +27,7 @@ SbieApi_GetHomePath=_SbieApi_GetHomePath@16
SbieApi_GetUnmountHive=_SbieApi_GetUnmountHive@4
SbieApi_GetVersion=_SbieApi_GetVersion@4
;;; SbieApi_GetWork=_SbieApi_GetWork@12
SbieApi_GetMessage=_SbieApi_GetMessage@20
SbieApi_GetMessage=_SbieApi_GetMessage@24
SbieApi_HookTramp=_SbieApi_HookTramp@8

View File

@ -178,6 +178,12 @@ skip_e9_rewrite: ;
SourceFunc = (void *)target;
}
//
// this simplification fails for delay loaded libraries, see coments about SetSecurityInfo,
// resulting in an endless loop, so just dont do that
//
#if 0
//
// 64-bit only: if the function begins with 'jmp qword ptr [x]'
// (6 bytes) then replace the value at x, rather than overwrite
@ -216,6 +222,7 @@ skip_e9_rewrite: ;
return orig_addr;
}
#endif
#endif _WIN64

View File

@ -1024,7 +1024,7 @@ _FX void Process_NotifyProcess_Create(
// don't put the process into a job if OpenWinClass=*
//
if (new_proc->open_all_win_classes) {
if (new_proc->open_all_win_classes || Conf_Get_Boolean(box->name, L"NoAddProcessToJob", 0, FALSE)) {
add_process_to_job = FALSE;
}

View File

@ -12,7 +12,7 @@ echo. > %OUTPUT%
for /F "tokens=3*" %%A in ('findstr /R "^#define.SBIE_INSTALLER_PATH\>" %INPUT%') do ( echo ^^!define SBIE_INSTALLER_PATH %%A) >> %OUTPUT%
for /F "tokens=3*" %%A in ('findstr /R "^#define.MY_VERSION_STRING_EX\>" %INPUT%') do ( echo ^^!define VERSION %%A) >> %OUTPUT%
for /F "tokens=3*" %%A in ('findstr /R "^#define.MY_VERSION_STRING\>" %INPUT%') do ( echo ^^!define VERSION %%A) >> %OUTPUT%
for /F "tokens=3*" %%A in ('findstr /R "^#define.MY_PRODUCT_NAME_STRING\>" %INPUT%') do ( set C=%%A %%B& echo ^^!define PRODUCT_FULL_NAME !C! & set C=!C: =!& echo ^^!define PRODUCT_NAME !C!) >> %OUTPUT%

View File

@ -28,7 +28,9 @@ SetCompressor /SOLID /FINAL lzma
; these are the build-time config settings. Need to be cmd line args or something better.
; pick either 32 or 64 bit
;!define _BUILDARCH Win32
!define _BUILDARCH x64
;!define _BUILDARCH x64
!define _BUILDARCH "$%SBIE_BUILDARCH%"
; uncomment this line if you want to make the special versions that download VC Redist
;!define INCLUDE_VCREDIST_DNLD

View File

@ -132,6 +132,11 @@ void CComboInputDialog::setValue(const QString &t)
d->combo->setCurrentIndex(idx);
}
int CComboInputDialog::findValue(const QString &t) const
{
return d->combo->findText(t);
}
QVariant CComboInputDialog::data() const
{
return d->combo->currentData();
@ -142,6 +147,11 @@ void CComboInputDialog::setData(const QVariant & v)
d->combo->setCurrentIndex(d->combo->findData(v));
}
int CComboInputDialog::findData(const QVariant & v) const
{
return d->combo->findData(v);
}
QPixmap CComboInputDialog::iconPixmap() const
{
if (const QPixmap *p = d->pixmapLabel->pixmap())

View File

@ -28,10 +28,11 @@ public:
QString value() const;
void setValue(const QString &);
int findValue(const QString &) const;
QVariant data() const;
void setData(const QVariant &);
int findData(const QVariant &) const;
QDialogButtonBox::StandardButtons standardButtons() const;
void setStandardButtons(QDialogButtonBox::StandardButtons s);

View File

@ -185,9 +185,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Sandboxie\BoxBorder.cpp" />
<ClCompile Include="Sandboxie\BoxedProcess.cpp" />
<ClCompile Include="Sandboxie\SandBox.cpp" />
<ClCompile Include="Sandboxie\IniSection.cpp" />
<ClCompile Include="Sandboxie\SbieIni.cpp" />
<ClCompile Include="SbieAPI.cpp" />
<ClCompile Include="SbieUtils.cpp" />
<ClCompile Include="stdafx.cpp">
@ -203,7 +204,8 @@
<ClInclude Include="qsbieapi_global.h" />
<QtMoc Include="Sandboxie\BoxedProcess.h" />
<QtMoc Include="Sandboxie\SandBox.h" />
<QtMoc Include="Sandboxie\IniSection.h" />
<QtMoc Include="Sandboxie\SbieIni.h" />
<QtMoc Include="Sandboxie\BoxBorder.h" />
<ClInclude Include="SbieDefs.h" />
<ClInclude Include="SbieError.h" />
<ClInclude Include="SbieUtils.h" />

View File

@ -39,12 +39,15 @@
<ClCompile Include="Sandboxie\SandBox.cpp">
<Filter>Sandboxie</Filter>
</ClCompile>
<ClCompile Include="Sandboxie\IniSection.cpp">
<Filter>Sandboxie</Filter>
</ClCompile>
<ClCompile Include="SbieUtils.cpp">
<Filter>SbieAPI</Filter>
</ClCompile>
<ClCompile Include="Sandboxie\BoxBorder.cpp">
<Filter>Sandboxie</Filter>
</ClCompile>
<ClCompile Include="Sandboxie\SbieIni.cpp">
<Filter>Sandboxie</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -78,7 +81,10 @@
<QtMoc Include="SbieAPI.h">
<Filter>SbieAPI</Filter>
</QtMoc>
<QtMoc Include="Sandboxie\IniSection.h">
<QtMoc Include="Sandboxie\BoxBorder.h">
<Filter>Sandboxie</Filter>
</QtMoc>
<QtMoc Include="Sandboxie\SbieIni.h">
<Filter>Sandboxie</Filter>
</QtMoc>
</ItemGroup>

View File

@ -23,7 +23,7 @@
//{
//};
CSandBox::CSandBox(const QString& BoxName, class CSbieAPI* pAPI) : CIniSection(BoxName, pAPI)
CSandBox::CSandBox(const QString& BoxName, class CSbieAPI* pAPI) : CSbieIni(BoxName, pAPI)
{
//m = new SSandBox;
@ -41,7 +41,7 @@ CSandBox::CSandBox(const QString& BoxName, class CSbieAPI* pAPI) : CIniSection(B
}
else
{
SetBool("AutoRecover", true);
SetBool("AutoRecover", false);
SetBool("BlockNetworkFiles", true);
//SetDefaultTemplates6(*this); // why 6?

View File

@ -21,9 +21,9 @@
#include "../qsbieapi_global.h"
#include "BoxedProcess.h"
#include "IniSection.h"
#include "SbieIni.h"
class QSBIEAPI_EXPORT CSandBox : public CIniSection
class QSBIEAPI_EXPORT CSandBox : public CSbieIni
{
Q_OBJECT
public:
@ -32,8 +32,6 @@ public:
virtual void UpdateDetails();
virtual QString GetName() const { return m_Name; }
virtual QString GetFileRoot() const { return m_FilePath; }
virtual QString GetRegRoot() const { return m_RegPath; }
virtual QString GetIpcRoot() const { return m_IpcPath; }

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
#include "IniSection.h"
#include "SbieIni.h"
#include "../SbieAPI.h"
#include <ntstatus.h>
@ -25,39 +25,39 @@ typedef long NTSTATUS;
#include "..\..\Sandboxie\core\drv\api_flags.h"
CIniSection::CIniSection(const QString& Section, class CSbieAPI* pAPI, QObject* parent) : QObject(parent)
CSbieIni::CSbieIni(const QString& Section, class CSbieAPI* pAPI, QObject* parent) : QObject(parent)
{
m_Name = Section;
m_pAPI = pAPI;
}
CIniSection::~CIniSection()
CSbieIni::~CSbieIni()
{
}
SB_STATUS CIniSection::SetText(const QString& Setting, const QString& Value)
SB_STATUS CSbieIni::SetText(const QString& Setting, const QString& Value)
{
if (GetText(Setting) == Value)
return SB_OK;
return m_pAPI->SbieIniSet(m_Name, Setting, Value);
}
SB_STATUS CIniSection::SetNum(const QString& Setting, int Value)
SB_STATUS CSbieIni::SetNum(const QString& Setting, int Value)
{
return SetText(Setting, QString::number(Value));
}
SB_STATUS CIniSection::SetNum64(const QString& Setting, __int64 Value)
SB_STATUS CSbieIni::SetNum64(const QString& Setting, __int64 Value)
{
return SetText(Setting, QString::number(Value));
}
SB_STATUS CIniSection::SetBool(const QString& Setting, bool Value)
SB_STATUS CSbieIni::SetBool(const QString& Setting, bool Value)
{
return SetText(Setting, Value ? "y" : "n");
}
QString CIniSection::GetText(const QString& Setting, const QString& Default) const
QString CSbieIni::GetText(const QString& Setting, const QString& Default) const
{
int flags = (m_Name.isEmpty() ? 0 : CONF_GET_NO_GLOBAL) | CONF_GET_NO_EXPAND;
QString Value = m_pAPI->SbieIniGet(m_Name, Setting, flags);
@ -65,7 +65,7 @@ QString CIniSection::GetText(const QString& Setting, const QString& Default) con
return Value;
}
int CIniSection::GetNum(const QString& Setting, int Default) const
int CSbieIni::GetNum(const QString& Setting, int Default) const
{
QString StrValue = GetText(Setting);
bool ok;
@ -74,7 +74,7 @@ int CIniSection::GetNum(const QString& Setting, int Default) const
return Value;
}
__int64 CIniSection::GetNum64(const QString& Setting, __int64 Default) const
__int64 CSbieIni::GetNum64(const QString& Setting, __int64 Default) const
{
QString StrValue = GetText(Setting);
bool ok;
@ -83,7 +83,7 @@ __int64 CIniSection::GetNum64(const QString& Setting, __int64 Default) const
return Value;
}
bool CIniSection::GetBool(const QString& Setting, bool Default) const
bool CSbieIni::GetBool(const QString& Setting, bool Default) const
{
QString StrValue = GetText(Setting);
if (StrValue.compare("y", Qt::CaseInsensitive) == 0)
@ -93,15 +93,15 @@ bool CIniSection::GetBool(const QString& Setting, bool Default) const
return Default;
}
QStringList CIniSection::GetTextList(const QString &Setting, bool withBrackets)
QStringList CSbieIni::GetTextList(const QString &Setting, bool withTemplates) const
{
QStringList TextList;
int flags = (m_Name.isEmpty() ? 0 : CONF_GET_NO_GLOBAL) | CONF_GET_NO_EXPAND;
if (withBrackets)
if (!withTemplates)
flags |= CONF_GET_NO_TEMPLS;
for(int index = 0; ; index++)
for (int index = 0; ; index++)
{
QString Value = m_pAPI->SbieIniGet(m_Name, Setting, index | flags);
if (Value.isNull())
@ -112,35 +112,80 @@ QStringList CIniSection::GetTextList(const QString &Setting, bool withBrackets)
return TextList;
}
SB_STATUS CIniSection::InsertText(const QString& Setting, const QString& Value)
SB_STATUS CSbieIni::UpdateTextList(const QString &Setting, const QStringList& List)
{
QStringList OldSettings = GetTextList(Setting);
QStringList NewSettings;
foreach(const QString& Value, List) {
if (!OldSettings.removeOne(Value))
NewSettings.append(Value);
}
// delete removed or changed settings
foreach(const QString& Value, OldSettings)
DelValue(Setting, Value);
// add new or changed settings
foreach(const QString& Value, NewSettings)
InsertText(Setting, Value);
return SB_OK;
}
QStringList CSbieIni::GetTemplates() const
{
QStringList Templates;
for (int tmpl_index = 0; ; tmpl_index++)
{
QString TmplName = m_pAPI->SbieIniGet(m_Name, "Template", tmpl_index | CONF_GET_NO_TEMPLS);
if (TmplName.isNull())
break;
Templates.append(TmplName);
}
return Templates;
}
QStringList CSbieIni::GetTextListTmpl(const QString &Setting, const QString& Template) const
{
QStringList TextList;
for (int index = 0; ; index++)
{
QString Value = m_pAPI->SbieIniGet("Template_" + Template, Setting, index | CONF_GET_NO_GLOBAL);
if (Value.isNull())
break;
TextList.append(Value);
}
return TextList;
}
SB_STATUS CSbieIni::InsertText(const QString& Setting, const QString& Value)
{
return m_pAPI->SbieIniSet(m_Name, Setting, Value, CSbieAPI::eIniInsert);
}
SB_STATUS CIniSection::AppendText(const QString& Setting, const QString& Value)
SB_STATUS CSbieIni::AppendText(const QString& Setting, const QString& Value)
{
return m_pAPI->SbieIniSet(m_Name, Setting, Value, CSbieAPI::eIniAppend);
}
SB_STATUS CIniSection::DelValue(const QString& Setting, const QString& Value)
SB_STATUS CSbieIni::DelValue(const QString& Setting, const QString& Value)
{
return m_pAPI->SbieIniSet(m_Name, Setting, Value, CSbieAPI::eIniDelete);
}
SB_STATUS CIniSection::RenameSection( const QString& NewName, bool deleteOld) // Note: deleteOld is used when duplicating a box
QList<QPair<QString, QString>> CSbieIni::GetIniSection(qint32* pStatus, bool withTemplates) const
{
if (m_Name.isEmpty() || NewName.isEmpty())
return SB_ERR();
bool SameName = (bool)(NewName.compare(m_Name, Qt::CaseInsensitive) == 0);
qint32 status = STATUS_SUCCESS;
// Get all Settigns
int flags = CONF_GET_NO_EXPAND;
if (!withTemplates)
flags |= CONF_GET_NO_TEMPLS;
QList<QPair<QString, QString>> Settings;
for (int setting_index = 0; ; setting_index++)
{
QString setting_name = m_pAPI->SbieIniGet(m_Name, NULL, setting_index | CONF_GET_NO_TEMPLS | CONF_GET_NO_EXPAND, &status);
QString setting_name = m_pAPI->SbieIniGet(m_Name, "", setting_index | flags, &status);
if (status == STATUS_RESOURCE_NAME_NOT_FOUND) {
status = STATUS_SUCCESS;
break;
@ -150,7 +195,7 @@ SB_STATUS CIniSection::RenameSection( const QString& NewName, bool deleteOld) //
for (int value_index = 0; ; value_index++)
{
QString setting_value = m_pAPI->SbieIniGet(m_Name, setting_name, value_index | CONF_GET_NO_GLOBAL | CONF_GET_NO_TEMPLS | CONF_GET_NO_EXPAND, &status);
QString setting_value = m_pAPI->SbieIniGet(m_Name, setting_name, value_index | CONF_GET_NO_GLOBAL | flags, &status);
if (status == STATUS_RESOURCE_NAME_NOT_FOUND) {
status = STATUS_SUCCESS;
break;
@ -165,13 +210,27 @@ SB_STATUS CIniSection::RenameSection( const QString& NewName, bool deleteOld) //
break;
}
if (pStatus) *pStatus = status;
return Settings;
}
SB_STATUS CSbieIni::RenameSection( const QString& NewName, bool deleteOld) // Note: deleteOld is used when duplicating a box
{
qint32 status = STATUS_SUCCESS;
if (m_Name.isEmpty() || NewName.isEmpty())
return SB_ERR();
bool SameName = (bool)(NewName.compare(m_Name, Qt::CaseInsensitive) == 0);
// Get all Settigns
QList<QPair<QString, QString>> Settings = GetIniSection(&status);
if (status != STATUS_SUCCESS)
return SB_ERR(CSbieAPI::tr("Failed to copy configuration from sandbox %1: %2").arg(m_Name).arg(status, 8, 16), status);
// check if such a box already exists
if (!SameName)
{
m_pAPI->SbieIniGet(NewName, NULL, CONF_GET_NO_EXPAND, &status);
m_pAPI->SbieIniGet(NewName, "", CONF_GET_NO_EXPAND, &status);
if (status != STATUS_RESOURCE_NAME_NOT_FOUND)
return SB_ERR(CSbieAPI::tr("A sandbox of the name %1 already exists").arg(NewName));
}
@ -185,7 +244,7 @@ do_write:
// Apply all Settigns
for (QList<QPair<QString, QString>>::iterator I = Settings.begin(); I != Settings.end(); ++I)
{
SB_STATUS Status = m_pAPI->SbieIniSet(NewName, I->first, I->second);
SB_STATUS Status = m_pAPI->SbieIniSet(NewName, I->first, I->second, CSbieAPI::eIniInsert);
if (Status.IsError())
return Status;
}
@ -206,7 +265,7 @@ do_delete:
return SB_OK;
}
SB_STATUS CIniSection::RemoveSection()
SB_STATUS CSbieIni::RemoveSection()
{
return m_pAPI->SbieIniSet(m_Name, "*", "");
}

View File

@ -5,12 +5,14 @@
#include "../SbieError.h"
class QSBIEAPI_EXPORT CIniSection: public QObject
class QSBIEAPI_EXPORT CSbieIni: public QObject
{
Q_OBJECT
public:
CIniSection(const QString& Section, class CSbieAPI* pAPI, QObject* parent = 0);
virtual ~CIniSection();
CSbieIni(const QString& Section, class CSbieAPI* pAPI, QObject* parent = 0);
virtual ~CSbieIni();
virtual QString GetName() const { return m_Name; }
virtual SB_STATUS SetText(const QString& Setting, const QString& Value);
virtual SB_STATUS SetNum(const QString& Setting, int Value);
@ -22,16 +24,23 @@ public:
virtual __int64 GetNum64(const QString& Setting, __int64 Default = 0) const;
virtual bool GetBool(const QString& Setting, bool Default = false) const;
virtual QStringList GetTextList(const QString &Setting, bool withBrackets = false);
virtual QStringList GetTextList(const QString &Setting, bool withTemplates = true) const;
virtual SB_STATUS UpdateTextList(const QString &Setting, const QStringList& List);
virtual QStringList GetTemplates() const;
virtual QStringList GetTextListTmpl(const QString &Setting, const QString& Template) const;
virtual SB_STATUS InsertText(const QString& Setting, const QString& Value);
virtual SB_STATUS AppendText(const QString& Setting, const QString& Value);
virtual SB_STATUS DelValue(const QString& Setting, const QString& Value);
virtual QList<QPair<QString, QString>> GetIniSection(qint32* pStatus = NULL, bool withTemplates = false) const;
virtual SB_STATUS RenameSection(const QString& NewName, bool deleteOld = true);
virtual SB_STATUS RemoveSection();
CSbieAPI* GetAPI() { return m_pAPI; }
protected:
QString m_Name;

View File

@ -72,7 +72,7 @@ struct SSbieAPI
ULONG SizeofPortMsg;
ULONG CallSeqNumber;
QString Password; // todo: suppor lcoked configurations
QString Password;
ULONG sessionId;
@ -111,6 +111,8 @@ CSbieAPI::CSbieAPI(QObject* parent) : QThread(parent)
{
m = new SSbieAPI();
m_pGlobalSection = new CSbieIni("GlobalSettings", this, this);
m_bReloadPending = false;
connect(&m_IniWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(OnIniChanged(const QString&)));
@ -398,6 +400,11 @@ SB_STATUS CSbieAPI__CallServer(SSbieAPI* m, MSG_HEADER* req, MSG_HEADER** prpl)
SB_STATUS CSbieAPI::CallServer(void* req, void* rpl) const
{
//
// Note: Once we open a port to the server from a threat the service will remember it we can't reconnect after disconnection
// So for every new connection we need a new threat, we achive this by letting our monitor threat issue all requests
//
while (InterlockedCompareExchange(&m->SvcLock, SVC_OP_STATE_PREP, SVC_OP_STATE_IDLE) != SVC_OP_STATE_IDLE)
QThread::msleep(1);
@ -535,6 +542,7 @@ void CSbieAPI::OnIniChanged(const QString &path)
void CSbieAPI::OnReloadConfig()
{
m_bReloadPending = false;
ReloadConfig();
}
@ -668,7 +676,9 @@ SB_STATUS CSbieAPI::ReloadBoxes()
SB_STATUS CSbieAPI::SbieIniSet(void *RequestBuf, void *pPasswordWithinRequestBuf, const QString& SectionName, const QString& SettingName)
{
retry:
m->Password.toWCharArray((WCHAR*)pPasswordWithinRequestBuf); // fix-me: potential overflow
((WCHAR*)pPasswordWithinRequestBuf)[m->Password.length()] = L'\0';
MSG_HEADER *rpl = NULL;
SB_STATUS Status = CSbieAPI::CallServer((MSG_HEADER *)RequestBuf, &rpl);
@ -679,8 +689,17 @@ SB_STATUS CSbieAPI::SbieIniSet(void *RequestBuf, void *pPasswordWithinRequestBuf
free(rpl);
if (status == 0)
return SB_OK;
if (status == STATUS_LOGON_NOT_GRANTED || status == STATUS_WRONG_PASSWORD)
if (status == STATUS_LOGON_NOT_GRANTED || status == STATUS_WRONG_PASSWORD)
{
if (((MSG_HEADER *)RequestBuf)->msgid != MSGID_SBIE_INI_TEST_PASSWORD)
{
bool bRetry = false;
emit NotAuthorized(status == STATUS_WRONG_PASSWORD, bRetry);
if (bRetry)
goto retry;
}
return SB_ERR(CSbieAPI::tr("You are not authorized to update configuration in section '%1'").arg(SectionName), status);
}
return SB_ERR(CSbieAPI::tr("Failed to set configuration setting %1 in section %2: %3").arg(SettingName).arg(SectionName).arg(status, 8, 16), status);
}
@ -1179,6 +1198,43 @@ bool CSbieAPI::IsBoxEnabled(const QString& BoxName)
return NT_SUCCESS(m->IoControl(parms));
}
bool CSbieAPI::IsConfigLocked()
{
return m->Password.isEmpty() && !SbieIniGet("GlobalSettings", "EditPassword", 0).isEmpty();
}
SB_STATUS CSbieAPI::UnlockConfig(const QString& Password)
{
SBIE_INI_PASSWORD_REQ *req = (SBIE_INI_PASSWORD_REQ *)malloc(REQUEST_LEN);
req->h.msgid = MSGID_SBIE_INI_TEST_PASSWORD;
req->h.length = sizeof(SBIE_INI_PASSWORD_REQ);
m->Password = Password;
SB_STATUS Status = SbieIniSet(req, req->old_password, "GlobalSettings", "*");
if (Status.IsError())
m->Password.clear();
free(req);
return Status;
}
SB_STATUS CSbieAPI::LockConfig(const QString& NewPassword)
{
SBIE_INI_PASSWORD_REQ *req = (SBIE_INI_PASSWORD_REQ *)malloc(REQUEST_LEN);
req->h.msgid = MSGID_SBIE_INI_SET_PASSWORD;
req->h.length = sizeof(SBIE_INI_PASSWORD_REQ);
m->Password.toWCharArray(req->new_password); // fix-me: potential overflow
req->new_password[m->Password.length()] = L'\0';
SB_STATUS Status = SbieIniSet(req, req->old_password, "GlobalSettings", "*");
if (!Status.IsError())
m->Password = NewPassword;
free(req);
return Status;
}
void CSbieAPI::ClearPassword()
{
m->Password.clear();
}
///////////////////////////////////////////////////////////////////////////////
// Log
//
@ -1213,7 +1269,7 @@ bool CSbieAPI::GetLog()
wchar_t* Buffer[4*1024];
ULONG Length = ARRAYSIZE(Buffer);
ULONG MessageId = 0;
ULONG MsgCode = 0;
ULONG ProcessId = 0;
ULONG MessageNum = m->lastMessageNum;
@ -1225,7 +1281,7 @@ bool CSbieAPI::GetLog()
args->func_code = API_GET_MESSAGE;
args->msg_num.val = &MessageNum;
args->session_id.val = m->sessionId;
args->msgid.val = &MessageId;
args->msgid.val = &MsgCode;
args->msgtext.val = &msgtext;
args->process_id.val = &ProcessId;
@ -1237,7 +1293,7 @@ bool CSbieAPI::GetLog()
// we missed something
m->lastMessageNum = MessageNum;
if (MessageId == 0)
if (MsgCode == 0)
return true; // empty dummy message for maintaining sequence consistency
WCHAR *str1 = (WCHAR*)msgtext.Buffer;
@ -1245,7 +1301,36 @@ bool CSbieAPI::GetLog()
WCHAR *str2 = str1 + str1_len + 1;
ULONG str2_len = wcslen(str2);
QString Message = CSbieAPI__FormatSbieMsg(m, MessageId, str1, str2);
//
// 0xTFFFMMMM
//
// T = ttcr
// tt = 00 - Ok
// tt = 01 - Info
// tt = 10 - Warning
// tt = 11 - Error
// c = unused
// r = reserved
//
// FFF = 0x000 UIstr
// FFF = 0x101 POPUP
// FFF = 0x102 EVENT
//
// MMMM = Message Code
//
quint8 Severity = MsgCode >> 30;
quint16 Facility = (MsgCode >> 16) & 0x0FFF;
quint16 MessageId= MsgCode & 0xFFFF;
if (MessageId == 2199) // Auto Recovery notification
{
QString TempStr = QString::fromWCharArray(str1);
int TempPos = TempStr.indexOf(" ");
FileToRecover(TempStr.left(TempPos), Nt2DosPath(TempStr.mid(TempPos + 1)));
return true;
}
QString Message = CSbieAPI__FormatSbieMsg(m, MsgCode, str1, str2);
if(ProcessId != 4) // if its not from the driver add the pid
Message += tr(" by process: %1").arg(ProcessId);
emit LogMessage(Message);
@ -1253,6 +1338,45 @@ bool CSbieAPI::GetLog()
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Forced Processes
//
SB_STATUS CSbieAPI::DisableForceProcess(bool Set)
{
//m_pGlobalSection->SetNum("ForceDisableSeconds", Seconds);
ULONG uEnable = Set ? TRUE : FALSE;
__declspec(align(8)) ULONG64 parms[API_NUM_ARGS];
API_DISABLE_FORCE_PROCESS_ARGS* args = (API_DISABLE_FORCE_PROCESS_ARGS*)parms;
memset(parms, 0, sizeof(parms));
args->func_code = API_DISABLE_FORCE_PROCESS;
args->set_flag.val = &uEnable; // NewState
args->get_flag.val = NULL; // OldState
NTSTATUS status = m->IoControl(parms);
if (!NT_SUCCESS(status))
return SB_ERR(status);
return SB_OK;
}
bool CSbieAPI::AreForceProcessDisabled()
{
ULONG uEnabled = FALSE;
__declspec(align(8)) ULONG64 parms[API_NUM_ARGS];
API_DISABLE_FORCE_PROCESS_ARGS* args = (API_DISABLE_FORCE_PROCESS_ARGS*)parms;
memset(parms, 0, sizeof(parms));
args->func_code = API_DISABLE_FORCE_PROCESS;
args->set_flag.val = NULL; // NewState
args->get_flag.val = &uEnabled; // OldState
return NT_SUCCESS(m->IoControl(parms)) && uEnabled;
}
///////////////////////////////////////////////////////////////////////////////
// Monitor
//
@ -1326,6 +1450,15 @@ bool CSbieAPI::GetMonitor()
return true;
}
///////////////////////////////////////////////////////////////////////////////
// Other
//
QString CSbieAPI::GetSbieMessage(int MessageId, const QString& arg1, const QString& arg2) const
{
return CSbieAPI__FormatSbieMsg(m, MessageId, arg1.toStdWString().c_str(), arg2.toStdWString().c_str());
}
///////////////////////////////////////////////////////////////////////////////
//
//

View File

@ -108,6 +108,15 @@ public:
virtual QString SbieIniGet(const QString& Section, const QString& Setting, quint32 Index = 0, qint32* ErrCode = NULL);
virtual SB_STATUS SbieIniSet(const QString& Section, const QString& Setting, const QString& Value, ESetMode Mode = eIniUpdate);
virtual bool IsBoxEnabled(const QString& BoxName);
virtual CSbieIni* GetGlobalSettings() const { return m_pGlobalSection; }
virtual bool IsConfigLocked();
virtual SB_STATUS UnlockConfig(const QString& Password);
virtual SB_STATUS LockConfig(const QString& NewPassword);
virtual void ClearPassword();
// Forced Processes
virtual SB_STATUS DisableForceProcess(bool Set);
virtual bool AreForceProcessDisabled();
// Monitor
virtual SB_STATUS EnableMonitor(bool Enable);
@ -116,9 +125,14 @@ public:
virtual QList<CResLogEntryPtr> GetResLog() const { QReadLocker Lock(&m_ResLogMutex); return m_ResLogList; }
virtual void ClearResLog() { QWriteLocker Lock(&m_ResLogMutex); m_ResLogList.clear(); }
// Other
virtual QString GetSbieMessage(int MessageId, const QString& arg1 = QString(), const QString& arg2 = QString()) const;
signals:
void StatusChanged();
void LogMessage(const QString& Message, bool bNotify = true);
void FileToRecover(const QString& BoxName, const QString& FilePath);
void NotAuthorized(bool bLoginRequired, bool &bRetry);
private slots:
//virtual void OnMonitorEntry(quint64 ProcessId, quint32 Type, const QString& Value);
@ -169,6 +183,8 @@ protected:
bool m_bTerminate;
CSbieIni* m_pGlobalSection;
private:
mutable QMutex m_ThreadMutex;
mutable QWaitCondition m_ThreadWait;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,362 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsWindow</class>
<widget class="QWidget" name="SettingsWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>573</width>
<height>451</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>SandboxiePlus Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="font">
<font>
<kerning>true</kerning>
</font>
</property>
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_1">
<attribute name="title">
<string>General Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="8" column="2">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="chkShowTray">
<property name="text">
<string>Show Sys-Tray</string>
</property>
</widget>
</item>
<item row="8" column="1">
<spacer name="verticalSpacer_4">
<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="5" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Tray options</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Restart required (!)</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkAutoStart">
<property name="text">
<string>Start with Windows</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="onClose"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="uiLang"/>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="chkDarkTheme">
<property name="text">
<string>Use Dark Theme</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="chkNotifications">
<property name="text">
<string>Show Notifications for relevant log Messages</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>On main window close:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chkWatchConfig">
<property name="text">
<string>Watch Sandboxie.ini for changes</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Advanced Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_5">
<item row="8" column="1" colspan="2">
<widget class="QCheckBox" name="chkAdminOnlyFP">
<property name="text">
<string>Only Administrator user accounts can use Disable Forced Programs command</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="chkAdminOnly">
<property name="text">
<string>Only Administrator user accounts can make changes</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_44">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Config protection</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="chkPassRequired">
<property name="text">
<string>Password must be entered in order to make changes</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="btnSetPassword">
<property name="text">
<string>Change Password</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="fileRoot"/>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="regRoot"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_43">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Sandbox default</string>
</property>
</widget>
</item>
<item row="10" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="10" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Sandbox file system root: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Sandbox ipc root: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="ipcRoot"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Sandbox registry root: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="chkSeparateUserFolders">
<property name="text">
<string>Separate user folders</string>
</property>
</widget>
</item>
<item row="10" column="1">
<spacer name="verticalSpacer_2">
<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="9" column="1">
<widget class="QCheckBox" name="chkClearPass">
<property name="text">
<string>Clear password when main window becomes hidden</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,129 @@
#include "stdafx.h"
#include "WinAdmin.h"
#include <windows.h>
#include <codecvt>
#include <Shlwapi.h>
bool IsElevated()
{
bool fRet = false;
HANDLE hToken = NULL;
if(OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken))
{
TOKEN_ELEVATION Elevation;
DWORD cbSize = sizeof(TOKEN_ELEVATION);
if(GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof( Elevation ), &cbSize))
fRet = Elevation.TokenIsElevated;
}
if(hToken)
CloseHandle(hToken);
return fRet;
}
int RunElevated(const wstring& Params, bool bGetCode)
{
wchar_t szPath[MAX_PATH];
if (!GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)))
return -3;
return RunElevated(wstring(szPath), Params, bGetCode);
}
int RunElevated(const wstring& binaryPath, const wstring& Params, bool bGetCode)
{
// Launch itself as admin
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb = L"runas";
sei.lpFile = binaryPath.c_str();
sei.lpParameters = Params.c_str();
sei.hwnd = NULL;
sei.nShow = SW_NORMAL;
if (!ShellExecuteEx(&sei))
{
DWORD dwError = GetLastError();
if (dwError == ERROR_CANCELLED)
return -2; // The user refused to allow privileges elevation.
}
else
{
if (bGetCode)
{
WaitForSingleObject(sei.hProcess, 10000);
DWORD ExitCode = -4;
BOOL success = GetExitCodeProcess(sei.hProcess, &ExitCode);
CloseHandle(sei.hProcess);
return success ? ExitCode : -4;
}
return 0;
}
return -1;
}
int RestartElevated(int &argc, char **argv)
{
wstring Params;
for (int i = 1; i < argc; i++)
{
if (i > 1)
Params.append(L" ");
Params.append(L"\"" + wstring_convert<codecvt_utf8<wchar_t>>().from_bytes(argv[i]) + L"\"");
}
return RunElevated(Params);
}
//////////////////////////////////////////////////////////////////////////////////
// AutoRun
#define APP_NAME L"SandboxiePlus"
#define AUTO_RUN_KEY_NAME APP_NAME L"_AutoRun"
bool IsAutorunEnabled()
{
bool result = false;
HKEY hkey = nullptr;
if (RegOpenKeyEx (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS)
{
WCHAR buffer[MAX_PATH] = {0};
DWORD size = _countof (buffer);
if (RegQueryValueEx (hkey, AUTO_RUN_KEY_NAME, nullptr, nullptr, (LPBYTE)buffer, &size) == ERROR_SUCCESS)
{
result = true; // todo: check path
}
RegCloseKey (hkey);
}
return result;
}
bool AutorunEnable (bool is_enable)
{
bool result = false;
HKEY hkey = nullptr;
if (RegOpenKeyEx (HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey) == ERROR_SUCCESS)
{
if (is_enable)
{
wchar_t szPath[MAX_PATH];
if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)))
{
wstring path = L"\"" + wstring(szPath) + L"\" -autorun";
result = (RegSetValueEx(hkey, AUTO_RUN_KEY_NAME, 0, REG_SZ, (LPBYTE)path.c_str(), DWORD((path.length() + 1) * sizeof(WCHAR))) == ERROR_SUCCESS);
}
}
else
{
result = (RegDeleteValue (hkey, AUTO_RUN_KEY_NAME) == ERROR_SUCCESS);
}
RegCloseKey (hkey);
}
return false;
}

View File

@ -0,0 +1,9 @@
#pragma once
bool IsElevated();
int RunElevated(const wstring& Params, bool bGetCode = false);
int RunElevated(const wstring& binaryPath, const wstring& Params, bool bGetCode = false);
int RestartElevated(int &argc, char **argv);
bool IsAutorunEnabled();
bool AutorunEnable(bool is_enable);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -25,6 +25,7 @@
<file alias="Stop">Actions/Stop.png</file>
<file alias="Advanced">Actions/Advanced.png</file>
<file alias="Service">Actions/Service.png</file>
<file alias="Settings">Actions/config.png</file>
</qresource>
<qresource prefix="/Boxes">
<file alias="Empty3">Boxes/sandbox-b-empty.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -10,6 +10,7 @@
#include "./Dialogs/MultiErrorDialog.h"
#include "../QSbieAPI/SbieUtils.h"
#include "../QSbieAPI/Sandboxie/BoxBorder.h"
#include "Windows/SettingsWindow.h"
CSbiePlusAPI* theAPI = NULL;
@ -81,6 +82,13 @@ CSandMan::CSandMan(QWidget *parent)
theGUI = this;
m_DefaultStyle = QApplication::style()->objectName();
m_DefaultPalett = QApplication::palette();
LoadLanguage();
if (theConf->GetBool("Options/DarkTheme", false))
SetDarkTheme(true);
m_bExit = false;
theAPI = new CSbiePlusAPI(this);
@ -114,47 +122,6 @@ CSandMan::CSandMan(QWidget *parent)
m_pPanelSplitter->setOrientation(Qt::Horizontal);
m_pLogSplitter->addWidget(m_pPanelSplitter);
/*
// Box Tree
m_pBoxModel = new CSbieModel();
m_pBoxModel->SetTree(true);
m_pBoxModel->SetUseIcons(true);
m_pSortProxy = new CSortFilterProxyModel(false, this);
m_pSortProxy->setSortRole(Qt::EditRole);
m_pSortProxy->setSourceModel(m_pBoxModel);
m_pSortProxy->setDynamicSortFilter(true);
m_pBoxTree = new QTreeViewEx();
//m_pBoxTree->setItemDelegate(theGUI->GetItemDelegate());
m_pBoxTree->setModel(m_pSortProxy);
m_pBoxTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
#ifdef WIN32
QStyle* pStyle = QStyleFactory::create("windows");
m_pBoxTree->setStyle(pStyle);
#endif
m_pBoxTree->setSortingEnabled(true);
m_pBoxTree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_pBoxTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnMenu(const QPoint &)));
//connect(theGUI, SIGNAL(ReloadPanels()), m_pWindowModel, SLOT(Clear()));
m_pBoxTree->setColumnReset(2);
connect(m_pBoxTree, SIGNAL(ResetColumns()), this, SLOT(OnResetColumns()));
connect(m_pBoxTree, SIGNAL(ColumnChanged(int, bool)), this, SLOT(OnColumnsChanged()));
//m_pSplitter->addWidget(CFinder::AddFinder(m_pBoxTree, m_pSortProxy));
//m_pSplitter->setCollapsible(0, false);
//
//connect(m_pBoxTree, SIGNAL(clicked(const QModelIndex&)), this, SLOT(OnItemSelected(const QModelIndex&)));
//connect(m_pBoxTree->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(OnItemSelected(QModelIndex)));
m_pPanelSplitter->addWidget(m_pBoxTree);
*/
m_pBoxView = new CSbieView();
m_pPanelSplitter->addWidget(m_pBoxView);
@ -246,6 +213,8 @@ CSandMan::CSandMan(QWidget *parent)
m_pKeepTerminated->setCheckable(true);
m_pMenuOptions = menuBar()->addMenu(tr("&Options"));
m_pMenuSettings = m_pMenuOptions->addAction(MakeActionIcon(":/Actions/Settings"), tr("Global Settings"), this, SLOT(OnSettings()));
m_pMenuOptions->addSeparator();
m_pEditIni = m_pMenuOptions->addAction(QIcon(":/Actions/EditIni"), tr("Edit ini file"), this, SLOT(OnEditIni()));
m_pReloadIni = m_pMenuOptions->addAction(QIcon(":/Actions/ReloadIni"), tr("Reload ini file"), this, SLOT(OnReloadIni()));
m_pMenuOptions->addSeparator();
@ -264,6 +233,8 @@ CSandMan::CSandMan(QWidget *parent)
m_pAbout = m_pMenuHelp->addAction(QIcon(":/SandMan.png"), tr("About Sandboxie-Plus"), this, SLOT(OnAbout()));
m_pToolBar->addAction(m_pMenuSettings);
m_pToolBar->addSeparator();
//m_pToolBar->addAction(m_pMenuNew);
//m_pToolBar->addAction(m_pMenuEmptyAll);
@ -341,18 +312,22 @@ CSandMan::CSandMan(QWidget *parent)
if (theConf->GetBool("Options/NoStatusBar", false))
statusBar()->hide();
else if (theConf->GetBool("Options/NoSizeGrip", false))
statusBar()->setSizeGripEnabled(false);
//else if (theConf->GetBool("Options/NoSizeGrip", false))
// statusBar()->setSizeGripEnabled(false);
m_pKeepTerminated->setChecked(theConf->GetBool("Options/KeepTerminated"));
m_pProgressDialog = new CProgressDialog("Maintenance operation progress...", this);
m_pProgressDialog->setWindowModality(Qt::ApplicationModal);
if (!bAutoRun)
show();
if (CSbieUtils::IsRunning(CSbieUtils::eAll) || theConf->GetBool("Options/StartIfStopped", true))
ConnectSbie();
connect(theAPI, SIGNAL(LogMessage(const QString&, bool)), this, SLOT(OnLogMessage(const QString&, bool)));
connect(theAPI, SIGNAL(NotAuthorized(bool, bool&)), this, SLOT(OnNotAuthorized(bool, bool&)), Qt::DirectConnection);
m_uTimerID = startTimer(250);
}
@ -395,6 +370,9 @@ void CSandMan::closeEvent(QCloseEvent *e)
{
hide();
if (theAPI->GetGlobalSettings()->GetBool("ForgetPassword", false))
theAPI->ClearPassword();
e->ignore();
return;
}
@ -486,8 +464,6 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
theAPI->UpdateProcesses(m_pKeepTerminated->isChecked());
}
m_pBoxView->Refresh();
if (m_bIconEmpty != (theAPI->TotalProcesses() == 0))
{
m_bIconEmpty = (theAPI->TotalProcesses() == 0);
@ -496,16 +472,10 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
m_pTrayIcon->setIcon(Icon);
}
/*QList<QVariant> Added = m_pBoxModel->Sync(theAPI->GetAllBoxes());
if (!isVisible() || windowState().testFlag(Qt::WindowMinimized))
return;
if (m_pBoxModel->IsTree())
{
QTimer::singleShot(100, this, [this, Added]() {
foreach(const QVariant ID, Added) {
m_pBoxTree->expand(m_pSortProxy->mapFromSource(m_pBoxModel->FindIndex(ID)));
}
});
}*/
m_pBoxView->Refresh();
OnSelectionChanged();
}
@ -605,7 +575,7 @@ void CSandMan::OnLogMessage(const QString& Message, bool bNotify)
if (bNotify)
{
int iNotify = theConf->GetInt("Options/Notifications", 1);
int iNotify = theConf->GetInt("Options/ShowNotifications", 1);
if (iNotify & 1)
m_pTrayIcon->showMessage("Sandboxie-Plus", Message);
if (iNotify & 2)
@ -613,25 +583,36 @@ void CSandMan::OnLogMessage(const QString& Message, bool bNotify)
}
}
/*
void CSandMan::OnResetColumns()
void CSandMan::OnNotAuthorized(bool bLoginRequired, bool& bRetry)
{
for (int i = 0; i < m_pBoxModel->columnCount(); i++)
m_pBoxTree->SetColumnHidden(i, false);
}
if (!bLoginRequired)
{
QMessageBox::warning(this, "Sandboxie-Plus", tr("Only Administrators can change the config."));
return;
}
void CSandMan::OnColumnsChanged()
{
m_pBoxModel->Sync(theAPI->GetAllBoxes());
static bool LoginOpen = false;
if (LoginOpen)
return;
LoginOpen = true;
for (;;)
{
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the configuration password."), QLineEdit::Password);
if (Value.isEmpty())
break;
SB_STATUS Status = theAPI->UnlockConfig(Value);
if (!Status.IsError()) {
bRetry = true;
break;
}
QMessageBox::warning(this, "Sandboxie-Plus", tr("Login Failed: %1").arg(Status.GetText()));
}
LoginOpen = false;
}
void CSandMan::OnMenu(const QPoint& Point)
{
}*/
void CSandMan::OnNewBox()
{
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", "Please enter a name for the new Sandbox.", QLineEdit::Normal, "NewBox");
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter a name for the new Sandbox."), QLineEdit::Normal, "NewBox");
if (Value.isEmpty())
return;
theAPI->CreateBox(Value);
@ -784,6 +765,23 @@ void CSandMan::OnSetKeep()
theAPI->UpdateProcesses(false);
}
void CSandMan::OnSettings()
{
CSettingsWindow* pSettingsWindow = new CSettingsWindow(this);
connect(pSettingsWindow, SIGNAL(OptionsChanged()), this, SLOT(UpdateSettings()));
pSettingsWindow->show();
}
void CSandMan::UpdateSettings()
{
SetDarkTheme(theConf->GetBool("Options/DarkTheme", false));
if (theConf->GetBool("Options/ShowSysTray", true))
m_pTrayIcon->show();
else
m_pTrayIcon->hide();
}
void CSandMan::OnEditIni()
{
if (theConf->GetBool("Options/NoEditInfo", true))
@ -901,7 +899,12 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason)
{
if(TriggerSet)
NullifyTrigger = true;
hide();
if (theAPI->GetGlobalSettings()->GetBool("ForgetPassword", false))
theAPI->ClearPassword();
break;
}
show();
@ -976,6 +979,62 @@ void CSandMan::OnAbout()
QDesktopServices::openUrl(QUrl("https://www.patreon.com/DavidXanatos"));
}
void CSandMan::SetDarkTheme(bool bDark)
{
if (bDark)
{
QApplication::setStyle(QStyleFactory::create("Fusion"));
QPalette palette;
palette.setColor(QPalette::Window, QColor(53, 53, 53));
palette.setColor(QPalette::WindowText, Qt::white);
palette.setColor(QPalette::Base, QColor(25, 25, 25));
palette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
palette.setColor(QPalette::ToolTipBase, Qt::white);
palette.setColor(QPalette::ToolTipText, Qt::white);
palette.setColor(QPalette::Text, Qt::white);
palette.setColor(QPalette::Button, QColor(53, 53, 53));
palette.setColor(QPalette::ButtonText, Qt::white);
palette.setColor(QPalette::BrightText, Qt::red);
palette.setColor(QPalette::Link, QColor(218, 130, 42));
palette.setColor(QPalette::Highlight, QColor(42, 130, 218));
palette.setColor(QPalette::HighlightedText, Qt::black);
QApplication::setPalette(palette);
}
else
{
QApplication::setStyle(QStyleFactory::create(m_DefaultStyle));
QApplication::setPalette(m_DefaultPalett);
}
CTreeItemModel::SetDarkMode(bDark);
CListItemModel::SetDarkMode(bDark);
}
void CSandMan::LoadLanguage()
{
qApp->removeTranslator(&m_Translator);
m_Translation.clear();
QString Lang = theConf->GetString("Options/Language");
if (!Lang.isEmpty())
{
QString LangAux = Lang; // Short version as fallback
LangAux.truncate(LangAux.lastIndexOf('_'));
QString LangPath = QApplication::applicationDirPath() + "/translations/taskexplorer_";
bool bAux = false;
if (QFile::exists(LangPath + Lang + ".qm") || (bAux = QFile::exists(LangPath + LangAux + ".qm")))
{
QFile File(LangPath + (bAux ? LangAux : Lang) + ".qm");
File.open(QFile::ReadOnly);
m_Translation = File.readAll();
}
if (!m_Translation.isEmpty() && m_Translator.load((const uchar*)m_Translation.data(), m_Translation.size()))
qApp->installTranslator(&m_Translator);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//
/*

View File

@ -8,10 +8,11 @@
#include "../MiscHelpers/Common/ProgressDialog.h"
#include "Models/ResMonModel.h"
#include "Models/ApiMonModel.h"
#include <QTranslator>
#define VERSION_MJR 0
#define VERSION_MIN 3
#define VERSION_REV 0
#define VERSION_REV 5
#define VERSION_UPD 0
@ -60,13 +61,13 @@ public slots:
void OnStatusChanged();
void OnLogMessage(const QString& Message, bool bNotify = false);
void OnNotAuthorized(bool bLoginRequired, bool& bRetry);
void UpdateSettings();
private slots:
void OnSelectionChanged();
//void OnResetColumns();
//void OnColumnsChanged();
//void OnMenu(const QPoint& Point);
void OnMenuHover(QAction* action);
void OnNewBox();
@ -76,6 +77,7 @@ private slots:
void OnCleanUp();
void OnSetKeep();
void OnSettings();
void OnEditIni();
void OnReloadIni();
void OnSetMonitoring();
@ -96,9 +98,6 @@ private:
QSplitter* m_pLogSplitter;
//QTreeViewEx* m_pBoxTree;
//CSbieModel* m_pBoxModel;
//QSortFilterProxyModel* m_pSortProxy;
CSbieView* m_pBoxView;
@ -139,6 +138,7 @@ private:
QAction* m_pKeepTerminated;
QMenu* m_pMenuOptions;
QAction* m_pMenuSettings;
QAction* m_pEditIni;
QAction* m_pReloadIni;
QAction* m_pEnableMonitoring;
@ -156,6 +156,14 @@ private:
bool m_bExit;
CProgressDialog* m_pProgressDialog;
void SetDarkTheme(bool bDark);
QString m_DefaultStyle;
QPalette m_DefaultPalett;
void LoadLanguage();
QTranslator m_Translator;
QByteArray m_Translation;
};
extern CSandMan* theGUI;

View File

@ -193,7 +193,9 @@
<ItemGroup>
<ClCompile Include="ApiLog.cpp" />
<ClCompile Include="Dialogs\MultiErrorDialog.cpp" />
<ClCompile Include="Helpers\WinAdmin.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="Models\ApiMonModel.cpp" />
<ClCompile Include="Models\ResMonModel.cpp" />
<ClCompile Include="Models\SbieModel.cpp" />
<ClCompile Include="SandMan.cpp" />
@ -205,14 +207,20 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Views\SbieView.cpp" />
<ClCompile Include="Windows\OptionsWindow.cpp" />
<ClCompile Include="Windows\SettingsWindow.cpp" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="Windows\SettingsWindow.h" />
<QtMoc Include="Windows\OptionsWindow.h" />
<QtMoc Include="Views\SbieView.h" />
<QtMoc Include="SandMan.h" />
<QtMoc Include="Models\SbieModel.h" />
<QtMoc Include="Models\ResMonModel.h" />
<QtMoc Include="ApiLog.h" />
<QtMoc Include="Dialogs\MultiErrorDialog.h" />
<QtMoc Include="Models\ApiMonModel.h" />
<ClInclude Include="Helpers\WinAdmin.h" />
<ClInclude Include="Resources\resource.h" />
<QtMoc Include="SbiePlusAPI.h" />
<ClInclude Include="stdafx.h" />
@ -226,6 +234,10 @@
<ItemGroup>
<Image Include="Resources\SandMan.ico" />
</ItemGroup>
<ItemGroup>
<QtUic Include="Forms\OptionsWindow.ui" />
<QtUic Include="Forms\SettingsWindow.ui" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
<Import Project="$(QtMsBuild)\qt.targets" />

View File

@ -35,6 +35,12 @@
<Filter Include="Dialogs">
<UniqueIdentifier>{6accf3ae-da17-4c0f-ba83-214e3874b029}</UniqueIdentifier>
</Filter>
<Filter Include="Helpers">
<UniqueIdentifier>{20d5954b-be86-4a34-948d-00954dcfd07b}</UniqueIdentifier>
</Filter>
<Filter Include="Windows">
<UniqueIdentifier>{d0068730-c9fb-49ef-90ec-8ecd2131ae47}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
@ -64,6 +70,18 @@
<ClCompile Include="SbiePlusAPI.cpp">
<Filter>SandMan</Filter>
</ClCompile>
<ClCompile Include="Models\ApiMonModel.cpp">
<Filter>Models</Filter>
</ClCompile>
<ClCompile Include="Helpers\WinAdmin.cpp">
<Filter>Helpers</Filter>
</ClCompile>
<ClCompile Include="Windows\OptionsWindow.cpp">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="Windows\SettingsWindow.cpp">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@ -72,6 +90,9 @@
<ClInclude Include="Resources\resource.h">
<Filter>Resource Files</Filter>
</ClInclude>
<ClInclude Include="Helpers\WinAdmin.h">
<Filter>Helpers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtMoc Include="SandMan.h">
@ -95,6 +116,15 @@
<QtMoc Include="SbiePlusAPI.h">
<Filter>SandMan</Filter>
</QtMoc>
<QtMoc Include="Models\ApiMonModel.h">
<Filter>Models</Filter>
</QtMoc>
<QtMoc Include="Windows\OptionsWindow.h">
<Filter>Windows</Filter>
</QtMoc>
<QtMoc Include="Windows\SettingsWindow.h">
<Filter>Windows</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtRcc Include="Resources\SandMan.qrc">
@ -111,4 +141,12 @@
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<QtUic Include="Forms\SettingsWindow.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="Forms\OptionsWindow.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
</Project>

View File

@ -1,5 +1,6 @@
#include "stdafx.h"
#include "SbiePlusAPI.h"
#include "..\MiscHelpers\Common\Common.h"
CSbiePlusAPI::CSbiePlusAPI(QObject* parent) : CSbieAPI(parent)
@ -120,14 +121,14 @@ void CSandBoxPlus::SetLogApi(bool bEnable)
void CSandBoxPlus::SetINetBlock(bool bEnable)
{
if (bEnable)
DelValue("ClosedFilePath", "InternetAccessDevices");
DelValue("ClosedFilePath", "!<InternetAccess>,InternetAccessDevices");
else
InsertText("ClosedFilePath", "InternetAccessDevices");
}
void CSandBoxPlus::SetAllowShares(bool bEnable)
{
SetBool("BlockNetworkFiles", bEnable);
SetBool("BlockNetworkFiles", !bEnable);
}
void CSandBoxPlus::SetDropRights(bool bEnable)

View File

@ -4,6 +4,7 @@
#include "../QSbieAPI/SbieAPI.h"
#include "../../MiscHelpers/Common/SortFilterProxyModel.h"
#include "../../MiscHelpers/Common/Settings.h"
#include "../Windows/OptionsWindow.h"
CSbieView::CSbieView(QWidget* parent) : CPanelView(parent)
{
@ -32,6 +33,7 @@ CSbieView::CSbieView(QWidget* parent) : CPanelView(parent)
m_pSbieTree->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_pSbieTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnMenu(const QPoint &)));
connect(m_pSbieTree, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(OnDoubleClicked(const QModelIndex&)));
connect(m_pSbieTree->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(ProcessSelection(QItemSelection, QItemSelection)));
//connect(theGUI, SIGNAL(ReloadPanels()), m_pSbieModel, SLOT(Clear()));
@ -62,7 +64,7 @@ CSbieView::CSbieView(QWidget* parent) : CPanelView(parent)
m_pMenuPresetsShares->setCheckable(true);
m_pMenuPresetsNoAdmin = m_pMenuPresets->addAction(tr("Drop Admin Rights"), this, SLOT(OnSandBoxAction()));
m_pMenuPresetsNoAdmin->setCheckable(true);
m_pMenuOptions = m_pMenu->addAction(tr("Sandbox Options"), this, SLOT(OnSandBoxAction()));
m_pMenuRename = m_pMenu->addAction(tr("Rename Sandbox"), this, SLOT(OnSandBoxAction()));
m_pMenuRemove = m_pMenu->addAction(tr("Remove Sandbox"), this, SLOT(OnSandBoxAction()));
m_iMenuBox = m_pMenu->actions().count();
@ -168,6 +170,7 @@ void CSbieView::OnMenu(const QPoint& Point)
m_pMenuPresetsShares->setChecked(pBox && pBox.objectCast<CSandBoxPlus>()->HasSharesAccess());
m_pMenuPresetsNoAdmin->setChecked(pBox && pBox.objectCast<CSandBoxPlus>()->IsDropRights());
m_pMenuOptions->setEnabled(iSandBoxeCount == 1);
for (int i = m_iMenuBox; i < m_iMenuProc; i++)
MenuActions[i]->setVisible(iProcessCount > 0 && iSandBoxeCount == 0);
@ -207,11 +210,15 @@ void CSbieView::OnSandBoxAction()
SandBoxes.first().objectCast<CSandBoxPlus>()->SetAllowShares(m_pMenuPresetsShares->isChecked());
else if (Action == m_pMenuPresetsNoAdmin)
SandBoxes.first().objectCast<CSandBoxPlus>()->SetDropRights(m_pMenuPresetsNoAdmin->isChecked());
else if (Action == m_pMenuOptions)
{
COptionsWindow* pOptionsWindow = new COptionsWindow(SandBoxes.first(), SandBoxes.first()->GetName(), this);
pOptionsWindow->show();
}
else if (Action == m_pMenuRename)
{
QString OldValue = SandBoxes.first()->GetName().replace("_", " ");
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", "Please enter a new name for the Sandbox.", QLineEdit::Normal, OldValue);
QString Value = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter a new name for the Sandbox."), QLineEdit::Normal, OldValue);
if (Value.isEmpty() || Value == OldValue)
return;
Results.append((SandBoxes.first()->RenameBox(Value)));
@ -281,6 +288,17 @@ void CSbieView::OnProcessAction()
CSandMan::CheckResults(Results);
}
void CSbieView::OnDoubleClicked(const QModelIndex& index)
{
QModelIndex ModelIndex = m_pSortProxy->mapToSource(index);
CSandBoxPtr pBox = m_pSbieModel->GetSandBox(ModelIndex);
if (pBox.isNull())
return;
COptionsWindow* pOptionsWindow = new COptionsWindow(pBox, pBox->GetName(), this);
pOptionsWindow->show();
}
void CSbieView::ProcessSelection(const QItemSelection& selected, const QItemSelection& deselected)
{
if (selected.empty())

View File

@ -21,6 +21,7 @@ public slots:
private slots:
void OnToolTipCallback(const QVariant& ID, QString& ToolTip);
void OnDoubleClicked(const QModelIndex& index);
void ProcessSelection(const QItemSelection& selected, const QItemSelection& deselected);
void OnSandBoxAction();
@ -52,6 +53,7 @@ private:
QAction* m_pMenuPresetsINet;
QAction* m_pMenuPresetsShares;
QAction* m_pMenuPresetsNoAdmin;
QAction* m_pMenuOptions;
QAction* m_pMenuEmptyBox;
QAction* m_pMenuCleanUp;
QAction* m_pMenuRemove;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,196 @@
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_OptionsWindow.h"
#include "SbiePlusAPI.h"
class COptionsWindow : public QMainWindow
{
Q_OBJECT
public:
COptionsWindow(const QSharedPointer<CSbieIni>& pBox, const QString& Name, QWidget *parent = Q_NULLPTR);
~COptionsWindow();
signals:
void OptionsChanged();
public slots:
void apply();
void accept();
void reject();
private slots:
void OnPickColor();
void OnAddGroup();
void OnAddProg();
void OnDelProg();
void OnForceProg();
void OnForceDir();
void OnDelForce();
void OnShowForceTmpl() { LoadForced(); }
void OnAddLingering();
void OnAddLeader();
void OnDelStopProg();
void OnShowStopTmpl() { LoadStop(); }
void OnRestrictStart();
void OnAddStartProg();
void OnDelStartProg();
void OnBlockINet();
void OnAddINetProg();
void OnDelINetProg();
void OnAccessItemClicked(QTreeWidgetItem* pItem, int Column);
void OnAccessItemDoubleClicked(QTreeWidgetItem* pItem, int Column);
void OnAddFile() { AddAccessEntry(eFile, eDirect, "", ""); }
void OnAddKey() { AddAccessEntry(eKey, eDirect, "", ""); }
void OnAddIPC() { AddAccessEntry(eIPC, eDirect, "", ""); }
void OnAddClsId() { AddAccessEntry(eWndCls, eDirect, "", ""); }
void OnAddCOM() { AddAccessEntry(eClsId, eDirect, "", ""); }
void OnDelAccess();
void OnShowAccessTmpl() { LoadAccessList(); }
void OnAddUser();
void OnDelUser();
void OnFilterTemplates() { ShowTemplates(); }
void OnTemplateClicked(QTreeWidgetItem* pItem, int Column);
void OnTemplateDoubleClicked(QTreeWidgetItem* pItem, int Column);
void OnTab();
void OnGeneralChanged();
void OnStartChanged() { m_StartChanged = true; }
void OnRestrictionChanged() { m_RestrictionChanged = true; }
void OnINetBlockChanged() { m_INetBlockChanged = true; }
void OnAdvancedChanged();
void SetIniEdit(bool bEnable);
void OnEditIni();
void OnSaveIni();
void OnCancelEdit();
protected:
void closeEvent(QCloseEvent *e);
enum EAccessEntry
{
eOpenFilePath,
eOpenPipePath,
eClosedFilePath,
eReadFilePath,
eWriteFilePath,
eOpenKeyPath,
eClosedKeyPath,
eReadKeyPath,
eWriteKeyPath,
eOpenIpcPath,
eClosedIpcPath,
eOpenWinClass,
eOpenClsid,
eMaxAccessType
};
enum EAccessType
{
eFile,
eKey,
eIPC,
eWndCls,
eClsId
};
enum EAccessMode
{
eDirect,
eFull,
eClosed,
eReadOnly,
eWriteOnly
};
void SetProgramItem(QString Program, QTreeWidgetItem* pItem, int Column);
QString SelectProgram(bool bOrGroup = true);
void CopyGroupToList(const QString& Groupe, QTreeWidget* pTree);
QTreeWidgetItem* GetAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
void SetAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
void DelAccessEntry(EAccessType Type, const QString& Program, EAccessMode Mode, const QString& Path);
void AddProgToGroup(QTreeWidget* pTree, const QString& Groupe);
void AddProgToGroup(const QString& Value, const QString& Groupe);
void DelProgFromGroup(QTreeWidget* pTree, const QString& Groupe);
void LoadConfig();
void SaveConfig();
void LoadGroups();
void SaveGroups();
void LoadForced();
void AddForcedEntry(const QString& Name, int type, const QString& Template = QString());
void SaveForced();
void LoadStop();
void AddStopEntry(const QString& Name, int type, const QString& Template = QString());
void SaveStop();
QString AccessTypeToName(EAccessEntry Type);
void LoadAccessList();
QString GetAccessTypeStr(EAccessType Type);
QString GetAccessModeStr(EAccessMode Mode);
void ParseAndAddAccessEntry(EAccessEntry EntryType, const QString& Value, const QString& Template = QString());
void AddAccessEntry(EAccessType Type, EAccessMode Mode, QString Program, const QString& Path, const QString& Template = QString());
QString MakeAccessStr(EAccessType Type, EAccessMode Mode);
void SaveAccessList();
QList<EAccessMode> GetAccessModes(EAccessType Type);
void DeleteAccessEntry(QTreeWidgetItem* pItem);
void LoadTemplates();
void ShowTemplates();
void SaveTemplates();
void LoadIniSection();
void SaveIniSection();
bool m_ConfigDirty;
QColor m_BorderColor;
bool m_GeneralChanged;
bool m_GroupsChanged;
bool m_ForcedChanged;
bool m_StopChanged;
bool m_StartChanged;
bool m_RestrictionChanged;
bool m_INetBlockChanged;
bool m_AccessChanged;
bool m_TemplatesChanged;
bool m_AdvancedChanged;
bool m_Template;
QSet<QString> m_TemplateGroups;
QMultiMap<QString, QPair<QString, QString>> m_AllTemplates;
QStringList m_GlobalTemplates;
QStringList m_BoxTemplates;
QList<QPair<QString, QString>> m_Settings;
QSharedPointer<CSbieIni> m_pBox;
private:
Ui::OptionsWindow ui;
};

View File

@ -0,0 +1,168 @@
#include "stdafx.h"
#include "SettingsWindow.h"
#include "SandMan.h"
#include "../MiscHelpers/Common/Settings.h"
#include "Helpers/WinAdmin.h"
CSettingsWindow::CSettingsWindow(QWidget *parent)
: QMainWindow(parent)
{
QWidget* centralWidget = new QWidget();
ui.setupUi(centralWidget);
this->setCentralWidget(centralWidget);
this->setWindowTitle(tr("Sandboxie Plus - Settings"));
ui.uiLang->addItem("International Englisch", "");
QDir langDir(QApplication::applicationDirPath() + "/translations/");
foreach(const QString& langFile, langDir.entryList(QStringList("taskexplorer_*.qm"), QDir::Files))
{
QString Code = langFile.mid(13, langFile.length() - 13 - 3);
QLocale Locale(Code);
QString Lang = Locale.nativeLanguageName();
ui.uiLang->addItem(Lang, Code);
}
ui.uiLang->setCurrentIndex(ui.uiLang->findData(theConf->GetString("Options/Language")));
ui.chkAutoStart->setChecked(IsAutorunEnabled());
ui.chkDarkTheme->setChecked(theConf->GetBool("Options/DarkTheme", false));
ui.chkNotifications->setChecked(theConf->GetBool("Options/ShowNotifications", true));
ui.chkWatchConfig->setChecked(theConf->GetBool("Options/WatchIni", true));
ui.onClose->addItem(tr("Close to Tray"), "ToTray");
ui.onClose->addItem(tr("Prompt before Close"), "Prompt");
ui.onClose->addItem(tr("Close"), "Close");
ui.onClose->setCurrentIndex(ui.onClose->findData(theConf->GetString("Options/OnClose", "ToTray")));
ui.chkShowTray->setChecked(theConf->GetBool("Options/ShowSysTray", true));
connect(ui.chkShowTray, SIGNAL(stateChanged(int)), this, SLOT(OnChange()));
//connect(ui.chkUseCycles, SIGNAL(stateChanged(int)), this, SLOT(OnChange()));
ui.fileRoot->setText(theAPI->GetGlobalSettings()->GetText("FileRootPath"));
ui.chkSeparateUserFolders->setChecked(theAPI->GetGlobalSettings()->GetBool("SeparateUserFolders", true));
ui.regRoot->setText(theAPI->GetGlobalSettings()->GetText("KeyRootPath"));
ui.ipcRoot->setText(theAPI->GetGlobalSettings()->GetText("IpcRootPath"));
ui.chkAdminOnly->setChecked(theAPI->GetGlobalSettings()->GetBool("EditAdminOnly", false));
ui.chkPassRequired->setChecked(!theAPI->GetGlobalSettings()->GetText("EditPassword", "").isEmpty());
connect(ui.chkPassRequired, SIGNAL(stateChanged(int)), this, SLOT(OnChange()));
connect(ui.btnSetPassword, SIGNAL(pressed()), this, SLOT(OnSetPassword()));
ui.chkAdminOnlyFP->setChecked(theAPI->GetGlobalSettings()->GetBool("ForceDisableAdminOnly", false));
ui.chkClearPass->setChecked(theAPI->GetGlobalSettings()->GetBool("ForgetPassword", false));
connect(ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(pressed()), this, SLOT(accept()));
connect(ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(pressed()), this, SLOT(apply()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
restoreGeometry(theConf->GetBlob("SettingsWindow/Window_Geometry"));
OnChange();
}
CSettingsWindow::~CSettingsWindow()
{
theConf->SetBlob("SettingsWindow/Window_Geometry",saveGeometry());
}
void CSettingsWindow::closeEvent(QCloseEvent *e)
{
this->deleteLater();
}
void CSettingsWindow::apply()
{
theConf->SetValue("Options/Language", ui.uiLang->currentData());
theConf->SetValue("Options/DarkTheme", ui.chkDarkTheme->isChecked());
AutorunEnable(ui.chkAutoStart->isChecked());
theConf->SetValue("Options/ShowNotifications", ui.chkNotifications->isChecked());
theConf->SetValue("Options/WatchIni", ui.chkWatchConfig->isChecked());
theConf->SetValue("Options/OnClose", ui.onClose->currentData());
theConf->SetValue("Options/ShowSysTray", ui.chkShowTray->isChecked());
if (ui.fileRoot->text().isEmpty())
ui.fileRoot->setText("\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%");
theAPI->GetGlobalSettings()->SetText("FileRootPath", ui.fileRoot->text());
theAPI->GetGlobalSettings()->SetBool("SeparateUserFolders", ui.chkSeparateUserFolders->isChecked());
if (ui.regRoot->text().isEmpty())
ui.regRoot->setText("\\REGISTRY\\USER\\Sandbox_%USER%_%SANDBOX%");
theAPI->GetGlobalSettings()->SetText("KeyRootPath", ui.regRoot->text());
if (ui.ipcRoot->text().isEmpty())
ui.ipcRoot->setText("\\Sandbox\\%USER%\\%SANDBOX%\\Session_%SESSION%");
theAPI->GetGlobalSettings()->SetText("IpcRootPath", ui.ipcRoot->text());
theAPI->GetGlobalSettings()->SetBool("EditAdminOnly", ui.chkAdminOnly->isChecked());
bool isPassSet = !theAPI->GetGlobalSettings()->GetText("EditPassword", "").isEmpty();
if (ui.chkPassRequired->isChecked())
{
if (!isPassSet && m_NewPassword.isEmpty())
OnSetPassword(); // request password entry if it wasn't already
if (!m_NewPassword.isEmpty()) {
theAPI->LockConfig(m_NewPassword); // set new/changed password
m_NewPassword.clear();
}
}
else if (isPassSet)
theAPI->LockConfig(QString()); // clear password
theAPI->GetGlobalSettings()->SetBool("ForceDisableAdminOnly", ui.chkAdminOnlyFP->isChecked());
theAPI->GetGlobalSettings()->SetBool("ForgetPassword", ui.chkClearPass->isChecked());
emit OptionsChanged();
}
void CSettingsWindow::accept()
{
apply();
this->close();
}
void CSettingsWindow::reject()
{
this->close();
}
void CSettingsWindow::OnChange()
{
//ui.chkLinuxStyle->setEnabled(!ui.chkUseCycles->isChecked());
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(ui.onClose->model());
QStandardItem *item = model->item(0);
item->setFlags((!ui.chkShowTray->isChecked()) ? item->flags() & ~Qt::ItemIsEnabled : item->flags() | Qt::ItemIsEnabled);
ui.btnSetPassword->setEnabled(ui.chkPassRequired->isChecked());
}
void CSettingsWindow::OnSetPassword()
{
retry:
QString Value1 = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please enter the new configuration password."), QLineEdit::Password);
if (Value1.isEmpty())
return;
QString Value2 = QInputDialog::getText(this, "Sandboxie-Plus", tr("Please re enter the new configuration password."), QLineEdit::Password);
if (Value2.isEmpty())
return;
if (Value1 != Value2) {
QMessageBox::warning(this, "Sandboxie-Plus", tr("Passwords did not match, please retry."));
goto retry;
}
m_NewPassword = Value1;
}

View File

@ -0,0 +1,33 @@
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_SettingsWindow.h"
class CSettingsWindow : public QMainWindow
{
Q_OBJECT
public:
CSettingsWindow(QWidget *parent = Q_NULLPTR);
~CSettingsWindow();
signals:
void OptionsChanged();
public slots:
void apply();
void accept();
void reject();
private slots:
void OnChange();
void OnSetPassword();
protected:
void closeEvent(QCloseEvent *e);
QString m_NewPassword;
private:
Ui::SettingsWindow ui;
};

View File

@ -49,8 +49,6 @@ int main(int argc, char *argv[])
CSandMan* pWnd = new CSandMan();
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), pWnd, SLOT(OnMessage(const QString&)));
pWnd->show();
int ret = app.exec();
delete pWnd;