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; 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 // Gui_WindowProcA
@ -1629,6 +1651,8 @@ _FX LRESULT Gui_WindowProcA(
if (uMsg == WM_SETTEXT && Gui_ShouldCreateTitle(hWnd)) if (uMsg == WM_SETTEXT && Gui_ShouldCreateTitle(hWnd))
new_lParam = (LPARAM)Gui_CreateTitleA((UCHAR *)lParam); new_lParam = (LPARAM)Gui_CreateTitleA((UCHAR *)lParam);
if (uMsg == WM_CREATE)
ProtectScreen(hWnd);
else else
new_lParam = lParam; new_lParam = lParam;
@ -2702,3 +2726,4 @@ _FX BOOLEAN ComDlg32_Init(HMODULE module)
return TRUE; return TRUE;
} }

View File

@ -45,7 +45,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>10</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tabGeneral"> <widget class="QWidget" name="tabGeneral">
<attribute name="title"> <attribute name="title">
@ -1004,7 +1004,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabsSecurity"> <widget class="QTabWidget" name="tabsSecurity">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tabHarden"> <widget class="QWidget" name="tabHarden">
<attribute name="title"> <attribute name="title">
@ -1346,176 +1346,179 @@
<attribute name="title"> <attribute name="title">
<string>Box Protection</string> <string>Box Protection</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_83"> <layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0"> <item row="0" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_82"> <widget class="QLabel" name="label_52">
<item row="1" column="2"> <property name="text">
<spacer name="horizontalSpacer_19"> <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 name="orientation"> </property>
<enum>Qt::Horizontal</enum> <property name="wordWrap">
</property> <bool>true</bool>
<property name="sizeHint" stdset="0"> </property>
<size> </widget>
<width>40</width> </item>
<height>20</height> <item row="2" column="1" colspan="2">
</size> <widget class="QCheckBox" name="chkConfidential">
</property> <property name="text">
</spacer> <string>Protect processes within this box from host processes</string>
</item> </property>
<item row="7" column="3"> </widget>
<widget class="QPushButton" name="btnHostProcessDeny"> </item>
<property name="text"> <item row="7" column="3">
<string>Deny Process</string> <widget class="QPushButton" name="btnHostProcessDeny">
</property> <property name="text">
</widget> <string>Deny Process</string>
</item> </property>
<item row="8" column="3"> </widget>
<spacer name="verticalSpacer_31"> </item>
<property name="orientation"> <item row="11" column="0" colspan="3">
<enum>Qt::Vertical</enum> <widget class="QCheckBox" name="chkNotifyProtect">
</property> <property name="text">
<property name="sizeHint" stdset="0"> <string>Issue message 1318/1317 when a host process tries to access a sandboxed process/the box root</string>
<size> </property>
<width>20</width> </widget>
<height>40</height> </item>
</size> <item row="3" column="2">
</property> <widget class="QCheckBox" name="chkLessConfidential">
</spacer> <property name="text">
</item> <string>Allow useful Windows processes access to protected processes</string>
<item row="10" column="3"> </property>
<widget class="QPushButton" name="btnDelHostProcess"> </widget>
<property name="text"> </item>
<string>Remove</string> <item row="1" column="2">
</property> <spacer name="horizontalSpacer_19">
</widget> <property name="orientation">
</item> <enum>Qt::Horizontal</enum>
<item row="11" column="0" colspan="4"> </property>
<widget class="QCheckBox" name="chkNotifyProtect"> <property name="sizeHint" stdset="0">
<property name="text"> <size>
<string>Issue message 1318/1317 when a host process tries to access a sandboxed process/the box root</string> <width>471</width>
</property> <height>20</height>
</widget> </size>
</item> </property>
<item row="6" column="0" rowspan="5" colspan="3"> </spacer>
<widget class="QTreeWidget" name="treeHostProc"> </item>
<property name="sortingEnabled"> <item row="4" column="3">
<bool>true</bool> <spacer name="verticalSpacer_40">
</property> <property name="orientation">
<column> <enum>Qt::Vertical</enum>
<property name="text"> </property>
<string>Process</string> <property name="sizeHint" stdset="0">
</property> <size>
</column> <width>20</width>
<column> <height>40</height>
<property name="text"> </size>
<string>Action</string> </property>
</property> </spacer>
</column> </item>
<column> <item row="8" column="3">
<property name="text"> <spacer name="verticalSpacer_31">
<string/> <property name="orientation">
</property> <enum>Qt::Vertical</enum>
</column> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="4" column="3"> <width>20</width>
<spacer name="verticalSpacer_40"> <height>76</height>
<property name="orientation"> </size>
<enum>Qt::Vertical</enum> </property>
</property> </spacer>
<property name="sizeHint" stdset="0"> </item>
<size> <item row="10" column="3">
<width>20</width> <widget class="QPushButton" name="btnDelHostProcess">
<height>40</height> <property name="text">
</size> <string>Remove</string>
</property> </property>
</spacer> </widget>
</item> </item>
<item row="9" column="3"> <item row="6" column="3">
<widget class="QCheckBox" name="chkShowHostProcTmpl"> <widget class="QPushButton" name="btnHostProcessAllow">
<property name="text"> <property name="text">
<string>Show Templates</string> <string>Allow Process</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="5" column="0" colspan="3">
<widget class="QLabel" name="lblBoxProtection"> <widget class="QLabel" name="label_5">
<property name="font"> <property name="text">
<font> <string>Protect processes in this box from being accessed by specified unsandboxed host processes.</string>
<weight>75</weight> </property>
<bold>true</bold> <property name="wordWrap">
<kerning>true</kerning> <bool>false</bool>
</font> </property>
</property> </widget>
<property name="toolTip"> </item>
<string>Protect the sandbox integrity itself</string> <item row="3" column="1">
</property> <widget class="QLabel" name="label_47">
<property name="text"> <property name="minimumSize">
<string>Box Protection</string> <size>
</property> <width>20</width>
</widget> <height>0</height>
</item> </size>
<item row="0" column="0" colspan="4"> </property>
<widget class="QLabel" name="label_52"> <property name="maximumSize">
<property name="text"> <size>
<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> <width>20</width>
</property> <height>16777215</height>
<property name="wordWrap"> </size>
<bool>true</bool> </property>
</property> <property name="text">
</widget> <string/>
</item> </property>
<item row="6" column="3"> </widget>
<widget class="QPushButton" name="btnHostProcessAllow"> </item>
<property name="text"> <item row="9" column="3">
<string>Allow Process</string> <widget class="QCheckBox" name="chkShowHostProcTmpl">
</property> <property name="text">
</widget> <string>Show Templates</string>
</item> </property>
<item row="5" column="0" colspan="3"> </widget>
<widget class="QLabel" name="label_5"> </item>
<property name="text"> <item row="6" column="0" rowspan="5" colspan="3">
<string>Protect processes in this box from being accessed by specified unsandboxed host processes.</string> <widget class="QTreeWidget" name="treeHostProc">
</property> <property name="sortingEnabled">
<property name="wordWrap"> <bool>true</bool>
<bool>false</bool> </property>
</property> <column>
</widget> <property name="text">
</item> <string>Process</string>
<item row="3" column="1"> </property>
<widget class="QLabel" name="label_47"> </column>
<property name="minimumSize"> <column>
<size> <property name="text">
<width>20</width> <string>Action</string>
<height>0</height> </property>
</size> </column>
</property> <column>
<property name="maximumSize"> <property name="text">
<size> <string/>
<width>20</width> </property>
<height>16777215</height> </column>
</size> </widget>
</property> </item>
<property name="text"> <item row="1" column="0">
<string/> <widget class="QLabel" name="lblBoxProtection">
</property> <property name="font">
</widget> <font>
</item> <weight>75</weight>
<item row="3" column="2" colspan="2"> <bold>true</bold>
<widget class="QCheckBox" name="chkLessConfidential"> <kerning>true</kerning>
<property name="text"> </font>
<string>Allow useful Windows processes access to protected processes</string> </property>
</property> <property name="toolTip">
</widget> <string>Protect the sandbox integrity itself</string>
</item> </property>
<item row="2" column="1" colspan="3"> <property name="text">
<widget class="QCheckBox" name="chkConfidential"> <string>Box Protection</string>
<property name="text"> </property>
<string>Protect processes within this box from host processes</string> </widget>
</property> </item>
</widget> <item row="4" column="1" colspan="2">
</item> <widget class="QCheckBox" name="chkProtectWindow">
</layout> <property name="text">
<string>Prevents getting an image of the window in the sandbox.</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -4505,7 +4508,7 @@ instead of &quot;*&quot;.</string>
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>92</width> <width>75</width>
<height>16</height> <height>16</height>
</rect> </rect>
</property> </property>

View File

@ -65,43 +65,6 @@
<string>General Options</string> <string>General Options</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_8"> <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"> <item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="chkMonitorSize"> <widget class="QCheckBox" name="chkMonitorSize">
<property name="text"> <property name="text">
@ -109,48 +72,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="7" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
@ -165,13 +86,90 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="1" colspan="2"> <item row="13" column="1">
<widget class="QCheckBox" name="chkAsyncBoxOps"> <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"> <property name="text">
<string>Run box operations asynchronously whenever possible (like content deletion)</string> <string>SandMan Options</string>
</property> </property>
</widget> </widget>
</item> </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"> <item row="9" column="0">
<widget class="QLabel" name="lblRecovery"> <widget class="QLabel" name="lblRecovery">
<property name="font"> <property name="font">
@ -186,59 +184,75 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1" colspan="2"> <item row="2" column="1">
<widget class="QCheckBox" name="chkShowRecovery"> <widget class="QCheckBox" name="chkSandboxUrls">
<property name="text"> <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> </property>
</widget> </widget>
</item> </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"> <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"> <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> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_4"> <widget class="QWidget" name="tab_4">

View File

@ -82,10 +82,10 @@ public:
if (theGUI) if (theGUI)
theGUI->UpdateDrives(); 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); UCHAR driveNumber = (UCHAR)(msg->wParam & 0x1F);
if (driveNumber < 26) { if (driveNumber < 26) {
} }
} }
else if (msg->wParam == DBT_DEVNODES_CHANGED) // hardware changed else if (msg->wParam == DBT_DEVNODES_CHANGED) // hardware changed
@ -374,8 +374,8 @@ void CSandMan::CreateUI()
// Clear old ToolBar references. // Clear old ToolBar references.
m_pNewBoxButton = nullptr; m_pNewBoxButton = nullptr;
m_pCleanUpButton = nullptr; m_pCleanUpButton = nullptr;
m_pEditIniButton = nullptr; m_pEditIniButton = nullptr;
int iViewMode = theConf->GetInt("Options/ViewMode", 1); int iViewMode = theConf->GetInt("Options/ViewMode", 1);
if(iViewMode == 2) if(iViewMode == 2)
@ -418,7 +418,7 @@ void CSandMan::CreateUI()
int iUsePizza = theConf->GetInt("Options/UseBackground", 2); int iUsePizza = theConf->GetInt("Options/UseBackground", 2);
if (iUsePizza == 2) if (iUsePizza == 2)
iUsePizza = theConf->GetInt("Options/ViewMode", 1) == 2 ? 1 : 0; iUsePizza = theConf->GetInt("Options/ViewMode", 1) == 2 ? 1 : 0;
if (iUsePizza) if (iUsePizza)
{ {
QPalette pizzaPalete = GetBoxView()->GetTree()->palette(); // QPalette pizzaPalete = QApplication::palette(); QPalette pizzaPalete = GetBoxView()->GetTree()->palette(); // QPalette pizzaPalete = QApplication::palette();
SetPaleteTexture(pizzaPalete, QPalette::Base, QImage(":/Assets/background.png")); 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_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_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 = m_pMenuFile->addAction(CSandMan::GetIcon("UnPackBox"), tr("Import Box"), this, SLOT(OnSandBoxAction()));
m_pImportBox->setEnabled(CArchive::IsInit()); m_pImportBox->setEnabled(CArchive::IsInit());
m_pMenuFile->addSeparator(); m_pMenuFile->addSeparator();
m_pRunBoxed = m_pMenuFile->addAction(CSandMan::GetIcon("Run"), tr("Run Sandboxed"), this, SLOT(OnSandBoxAction())); 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_pSetupWizard = NULL;
//m_pUpdateCore = NULL; //m_pUpdateCore = NULL;
} }
m_pMenuFile->addSeparator(); 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())); 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); m_pEnableMonitoring->setCheckable(true);
if (!bAdvanced) if (!bAdvanced)
m_pMenuView->addAction(CSandMan::GetIcon("Recover"), tr("Recovery Log"), this, SLOT(OnRecoveryLog())); m_pMenuView->addAction(CSandMan::GetIcon("Recover"), tr("Recovery Log"), this, SLOT(OnRecoveryLog()));
m_pMenuOptions = m_pMenuBar->addMenu(tr("&Options")); m_pMenuOptions = m_pMenuBar->addMenu(tr("&Options"));
m_pMenuSettings = m_pMenuOptions->addAction(CSandMan::GetIcon("Settings"), tr("Global Settings"), this, SLOT(OnSettings())); 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->setCheckable(true);
m_pDisableRecovery = NULL; m_pDisableRecovery = NULL;
//m_pDisableMessages = m_pMenuFile->addAction(tr("Disable Message Popup")); //m_pDisableMessages = m_pMenuFile->addAction(tr("Disable Message Popup"));
//m_pDisableMessages->setCheckable(true); //m_pDisableMessages->setCheckable(true);
m_pDisableMessages = NULL; m_pDisableMessages = NULL;
m_pMenuFile->addSeparator(); m_pMenuFile->addSeparator();
m_pWndFinder = m_pMenuFile->addAction(CSandMan::GetIcon("finder"), tr("Is Window Sandboxed?"), this, SLOT(OnWndFinder())); 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_pSetupWizard = NULL;
//m_pUpdateCore = 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_pExit = m_pMenuFile->addAction(CSandMan::GetIcon("Exit"), tr("Exit"), this, SLOT(OnExit()));
m_pMenuView = m_pMenuBar->addMenu(tr("&View")); m_pMenuView = m_pMenuBar->addMenu(tr("&View"));
@ -797,7 +799,7 @@ QSet<QString> CSandMan::GetToolBarItemsConfig()
QSet<QString> validSet; QSet<QString> validSet;
for (auto item : GetAvailableToolBarActions()) { for (auto item : GetAvailableToolBarActions()) {
if (!item.scriptName.isEmpty()) validSet.insert(item.scriptName); if (!item.scriptName.isEmpty()) validSet.insert(item.scriptName);
} }
@ -862,6 +864,7 @@ QList<ToolBarAction> CSandMan::GetAvailableToolBarActions()
ToolBarAction{ "CheckForUpdates", m_pUpdate }, ToolBarAction{ "CheckForUpdates", m_pUpdate },
ToolBarAction{ "About", m_pAbout }, ToolBarAction{ "About", m_pAbout },
ToolBarAction{ "", nullptr }, // separator ToolBarAction{ "", nullptr }, // separator
ToolBarAction{ "RestartAsAdmin", m_pRestart },
ToolBarAction{ "Exit", m_pExit }, ToolBarAction{ "Exit", m_pExit },
ToolBarAction{ "", nullptr }, // separator ToolBarAction{ "", nullptr }, // separator
ToolBarAction{ "Contribute", m_pContribution } 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, QObject::connect(m_pToolBar, &QToolBar::customContextMenuRequested, this,
[&](const QPoint& p) { [&](const QPoint& p) {
m_pToolBarContextMenu->exec(mapToGlobal(p)); m_pToolBarContextMenu->exec(mapToGlobal(p));
@ -934,7 +937,7 @@ void CSandMan::CreateToolBarConfigMenu(const QList<ToolBarAction>& actions, cons
void CSandMan::CreateToolBar(bool rebuild) void CSandMan::CreateToolBar(bool rebuild)
{ {
// Assumes UI is in Advanced-Mode and menus have been built. // Assumes UI is in Advanced-Mode and menus have been built.
auto pOldToolBar = m_pToolBar; auto pOldToolBar = m_pToolBar;
m_pToolBar = new QToolBar(); m_pToolBar = new QToolBar();
m_pMainLayout->insertWidget(0, m_pToolBar); m_pMainLayout->insertWidget(0, m_pToolBar);
@ -983,7 +986,7 @@ void CSandMan::CreateToolBar(bool rebuild)
but->setToolTip(tr("Cleanup")); but->setToolTip(tr("Cleanup"));
but->setText(tr("Cleanup")); but->setText(tr("Cleanup"));
but->setPopupMode(QToolButton::MenuButtonPopup); but->setPopupMode(QToolButton::MenuButtonPopup);
but->setMenu(m_pCleanUpMenu); but->setMenu(m_pCleanUpMenu);
QObject::connect(but, SIGNAL(clicked(bool)), this, SLOT(OnCleanUp())); QObject::connect(but, SIGNAL(clicked(bool)), this, SLOT(OnCleanUp()));
m_pCleanUpButton = but; m_pCleanUpButton = but;
m_pToolBar->addWidget(but); m_pToolBar->addWidget(but);
@ -1079,7 +1082,7 @@ void CSandMan::UpdateLabel()
//auto neon = new CNeonEffect(10, 4, 180); // 140 //auto neon = new CNeonEffect(10, 4, 180); // 140
//m_pLabel->setGraphicsEffect(NULL); //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>"); 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"); LabelTip = tr("Click to open web browser");
@ -1166,7 +1169,7 @@ void CSandMan::CreateView(int iViewMode)
else else
m_pRecoveryLogWnd = NULL; m_pRecoveryLogWnd = NULL;
if (iViewMode == 2) if (iViewMode == 2)
{ {
m_pViewStack = new QStackedLayout(); m_pViewStack = new QStackedLayout();
m_pViewStack->addWidget(m_pBoxView); m_pViewStack->addWidget(m_pBoxView);
@ -1203,7 +1206,7 @@ void CSandMan::CreateView(int iViewMode)
m_pViewStack = NULL; m_pViewStack = NULL;
m_pBoxCombo = NULL; m_pBoxCombo = NULL;
if (iViewMode == 1) if (iViewMode == 1)
{ {
m_pLogSplitter = new QSplitter(); m_pLogSplitter = new QSplitter();
m_pLogSplitter->setOrientation(Qt::Vertical); m_pLogSplitter->setOrientation(Qt::Vertical);
@ -1214,7 +1217,7 @@ void CSandMan::CreateView(int iViewMode)
m_pPanelSplitter->setOrientation(Qt::Horizontal); m_pPanelSplitter->setOrientation(Qt::Horizontal);
if (iViewMode == 1) if (iViewMode == 1)
m_pLogSplitter->addWidget(m_pPanelSplitter); m_pLogSplitter->addWidget(m_pPanelSplitter);
else else
m_pMainLayout->addWidget(m_pPanelSplitter); m_pMainLayout->addWidget(m_pPanelSplitter);
m_pPanelSplitter->addWidget(m_pBoxView); m_pPanelSplitter->addWidget(m_pBoxView);
@ -1233,7 +1236,7 @@ void CSandMan::CreateView(int iViewMode)
m_pMessageLog->GetTree()->setItemDelegate(new CTreeItemDelegate()); m_pMessageLog->GetTree()->setItemDelegate(new CTreeItemDelegate());
m_pMessageLog->GetTree()->setAlternatingRowColors(theConf->GetBool("Options/AltRowColors", false)); m_pMessageLog->GetTree()->setAlternatingRowColors(theConf->GetBool("Options/AltRowColors", false));
//m_pMessageLog->GetView()->setItemDelegate(theGUI->GetItemDelegate()); //m_pMessageLog->GetView()->setItemDelegate(theGUI->GetItemDelegate());
((QTreeWidgetEx*)m_pMessageLog->GetView())->setHeaderLabels(tr("Time|Message").split("|")); ((QTreeWidgetEx*)m_pMessageLog->GetView())->setHeaderLabels(tr("Time|Message").split("|"));
((QTreeWidgetEx*)m_pMessageLog->GetView())->setColumnFixed(1, true); ((QTreeWidgetEx*)m_pMessageLog->GetView())->setColumnFixed(1, true);
@ -1296,7 +1299,20 @@ void CSandMan::CheckForUpdates(bool bManual)
} }
#include "SandManTray.cpp" #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() void CSandMan::OnExit()
{ {
m_bExit = true; m_bExit = true;
@ -1364,9 +1380,9 @@ void CSandMan::closeEvent(QCloseEvent *e)
void CSandMan::changeEvent(QEvent* e) void CSandMan::changeEvent(QEvent* e)
{ {
if (e->type() == QEvent::WindowStateChange) if (e->type() == QEvent::WindowStateChange)
{ {
if (isMinimized()) if (isMinimized())
{ {
if (m_bOnTop) { if (m_bOnTop) {
m_bOnTop = false; m_bOnTop = false;
@ -1387,16 +1403,16 @@ void CSandMan::changeEvent(QEvent* e)
} }
} }
} }
QMainWindow::changeEvent(e); QMainWindow::changeEvent(e);
} }
void CSandMan::commitData(QSessionManager& manager) void CSandMan::commitData(QSessionManager& manager)
{ {
//if (manager.allowsInteraction()) //if (manager.allowsInteraction())
//{ //{
// manager.cancel(); // manager.cancel();
// return; // return;
//} //}
m_pBoxView->SaveState(); m_pBoxView->SaveState();
m_pFileView->SaveState(); m_pFileView->SaveState();
@ -1442,7 +1458,7 @@ QIcon CSandMan::GetColorIcon(QColor boxColor, bool inUse/*, bool bOut*/)
*c = rgb; *c = rgb;
} }
//} //}
QPixmap result(32, 32); QPixmap result(32, 32);
result.fill(Qt::transparent); // force alpha channel result.fill(Qt::transparent); // force alpha channel
QPainter painter(&result); QPainter painter(&result);
@ -1458,8 +1474,8 @@ QIcon CSandMan::GetColorIcon(QColor boxColor, bool inUse/*, bool bOut*/)
painter.drawPixmap(0, 0, FrameDM); painter.drawPixmap(0, 0, FrameDM);
else else
painter.drawPixmap(0, 0, Frame); painter.drawPixmap(0, 0, Frame);
if (inUse) if (inUse)
{ {
//rgb = change_hsv_c(rgb, -60, 2, 1); // yellow -> red //rgb = change_hsv_c(rgb, -60, 2, 1); // yellow -> red
my_rgb rgb1 = { (double)qRed(rgb), (double)qGreen(rgb), (double)qBlue(rgb) }; my_rgb rgb1 = { (double)qRed(rgb), (double)qGreen(rgb), (double)qBlue(rgb) };
@ -1535,7 +1551,7 @@ QString CSandMan::GetBoxDescription(int boxType)
break; break;
case CSandBoxPlus::eDefaultPlus: case CSandBoxPlus::eDefaultPlus:
case CSandBoxPlus::eDefault: 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; break;
case CSandBoxPlus::eAppBoxPlus: case CSandBoxPlus::eAppBoxPlus:
case CSandBoxPlus::eAppBox: 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>."); 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; break;
} }
if(boxType == CSandBoxPlus::eHardenedPlus || boxType == CSandBoxPlus::eDefaultPlus || boxType == CSandBoxPlus::eAppBoxPlus) 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.")); 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() bool CSandMan::KeepTerminated()
{ {
if (CWizardEngine::GetInstanceCount() > 0) if (CWizardEngine::GetInstanceCount() > 0)
return true; return true;
return m_pKeepTerminated && m_pKeepTerminated->isChecked(); 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>(); auto pBoxEx = theAPI->GetBoxByName(BoxName).objectCast<CSandBoxPlus>();
if (pBoxEx && pBoxEx->UseImageFile() && pBoxEx->GetMountRoot().isEmpty()){ if (pBoxEx && pBoxEx->UseImageFile() && pBoxEx->GetMountRoot().isEmpty()){
SB_STATUS Status = ImBoxMount(pBoxEx, true); SB_STATUS Status = ImBoxMount(pBoxEx, true);
if (Status.IsError()) if (Status.IsError())
return Status; return Status;
@ -1738,7 +1754,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
m_pDisableForce->setChecked(bForceProcessDisabled); m_pDisableForce->setChecked(bForceProcessDisabled);
m_pDisableForce2->setChecked(bForceProcessDisabled); m_pDisableForce2->setChecked(bForceProcessDisabled);
if (m_pTraceView) if (m_pTraceView)
{ {
bool bIsMonitoring = theAPI->IsMonitoring(); bool bIsMonitoring = theAPI->IsMonitoring();
m_pEnableMonitoring->setChecked(bIsMonitoring); m_pEnableMonitoring->setChecked(bIsMonitoring);
@ -1758,7 +1774,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
ActiveProcesses++; ActiveProcesses++;
} }
} }
else else
ActiveProcesses = Processes.count(); ActiveProcesses = Processes.count();
@ -1854,7 +1870,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
QSharedPointer<CSbieIni> Section; QSharedPointer<CSbieIni> Section;
if (I.key() == "GlobalSettings") if (I.key() == "GlobalSettings")
Section = theAPI->GetGlobalSettings(); Section = theAPI->GetGlobalSettings();
else else
Section = theAPI->GetBoxByName(I.key()); Section = theAPI->GetBoxByName(I.key());
if (!Section) continue; if (!Section) continue;
@ -1872,7 +1888,7 @@ void CSandMan::timerEvent(QTimerEvent* pEvent)
} }
} }
void CSandMan::UpdateDrives() void CSandMan::UpdateDrives()
{ {
static bool UpdatePending = false; static bool UpdatePending = false;
if (!UpdatePending) { if (!UpdatePending) {
@ -1891,7 +1907,7 @@ void CSandMan::UpdateDrives()
qDebug() << "=============="; qDebug() << "==============";
for (auto I = volumes.begin(); I != volumes.end(); ++I) { for (auto I = volumes.begin(); I != volumes.end(); ++I) {
for (auto J = I->mountPoints.begin(); J != I->mountPoints.end(); ++J) { for (auto J = I->mountPoints.begin(); J != I->mountPoints.end(); ++J) {
QString Device; QString Device;
bool bOnUSB = false; bool bOnUSB = false;
for (auto J = I->disks.begin(); J != I->disks.end(); ++J) { 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) { if (Mode != eForDelete) {
// //
// schedule async OnBoxDelete triggers and clean up // schedule async OnBoxDelete triggers and clean up
// //
@ -2033,7 +2049,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
m_iDeletingContent++; m_iDeletingContent++;
if (Mode != eForDelete) { if (Mode != eForDelete) {
// //
// execute OnBoxDelete triggers // execute OnBoxDelete triggers
// //
@ -2050,7 +2066,7 @@ SB_STATUS CSandMan::DeleteBoxContent(const CSandBoxPtr& pBox, EDelMode Mode, boo
} }
} }
} }
{ {
// //
// delete content synchronously // delete content synchronously
@ -2182,7 +2198,7 @@ void CSandMan::SyncStartMenu()
EnumBoxLinks(BoxLinks, "Desktop", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), false); EnumBoxLinks(BoxLinks, "Desktop", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), false);
QMap<QString, CSandBoxPtr> Boxes = theAPI->GetAllBoxes(); QMap<QString, CSandBoxPtr> Boxes = theAPI->GetAllBoxes();
foreach(const CSandBoxPtr & pBox, Boxes) foreach(const CSandBoxPtr & pBox, Boxes)
{ {
CSandBoxPlus* pBoxEx = (CSandBoxPlus*)pBox.data(); CSandBoxPlus* pBoxEx = (CSandBoxPlus*)pBox.data();
@ -2285,7 +2301,7 @@ void CSandMan::OnBoxClosed(const CSandBoxPtr& pBox)
void CSandMan::OnBoxCleaned(CSandBoxPlus* pBoxEx) void CSandMan::OnBoxCleaned(CSandBoxPlus* pBoxEx)
{ {
if (pBoxEx->GetBool("AutoRemove", false)) if (pBoxEx->GetBool("AutoRemove", false))
{ {
if (theConf->GetBool("Options/AutoBoxOpsNotify", false)) if (theConf->GetBool("Options/AutoBoxOpsNotify", false))
OnLogMessage(tr("Auto removing sandbox %1").arg(pBoxEx->GetName()), true); OnLogMessage(tr("Auto removing sandbox %1").arg(pBoxEx->GetName()), true);
@ -2302,7 +2318,7 @@ void CSandMan::OnStatusChanged()
#else #else
QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion()); QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion());
#endif #endif
bool bConnected = theAPI->IsConnected(); bool bConnected = theAPI->IsConnected();
m_pConnect->setEnabled(!bConnected); m_pConnect->setEnabled(!bConnected);
m_pDisconnect->setEnabled(bConnected); m_pDisconnect->setEnabled(bConnected);
@ -2318,7 +2334,7 @@ void CSandMan::OnStatusChanged()
OnLogMessage(tr("Data Directory: %1").arg(QString(theConf->GetConfigDir()).replace("/","\\"))); OnLogMessage(tr("Data Directory: %1").arg(QString(theConf->GetConfigDir()).replace("/","\\")));
//statusBar()->showMessage(tr("Driver version: %1").arg(theAPI->GetVersion())); //statusBar()->showMessage(tr("Driver version: %1").arg(theAPI->GetVersion()));
//appTitle.append(tr(" - Driver: v%1").arg(theAPI->GetVersion())); //appTitle.append(tr(" - Driver: v%1").arg(theAPI->GetVersion()));
if (bPortable) if (bPortable)
{ {
@ -2332,7 +2348,7 @@ void CSandMan::OnStatusChanged()
QString NtBoxRoot = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%", false, false).replace("GlobalSettings", "[BoxName]"); QString NtBoxRoot = theAPI->GetGlobalSettings()->GetText("FileRootPath", "\\??\\%SystemDrive%\\Sandbox\\%USER%\\%SANDBOX%", false, false).replace("GlobalSettings", "[BoxName]");
bool State = false; 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") 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(BoxPath + "\\[BoxName]")
.arg(theAPI->Nt2DosPath(NtBoxRoot)) .arg(theAPI->Nt2DosPath(NtBoxRoot))
@ -2392,7 +2408,7 @@ void CSandMan::OnStatusChanged()
theAPI->SetSecureParam("UsageFlags", &UsageFlags, sizeof(UsageFlags)); theAPI->SetSecureParam("UsageFlags", &UsageFlags, sizeof(UsageFlags));
} }
} }
g_FeatureFlags = theAPI->GetFeatureFlags(); g_FeatureFlags = theAPI->GetFeatureFlags();
SB_STATUS Status = theAPI->ReloadBoxes(true); SB_STATUS Status = theAPI->ReloadBoxes(true);
@ -2432,20 +2448,20 @@ void CSandMan::OnStatusChanged()
} }
int DynData = theAPI->IsDyndataActive(); int DynData = theAPI->IsDyndataActive();
if (DynData != 1) if (DynData != 1)
{ {
RTL_OSVERSIONINFOEXW versionInfo; RTL_OSVERSIONINFOEXW versionInfo;
memset(&versionInfo, 0, sizeof(RTL_OSVERSIONINFOEXW)); memset(&versionInfo, 0, sizeof(RTL_OSVERSIONINFOEXW));
versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
NTSTATUS(WINAPI *RtlGetVersion)(PRTL_OSVERSIONINFOEXW); NTSTATUS(WINAPI *RtlGetVersion)(PRTL_OSVERSIONINFOEXW);
*(void**)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlGetVersion"); *(void**)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll.dll"), "RtlGetVersion");
if (RtlGetVersion != NULL) if (RtlGetVersion != NULL)
RtlGetVersion(&versionInfo); RtlGetVersion(&versionInfo);
else else
GetVersionExW((LPOSVERSIONINFOW)&versionInfo); // since windows 10 this one is lying GetVersionExW((LPOSVERSIONINFOW)&versionInfo); // since windows 10 this one is lying
RtlGetVersion(&versionInfo); RtlGetVersion(&versionInfo);
if (DynData == 0) if (DynData == 0)
{ {
QString Message = tr("Your Windows build %1 exceeds the current support capabilities of your Sandboxie version, " 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" "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; return;
} }
} }
m_SbieTemplates->RunCheck(); m_SbieTemplates->RunCheck();
qDebug() << "Template Check took" << timer->elapsed() << "ms"; qDebug() << "Template Check took" << timer->elapsed() << "ms";
@ -2610,7 +2626,7 @@ void CSandMan::CheckSupport()
return; return;
static bool ReminderShown = false; 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; ReminderShown = true;
CSettingsWindow* pSettingsWindow = new CSettingsWindow(this); CSettingsWindow* pSettingsWindow = new CSettingsWindow(this);
@ -2661,8 +2677,11 @@ void CSandMan::OnHotKey(size_t id)
case HK_SUSPEND: case HK_SUSPEND:
{ {
for (auto each : theAPI->GetAllBoxes())
each->SetSuspendedAll(TRUE); for (auto each : theAPI->GetAllBoxes().toStdMap()) {
each.second->SetSuspendedAll(TRUE);
}
break; break;
} }
@ -2753,7 +2772,7 @@ void CSandMan::AddLogMessage(const QDateTime& TimeStamp, const QString& Message,
else else
pItem->setText(1, Message); pItem->setText(1, Message);
#endif #endif
m_pMessageLog->GetView()->verticalScrollBar()->setValue(m_pMessageLog->GetView()->verticalScrollBar()->maximum()); m_pMessageLog->GetView()->verticalScrollBar()->setValue(m_pMessageLog->GetView()->verticalScrollBar()->maximum());
} }
@ -2825,7 +2844,7 @@ void CSandMan::OnLogSbieMessage(quint32 MsgCode, const QStringList& MsgData, qui
else 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>")); 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; static quint64 iLastCertWarning = 0;
if (iLastCertWarning + 60 < QDateTime::currentDateTime().toSecsSinceEpoch()) { // reset after 60 seconds 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"); 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; QString Message;
if (iType == 1) if (iType == 1)
@ -2949,13 +2968,13 @@ SB_STATUS CSandMan::ReloadCert(QWidget* pWidget)
} }
else if (Status.GetStatus() == 0xC0000804L /*STATUS_CONTENT_BLOCKED*/) 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!")); 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; BYTE CertBlocked = 1;
theAPI->SetSecureParam("CertBlocked", &CertBlocked, sizeof(CertBlocked)); theAPI->SetSecureParam("CertBlocked", &CertBlocked, sizeof(CertBlocked));
} }
else if (Status.GetStatus() != 0xC0000225L /*STATUS_NOT_FOUND*/) else if (Status.GetStatus() != 0xC0000225L /*STATUS_NOT_FOUND*/)
{ {
QString Info; QString Info;
switch (Status.GetStatus()) switch (Status.GetStatus())
@ -3005,7 +3024,7 @@ void CSandMan::UpdateCertState()
if (theConf->GetBool("Debug/CertFakeGracePeriode", false)) if (theConf->GetBool("Debug/CertFakeGracePeriode", false))
g_CertInfo.grace_period = 1; 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)) { if (theConf->GetBool("Debug/CertFakeOld", false)) {
g_CertInfo.active = 0; g_CertInfo.active = 0;
g_CertInfo.expired = 1; g_CertInfo.expired = 1;
@ -3060,7 +3079,7 @@ void CSandMan::UpdateCertState()
void CSandMan::OnQueuedRequest(quint32 ClientPid, quint32 ClientTid, quint32 RequestId, const QVariantMap& Data) void CSandMan::OnQueuedRequest(quint32 ClientPid, quint32 ClientTid, quint32 RequestId, const QVariantMap& Data)
{ {
if (Data["id"].toInt() == 0) if (Data["id"].toInt() == 0)
{ {
QVariantMap Ret; QVariantMap Ret;
Ret["retval"] = (theAPI->IsStarting(ClientPid) || CSupportDialog::ShowDialog()) ? 1 : 0; Ret["retval"] = (theAPI->IsStarting(ClientPid) || CSupportDialog::ShowDialog()) ? 1 : 0;
@ -3213,7 +3232,7 @@ void CSandMan::OnDisablePopUp()
SB_RESULT(void*) CSandMan::ConnectSbie() SB_RESULT(void*) CSandMan::ConnectSbie()
{ {
SB_RESULT(void*) Status; SB_RESULT(void*) Status;
if (!CSbieUtils::IsRunning(CSbieUtils::eAll)) if (!CSbieUtils::IsRunning(CSbieUtils::eAll))
{ {
if (!CSbieUtils::IsInstalled(CSbieUtils::eAll)) if (!CSbieUtils::IsInstalled(CSbieUtils::eAll))
{ {
@ -3248,7 +3267,7 @@ SB_RESULT(void*) CSandMan::ConnectSbie()
SB_STATUS CSandMan::ConnectSbieImpl() SB_STATUS CSandMan::ConnectSbieImpl()
{ {
SB_STATUS Status = theAPI->Connect(g_PendingMessage.isEmpty(), theConf->GetBool("Options/UseInteractiveQueue", true)); SB_STATUS Status = theAPI->Connect(g_PendingMessage.isEmpty(), theConf->GetBool("Options/UseInteractiveQueue", true));
if (!g_PendingMessage.isEmpty()) { if (!g_PendingMessage.isEmpty()) {
OnMessage(g_PendingMessage); OnMessage(g_PendingMessage);
PostQuitMessage(0); PostQuitMessage(0);
@ -3326,11 +3345,11 @@ void CSandMan::OnMaintenance()
} }
//else if (sender() == m_pUpdateCore) { //else if (sender() == m_pUpdateCore) {
// // todo // // todo
// return; // return;
//} //}
// uninstall // uninstall
else if (sender() == m_pUninstallAll) { else if (sender() == m_pUninstallAll) {
Status = StopSbie(true); Status = StopSbie(true);
@ -3351,7 +3370,7 @@ void CSandMan::HandleMaintenance(SB_RESULT(void*) Status)
connect(processFinishedNotifier, &QWinEventNotifier::activated, this, [processFinishedNotifier, this, hProcess]() { connect(processFinishedNotifier, &QWinEventNotifier::activated, this, [processFinishedNotifier, this, hProcess]() {
processFinishedNotifier->setEnabled(false); processFinishedNotifier->setEnabled(false);
processFinishedNotifier->deleteLater(); processFinishedNotifier->deleteLater();
DWORD dwStatus = 0; DWORD dwStatus = 0;
GetExitCodeProcess(hProcess, & dwStatus); GetExitCodeProcess(hProcess, & dwStatus);
@ -3444,16 +3463,16 @@ void CSandMan::OnCleanUp()
m_MessageLog.clear(); m_MessageLog.clear();
if (m_pMessageLog) m_pMessageLog->GetTree()->clear(); if (m_pMessageLog) m_pMessageLog->GetTree()->clear();
} }
if (sender() == m_pCleanUpTrace || sender() == m_pCleanUpButton) if (sender() == m_pCleanUpTrace || sender() == m_pCleanUpButton)
if (m_pTraceView) { if (m_pTraceView) {
m_pTraceView->Clear(); m_pTraceView->Clear();
m_pTraceInfo->clear(); m_pTraceInfo->clear();
} }
if (sender() == m_pCleanUpRecovery || sender() == m_pCleanUpButton) if (sender() == m_pCleanUpRecovery || sender() == m_pCleanUpButton)
if(m_pRecoveryLog) m_pRecoveryLog->GetTree()->clear(); if(m_pRecoveryLog) m_pRecoveryLog->GetTree()->clear();
if (sender() == m_pCleanUpProcesses || sender() == m_pCleanUpButton) if (sender() == m_pCleanUpProcesses || sender() == m_pCleanUpButton)
theAPI->UpdateProcesses(0, ShowAllSessions()); theAPI->UpdateProcesses(0, ShowAllSessions());
} }
@ -3539,7 +3558,7 @@ void CSandMan::UpdateSettings(bool bRebuildUI)
m_pTrayIcon->hide(); m_pTrayIcon->hide();
if (bRebuildUI) if (bRebuildUI)
{ {
StoreState(); StoreState();
@ -3721,7 +3740,7 @@ void CSandMan::EditIni(const QString& IniPath, bool bPlus)
if (!bPlus && theConf->GetBool("Options/WatchIni", true)) if (!bPlus && theConf->GetBool("Options/WatchIni", true))
return; // if the ini is watched don't double reload return; // if the ini is watched don't double reload
QWinEventNotifier* processFinishedNotifier = new QWinEventNotifier(si.hProcess); QWinEventNotifier* processFinishedNotifier = new QWinEventNotifier(si.hProcess);
processFinishedNotifier->setEnabled(true); processFinishedNotifier->setEnabled(true);
connect(processFinishedNotifier, &QWinEventNotifier::activated, this, [processFinishedNotifier, this, si, bPlus]() { 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_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_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_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_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_SnapMkDirFail: Message = tr("Failed to create directory for new snapshot"); break;
case SB_SnapCopyDatFail:Message = tr("Failed to copy box data files"); 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) 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); SetWindowPos((HWND)m_pPopUpWindow->winId(), HWND_NOTOPMOST , 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
QPointer<CBoxAssistant> pWizard = new CBoxAssistant(this); QPointer<CBoxAssistant> pWizard = new CBoxAssistant(this);
pWizard->TryFix(MsgCode, MsgData, ProcessName, BoxName); pWizard->TryFix(MsgCode, MsgData, ProcessName, BoxName);
pWizard->setAttribute(Qt::WA_DeleteOnClose); pWizard->setAttribute(Qt::WA_DeleteOnClose);
@ -3976,7 +3995,7 @@ void CSandMan::OpenUrl(const QUrl& url)
{ {
QString scheme = url.scheme(); QString scheme = url.scheme();
QString host = url.host(); QString host = url.host();
QString path = url.path(); QString path = url.path();
QString query = url.query(); QString query = url.query();
if (scheme == "addon") { if (scheme == "addon") {
@ -4002,7 +4021,7 @@ void CSandMan::OpenUrl(const QUrl& url)
{ {
bool bCheck = false; bool bCheck = false;
//QString Message = tr("Do you want to open %1 in a sandboxed (yes) or unsandboxed (no) Web browser?").arg(url.toString()); //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); // &bCheck, QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel, QDialogButtonBox::Yes, QMessageBox::Question);
CCheckableMessageBox mb(this); 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); else ShellExecute(MainWndHandle, NULL, url.toString().toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL);
} }
bool CSandMan::IsWFPEnabled() const bool CSandMan::IsWFPEnabled() const
{ {
return (g_FeatureFlags & CSbieAPI::eSbieFeatureWFP) != 0; return (g_FeatureFlags & CSbieAPI::eSbieFeatureWFP) != 0;
} }
QString CSandMan::GetVersion() QString CSandMan::GetVersion()
@ -4058,7 +4077,7 @@ void CSandMan::SetUITheme()
bDark = (settings.value("AppsUseLightTheme") == 0); bDark = (settings.value("AppsUseLightTheme") == 0);
} else } else
bDark = (iDark == 1); bDark = (iDark == 1);
if (bDark) if (bDark)
QApplication::setPalette(m_DarkPalett); QApplication::setPalette(m_DarkPalett);
else else
@ -4070,7 +4089,7 @@ void CSandMan::SetUITheme()
int iFusion = theConf->GetInt("Options/UseFusionTheme", 2); int iFusion = theConf->GetInt("Options/UseFusionTheme", 2);
if (iFusion == 2) if (iFusion == 2)
bFusion = bDark; bFusion = bDark;
else else
bFusion = (iFusion == 1); bFusion = (iFusion == 1);
if (bFusion) if (bFusion)
@ -4111,7 +4130,7 @@ void CSandMan::SetTitleTheme(const HWND& hwnd)
QSettings::NativeFormat).value("CurrentBuild").toInt(); QSettings::NativeFormat).value("CurrentBuild").toInt();
if (CurrentVersion < 17763) // Windows 10 1809 - if (CurrentVersion < 17763) // Windows 10 1809 -
return; return;
HMODULE dwmapi = GetModuleHandle(L"dwmapi.dll"); HMODULE dwmapi = GetModuleHandle(L"dwmapi.dll");
if (dwmapi) if (dwmapi)
{ {
@ -4162,7 +4181,7 @@ void CSandMan::LoadLanguage()
#endif #endif
m_LanguageId = LocaleNameToLCID(m_Language.toStdWString().c_str(), 0); m_LanguageId = LocaleNameToLCID(m_Language.toStdWString().c_str(), 0);
if (!m_LanguageId) if (!m_LanguageId)
m_LanguageId = 1033; // default to English m_LanguageId = 1033; // default to English
LoadLanguage(m_Language, "sandman", 0); LoadLanguage(m_Language, "sandman", 0);
@ -4186,7 +4205,7 @@ void CSandMan::LoadLanguage(const QString& Lang, const QString& Module, int Inde
if (Lang.isEmpty()) if (Lang.isEmpty())
return; return;
QString LangAux = Lang; // Short version as fallback QString LangAux = Lang; // Short version as fallback
LangAux.truncate(LangAux.lastIndexOf('_')); LangAux.truncate(LangAux.lastIndexOf('_'));
@ -4210,7 +4229,7 @@ void CSandMan::OnHelp()
{ {
//if (sender() == m_pSupport) //if (sender() == m_pSupport)
// QDesktopServices::openUrl(QUrl("https://sandboxie-plus.com/go.php?to=donate")); // QDesktopServices::openUrl(QUrl("https://sandboxie-plus.com/go.php?to=donate"));
//else //else
if (sender() == m_pContribution) if (sender() == m_pContribution)
QDesktopServices::openUrl(QUrl("https://sandboxie-plus.com/go.php?to=sbie-contribute")); QDesktopServices::openUrl(QUrl("https://sandboxie-plus.com/go.php?to=sbie-contribute"));
else if (sender() == m_pManual) else if (sender() == m_pManual)
@ -4257,14 +4276,14 @@ void CSandMan::OnAbout()
msgBox->setInformativeText(AboutText); msgBox->setInformativeText(AboutText);
QIcon ico(QLatin1String(":/SandMan.png")); QIcon ico(QLatin1String(":/SandMan.png"));
QPixmap pix(128, 160); QPixmap pix(128, 160);
pix.fill(Qt::transparent); pix.fill(Qt::transparent);
QPainter painter(&pix); QPainter painter(&pix);
painter.drawPixmap(0, 0, ico.pixmap(128, 128)); painter.drawPixmap(0, 0, ico.pixmap(128, 128));
if (g_CertInfo.active) if (g_CertInfo.active)
{ {
//painter.setPen(Qt::blue); //painter.setPen(Qt::blue);
//painter.drawRect(0, 0, 127, 159); //painter.drawRect(0, 0, 127, 159);
@ -4335,20 +4354,20 @@ int g_CertAmount = 0;
void SlotSend(const std::wstring& message) void SlotSend(const std::wstring& message)
{ {
std::wstring strSlotName = L"\\\\*\\mailslot\\" + g_SlotName; std::wstring strSlotName = L"\\\\*\\mailslot\\" + g_SlotName;
HANDLE hSlot = CreateFile(strSlotName.c_str(), HANDLE hSlot = CreateFile(strSlotName.c_str(),
GENERIC_WRITE, GENERIC_WRITE,
FILE_SHARE_READ, FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES) NULL, (LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL); (HANDLE) NULL);
if (hSlot == INVALID_HANDLE_VALUE) if (hSlot == INVALID_HANDLE_VALUE)
{ {
//GetLastError(); //GetLastError();
return; return;
} }
DWORD cbWritten; DWORD cbWritten;
WriteFile(hSlot, message.c_str(), (DWORD)(message.size() + 1) * sizeof(wchar_t), &cbWritten, NULL); WriteFile(hSlot, message.c_str(), (DWORD)(message.size() + 1) * sizeof(wchar_t), &cbWritten, NULL);
CloseHandle(hSlot); CloseHandle(hSlot);
@ -4381,14 +4400,14 @@ int CountSeats()
DWORD WINAPI MailThreadFunc(LPVOID lpParam) DWORD WINAPI MailThreadFunc(LPVOID lpParam)
{ {
std::wstring strSlotName = L"\\\\.\\mailslot\\" + g_SlotName; std::wstring strSlotName = L"\\\\.\\mailslot\\" + g_SlotName;
HANDLE hSlot = CreateMailslot(strSlotName.c_str(), HANDLE hSlot = CreateMailslot(strSlotName.c_str(),
0, // no maximum message size 0, // no maximum message size
MAILSLOT_WAIT_FOREVER, // no time-out for operations MAILSLOT_WAIT_FOREVER, // no time-out for operations
(LPSECURITY_ATTRIBUTES) NULL); // default security (LPSECURITY_ATTRIBUTES) NULL); // default security
if (hSlot == INVALID_HANDLE_VALUE) { if (hSlot == INVALID_HANDLE_VALUE) {
//GetLastError() //GetLastError()
return FALSE; return FALSE;
} }
ScanForSeats(); ScanForSeats();
@ -4398,11 +4417,11 @@ DWORD WINAPI MailThreadFunc(LPVOID lpParam)
{ {
DWORD cbMessage; DWORD cbMessage;
DWORD dwMessageCount; DWORD dwMessageCount;
if(!GetMailslotInfo(hSlot, // mailslot handle if(!GetMailslotInfo(hSlot, // mailslot handle
(LPDWORD)NULL, // no maximum message size (LPDWORD)NULL, // no maximum message size
&cbMessage, // size of next message &cbMessage, // size of next message
&dwMessageCount, // number of messages &dwMessageCount, // number of messages
(LPDWORD)NULL)) // no read time-out (LPDWORD)NULL)) // no read time-out
{ {
//GetLastError(); //GetLastError();
continue; continue;

View File

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

View File

@ -104,6 +104,7 @@ void COptionsWindow::CreateAdvanced()
connect(ui.chkShowHostProcTmpl, SIGNAL(clicked(bool)), this, SLOT(OnShowHostProcTmpl())); connect(ui.chkShowHostProcTmpl, SIGNAL(clicked(bool)), this, SLOT(OnShowHostProcTmpl()));
connect(ui.chkConfidential, SIGNAL(clicked(bool)), this, SLOT(OnConfidentialChanged())); connect(ui.chkConfidential, SIGNAL(clicked(bool)), this, SLOT(OnConfidentialChanged()));
connect(ui.chkLessConfidential, SIGNAL(clicked(bool)), this, SLOT(OnLessConfidentialChanged())); 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.chkNotifyProtect, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged()));
connect(ui.treeInjectDll, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(OnToggleInjectDll(QTreeWidgetItem *, int))); 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.chkLessConfidential->setChecked(m_BoxTemplates.contains("LessConfidentialBox"));
ui.chkNotifyProtect->setChecked(m_pBox->GetBool("NotifyBoxProtected", false)); ui.chkNotifyProtect->setChecked(m_pBox->GetBool("NotifyBoxProtected", false));
ui.chkProtectWindow->setChecked(m_pBox->GetBool("IsProtectScreen"));
QStringList Users = m_pBox->GetText("Enabled").split(","); QStringList Users = m_pBox->GetText("Enabled").split(",");
ui.lstUsers->clear(); ui.lstUsers->clear();
@ -465,6 +467,8 @@ void COptionsWindow::SaveAdvanced()
WriteAdvancedCheck(ui.chkConfidential, "ConfidentialBox", "y", ""); WriteAdvancedCheck(ui.chkConfidential, "ConfidentialBox", "y", "");
WriteAdvancedCheck(ui.chkNotifyProtect, "NotifyBoxProtected", "y", ""); WriteAdvancedCheck(ui.chkNotifyProtect, "NotifyBoxProtected", "y", "");
WriteAdvancedCheck(ui.chkProtectWindow, "IsProtectScreen", "y", "n");
QStringList Users; QStringList Users;
for (int i = 0; i < ui.lstUsers->count(); i++) for (int i = 0; i < ui.lstUsers->count(); i++)
Users.append(ui.lstUsers->item(i)->text()); 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.chkNotifyRecovery, SIGNAL(stateChanged(int)), this, SLOT(OnOptChanged()));
connect(ui.chkShowRecovery, 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())); 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.chkSandboxUrls->setCheckState(CSettingsWindow__Int2Chk(theConf->GetInt("Options/OpenUrlsSandboxed", 2)));
ui.chkShowRecovery->setChecked(theConf->GetBool("Options/ShowRecovery", false)); 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.chkNotifyRecovery->setChecked(!theConf->GetBool("Options/InstantRecovery", true));
ui.chkRecoveryTop->setChecked(theConf->GetBool("Options/RecoveryOnTop", true)); ui.chkRecoveryTop->setChecked(theConf->GetBool("Options/RecoveryOnTop", true));
ui.chkAsyncBoxOps->setChecked(theConf->GetBool("Options/UseAsyncBoxOps", false)); 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/EnableSuspendKey", ui.chkSuspend->isChecked());
theConf->SetValue("Options/SuspendKeySequence", ui.keySuspend->keySequence().toString()); 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/WatchBoxSize", ui.chkMonitorSize->isChecked());
theConf->SetValue("Options/WatchIni", ui.chkWatchConfig->isChecked()); theConf->SetValue("Options/WatchIni", ui.chkWatchConfig->isChecked());