Merge pull request #3 from love-code-yeyixiao/FixAndCheckAutoDelete

Fix and add two feature
This commit is contained in:
爱编程的叶一笑 2024-03-02 15:54:50 +08:00 committed by GitHub
commit b264e37f3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 354 additions and 301 deletions

View File

@ -1629,6 +1629,8 @@ _FX LRESULT Gui_WindowProcA(
if (uMsg == WM_SETTEXT && Gui_ShouldCreateTitle(hWnd))
new_lParam = (LPARAM)Gui_CreateTitleA((UCHAR *)lParam);
if (uMsg == WM_CREATE)
ProtectScreen(hWnd);
else
new_lParam = lParam;
@ -2702,3 +2704,26 @@ _FX BOOLEAN ComDlg32_Init(HMODULE module)
return TRUE;
}
_FX VOID ProtectScreen(HWND hWnd) {
WCHAR buffer[BOXNAME_COUNT] = { L"\0" };
SbieApi_QueryProcess(GetCurrentProcess(), buffer, 0, 0, 0);
if (SbieApi_QueryConfBool(buffer, L"IsProtectScreen", FALSE)) {
OSVERSIONINFOEX os;
os.dwOSVersionInfoSize = sizeof(os);
if (GetVersionEx(&os))
{
if (os.dwMajorVersion == 6) {
HMODULE hDll = GetModuleHandleW(L"user32.dll");
if (hDll != NULL && hDll != INVALID_HANDLE_VALUE) {
typedef BOOL(*LPSETWINDOWDISPLAYAFFINITY)(HWND, DWORD);
LPSETWINDOWDISPLAYAFFINITY swda = GetProcAddress(hDll, "SetWindowDisplayAffinity");
if (swda) {
swda(hWnd, 0x00000001);
}
}
}
}
}
}

View File

@ -45,7 +45,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>10</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
@ -1004,7 +1004,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabsSecurity">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tabHarden">
<attribute name="title">
@ -1346,21 +1346,23 @@
<attribute name="title">
<string>Box Protection</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_83">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_82">
<item row="1" column="2">
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label_52">
<property name="text">
<string>Sandboxie-Plus is able to create confidential sandboxes that provide robust protection against unauthorized surveillance or tampering by host processes. By utilizing an encrypted sandbox image, this feature delivers the highest level of operational confidentiality, ensuring the safety and integrity of sandboxed processes.</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="wordWrap">
<bool>true</bool>
</property>
</spacer>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="chkConfidential">
<property name="text">
<string>Protect processes within this box from host processes</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QPushButton" name="btnHostProcessDeny">
@ -1369,55 +1371,33 @@
</property>
</widget>
</item>
<item row="8" column="3">
<spacer name="verticalSpacer_31">
<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="10" column="3">
<widget class="QPushButton" name="btnDelHostProcess">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="4">
<item row="11" column="0" colspan="3">
<widget class="QCheckBox" name="chkNotifyProtect">
<property name="text">
<string>Issue message 1318/1317 when a host process tries to access a sandboxed process/the box root</string>
</property>
</widget>
</item>
<item row="6" column="0" rowspan="5" colspan="3">
<widget class="QTreeWidget" name="treeHostProc">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<item row="3" column="2">
<widget class="QCheckBox" name="chkLessConfidential">
<property name="text">
<string>Process</string>
<string>Allow useful Windows processes access to protected processes</string>
</property>
</column>
<column>
<property name="text">
<string>Action</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_19">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>471</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="3">
<spacer name="verticalSpacer_40">
<property name="orientation">
@ -1431,37 +1411,23 @@
</property>
</spacer>
</item>
<item row="9" column="3">
<widget class="QCheckBox" name="chkShowHostProcTmpl">
<property name="text">
<string>Show Templates</string>
<item row="8" column="3">
<spacer name="verticalSpacer_31">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>76</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblBoxProtection">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="toolTip">
<string>Protect the sandbox integrity itself</string>
</property>
<item row="10" column="3">
<widget class="QPushButton" name="btnDelHostProcess">
<property name="text">
<string>Box Protection</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="label_52">
<property name="text">
<string>Sandboxie-Plus is able to create confidential sandboxes that provide robust protection against unauthorized surveillance or tampering by host processes. By utilizing an encrypted sandbox image, this feature delivers the highest level of operational confidentiality, ensuring the safety and integrity of sandboxed processes.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Remove</string>
</property>
</widget>
</item>
@ -1501,21 +1467,58 @@
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QCheckBox" name="chkLessConfidential">
<item row="9" column="3">
<widget class="QCheckBox" name="chkShowHostProcTmpl">
<property name="text">
<string>Allow useful Windows processes access to protected processes</string>
<string>Show Templates</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QCheckBox" name="chkConfidential">
<item row="6" column="0" rowspan="5" colspan="3">
<widget class="QTreeWidget" name="treeHostProc">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Protect processes within this box from host processes</string>
<string>Process</string>
</property>
</column>
<column>
<property name="text">
<string>Action</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblBoxProtection">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="toolTip">
<string>Protect the sandbox integrity itself</string>
</property>
<property name="text">
<string>Box Protection</string>
</property>
</widget>
</item>
</layout>
<item row="4" column="1" colspan="2">
<widget class="QCheckBox" name="chkProtectWindow">
<property name="text">
<string>Prevents getting an image of the window in the sandbox.</string>
</property>
</widget>
</item>
</layout>
</widget>
@ -4505,7 +4508,7 @@ instead of &quot;*&quot;.</string>
<rect>
<x>0</x>
<y>0</y>
<width>92</width>
<width>75</width>
<height>16</height>
</rect>
</property>

View File

@ -65,43 +65,6 @@
<string>General Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="lblGeneral">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>SandMan Options</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>UI Language:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="uiLang"/>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkSandboxUrls">
<property name="text">
<string>Open urls from this ui sandboxed</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="chkMonitorSize">
<property name="text">
@ -109,48 +72,6 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="chkPanic">
<property name="text">
<string>Hotkey for terminating all boxed processes:</string>
</property>
</widget>
</item>
<item>
<widget class="QKeySequenceEdit" name="keyPanic"/>
</item>
</layout>
</item>
<item row="5" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="chkTop">
<property name="text">
<string>Hotkey for bringing sandman to the top:</string>
</property>
</widget>
</item>
<item>
<widget class="QKeySequenceEdit" name="keyTop"/>
</item>
</layout>
</item>
<item row="6" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="chkPauseForce">
<property name="text">
<string>Hotkey for suspending process/folder forcing:</string>
</property>
</widget>
</item>
<item>
<widget class="QKeySequenceEdit" name="keyPauseForce"/>
</item>
</layout>
</item>
<item row="7" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@ -165,13 +86,90 @@
</item>
</layout>
</item>
<item row="8" column="1" colspan="2">
<widget class="QCheckBox" name="chkAsyncBoxOps">
<item row="13" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>84</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="2">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>195</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="3" rowspan="2">
<spacer name="horizontalSpacer_14">
<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" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="chkPanic">
<property name="text">
<string>Run box operations asynchronously whenever possible (like content deletion)</string>
<string>Hotkey for terminating all boxed processes:</string>
</property>
</widget>
</item>
<item>
<widget class="QKeySequenceEdit" name="keyPanic"/>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="uiLang"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblGeneral">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>SandMan Options</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="chkTop">
<property name="text">
<string>Hotkey for bringing sandman to the top:</string>
</property>
</widget>
</item>
<item>
<widget class="QKeySequenceEdit" name="keyTop"/>
</item>
</layout>
</item>
<item row="9" column="0">
<widget class="QLabel" name="lblRecovery">
<property name="font">
@ -186,58 +184,74 @@
</property>
</widget>
</item>
<item row="10" column="1" colspan="2">
<item row="2" column="1">
<widget class="QCheckBox" name="chkSandboxUrls">
<property name="text">
<string>Open urls from this ui sandboxed</string>
</property>
<property name="tristate">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>UI Language:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QCheckBox" name="chkPauseForce">
<property name="text">
<string>Hotkey for suspending process/folder forcing:</string>
</property>
</widget>
</item>
<item>
<widget class="QKeySequenceEdit" name="keyPauseForce"/>
</item>
</layout>
</item>
<item row="11" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="chkShowRecovery">
<property name="text">
<string>Show file recovery window when emptying sandboxes</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item>
<widget class="QCheckBox" name="chkCheckDelete">
<property name="text">
<string>Check sandboxes' auto-delete status when Sandman starts</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRecoveryTop">
<property name="text">
<string>Show the Recovery Window as Always on Top</string>
</property>
</widget>
</item>
<item row="11" column="3" rowspan="2">
<spacer name="horizontalSpacer_14">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</layout>
</item>
<item row="12" column="1">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="8" column="1" colspan="2">
<widget class="QCheckBox" name="chkAsyncBoxOps">
<property name="text">
<string>Run box operations asynchronously whenever possible (like content deletion)</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>84</height>
</size>
</property>
</spacer>
</item>
<item row="12" column="2">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>195</width>
<height>20</height>
</size>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>

View File

@ -2677,8 +2677,11 @@ void CSandMan::OnHotKey(size_t id)
case HK_SUSPEND:
{
for (auto each : theAPI->GetAllBoxes())
each->SetSuspendedAll(TRUE);
for (auto each : theAPI->GetAllBoxes().toStdMap()) {
each.second->SetSuspendedAll(TRUE);
};
break;
}

View File

@ -104,6 +104,7 @@ void COptionsWindow::CreateAdvanced()
connect(ui.chkShowHostProcTmpl, SIGNAL(clicked(bool)), this, SLOT(OnShowHostProcTmpl()));
connect(ui.chkConfidential, SIGNAL(clicked(bool)), this, SLOT(OnConfidentialChanged()));
connect(ui.chkLessConfidential, SIGNAL(clicked(bool)), this, SLOT(OnLessConfidentialChanged()));
connect(ui.chkProtectWindow, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged()));
connect(ui.chkNotifyProtect, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged()));
connect(ui.treeInjectDll, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(OnToggleInjectDll(QTreeWidgetItem *, int)));
@ -262,6 +263,7 @@ void COptionsWindow::LoadAdvanced()
ui.chkLessConfidential->setChecked(m_BoxTemplates.contains("LessConfidentialBox"));
ui.chkNotifyProtect->setChecked(m_pBox->GetBool("NotifyBoxProtected", false));
ui.chkProtectWindow->setChecked(m_pBox->GetBool("IsProtectScreen"));
QStringList Users = m_pBox->GetText("Enabled").split(",");
ui.lstUsers->clear();
@ -465,6 +467,8 @@ void COptionsWindow::SaveAdvanced()
WriteAdvancedCheck(ui.chkConfidential, "ConfidentialBox", "y", "");
WriteAdvancedCheck(ui.chkNotifyProtect, "NotifyBoxProtected", "y", "");
WriteAdvancedCheck(ui.chkProtectWindow, "IsProtectScreen", "y", "n");
QStringList Users;
for (int i = 0; i < ui.lstUsers->count(); i++)
Users.append(ui.lstUsers->item(i)->text());

View File

@ -313,6 +313,7 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
connect(ui.chkNotifyRecovery, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkShowRecovery, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkCheckDelete, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkRecoveryTop, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
//
@ -908,6 +909,7 @@ void CSettingsWindow::LoadSettings()
ui.chkSandboxUrls->setCheckState(CSettingsWindow__Int2Chk(theConf->GetInt("Options/OpenUrlsSandboxed", 2)));
ui.chkShowRecovery->setChecked(theConf->GetBool("Options/ShowRecovery", false));
ui.chkCheckDelete->setChecked(!theConf->GetBool("Options/CleanUpOnStart", false));
ui.chkNotifyRecovery->setChecked(!theConf->GetBool("Options/InstantRecovery", true));
ui.chkRecoveryTop->setChecked(theConf->GetBool("Options/RecoveryOnTop", true));
ui.chkAsyncBoxOps->setChecked(theConf->GetBool("Options/UseAsyncBoxOps", false));
@ -1558,6 +1560,8 @@ void CSettingsWindow::SaveSettings()
theConf->SetValue("Options/EnableSuspendKey", ui.chkSuspend->isChecked());
theConf->SetValue("Options/SuspendKeySequence", ui.keySuspend->keySequence().toString());
theConf->SetValue("Options/CleanUpOnStart", !ui.chkCheckDelete->isChecked());
theConf->SetValue("Options/WatchBoxSize", ui.chkMonitorSize->isChecked());
theConf->SetValue("Options/WatchIni", ui.chkWatchConfig->isChecked());