2021-10-16 16:19:51 +01:00
# include "stdafx.h"
# include "OptionsWindow.h"
# include "SandMan.h"
# include "SettingsWindow.h"
# include "../MiscHelpers/Common/Settings.h"
# include "../MiscHelpers/Common/Common.h"
# include "../MiscHelpers/Common/ComboInputDialog.h"
# include "../MiscHelpers/Common/SettingsWidgets.h"
# include "Helpers/WinAdmin.h"
void COptionsWindow : : LoadForced ( )
{
ui . treeForced - > clear ( ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " ForceProcess " , m_Template ) )
2021-12-03 19:26:09 +00:00
AddForcedEntry ( Value , ( int ) eProcess ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " ForceProcessDisabled " , m_Template ) )
AddForcedEntry ( Value , ( int ) eProcess , true ) ;
2021-10-16 16:19:51 +01:00
2024-07-21 19:41:14 +01:00
foreach ( const QString & Value , m_pBox - > GetTextList ( " ForceChildren " , m_Template ) )
AddForcedEntry ( Value , ( int ) eParent ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " ForceChildrenDisabled " , m_Template ) )
AddForcedEntry ( Value , ( int ) eParent , true ) ;
2021-10-16 16:19:51 +01:00
foreach ( const QString & Value , m_pBox - > GetTextList ( " ForceFolder " , m_Template ) )
2021-12-03 19:26:09 +00:00
AddForcedEntry ( Value , ( int ) ePath ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " ForceFolderDisabled " , m_Template ) )
AddForcedEntry ( Value , ( int ) ePath , true ) ;
2021-10-16 16:19:51 +01:00
2023-04-23 19:08:25 +01:00
ui . chkDisableForced - > setChecked ( m_pBox - > GetBool ( " DisableForceRules " , false ) ) ;
2022-09-29 17:28:48 +01:00
ui . treeBreakout - > clear ( ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " BreakoutProcess " , m_Template ) )
AddBreakoutEntry ( Value , ( int ) eProcess ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " BreakoutProcessDisabled " , m_Template ) )
AddBreakoutEntry ( Value , ( int ) eProcess , true ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " BreakoutFolder " , m_Template ) )
AddBreakoutEntry ( Value , ( int ) ePath ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " BreakoutFolderDisabled " , m_Template ) )
AddBreakoutEntry ( Value , ( int ) ePath , true ) ;
2024-07-21 19:41:14 +01:00
foreach ( const QString & Value , m_pBox - > GetTextList ( " BreakoutDocument " , m_Template ) )
AddBreakoutEntry ( Value , ( int ) eText ) ;
foreach ( const QString & Value , m_pBox - > GetTextList ( " BreakoutDocumentDisabled " , m_Template ) )
AddBreakoutEntry ( Value , ( int ) eText , true ) ;
2022-09-29 17:28:48 +01:00
2021-10-16 16:19:51 +01:00
LoadForcedTmpl ( ) ;
2022-10-28 18:30:18 +01:00
LoadBreakoutTmpl ( ) ;
2021-10-16 16:19:51 +01:00
m_ForcedChanged = false ;
}
void COptionsWindow : : LoadForcedTmpl ( bool bUpdate )
{
if ( ui . chkShowForceTmpl - > isChecked ( ) )
{
foreach ( const QString & Template , m_pBox - > GetTemplates ( ) )
{
foreach ( const QString & Value , m_pBox - > GetTextListTmpl ( " ForceProcess " , Template ) )
2021-12-03 19:26:09 +00:00
AddForcedEntry ( Value , ( int ) eProcess , false , Template ) ;
2021-10-16 16:19:51 +01:00
2024-07-21 19:41:14 +01:00
foreach ( const QString & Value , m_pBox - > GetTextListTmpl ( " ForceChildren " , Template ) )
AddForcedEntry ( Value , ( int ) eParent , false , Template ) ;
2021-10-16 16:19:51 +01:00
foreach ( const QString & Value , m_pBox - > GetTextListTmpl ( " ForceFolder " , Template ) )
2021-12-03 19:26:09 +00:00
AddForcedEntry ( Value , ( int ) ePath , false , Template ) ;
2021-10-16 16:19:51 +01:00
}
}
else if ( bUpdate )
{
for ( int i = 0 ; i < ui . treeForced - > topLevelItemCount ( ) ; )
{
QTreeWidgetItem * pItem = ui . treeForced - > topLevelItem ( i ) ;
int Type = pItem - > data ( 0 , Qt : : UserRole ) . toInt ( ) ;
2021-12-21 13:57:27 +00:00
if ( Type = = ( int ) eTemplate ) {
2021-10-16 16:19:51 +01:00
delete pItem ;
continue ; // entry from template
}
i + + ;
}
2022-10-28 18:30:18 +01:00
}
}
void COptionsWindow : : LoadBreakoutTmpl ( bool bUpdate )
{
if ( ui . chkShowBreakoutTmpl - > isChecked ( ) )
{
foreach ( const QString & Template , m_pBox - > GetTemplates ( ) )
{
foreach ( const QString & Value , m_pBox - > GetTextListTmpl ( " BreakoutProcess " , Template ) )
AddBreakoutEntry ( Value , ( int ) eProcess , false , Template ) ;
2022-09-29 17:28:48 +01:00
2022-10-28 18:30:18 +01:00
foreach ( const QString & Value , m_pBox - > GetTextListTmpl ( " BreakoutFolder " , Template ) )
AddBreakoutEntry ( Value , ( int ) ePath , false , Template ) ;
2024-10-18 12:07:56 +01:00
foreach ( const QString & Value , m_pBox - > GetTextListTmpl ( " BreakoutDocument " , Template ) )
AddBreakoutEntry ( Value , ( int ) eText , false , Template ) ;
2022-10-28 18:30:18 +01:00
}
}
else if ( bUpdate )
{
2022-09-29 17:28:48 +01:00
for ( int i = 0 ; i < ui . treeBreakout - > topLevelItemCount ( ) ; )
{
QTreeWidgetItem * pItem = ui . treeBreakout - > topLevelItem ( i ) ;
int Type = pItem - > data ( 0 , Qt : : UserRole ) . toInt ( ) ;
if ( Type = = ( int ) eTemplate ) {
delete pItem ;
continue ; // entry from template
}
i + + ;
}
2021-10-16 16:19:51 +01:00
}
}
2021-12-03 19:26:09 +00:00
void COptionsWindow : : AddForcedEntry ( const QString & Name , int type , bool disabled , const QString & Template )
2021-10-16 16:19:51 +01:00
{
QTreeWidgetItem * pItem = new QTreeWidgetItem ( ) ;
2021-12-03 19:26:09 +00:00
pItem - > setCheckState ( 0 , disabled ? Qt : : Unchecked : Qt : : Checked ) ;
2024-07-21 19:41:14 +01:00
QString Type ;
switch ( type )
{
case eProcess : Type = tr ( " Process " ) ; break ;
case ePath : Type = tr ( " Folder " ) ; break ;
case eParent : Type = tr ( " Children " ) ; break ;
}
pItem - > setText ( 0 , Type + ( Template . isEmpty ( ) ? " " : ( " ( " + Template + " ) " ) ) ) ;
2021-12-03 19:26:09 +00:00
pItem - > setData ( 0 , Qt : : UserRole , Template . isEmpty ( ) ? type : ( int ) eTemplate ) ;
2024-07-21 19:41:14 +01:00
SetProgramItem ( Name , pItem , 1 ) ;
2021-12-03 19:26:09 +00:00
pItem - > setFlags ( pItem - > flags ( ) | Qt : : ItemIsEditable ) ;
2021-10-16 16:19:51 +01:00
ui . treeForced - > addTopLevelItem ( pItem ) ;
}
2022-09-29 17:28:48 +01:00
void COptionsWindow : : AddBreakoutEntry ( const QString & Name , int type , bool disabled , const QString & Template )
{
QTreeWidgetItem * pItem = new QTreeWidgetItem ( ) ;
pItem - > setCheckState ( 0 , disabled ? Qt : : Unchecked : Qt : : Checked ) ;
2024-07-21 19:41:14 +01:00
QString Type ;
switch ( type )
{
case eProcess : Type = tr ( " Process " ) ; break ;
case ePath : Type = tr ( " Folder " ) ; break ;
2024-10-18 12:07:56 +01:00
case eText : Type = tr ( " Document " ) ; break ;
2024-07-21 19:41:14 +01:00
}
pItem - > setText ( 0 , Type + ( Template . isEmpty ( ) ? " " : ( " ( " + Template + " ) " ) ) ) ;
2022-09-29 17:28:48 +01:00
pItem - > setData ( 0 , Qt : : UserRole , Template . isEmpty ( ) ? type : ( int ) eTemplate ) ;
2024-07-21 19:41:14 +01:00
SetProgramItem ( Name , pItem , 1 , QString ( ) , type = = eProcess ) ;
2022-09-29 17:28:48 +01:00
pItem - > setFlags ( pItem - > flags ( ) | Qt : : ItemIsEditable ) ;
ui . treeBreakout - > addTopLevelItem ( pItem ) ;
}
2021-10-16 16:19:51 +01:00
void COptionsWindow : : SaveForced ( )
{
QStringList ForceProcess ;
2021-12-03 19:26:09 +00:00
QStringList ForceProcessDisabled ;
2024-07-21 19:41:14 +01:00
QStringList ForceChildren ;
QStringList ForceChildrenDisabled ;
2021-10-16 16:19:51 +01:00
QStringList ForceFolder ;
2021-12-03 19:26:09 +00:00
QStringList ForceFolderDisabled ;
2021-10-16 16:19:51 +01:00
for ( int i = 0 ; i < ui . treeForced - > topLevelItemCount ( ) ; i + + )
{
QTreeWidgetItem * pItem = ui . treeForced - > topLevelItem ( i ) ;
int Type = pItem - > data ( 0 , Qt : : UserRole ) . toInt ( ) ;
2021-12-03 19:26:09 +00:00
if ( Type = = ( int ) eTemplate )
2021-10-16 16:19:51 +01:00
continue ; // entry from template
2021-12-03 19:26:09 +00:00
if ( pItem - > checkState ( 0 ) = = Qt : : Checked ) {
switch ( Type ) {
case eProcess : ForceProcess . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2024-07-21 19:41:14 +01:00
case eParent : ForceChildren . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
case ePath : ForceFolder . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2021-12-03 19:26:09 +00:00
}
}
else {
switch ( Type ) {
case eProcess : ForceProcessDisabled . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2024-07-22 22:46:55 +01:00
case eParent : ForceChildrenDisabled . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2024-07-21 19:41:14 +01:00
case ePath : ForceFolderDisabled . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2021-12-03 19:26:09 +00:00
}
2021-10-16 16:19:51 +01:00
}
}
WriteTextList ( " ForceProcess " , ForceProcess ) ;
2021-12-03 19:26:09 +00:00
WriteTextList ( " ForceProcessDisabled " , ForceProcessDisabled ) ;
2024-07-21 19:41:14 +01:00
WriteTextList ( " ForceChildren " , ForceChildren ) ;
WriteTextList ( " ForceChildrenDisabled " , ForceChildrenDisabled ) ;
2021-10-16 16:19:51 +01:00
WriteTextList ( " ForceFolder " , ForceFolder ) ;
2021-12-03 19:26:09 +00:00
WriteTextList ( " ForceFolderDisabled " , ForceFolderDisabled ) ;
2021-10-16 16:19:51 +01:00
2023-04-23 19:08:25 +01:00
WriteAdvancedCheck ( ui . chkDisableForced , " DisableForceRules " , " y " , " " ) ;
2022-09-29 17:28:48 +01:00
QStringList BreakoutProcess ;
QStringList BreakoutProcessDisabled ;
QStringList BreakoutFolder ;
QStringList BreakoutFolderDisabled ;
2024-10-18 12:07:56 +01:00
QStringList BreakoutDocument ;
QStringList BreakoutDocumentDisabled ;
2022-09-29 17:28:48 +01:00
for ( int i = 0 ; i < ui . treeBreakout - > topLevelItemCount ( ) ; i + + )
{
QTreeWidgetItem * pItem = ui . treeBreakout - > topLevelItem ( i ) ;
int Type = pItem - > data ( 0 , Qt : : UserRole ) . toInt ( ) ;
if ( Type = = ( int ) eTemplate )
continue ; // entry from template
if ( pItem - > checkState ( 0 ) = = Qt : : Checked ) {
switch ( Type ) {
case eProcess : BreakoutProcess . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
case ePath : BreakoutFolder . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2024-10-18 12:07:56 +01:00
case eText : BreakoutDocument . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2022-09-29 17:28:48 +01:00
}
}
else {
switch ( Type ) {
case eProcess : BreakoutProcessDisabled . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
case ePath : BreakoutFolderDisabled . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2024-10-18 12:07:56 +01:00
case eText : BreakoutDocumentDisabled . append ( pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ) ; break ;
2022-09-29 17:28:48 +01:00
}
}
}
WriteTextList ( " BreakoutProcess " , BreakoutProcess ) ;
WriteTextList ( " BreakoutProcessDisabled " , BreakoutProcessDisabled ) ;
WriteTextList ( " BreakoutFolder " , BreakoutFolder ) ;
WriteTextList ( " BreakoutFolderDisabled " , BreakoutFolderDisabled ) ;
2024-10-18 12:07:56 +01:00
WriteTextList ( " BreakoutDocument " , BreakoutDocument ) ;
WriteTextList ( " BreakoutDocumentDisabled " , BreakoutDocumentDisabled ) ;
2022-09-29 17:28:48 +01:00
2021-10-16 16:19:51 +01:00
m_ForcedChanged = false ;
}
void COptionsWindow : : OnForceProg ( )
{
QString Value = SelectProgram ( ) ;
if ( Value . isEmpty ( ) )
return ;
2023-11-26 13:17:20 +00:00
if ( ! CheckForcedItem ( Value , ( int ) eProcess ) )
return ;
2021-12-03 19:26:09 +00:00
AddForcedEntry ( Value , ( int ) eProcess ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2021-10-16 16:19:51 +01:00
}
2022-09-29 17:28:48 +01:00
void COptionsWindow : : OnBreakoutProg ( )
{
QString Value = SelectProgram ( ) ;
if ( Value . isEmpty ( ) )
return ;
AddBreakoutEntry ( Value , ( int ) eProcess ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2022-09-29 17:28:48 +01:00
}
2024-07-21 19:51:28 +01:00
void COptionsWindow : : OnForceBrowseProg ( )
2022-09-29 17:28:48 +01:00
{
QString Value = QFileDialog : : getOpenFileName ( this , tr ( " Select Executable File " ) , " " , tr ( " Executable Files (*.exe) " ) ) ;
if ( Value . isEmpty ( ) )
return ;
2023-10-22 13:49:41 +01:00
if ( ! CheckForcedItem ( Value , ( int ) eProcess ) )
return ;
2022-09-29 17:28:48 +01:00
AddForcedEntry ( Split2 ( Value , " / " , true ) . second , ( int ) eProcess ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2022-09-29 17:28:48 +01:00
}
void COptionsWindow : : OnBreakoutBrowse ( )
{
QString Value = QFileDialog : : getOpenFileName ( this , tr ( " Select Executable File " ) , " " , tr ( " Executable Files (*.exe) " ) ) ;
if ( Value . isEmpty ( ) )
return ;
AddBreakoutEntry ( Split2 ( Value , " / " , true ) . second , ( int ) eProcess ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2022-09-29 17:28:48 +01:00
}
2024-07-21 19:41:14 +01:00
void COptionsWindow : : OnForceChild ( )
{
QString Value = SelectProgram ( ) ;
if ( Value . isEmpty ( ) )
return ;
if ( ! CheckForcedItem ( Value , ( int ) eParent ) )
return ;
AddForcedEntry ( Value , ( int ) eParent ) ;
OnForcedChanged ( ) ;
}
void COptionsWindow : : OnForceBrowseChild ( )
{
QString Value = QFileDialog : : getOpenFileName ( this , tr ( " Select Executable File " ) , " " , tr ( " Executable Files (*.exe) " ) ) ;
if ( Value . isEmpty ( ) )
return ;
if ( ! CheckForcedItem ( Value , ( int ) eParent ) )
return ;
AddForcedEntry ( Split2 ( Value , " / " , true ) . second , ( int ) eParent ) ;
OnForcedChanged ( ) ;
}
2021-10-16 16:19:51 +01:00
void COptionsWindow : : OnForceDir ( )
{
QString Value = QFileDialog : : getExistingDirectory ( this , tr ( " Select Directory " ) ) . replace ( " / " , " \\ " ) ;
if ( Value . isEmpty ( ) )
return ;
2023-10-22 13:49:41 +01:00
if ( ! CheckForcedItem ( Value , ( int ) ePath ) )
return ;
2021-12-03 19:26:09 +00:00
AddForcedEntry ( Value , ( int ) ePath ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2021-10-16 16:19:51 +01:00
}
2022-09-29 17:28:48 +01:00
void COptionsWindow : : OnBreakoutDir ( )
{
QString Value = QFileDialog : : getExistingDirectory ( this , tr ( " Select Directory " ) ) . replace ( " / " , " \\ " ) ;
if ( Value . isEmpty ( ) )
return ;
AddBreakoutEntry ( Value , ( int ) ePath ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2022-09-29 17:28:48 +01:00
}
2024-10-18 12:07:56 +01:00
void COptionsWindow : : OnBreakoutDoc ( )
{
QString Value = QFileDialog : : getExistingDirectory ( this , tr ( " Select Document Directory " ) ) . replace ( " / " , " \\ " ) ;
if ( Value . isEmpty ( ) )
return ;
QString Ext = QInputDialog : : getText ( this , " Sandboxie-Plus " , tr ( " Please enter Document File Extension. " ) ) ;
if ( Ext . isEmpty ( ) )
return ;
if ( Ext . left ( 1 ) = = " . " )
Ext . prepend ( " * " ) ;
else if ( Ext . left ( 1 ) ! = " * " )
Ext . prepend ( " *. " ) ;
if ( Ext . right ( 1 ) = = " * " ) {
2024-10-19 13:35:28 +01:00
QMessageBox : : warning ( this , " Sandboxie-Plus " , tr ( " For security reasons it it not permitted to create entirely wildcard BreakoutDocument presets. " ) ) ;
2024-10-18 12:07:56 +01:00
return ;
}
QStringList BannedExt = QString ( // from: https://learn.microsoft.com/en-us/troubleshoot/developer/browsers/security-privacy/information-about-the-unsafe-file-list
" *.ade;*.adp;*.app;*.asp;*.bas;*.bat;*.cer;*.chm;*.cmd;*.cnt;*.com;*.cpl;*.crt;*.csh;*.der;*.exe;*.fxp;*.gadget;*.grp;*.hlp;*.hpj;*.hta; "
" *.img;*.inf;*.ins;*.iso;*.isp;*.its;*.js;*.jse;*.ksh;*.lnk;*.mad;*.maf;*.mag;*.mam;*.maq;*.mar;*.mas;*.mat;*.mau;*.mav;*.maw;*.mcf;*.mda; "
" *.mdb;*.mde;*.mdt;*.mdw;*.mdz;*.msc;*.msh;*.msh1;*.msh1xml;*.msh2;*.msh2xml;*.mshxml;*.msi;*.msp;*.mst;*.msu;*.ops;*.pcd;*.pif;*.pl;*.plg; "
" *.prf;*.prg;*.printerexport;*.ps1;*.ps1xml;*.ps2;*.ps2xml;*.psc1;*.psc2;*.psd1;*.psm1;*.pst;*.reg;*.scf;*.scr;*.sct;*.shb;*.shs;*.theme; "
" *.tmp;*.url;*.vb;*.vbe;*.vbp;*.vbs;*.vhd;*.vhdx;*.vsmacros;*.vsw;*.webpnp;*.ws;*.wsc;*.wsf;*.wsh;*.xnk " ) . split ( " ; " ) ;
if ( BannedExt . contains ( Ext . toLower ( ) ) ) {
QMessageBox : : warning ( this , " Sansboxie-Plus " , tr ( " For security reasons the specified extension %1 should not be broken out. " ) . arg ( Ext ) ) ;
// bypass security by holding down Ctr+Alt
if ( ( QGuiApplication : : queryKeyboardModifiers ( ) & ( Qt : : AltModifier | Qt : : ControlModifier ) ) ! = ( Qt : : AltModifier | Qt : : ControlModifier ) )
return ;
}
Value + = " \\ " + Ext ;
AddBreakoutEntry ( Value , ( int ) eText ) ;
OnForcedChanged ( ) ;
}
2021-10-16 16:19:51 +01:00
void COptionsWindow : : OnDelForce ( )
{
DeleteAccessEntry ( ui . treeForced - > currentItem ( ) ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2021-10-16 16:19:51 +01:00
}
2021-12-03 19:26:09 +00:00
2022-09-29 17:28:48 +01:00
void COptionsWindow : : OnDelBreakout ( )
{
DeleteAccessEntry ( ui . treeBreakout - > currentItem ( ) ) ;
2023-10-22 13:49:41 +01:00
OnForcedChanged ( ) ;
2022-09-29 17:28:48 +01:00
}
2023-10-22 13:49:41 +01:00
void COptionsWindow : : OnForcedChanged ( )
2021-12-03 19:26:09 +00:00
{
m_ForcedChanged = true ;
OnOptChanged ( ) ;
2022-09-29 17:28:48 +01:00
}
2023-10-22 13:49:41 +01:00
bool COptionsWindow : : CheckForcedItem ( const QString & Value , int type )
{
bool bDangerous = false ;
QString winPath = QString : : fromUtf8 ( qgetenv ( " SystemRoot " ) ) ;
2024-07-21 19:41:14 +01:00
if ( type = = eProcess | | type = = eParent )
2023-10-22 13:49:41 +01:00
{
if ( Value . compare ( " explorer.exe " , Qt : : CaseInsensitive ) = = 0 | | Value . compare ( winPath + " \\ explorer.exe " , Qt : : CaseInsensitive ) = = 0 )
bDangerous = true ;
else if ( Value . compare ( " taskmgr.exe " , Qt : : CaseInsensitive ) = = 0 | | Value . compare ( winPath + " \\ system32 \\ taskmgr.exe " , Qt : : CaseInsensitive ) = = 0 )
bDangerous = true ;
2023-11-26 12:54:04 +00:00
else if ( Value . contains ( " sbiesvc.exe " , Qt : : CaseInsensitive ) )
2023-10-22 13:49:41 +01:00
bDangerous = true ;
2023-11-26 12:54:04 +00:00
else if ( Value . contains ( " sandman.exe " , Qt : : CaseInsensitive ) )
2023-10-22 13:49:41 +01:00
bDangerous = true ;
}
2024-07-21 19:41:14 +01:00
else if ( type = = ePath )
2023-10-22 13:49:41 +01:00
{
2024-04-20 19:27:15 +01:00
if ( Value . compare ( winPath . left ( 3 ) , Qt : : CaseInsensitive ) = = 0 )
2023-10-22 13:49:41 +01:00
bDangerous = true ; // SystemDrive (C:\)
else if ( Value . compare ( winPath , Qt : : CaseInsensitive ) = = 0 )
bDangerous = true ; // SystemRoot (C:\Windows)
else if ( Value . left ( winPath . length ( ) + 1 ) . compare ( winPath + " \\ " , Qt : : CaseInsensitive ) = = 0 )
bDangerous = true ; // sub path of C:\Windows
}
2023-11-26 13:39:43 +00:00
if ( bDangerous & & QMessageBox : : warning ( this , " Sandboxie-Plus " , tr ( " Forcing the specified entry will most likely break Windows, are you sure you want to proceed? " )
2023-10-22 13:49:41 +01:00
, QDialogButtonBox : : Yes , QDialogButtonBox : : No ) ! = QDialogButtonBox : : Yes )
return false ;
return true ;
}
void COptionsWindow : : OnForcedChanged ( QTreeWidgetItem * pItem , int )
{
QString Value = pItem - > data ( 1 , Qt : : UserRole ) . toString ( ) ;
if ( pItem - > checkState ( 0 ) = = Qt : : Checked & & ! CheckForcedItem ( Value , pItem - > data ( 0 , Qt : : UserRole ) . toInt ( ) ) )
pItem - > setCheckState ( 0 , Qt : : Unchecked ) ;
//qDebug() << Test;
OnForcedChanged ( ) ;
}
2023-10-22 14:08:33 +01:00
void COptionsWindow : : OnBreakoutChanged ( QTreeWidgetItem * pItem , int )
{
OnForcedChanged ( ) ;
}