Merge pull request #3656 from love-code-yeyixiao/master

add "restart as admin" feature
This commit is contained in:
DavidXanatos 2024-03-02 11:14:23 +01:00 committed by GitHub
commit 45ed7b91dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 481 additions and 409 deletions

View File

@ -1608,6 +1608,28 @@ _FX LRESULT Gui_WindowProcW(
return lResult;
}
_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 =(LPSETWINDOWDISPLAYAFFINITY) GetProcAddress(hDll, "SetWindowDisplayAffinity");
if (swda) {
swda(hWnd, 0x00000001);
}
}
}
}
}
}
//---------------------------------------------------------------------------
// Gui_WindowProcA
@ -1629,6 +1651,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 +2726,4 @@ _FX BOOLEAN ComDlg32_Init(HMODULE module)
return TRUE;
}

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,176 +1346,179 @@
<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>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="3">
<widget class="QPushButton" name="btnHostProcessDeny">
<property name="text">
<string>Deny Process</string>
</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">
<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>
<property name="text">
<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="4" column="3">
<spacer name="verticalSpacer_40">
<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="3">
<widget class="QCheckBox" name="chkShowHostProcTmpl">
<property name="text">
<string>Show Templates</string>
</property>
</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>
<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>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QPushButton" name="btnHostProcessAllow">
<property name="text">
<string>Allow Process</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Protect processes in this box from being accessed by specified unsandboxed host processes.</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_47">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QCheckBox" name="chkLessConfidential">
<property name="text">
<string>Allow useful Windows processes access to protected processes</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QCheckBox" name="chkConfidential">
<property name="text">
<string>Protect processes within this box from host processes</string>
</property>
</widget>
</item>
</layout>
<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="wordWrap">
<bool>true</bool>
</property>
</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">
<property name="text">
<string>Deny Process</string>
</property>
</widget>
</item>
<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="3" column="2">
<widget class="QCheckBox" name="chkLessConfidential">
<property name="text">
<string>Allow useful Windows processes access to protected processes</string>
</property>
</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">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</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>76</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="6" column="3">
<widget class="QPushButton" name="btnHostProcessAllow">
<property name="text">
<string>Allow Process</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Protect processes in this box from being accessed by specified unsandboxed host processes.</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_47">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QCheckBox" name="chkShowHostProcTmpl">
<property name="text">
<string>Show Templates</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>
<property name="text">
<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>
<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>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>Run box operations asynchronously whenever possible (like content deletion)</string>
<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,59 +184,75 @@
</property>
</widget>
</item>
<item row="10" column="1" colspan="2">
<widget class="QCheckBox" name="chkShowRecovery">
<item row="2" column="1">
<widget class="QCheckBox" name="chkSandboxUrls">
<property name="text">
<string>Show file recovery window when emptying sandboxes</string>
<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">
<widget class="QCheckBox" name="chkRecoveryTop">
<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>
<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>
</layout>
</item>
<item row="8" column="1" colspan="2">
<widget class="QCheckBox" name="chkAsyncBoxOps">
<property name="text">
<string>Show the Recovery Window as Always on Top</string>
<string>Run box operations asynchronously whenever possible (like content deletion)</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>
</item>
<item row="12" 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="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>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">

View File

@ -82,10 +82,10 @@ public:
if (theGUI)
theGUI->UpdateDrives();
}
/*else if ((msg->wParam & 0xFF80) == 0xAA00 && msg->lParam == 'xobs')
/*else if ((msg->wParam & 0xFF80) == 0xAA00 && msg->lParam == 'xobs')
{
UCHAR driveNumber = (UCHAR)(msg->wParam & 0x1F);
if (driveNumber < 26) {
if (driveNumber < 26) {
}
}
else if (msg->wParam == DBT_DEVNODES_CHANGED) // hardware changed
@ -374,8 +374,8 @@ void CSandMan::CreateUI()
// Clear old ToolBar references.
m_pNewBoxButton = nullptr;
m_pCleanUpButton = nullptr;
m_pEditIniButton = nullptr;
m_pEditIniButton = nullptr;
int iViewMode = theConf->GetInt("Options/ViewMode", 1);
if(iViewMode == 2)
@ -418,7 +418,7 @@ void CSandMan::CreateUI()
int iUsePizza = theConf->GetInt("Options/UseBackground", 2);
if (iUsePizza == 2)
iUsePizza = theConf->GetInt("Options/ViewMode", 1) == 2 ? 1 : 0;
if (iUsePizza)
if (iUsePizza)
{
QPalette pizzaPalete = GetBoxView()->GetTree()->palette(); // QPalette pizzaPalete = QApplication::palette();
SetPaleteTexture(pizzaPalete, QPalette::Base, QImage(":/Assets/background.png"));
@ -507,6 +507,7 @@ void CSandMan::CreateMenus(bool bAdvanced)
m_pNewBox = m_pMenuFile->addAction(CSandMan::GetIcon("NewBox"), tr("Create New Box"), this, SLOT(OnSandBoxAction()));
m_pNewGroup = m_pMenuFile->addAction(CSandMan::GetIcon("Group"), tr("Create Box Group"), this, SLOT(OnSandBoxAction()));
m_pImportBox = m_pMenuFile->addAction(CSandMan::GetIcon("UnPackBox"), tr("Import Box"), this, SLOT(OnSandBoxAction()));
m_pImportBox->setEnabled(CArchive::IsInit());
m_pMenuFile->addSeparator();
m_pRunBoxed = m_pMenuFile->addAction(CSandMan::GetIcon("Run"), tr("Run Sandboxed"), this, SLOT(OnSandBoxAction()));
@ -535,8 +536,9 @@ void CSandMan::CreateMenus(bool bAdvanced)
m_pSetupWizard = NULL;
//m_pUpdateCore = NULL;
}
m_pMenuFile->addSeparator();
m_pRestart = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Restart As Admin"), this, SLOT(OnRestartAsAdmin()));
m_pExit = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Exit"), this, SLOT(OnExit()));
@ -597,7 +599,7 @@ void CSandMan::CreateMenus(bool bAdvanced)
m_pEnableMonitoring->setCheckable(true);
if (!bAdvanced)
m_pMenuView->addAction(CSandMan::GetIcon("Recover"), tr("Recovery Log"), this, SLOT(OnRecoveryLog()));
m_pMenuOptions = m_pMenuBar->addMenu(tr("&Options"));
m_pMenuSettings = m_pMenuOptions->addAction(CSandMan::GetIcon("Settings"), tr("Global Settings"), this, SLOT(OnSettings()));
@ -663,7 +665,7 @@ void CSandMan::CreateOldMenus()
//m_pDisableRecovery->setCheckable(true);
m_pDisableRecovery = NULL;
//m_pDisableMessages = m_pMenuFile->addAction(tr("Disable Message Popup"));
//m_pDisableMessages->setCheckable(true);
//m_pDisableMessages->setCheckable(true);
m_pDisableMessages = NULL;
m_pMenuFile->addSeparator();
m_pWndFinder = m_pMenuFile->addAction(CSandMan::GetIcon("finder"), tr("Is Window Sandboxed?"), this, SLOT(OnWndFinder()));
@ -691,7 +693,7 @@ void CSandMan::CreateOldMenus()
m_pSetupWizard = NULL;
//m_pUpdateCore = NULL;
}
m_pRestart = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Restart As Admin"), this, SLOT(OnRestartAsAdmin()));
m_pExit = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Exit"), this, SLOT(OnExit()));
m_pMenuView = m_pMenuBar->addMenu(tr("&View"));
@ -797,7 +799,7 @@ QSet<QString> CSandMan::GetToolBarItemsConfig()
QSet<QString> validSet;
for (auto item : GetAvailableToolBarActions()) {
for (auto item : GetAvailableToolBarActions()) {
if (!item.scriptName.isEmpty()) validSet.insert(item.scriptName);
}
@ -862,6 +864,7 @@ QList<ToolBarAction> CSandMan::GetAvailableToolBarActions()
ToolBarAction{ "CheckForUpdates", m_pUpdate },
ToolBarAction{ "About", m_pAbout },
ToolBarAction{ "", nullptr }, // separator
ToolBarAction{ "RestartAsAdmin", m_pRestart },
ToolBarAction{ "Exit", m_pExit },
ToolBarAction{ "", nullptr }, // separator
ToolBarAction{ "Contribute", m_pContribution }
@ -923,7 +926,7 @@ void CSandMan::CreateToolBarConfigMenu(const QList<ToolBarAction>& actions, cons
}
}
m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
QObject::connect(m_pToolBar, &QToolBar::customContextMenuRequested, this,
[&](const QPoint& p) {
m_pToolBarContextMenu->exec(mapToGlobal(p));
@ -934,7 +937,7 @@ void CSandMan::CreateToolBarConfigMenu(const QList<ToolBarAction>& actions, cons
void CSandMan::CreateToolBar(bool rebuild)
{
// Assumes UI is in Advanced-Mode and menus have been built.
auto pOldToolBar = m_pToolBar;
m_pToolBar = new QToolBar();
m_pMainLayout->insertWidget(0, m_pToolBar);
@ -983,7 +986,7 @@ void CSandMan::CreateToolBar(bool rebuild)
but->setToolTip(tr("Cleanup"));
but->setText(tr("Cleanup"));
but->setPopupMode(QToolButton::MenuButtonPopup);
but->setMenu(m_pCleanUpMenu);
but->setMenu(m_pCleanUpMenu);
QObject::connect(but, SIGNAL(clicked(bool)), this, SLOT(OnCleanUp()));
m_pCleanUpButton = but;
m_pToolBar->addWidget(but);
@ -1079,7 +1082,7 @@ void CSandMan::UpdateLabel()
//auto neon = new CNeonEffect(10, 4, 180); // 140
//m_pLabel->setGraphicsEffect(NULL);
}
else if (g_Certificate.isEmpty())
else if (g_Certificate.isEmpty())
{
LabelText = tr("<a href=\"https://sandboxie-plus.com/go.php?to=patreon\">Support Sandboxie-Plus on Patreon</a>");
LabelTip = tr("Click to open web browser");
@ -1166,7 +1169,7 @@ void CSandMan::CreateView(int iViewMode)
else
m_pRecoveryLogWnd = NULL;
if (iViewMode == 2)
if (iViewMode == 2)
{
m_pViewStack = new QStackedLayout();
m_pViewStack->addWidget(m_pBoxView);
@ -1203,7 +1206,7 @@ void CSandMan::CreateView(int iViewMode)
m_pViewStack = NULL;
m_pBoxCombo = NULL;
if (iViewMode == 1)
if (iViewMode == 1)
{
m_pLogSplitter = new QSplitter();
m_pLogSplitter->setOrientation(Qt::Vertical);
@ -1214,7 +1217,7 @@ void CSandMan::CreateView(int iViewMode)
m_pPanelSplitter->setOrientation(Qt::Horizontal);
if (iViewMode == 1)
m_pLogSplitter->addWidget(m_pPanelSplitter);
else
else
m_pMainLayout->addWidget(m_pPanelSplitter);
m_pPanelSplitter->addWidget(m_pBoxView);
@ -1233,7 +1236,7 @@ void CSandMan::CreateView(int iViewMode)
m_pMessageLog->GetTree()->setItemDelegate(new CTreeItemDelegate());
m_pMessageLog->GetTree()->setAlternatingRowColors(theConf->GetBool("Options/AltRowColors", false));
//m_pMessageLog->GetView()->setItemDelegate(theGUI->GetItemDelegate());
((QTreeWidgetEx*)m_pMessageLog->GetView())->setHeaderLabels(tr("Time|Message").split("|"));
((QTreeWidgetEx*)m_pMessageLog->GetView())->setColumnFixed(1, true);
@ -1296,7 +1299,20 @@ void CSandMan::CheckForUpdates(bool bManual)
}
#include "SandManTray.cpp"
void CSandMan::OnRestartAsAdmin() {
theAPI->Disconnect();
WCHAR buf[255] = { 0 };
GetModuleFileNameW(NULL, buf, 255);
SHELLEXECUTEINFO se;
memset(&se, 0, sizeof(SHELLEXECUTEINFO));
se.cbSize = sizeof(SHELLEXECUTEINFO);
se.lpVerb = L"runas";
se.lpFile = buf;
se.nShow = SW_HIDE;
se.fMask = 0;
ShellExecuteEx(&se);
OnExit();
}
void CSandMan::OnExit()
{
m_bExit = true;
@ -1364,9 +1380,9 @@ void CSandMan::closeEvent(QCloseEvent *e)
void CSandMan::changeEvent(QEvent* e)
{
if (e->type() == QEvent::WindowStateChange)
if (e->type() == QEvent::WindowStateChange)
{
if (isMinimized())
if (isMinimized())
{
if (m_bOnTop) {
m_bOnTop = false;
@ -1387,16 +1403,16 @@ void CSandMan::changeEvent(QEvent* e)
}
}
}
QMainWindow::changeEvent(e);
QMainWindow::changeEvent(e);
}
void CSandMan::commitData(QSessionManager& manager)
{
//if (manager.allowsInteraction())
//if (manager.allowsInteraction())
//{
// manager.cancel();
// return;
//}
//}
m_pBoxView->SaveState();
m_pFileView->SaveState();
@ -1442,7 +1458,7 @@ QIcon CSandMan::GetColorIcon(QColor boxColor, bool inUse/*, bool bOut*/)
*c = rgb;
}
//}
QPixmap result(32, 32);
result.fill(Qt::transparent); // force alpha channel
QPainter painter(&result);
@ -1458,8 +1474,8 @@ QIcon CSandMan::GetColorIcon(QColor boxColor, bool inUse/*, bool bOut*/)
painter.drawPixmap(0, 0, FrameDM);
else
painter.drawPixmap(0, 0, Frame);
if (inUse)
{
if (inUse)
{
//rgb = change_hsv_c(rgb, -60, 2, 1); // yellow -> red
my_rgb rgb1 = { (double)qRed(rgb), (double)qGreen(rgb), (double)qBlue(rgb) };
@ -1535,7 +1551,7 @@ QString CSandMan::GetBoxDescription(int boxType)
break;
case CSandBoxPlus::eDefaultPlus:
case CSandBoxPlus::eDefault:
Info = tr("This box provides standard isolation, it is suitable to run your software to enhance security.");
Info = tr("This box provides standard isolation, it is suitable to run your software to enhance security.");
break;
case CSandBoxPlus::eAppBoxPlus:
case CSandBoxPlus::eAppBox:
@ -1545,7 +1561,7 @@ QString CSandMan::GetBoxDescription(int boxType)
Info = tr("This box will be <a href=\"sbie://docs/boxencryption\">encrypted</a> and <a href=\"sbie://docs/black-box\">access to sandboxed processes will be guarded</a>.");
break;
}
if(boxType == CSandBoxPlus::eHardenedPlus || boxType == CSandBoxPlus::eDefaultPlus || boxType == CSandBoxPlus::eAppBoxPlus)
Info.append(tr("<br /><br />This box <a href=\"sbie://docs/privacy-mode\">prevents access to all user data</a> locations, except explicitly granted in the Resource Access options."));
@ -1562,7 +1578,7 @@ bool CSandMan::IsFullyPortable()
}
bool CSandMan::KeepTerminated()
{
{
if (CWizardEngine::GetInstanceCount() > 0)
return true;
return m_pKeepTerminated && m_pKeepTerminated->isChecked();
@ -1678,7 +1694,7 @@ SB_RESULT(quint32) CSandMan::RunStart(const QString& BoxName, const QString& Com
{
auto pBoxEx = theAPI->GetBoxByName(BoxName).objectCast<CSandBoxPlus>();
if (pBoxEx && pBoxEx->UseImageFile() && pBoxEx->GetMountRoot().isEmpty()){
SB_STATUS Status = ImBoxMount(pBoxEx, true);
if (Status.IsError())
return Status;
@ -1738,7 +1754,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
m_pDisableForce->setChecked(bForceProcessDisabled);
m_pDisableForce2->setChecked(bForceProcessDisabled);
if (m_pTraceView)
if (m_pTraceView)
{
bool bIsMonitoring = theAPI->IsMonitoring();
m_pEnableMonitoring->setChecked(bIsMonitoring);
@ -1758,7 +1774,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
ActiveProcesses++;
}
}
else
else
ActiveProcesses = Processes.count();
@ -1854,7 +1870,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
QSharedPointer<CSbieIni> Section;
if (I.key() == "GlobalSettings")
Section = theAPI->GetGlobalSettings();
else
else
Section = theAPI->GetBoxByName(I.key());
if (!Section) continue;
@ -1872,7 +1888,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
}
}
void CSandMan::UpdateDrives()
void CSandMan::UpdateDrives()
{
static bool UpdatePending = false;
if (!UpdatePending) {
@ -1891,7 +1907,7 @@ void CSandMan::UpdateDrives()
qDebug() << "==============";
for (auto I = volumes.begin(); I != volumes.end(); ++I) {
for (auto J = I->mountPoints.begin(); J != I->mountPoints.end(); ++J) {
QString Device;
bool bOnUSB = false;
for (auto J = I->disks.begin(); J != I->disks.end(); ++J) {
@ -2021,7 +2037,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
}
if (Mode != eForDelete) {
//
// schedule async OnBoxDelete triggers and clean up
//
@ -2033,7 +2049,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
m_iDeletingContent++;
if (Mode != eForDelete) {
//
// execute OnBoxDelete triggers
//
@ -2050,7 +2066,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
}
}
}
{
//
// delete content synchronously
@ -2182,7 +2198,7 @@ void CSandMan::SyncStartMenu()
EnumBoxLinks(BoxLinks, "Desktop", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), false);
QMap<QString, CSandBoxPtr> Boxes = theAPI->GetAllBoxes();
foreach(const CSandBoxPtr & pBox, Boxes)
foreach(const CSandBoxPtr & pBox, Boxes)
{
CSandBoxPlus* pBoxEx = (CSandBoxPlus*)pBox.data();
@ -2285,7 +2301,7 @@ void CSandMan::OnBoxClosed(const CSandBoxPtr& pBox)
void CSandMan::OnBoxCleaned(CSandBoxPlus* pBoxEx)
{
if (pBoxEx->GetBool("AutoRemove", false))
if (pBoxEx->GetBool("AutoRemove", false))
{
if (theConf->GetBool("Options/AutoBoxOpsNotify", false))
OnLogMessage(tr("Auto removing sandbox %1").arg(pBoxEx->GetName()), true);
@ -2302,7 +2318,7 @@ void CSandMan::OnStatusChanged()
#else
QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion());
#endif
bool bConnected = theAPI->IsConnected();
m_pConnect->setEnabled(!bConnected);
m_pDisconnect->setEnabled(bConnected);
@ -2318,7 +2334,7 @@ void CSandMan::OnStatusChanged()
OnLogMessage(tr("Data Directory: %1").arg(QString(theConf->GetConfigDir()).replace("/","\\")));
//statusBar()->showMessage(tr("Driver version: %1").arg(theAPI->GetVersion()));
//appTitle.append(tr(" - Driver: v%1").arg(theAPI->GetVersion()));
if (bPortable)
{
@ -2332,7 +2348,7 @@ void CSandMan::OnStatusChanged()
QString NtBoxRoot = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%", false, false).replace("GlobalSettings", "[BoxName]");
bool State = false;
PortableRootDir = CCheckableMessageBox::question(this, "Sandboxie-Plus",
PortableRootDir = CCheckableMessageBox::question(this, "Sandboxie-Plus",
tr("Sandboxie-Plus was started in portable mode, do you want to put the Sandbox folder into its parent directory?\nYes will choose: %1\nNo will choose: %2")
.arg(BoxPath + "\\[BoxName]")
.arg(theAPI->Nt2DosPath(NtBoxRoot))
@ -2392,7 +2408,7 @@ void CSandMan::OnStatusChanged()
theAPI->SetSecureParam("UsageFlags", &UsageFlags, sizeof(UsageFlags));
}
}
g_FeatureFlags = theAPI->GetFeatureFlags();
SB_STATUS Status = theAPI->ReloadBoxes(true);
@ -2432,20 +2448,20 @@ void CSandMan::OnStatusChanged()
}
int DynData = theAPI->IsDyndataActive();
if (DynData != 1)
if (DynData != 1)
{
RTL_OSVERSIONINFOEXW versionInfo;
memset(&versionInfo, 0, sizeof(RTL_OSVERSIONINFOEXW));
versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
NTSTATUS(WINAPI *RtlGetVersion)(PRTL_OSVERSIONINFOEXW);
*(void**)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlGetVersion");
if (RtlGetVersion != NULL)
if (RtlGetVersion != NULL)
RtlGetVersion(&versionInfo);
else
GetVersionExW((LPOSVERSIONINFOW)&versionInfo); // since windows 10 this one is lying
RtlGetVersion(&versionInfo);
if (DynData == 0)
if (DynData == 0)
{
QString Message = tr("Your Windows build %1 exceeds the current support capabilities of your Sandboxie version, "
"resulting in the disabling of token-based security isolation. Consequently, all applications will operate in application compartment mode without secure isolation.\r\n"
@ -2522,7 +2538,7 @@ void CSandMan::CheckCompat(QObject* receiver, const char* member)
return;
}
}
m_SbieTemplates->RunCheck();
qDebug() << "Template Check took" << timer->elapsed() << "ms";
@ -2610,7 +2626,7 @@ void CSandMan::CheckSupport()
return;
static bool ReminderShown = false;
if (!ReminderShown && (g_CertInfo.expired || (g_CertInfo.expirers_in_sec > 0 && g_CertInfo.expirers_in_sec < (60 * 60 * 24 * 30))) && !theConf->GetBool("Options/NoSupportCheck", false))
if (!ReminderShown && (g_CertInfo.expired || (g_CertInfo.expirers_in_sec > 0 && g_CertInfo.expirers_in_sec < (60 * 60 * 24 * 30))) && !theConf->GetBool("Options/NoSupportCheck", false))
{
ReminderShown = true;
CSettingsWindow* pSettingsWindow = new CSettingsWindow(this);
@ -2661,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;
}
@ -2753,7 +2772,7 @@ void CSandMan::AddLogMessage(const QDateTime& TimeStamp, const QString& Message,
else
pItem->setText(1, Message);
#endif
m_pMessageLog->GetView()->verticalScrollBar()->setValue(m_pMessageLog->GetView()->verticalScrollBar()->maximum());
}
@ -2825,7 +2844,7 @@ void CSandMan::OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, qui
else
Message.append(tr("<br /><a href=\"https://sandboxie-plus.com/go.php?to=sbie-get-cert\">Become a project supporter</a>, and receive a <a href=\"https://sandboxie-plus.com/go.php?to=sbie-cert\">supporter certificate</a>"));
}
else
else
{
static quint64 iLastCertWarning = 0;
if (iLastCertWarning + 60 < QDateTime::currentDateTime().toSecsSinceEpoch()) { // reset after 60 seconds
@ -2892,7 +2911,7 @@ void CSandMan::SaveMessageLog(QIODevice* pFile)
pFile->write((Msg.TimeStamp.toString("dd.MM.yyyy hh:mm:ss.zzz") + "\t" + FormatSbieMessage(Msg.MsgCode, Msg.MsgData, Msg.ProcessName)).toLatin1() + "\n");
}
bool CSandMan::CheckCertificate(QWidget* pWidget, int iType)
bool CSandMan::CheckCertificate(QWidget* pWidget, int iType)
{
QString Message;
if (iType == 1)
@ -2949,13 +2968,13 @@ SB_STATUS CSandMan::ReloadCert(QWidget* pWidget)
}
else if (Status.GetStatus() == 0xC0000804L /*STATUS_CONTENT_BLOCKED*/)
{
QMessageBox::critical(pWidget ? pWidget : this, "Sandboxie-Plus",
QMessageBox::critical(pWidget ? pWidget : this, "Sandboxie-Plus",
tr("The certificate you are attempting to use has been blocked, meaning it has been invalidated for cause. Any attempt to use it constitutes a breach of its terms of use!"));
BYTE CertBlocked = 1;
theAPI->SetSecureParam("CertBlocked", &CertBlocked, sizeof(CertBlocked));
}
else if (Status.GetStatus() != 0xC0000225L /*STATUS_NOT_FOUND*/)
else if (Status.GetStatus() != 0xC0000225L /*STATUS_NOT_FOUND*/)
{
QString Info;
switch (Status.GetStatus())
@ -3005,7 +3024,7 @@ void CSandMan::UpdateCertState()
if (theConf->GetBool("Debug/CertFakeGracePeriode", false))
g_CertInfo.grace_period = 1;
// simulate a subscription type certificate having expired
// simulate a subscription type certificate having expired
if (theConf->GetBool("Debug/CertFakeOld", false)) {
g_CertInfo.active = 0;
g_CertInfo.expired = 1;
@ -3060,7 +3079,7 @@ void CSandMan::UpdateCertState()
void CSandMan::OnQueuedRequest(quint32 ClientPid, quint32 ClientTid, quint32 RequestId, const QVariantMap& Data)
{
if (Data["id"].toInt() == 0)
if (Data["id"].toInt() == 0)
{
QVariantMap Ret;
Ret["retval"] = (theAPI->IsStarting(ClientPid) || CSupportDialog::ShowDialog()) ? 1 : 0;
@ -3213,7 +3232,7 @@ void CSandMan::OnDisablePopUp()
SB_RESULT(void*) CSandMan::ConnectSbie()
{
SB_RESULT(void*) Status;
if (!CSbieUtils::IsRunning(CSbieUtils::eAll))
if (!CSbieUtils::IsRunning(CSbieUtils::eAll))
{
if (!CSbieUtils::IsInstalled(CSbieUtils::eAll))
{
@ -3248,7 +3267,7 @@ SB_RESULT(void*) CSandMan::ConnectSbie()
SB_STATUS CSandMan::ConnectSbieImpl()
{
SB_STATUS Status = theAPI->Connect(g_PendingMessage.isEmpty(), theConf->GetBool("Options/UseInteractiveQueue", true));
if (!g_PendingMessage.isEmpty()) {
OnMessage(g_PendingMessage);
PostQuitMessage(0);
@ -3326,11 +3345,11 @@ void CSandMan::OnMaintenance()
}
//else if (sender() == m_pUpdateCore) {
// // todo
// // todo
// return;
//}
// uninstall
// uninstall
else if (sender() == m_pUninstallAll) {
Status = StopSbie(true);
@ -3351,7 +3370,7 @@ void CSandMan::HandleMaintenance(SB_RESULT(void*) Status)
connect(processFinishedNotifier, &QWinEventNotifier::activated, this, [processFinishedNotifier, this, hProcess]() {
processFinishedNotifier->setEnabled(false);
processFinishedNotifier->deleteLater();
DWORD dwStatus = 0;
GetExitCodeProcess(hProcess, & dwStatus);
@ -3444,16 +3463,16 @@ void CSandMan::OnCleanUp()
m_MessageLog.clear();
if (m_pMessageLog) m_pMessageLog->GetTree()->clear();
}
if (sender() == m_pCleanUpTrace || sender() == m_pCleanUpButton)
if (m_pTraceView) {
m_pTraceView->Clear();
if (m_pTraceView) {
m_pTraceView->Clear();
m_pTraceInfo->clear();
}
if (sender() == m_pCleanUpRecovery || sender() == m_pCleanUpButton)
if(m_pRecoveryLog) m_pRecoveryLog->GetTree()->clear();
if (sender() == m_pCleanUpProcesses || sender() == m_pCleanUpButton)
theAPI->UpdateProcesses(0, ShowAllSessions());
}
@ -3539,7 +3558,7 @@ void CSandMan::UpdateSettings(bool bRebuildUI)
m_pTrayIcon->hide();
if (bRebuildUI)
if (bRebuildUI)
{
StoreState();
@ -3721,7 +3740,7 @@ void CSandMan::EditIni(const QString& IniPath, bool bPlus)
if (!bPlus && theConf->GetBool("Options/WatchIni", true))
return; // if the ini is watched don't double reload
QWinEventNotifier* processFinishedNotifier = new QWinEventNotifier(si.hProcess);
processFinishedNotifier->setEnabled(true);
connect(processFinishedNotifier, &QWinEventNotifier::activated, this, [processFinishedNotifier, this, si, bPlus]() {
@ -3892,7 +3911,7 @@ QString CSandMan::FormatError(const SB_STATUS& Error)
//case SB_RemNotEmpty: Message = tr("A sandbox must be emptied before it can be renamed."); break;
case SB_DelNotEmpty: Message = tr("A sandbox must be emptied before it can be deleted."); break;
case SB_FailedMoveDir: Message = tr("Failed to move directory '%1' to '%2'"); break;
case SB_FailedMoveImage:Message = tr("Failed to move box image '%1' to '%2'"); break;
case SB_FailedMoveImage:Message = tr("Failed to move box image '%1' to '%2'"); break;
case SB_SnapIsRunning: Message = tr("This Snapshot operation can not be performed while processes are still running in the box."); break;
case SB_SnapMkDirFail: Message = tr("Failed to create directory for new snapshot"); break;
case SB_SnapCopyDatFail:Message = tr("Failed to copy box data files"); break;
@ -3956,7 +3975,7 @@ void CSandMan::OnBoxAssistant()
void CSandMan::TryFix(quint32 MsgCode, const QStringList& MsgData, const QString& ProcessName, const QString& BoxName)
{
SetWindowPos((HWND)m_pPopUpWindow->winId(), HWND_NOTOPMOST , 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
QPointer<CBoxAssistant> pWizard = new CBoxAssistant(this);
pWizard->TryFix(MsgCode, MsgData, ProcessName, BoxName);
pWizard->setAttribute(Qt::WA_DeleteOnClose);
@ -3976,7 +3995,7 @@ void CSandMan::OpenUrl(const QUrl& url)
{
QString scheme = url.scheme();
QString host = url.host();
QString path = url.path();
QString path = url.path();
QString query = url.query();
if (scheme == "addon") {
@ -4002,7 +4021,7 @@ void CSandMan::OpenUrl(const QUrl& url)
{
bool bCheck = false;
//QString Message = tr("Do you want to open %1 in a sandboxed (yes) or unsandboxed (no) Web browser?").arg(url.toString());
//QDialogButtonBox::StandardButton Ret = CCheckableMessageBox::question(this, "Sandboxie-Plus", Message , tr("Remember choice for later."),
//QDialogButtonBox::StandardButton Ret = CCheckableMessageBox::question(this, "Sandboxie-Plus", Message , tr("Remember choice for later."),
// &bCheck, QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel, QDialogButtonBox::Yes, QMessageBox::Question);
CCheckableMessageBox mb(this);
@ -4028,9 +4047,9 @@ void CSandMan::OpenUrl(const QUrl& url)
else ShellExecute(MainWndHandle, NULL, url.toString().toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL);
}
bool CSandMan::IsWFPEnabled() const
{
return (g_FeatureFlags & CSbieAPI::eSbieFeatureWFP) != 0;
bool CSandMan::IsWFPEnabled() const
{
return (g_FeatureFlags & CSbieAPI::eSbieFeatureWFP) != 0;
}
QString CSandMan::GetVersion()
@ -4058,7 +4077,7 @@ void CSandMan::SetUITheme()
bDark = (settings.value("AppsUseLightTheme") == 0);
} else
bDark = (iDark == 1);
if (bDark)
QApplication::setPalette(m_DarkPalett);
else
@ -4070,7 +4089,7 @@ void CSandMan::SetUITheme()
int iFusion = theConf->GetInt("Options/UseFusionTheme", 2);
if (iFusion == 2)
bFusion = bDark;
else
else
bFusion = (iFusion == 1);
if (bFusion)
@ -4111,7 +4130,7 @@ void CSandMan::SetTitleTheme(const HWND& hwnd)
QSettings::NativeFormat).value("CurrentBuild").toInt();
if (CurrentVersion < 17763) // Windows 10 1809 -
return;
HMODULE dwmapi = GetModuleHandle(L"dwmapi.dll");
if (dwmapi)
{
@ -4162,7 +4181,7 @@ void CSandMan::LoadLanguage()
#endif
m_LanguageId = LocaleNameToLCID(m_Language.toStdWString().c_str(), 0);
if (!m_LanguageId)
if (!m_LanguageId)
m_LanguageId = 1033; // default to English
LoadLanguage(m_Language, "sandman", 0);
@ -4186,7 +4205,7 @@ void CSandMan::LoadLanguage(const QString& Lang, const QString& Module, int Inde
if (Lang.isEmpty())
return;
QString LangAux = Lang; // Short version as fallback
LangAux.truncate(LangAux.lastIndexOf('_'));
@ -4210,7 +4229,7 @@ void CSandMan::OnHelp()
{
//if (sender() == m_pSupport)
// QDesktopServices::openUrl(QUrl("https://sandboxie-plus.com/go.php?to=donate"));
//else
//else
if (sender() == m_pContribution)
QDesktopServices::openUrl(QUrl("https://sandboxie-plus.com/go.php?to=sbie-contribute"));
else if (sender() == m_pManual)
@ -4257,14 +4276,14 @@ void CSandMan::OnAbout()
msgBox->setInformativeText(AboutText);
QIcon ico(QLatin1String(":/SandMan.png"));
QPixmap pix(128, 160);
pix.fill(Qt::transparent);
QPainter painter(&pix);
painter.drawPixmap(0, 0, ico.pixmap(128, 128));
if (g_CertInfo.active)
if (g_CertInfo.active)
{
//painter.setPen(Qt::blue);
//painter.drawRect(0, 0, 127, 159);
@ -4335,20 +4354,20 @@ int g_CertAmount = 0;
void SlotSend(const std::wstring& message)
{
std::wstring strSlotName = L"\\\\*\\mailslot\\" + g_SlotName;
HANDLE hSlot = CreateFile(strSlotName.c_str(),
GENERIC_WRITE,
HANDLE hSlot = CreateFile(strSlotName.c_str(),
GENERIC_WRITE,
FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
if (hSlot == INVALID_HANDLE_VALUE)
{
(LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
if (hSlot == INVALID_HANDLE_VALUE)
{
//GetLastError();
return;
}
}
DWORD cbWritten;
DWORD cbWritten;
WriteFile(hSlot, message.c_str(), (DWORD)(message.size() + 1) * sizeof(wchar_t), &cbWritten, NULL);
CloseHandle(hSlot);
@ -4381,14 +4400,14 @@ int CountSeats()
DWORD WINAPI MailThreadFunc(LPVOID lpParam)
{
std::wstring strSlotName = L"\\\\.\\mailslot\\" + g_SlotName;
HANDLE hSlot = CreateMailslot(strSlotName.c_str(),
0, // no maximum message size
MAILSLOT_WAIT_FOREVER, // no time-out for operations
HANDLE hSlot = CreateMailslot(strSlotName.c_str(),
0, // no maximum message size
MAILSLOT_WAIT_FOREVER, // no time-out for operations
(LPSECURITY_ATTRIBUTES) NULL); // default security
if (hSlot == INVALID_HANDLE_VALUE) {
if (hSlot == INVALID_HANDLE_VALUE) {
//GetLastError()
return FALSE;
}
return FALSE;
}
ScanForSeats();
@ -4398,11 +4417,11 @@ DWORD WINAPI MailThreadFunc(LPVOID lpParam)
{
DWORD cbMessage;
DWORD dwMessageCount;
if(!GetMailslotInfo(hSlot, // mailslot handle
(LPDWORD)NULL, // no maximum message size
&cbMessage, // size of next message
&dwMessageCount, // number of messages
(LPDWORD)NULL)) // no read time-out
if(!GetMailslotInfo(hSlot, // mailslot handle
(LPDWORD)NULL, // no maximum message size
&cbMessage, // size of next message
&dwMessageCount, // number of messages
(LPDWORD)NULL)) // no read time-out
{
//GetLastError();
continue;

View File

@ -24,7 +24,7 @@ class CScriptManager;
class CAddonManager;
struct ToolBarAction {
// Identifier of action stored in ini. Empty for separator.
// Identifier of action stored in ini. Empty for separator.
QString scriptName = "";
// Not owned. Null for special cases.
@ -104,7 +104,7 @@ public:
QIcon MakeIconBusy(const QIcon& Icon, int Index = 0);
QIcon IconAddOverlay(const QIcon& Icon, const QString& Name, int Size = 24);
QString GetBoxDescription(int boxType);
bool CheckCertificate(QWidget* pWidget, int iType = 0);
bool IsAlwaysOnTop() const;
@ -156,7 +156,7 @@ protected:
CScriptManager* m_SbieScripts;
CAddonManager* m_AddonManager;
QMap<CSbieProgress*, QPair<CSbieProgressPtr, QPointer<QWidget>>> m_pAsyncProgress;
QMap<QString, QSet<QString>> m_MissingTemplates;
@ -183,7 +183,7 @@ protected:
struct SSbieMsg {
QDateTime TimeStamp;
quint32 MsgCode;
QStringList MsgData;
QStringList MsgData;
QString ProcessName;
};
QVector<SSbieMsg> m_MessageLog;
@ -279,6 +279,8 @@ private slots:
void CheckForUpdates(bool bManual = true);
void OnRestartAsAdmin();
void OnExit();
void OnHelp();
void OnAbout();
@ -366,6 +368,7 @@ private:
QHBoxLayout* m_pMenuLayout;
QMenu* m_pMenuFile;
QAction* m_pRestart;
QAction* m_pRunBoxed;
QAction* m_pNewBox;
QAction* m_pNewGroup;

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