Sandboxie/SandboxiePlus/SandMan/Windows/OptionsWindow.h

403 lines
10 KiB
C
Raw Normal View History

2021-10-16 16:19:51 +01:00
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_OptionsWindow.h"
#include "SbiePlusAPI.h"
class COptionsWindow : public QDialog
{
Q_OBJECT
public:
COptionsWindow(const QSharedPointer<CSbieIni>& pBox, const QString& Name, QWidget *parent = Q_NULLPTR);
~COptionsWindow();
virtual void accept() {}
virtual void reject();
2021-12-03 19:26:09 +00:00
QStringList GetCurrentGroups();
QSet<QString> GetPrograms() { return m_Programs; }
2022-01-29 09:18:22 +00:00
static void TriggerPathReload();
2021-12-03 19:26:09 +00:00
enum EntryTypes {
eUndefined = 0,
eProcess,
ePath,
eText,
eTemplate
};
2021-10-16 16:19:51 +01:00
signals:
void OptionsChanged();
void Closed();
public slots:
void ok();
void apply();
private slots:
//void OnWithTemplates();
2021-11-13 08:28:32 +00:00
void OnOptChanged();
2021-10-16 16:19:51 +01:00
void OnPickColor();
2021-11-13 08:28:32 +00:00
void OnBoxTypChanged();
void UpdateBoxType();
2021-10-16 16:19:51 +01:00
void OnBrowsePath();
void OnAddCommand();
void OnDelCommand();
void OnAddAutoCmd();
void OnAddAutoExe();
void OnDelAutoSvc();
void OnDelAuto();
void OnAddGroup();
void OnAddProg();
void OnDelProg();
void OnShowGroupTmpl() { LoadGroupsTmpl(true); }
2021-12-03 19:26:09 +00:00
void OnGroupsChanged(QTreeWidgetItem* pItem, int Index) { m_GroupsChanged = true; OnOptChanged(); }
2021-10-16 16:19:51 +01:00
void OnForceProg();
void OnForceDir();
void OnDelForce();
void OnShowForceTmpl() { LoadForcedTmpl(true); }
2021-12-03 19:26:09 +00:00
void OnForcedChanged(QTreeWidgetItem* pItem, int Index);
2021-10-16 16:19:51 +01:00
void OnAddLingering();
void OnAddLeader();
void OnDelStopProg();
void OnShowStopTmpl() { LoadStopTmpl(true); }
2021-12-03 19:26:09 +00:00
void OnStopChanged(QTreeWidgetItem* pItem, int Index) { m_StopChanged = true; OnOptChanged(); }
2021-10-16 16:19:51 +01:00
void OnRestrictStart();
void OnAddStartProg();
void OnDelStartProg();
2021-12-03 19:26:09 +00:00
void OnStartChanged(QTreeWidgetItem* pItem, int Index);
2021-10-16 16:19:51 +01:00
// net
void OnINetItemDoubleClicked(QTreeWidgetItem* pItem, int Column);
2021-11-13 08:28:32 +00:00
void OnINetSelectionChanged() { CloseINetEdit(); OnOptChanged();}
2021-12-03 19:26:09 +00:00
void OnINetChanged(QTreeWidgetItem* pItem, int Column);
2021-10-16 16:19:51 +01:00
void OnBlockINet();
void OnAddINetProg();
void OnDelINetProg();
void OnNetFwItemDoubleClicked(QTreeWidgetItem* pItem, int Column);
2021-11-13 08:28:32 +00:00
void OnNetFwSelectionChanged() { CloseNetFwEdit(); OnOptChanged();}
2021-12-03 19:26:09 +00:00
void OnNetFwChanged(QTreeWidgetItem* pItem, int Column);
2021-10-16 16:19:51 +01:00
void OnAddNetFwRule();
void OnDelNetFwRule();
void OnShowNetFwTmpl() { LoadNetFwRulesTmpl(true); }
void OnTestNetFwRule();
void OnClearNetFwTest();
//net
//
// access
//void OnAccessItemClicked(QTreeWidgetItem* pItem, int Column);
void OnAccessItemDoubleClicked(QTreeWidgetItem* pItem, int Column);
2021-11-13 08:28:32 +00:00
void OnAccessSelectionChanged() { CloseAccessEdit(); OnOptChanged();}
2021-12-03 19:26:09 +00:00
void OnAccessChanged(QTreeWidgetItem* pItem, int Column);
2021-10-16 16:19:51 +01:00
2021-11-13 08:28:32 +00:00
void OnAddFile() { AddAccessEntry(eFile, eOpen, "", ""); m_AccessChanged = true; OnOptChanged(); }
2021-10-16 16:19:51 +01:00
void OnBrowseFile();
void OnBrowseFolder();
2021-11-13 08:28:32 +00:00
void OnAddKey() { AddAccessEntry(eKey, eOpen, "", ""); m_AccessChanged = true; OnOptChanged(); }
void OnAddIPC() { AddAccessEntry(eIPC, eOpen, "", ""); m_AccessChanged = true; OnOptChanged(); }
void OnAddWnd() { AddAccessEntry(eWnd, eOpen, "", ""); m_AccessChanged = true; OnOptChanged(); }
void OnAddCOM() { AddAccessEntry(eCOM, eOpen, "", ""); m_AccessChanged = true; OnOptChanged(); }
2021-10-16 16:19:51 +01:00
void OnDelAccess();
void OnShowAccessTmpl() { LoadAccessListTmpl(true); }
//
void OnAddRecFolder();
void OnAddRecIgnore();
void OnAddRecIgnoreExt();
void OnDelRecEntry();
void OnShowRecoveryTmpl() { LoadRecoveryListTmpl(true); }
void OnAddAutoExec();
void OnDelAutoExec();
void OnAddProcess();
void OnDelProcess();
void OnNoWindowRename();
void OnAddUser();
void OnDelUser();
void OnFilterTemplates() { ShowTemplates(); }
void OnTemplateClicked(QTreeWidgetItem* pItem, int Column);
void OnTemplateDoubleClicked(QTreeWidgetItem* pItem, int Column);
void OnAddTemplates();
void OnDelTemplates();
void OnFolderChanged();
void OnScreenReaders();
void OnTab();
void OnGeneralChanged();
2021-11-13 08:28:32 +00:00
void OnStartChanged() { m_StartChanged = true; OnOptChanged(); }
//void OnRestrictionChanged() { m_RestrictionChanged = true; OnOptChanged(); }
void OnINetBlockChanged() { m_INetBlockChanged = true; OnOptChanged(); }
void OnRecoveryChanged() { m_RecoveryChanged = true; OnOptChanged(); }
void OnAccessChanged();
2021-12-20 11:55:02 +00:00
void OnSysSvcChanged();
2021-10-16 16:19:51 +01:00
void OnAdvancedChanged();
2021-11-13 08:28:32 +00:00
void OnOpenCOM();
void OnIsolationChanged();
2021-10-16 16:19:51 +01:00
void OnDebugChanged();
void SetIniEdit(bool bEnable);
void OnEditIni();
void OnSaveIni();
void OnCancelEdit();
protected:
friend struct SFirewallRule;
void closeEvent(QCloseEvent *e);
bool eventFilter(QObject *watched, QEvent *e);
enum ENetWfAction
{
eAllow,
eBlock
};
enum ENetWfProt
{
eAny,
eTcp,
eUdp,
eIcmp,
};
enum EAccessEntry
{
2021-11-13 08:28:32 +00:00
eNormalFilePath,
2021-10-16 16:19:51 +01:00
eOpenFilePath,
eOpenPipePath,
eClosedFilePath,
eReadFilePath,
eWriteFilePath,
2021-11-13 08:28:32 +00:00
eNormalKeyPath,
2021-10-16 16:19:51 +01:00
eOpenKeyPath,
2021-11-13 08:28:32 +00:00
eOpenConfPath,
2021-10-16 16:19:51 +01:00
eClosedKeyPath,
eReadKeyPath,
eWriteKeyPath,
2021-11-13 08:28:32 +00:00
eNormalIpcPath,
2021-10-16 16:19:51 +01:00
eOpenIpcPath,
eClosedIpcPath,
eOpenWinClass,
eOpenCOM,
eClosedCOM,
eClosedCOM_RT,
eMaxAccessType
};
enum EAccessType
{
eFile,
eKey,
eIPC,
eWnd,
eCOM
};
enum EAccessMode
{
2021-11-13 08:28:32 +00:00
eNormal,
eOpen,
eOpen4All,
2021-10-16 16:19:51 +01:00
eClosed,
eClosedRT,
eReadOnly,
eWriteOnly
};
void SetProgramItem(QString Program, QTreeWidgetItem* pItem, int Column);
QString SelectProgram(bool bOrGroup = true);
void AddProgramToGroup(const QString& Program, const QString& Group);
2021-12-03 19:26:09 +00:00
bool DelProgramFromGroup(const QString& Program, const QString& Group);
2021-10-16 16:19:51 +01:00
QTreeWidgetItem* FindGroupByName(const QString& Group, bool bAdd = false);
2021-12-03 19:26:09 +00:00
void CopyGroupToList(const QString& Groupe, QTreeWidget* pTree, bool disabled = false);
2021-10-16 16:19:51 +01:00
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);
2021-12-03 19:26:09 +00:00
void AddProgToGroup(QTreeWidget* pTree, const QString& Groupe, bool disabled = false);
2021-10-16 16:19:51 +01:00
void DelProgFromGroup(QTreeWidget* pTree, const QString& Groupe);
void LoadConfig();
void SaveConfig();
void UpdateCurrentTab();
void AddAutoRunItem(const QString& Value, int Type);
void AddRunItem(const QString& Name, const QString& Command);
void CreateGeneral();
void LoadGeneral();
void SaveGeneral();
void LoadGroups();
void LoadGroupsTmpl(bool bUpdate = false);
void SaveGroups();
void LoadForced();
void LoadForcedTmpl(bool bUpdate = false);
2021-12-03 19:26:09 +00:00
void AddForcedEntry(const QString& Name, int type, bool disabled = false, const QString& Template = QString());
2021-10-16 16:19:51 +01:00
void SaveForced();
void LoadStop();
void LoadStopTmpl(bool bUpdate = false);
2021-12-03 19:26:09 +00:00
void AddStopEntry(const QString& Name, int type, bool disabled = false, const QString& Template = QString());
2021-10-16 16:19:51 +01:00
void SaveStop();
void LoadStart();
void SaveStart();
// Network
void CreateNetwork();
int GroupToINetMode(const QString& Mode);
QString INetModeToGroup(int Mode);
void LoadBlockINet();
QString GetINetModeStr(int Mode);
void CloseINetEdit(bool bSave = true);
void CloseINetEdit(QTreeWidgetItem* pItem, bool bSave = true);
void CheckINetBlock();
bool FindEntryInSettingList(const QString& Name, const QString& Value);
void LoadINetAccess();
void SaveINetAccess();
2021-12-03 19:26:09 +00:00
void ParseAndAddFwRule(const QString& Value, bool disabled = false, const QString& Template = QString());
2021-10-16 16:19:51 +01:00
void CloseNetFwEdit(bool bSave = true);
void CloseNetFwEdit(QTreeWidgetItem* pItem, bool bSave = true);
ENetWfProt GetFwRuleProt(const QString& Value);
ENetWfAction GetFwRuleAction(const QString& Value);
QString GetFwRuleActionStr(ENetWfAction Action);
void LoadNetFwRules();
void SaveNetFwRules();
void LoadNetFwRulesTmpl(bool bUpdate = false);
//
// access
void CreateAccess();
QString AccessTypeToName(EAccessEntry Type);
void LoadAccessList();
void LoadAccessListTmpl(bool bUpdate = false);
QString GetAccessTypeStr(EAccessType Type);
QString GetAccessModeStr(EAccessMode Mode);
2021-12-03 19:26:09 +00:00
void ParseAndAddAccessEntry(EAccessEntry EntryType, const QString& Value, bool disabled = false, const QString& Template = QString());
void AddAccessEntry(EAccessType Type, EAccessMode Mode, QString Program, const QString& Path, bool disabled = false, const QString& Template = QString());
2021-10-16 16:19:51 +01:00
QString MakeAccessStr(EAccessType Type, EAccessMode Mode);
void SaveAccessList();
QList<EAccessMode> GetAccessModes(EAccessType Type);
void DeleteAccessEntry(QTreeWidgetItem* pItem);
void CloseAccessEdit(bool bSave = true);
void CloseAccessEdit(QTreeWidgetItem* pItem, bool bSave = true);
2021-11-13 08:28:32 +00:00
void UpdateAccessPolicy();
2021-10-16 16:19:51 +01:00
//
void LoadRecoveryList();
void LoadRecoveryListTmpl(bool bUpdate = false);
void AddRecoveryEntry(const QString& Name, int type, const QString& Template = QString());
void SaveRecoveryList();
void CreateAdvanced();
void LoadAdvanced();
void SaveAdvanced();
2021-11-13 08:28:32 +00:00
void UpdateBoxIsolation();
2021-10-16 16:19:51 +01:00
void CreateDebug();
void LoadDebug();
void SaveDebug();
void LoadTemplates();
void ShowTemplates();
void SaveTemplates();
2021-12-20 11:55:02 +00:00
void SetTemplate(const QString& Template, bool bEnabled);
2021-10-16 16:19:51 +01:00
void LoadFolders();
void ShowFolders();
void SaveFolders();
void LoadIniSection();
void SaveIniSection();
QString GetCategoryName(const QString& Category);
2021-11-13 08:28:32 +00:00
bool m_HoldChange;
2021-10-16 16:19:51 +01:00
bool m_ConfigDirty;
QColor m_BorderColor;
2021-11-13 08:28:32 +00:00
bool m_HoldBoxType;
2021-10-16 16:19:51 +01:00
bool m_GeneralChanged;
bool m_GroupsChanged;
bool m_ForcedChanged;
bool m_StopChanged;
bool m_StartChanged;
//bool m_RestrictionChanged;
bool m_INetBlockChanged;
bool m_NetFwRulesChanged;
bool m_AccessChanged;
bool m_TemplatesChanged;
bool m_FoldersChanged;
bool m_RecoveryChanged;
bool m_AdvancedChanged;
bool m_IsEnabledWFP;
bool m_WFPisBlocking;
bool m_Template;
QMultiMap<QString, QPair<QString, QString>> m_AllTemplates;
QStringList m_GlobalTemplates;
QStringList m_BoxTemplates;
QStringList m_BoxFolders;
QList<QPair<QString, QString>> m_Settings;
QSharedPointer<CSbieIni> m_pBox;
QSet<QString> m_Programs;
private:
void ReadAdvancedCheck(const QString& Name, QCheckBox* pCheck, const QString& Value = "y");
void WriteAdvancedCheck(QCheckBox* pCheck, const QString& Name, const QString& Value = "y");
void WriteAdvancedCheck(QCheckBox* pCheck, const QString& Name, const QString& OnValue, const QString& OffValue);
void WriteText(const QString& Name, const QString& Value);
void WriteTextList(const QString& Setting, const QStringList& List);
Ui::OptionsWindow ui;
struct SDbgOpt {
QString Name;
QString Value;
bool Changed;
};
QMap<QCheckBox*, SDbgOpt> m_DebugOptions;
};