From a202d3d990276f746cfdb36c1bdf43a6dd54660b Mon Sep 17 00:00:00 2001 From: DavidXanatos Date: Mon, 8 Jun 2020 17:17:37 +0200 Subject: [PATCH] SbiePlus 0.2 --- CHANGELOG.md | 18 + Sandboxie/SboxHostDll/SboxHostDll.rc | Bin 6172 -> 2614 bytes Sandboxie/apps/com/BITS/resource.rc | 16 - Sandboxie/apps/com/Crypto/resource.rc | 16 - Sandboxie/apps/com/DcomLaunch/resource.rc | 16 - Sandboxie/apps/com/RpcSs/resource.rc | 16 - Sandboxie/apps/com/WUAU/resource.rc | 16 - Sandboxie/apps/common/Common.vcxproj | 1 + Sandboxie/apps/ini/resource1.rc | 16 - Sandboxie/apps/start/resource.rc | 16 - Sandboxie/apps/start/start.cpp | 7 + Sandboxie/common/my_version.h | 6 +- Sandboxie/common/win32_ntddk.h | 168 +++--- Sandboxie/core/dll/obj.c | 48 ++ Sandboxie/core/dll/resource.rc | 16 - Sandboxie/core/drv/conf.c | 14 +- Sandboxie/core/drv/syscall_open.c | 4 + Sandboxie/core/svc/resource.rc | 16 - Sandboxie/install/release/resource.rc | 16 - SandboxiePlus/MiscHelpers/MiscHelpers.vcxproj | 80 +++ SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj | 13 +- .../QSbieAPI/QSbieAPI.vcxproj.filters | 12 + SandboxiePlus/QSbieAPI/SbieAPI.cpp | 537 +++++++++++------- SandboxiePlus/QSbieAPI/SbieAPI.h | 19 +- SandboxiePlus/QSbieAPI/SbieDefs.h | 20 + SandboxiePlus/QSbieAPI/SbieError.h | 3 + SandboxiePlus/QSbieAPI/SbieUtils.cpp | 182 ++++++ SandboxiePlus/QSbieAPI/SbieUtils.h | 39 ++ SandboxiePlus/QtSingleApp/INSTALL.TXT | 254 +++++++++ SandboxiePlus/QtSingleApp/README.TXT | 33 ++ .../QtSingleApp/buildlib/buildlib.pro | 13 + SandboxiePlus/QtSingleApp/common.pri | 6 + SandboxiePlus/QtSingleApp/configure | 25 + SandboxiePlus/QtSingleApp/configure.bat | 80 +++ .../QtSingleApp/doc/html/classic.css | 284 +++++++++ .../QtSingleApp/doc/html/images/qt-logo.png | Bin 0 -> 4075 bytes SandboxiePlus/QtSingleApp/doc/html/index.html | 48 ++ .../qtsingleapplication-example-loader.html | 175 ++++++ .../qtsingleapplication-example-trivial.html | 101 ++++ .../doc/html/qtsingleapplication-members.html | 235 ++++++++ .../html/qtsingleapplication-obsolete.html | 31 + .../doc/html/qtsingleapplication.dcf | 40 ++ .../doc/html/qtsingleapplication.html | 162 ++++++ .../doc/html/qtsingleapplication.index | 90 +++ .../doc/html/qtsingleapplication.qhp | 53 ++ ...singlecoreapplication-example-console.html | 118 ++++ .../html/qtsinglecoreapplication-members.html | 126 ++++ .../doc/html/qtsinglecoreapplication.html | 98 ++++ .../QtSingleApp/doc/images/qt-logo.png | Bin 0 -> 4075 bytes SandboxiePlus/QtSingleApp/doc/index.qdoc | 87 +++ .../QtSingleApp/examples/console/console.pro | 5 + .../QtSingleApp/examples/console/console.qdoc | 65 +++ .../QtSingleApp/examples/console/main.cpp | 89 +++ .../QtSingleApp/examples/examples.pro | 4 + .../QtSingleApp/examples/loader/file1.qsl | 1 + .../QtSingleApp/examples/loader/file2.qsl | 1 + .../QtSingleApp/examples/loader/loader.pro | 6 + .../QtSingleApp/examples/loader/loader.qdoc | 81 +++ .../QtSingleApp/examples/loader/main.cpp | 152 +++++ .../QtSingleApp/examples/trivial/main.cpp | 78 +++ .../QtSingleApp/examples/trivial/trivial.pro | 5 + .../QtSingleApp/examples/trivial/trivial.qdoc | 76 +++ .../QtSingleApp/qtsingleapp/qtsingleapp.sln | 26 + .../qtsingleapp/qtsingleapp/qtsingleapp.pri | 11 + .../qtsingleapp/qtsingleapp.qc.pro | 30 + .../qtsingleapp/qtsingleapp.vcxproj | 225 ++++++++ .../qtsingleapp/qtsingleapp.vcxproj.filters | 70 +++ .../QtSingleApp/qtsingleapplication.pro | 5 + SandboxiePlus/QtSingleApp/src/QtLockedFile | 1 + .../QtSingleApp/src/QtSingleApplication | 1 + SandboxiePlus/QtSingleApp/src/qtlocalpeer.cpp | 209 +++++++ SandboxiePlus/QtSingleApp/src/qtlocalpeer.h | 93 +++ .../QtSingleApp/src/qtlockedfile.cpp | 193 +++++++ SandboxiePlus/QtSingleApp/src/qtlockedfile.h | 97 ++++ .../QtSingleApp/src/qtlockedfile_unix.cpp | 115 ++++ .../QtSingleApp/src/qtlockedfile_win.cpp | 211 +++++++ .../QtSingleApp/src/qtsingleapplication.cpp | 347 +++++++++++ .../QtSingleApp/src/qtsingleapplication.h | 105 ++++ .../QtSingleApp/src/qtsingleapplication.pri | 17 + .../src/qtsinglecoreapplication.cpp | 149 +++++ .../QtSingleApp/src/qtsinglecoreapplication.h | 71 +++ .../src/qtsinglecoreapplication.pri | 10 + .../SandMan/Resources/Actions/Advanced.png | Bin 0 -> 2967 bytes .../SandMan/Resources/Actions/Connect.png | Bin 0 -> 3567 bytes .../SandMan/Resources/Actions/Disconnect.png | Bin 0 -> 3565 bytes .../SandMan/Resources/Actions/Maintenance.png | Bin 0 -> 2268 bytes .../SandMan/Resources/Actions/Service.png | Bin 0 -> 3408 bytes .../SandMan/Resources/Actions/Start.png | Bin 0 -> 1292 bytes .../SandMan/Resources/Actions/Stop.png | Bin 0 -> 678 bytes SandboxiePlus/SandMan/Resources/SandMan.qrc | 10 +- SandboxiePlus/SandMan/Resources/SandMan2.png | Bin 0 -> 8164 bytes SandboxiePlus/SandMan/SandMan.cpp | 359 ++++++++++-- SandboxiePlus/SandMan/SandMan.h | 49 +- SandboxiePlus/SandMan/SandMan.vcxproj | 13 +- SandboxiePlus/SandMan/Views/SbieView.cpp | 12 +- SandboxiePlus/SandMan/main.cpp | 15 +- SandboxiePlus/SandboxiePlus.sln | 23 +- 97 files changed, 5911 insertions(+), 509 deletions(-) create mode 100644 SandboxiePlus/QSbieAPI/SbieDefs.h create mode 100644 SandboxiePlus/QSbieAPI/SbieUtils.cpp create mode 100644 SandboxiePlus/QSbieAPI/SbieUtils.h create mode 100644 SandboxiePlus/QtSingleApp/INSTALL.TXT create mode 100644 SandboxiePlus/QtSingleApp/README.TXT create mode 100644 SandboxiePlus/QtSingleApp/buildlib/buildlib.pro create mode 100644 SandboxiePlus/QtSingleApp/common.pri create mode 100644 SandboxiePlus/QtSingleApp/configure create mode 100644 SandboxiePlus/QtSingleApp/configure.bat create mode 100644 SandboxiePlus/QtSingleApp/doc/html/classic.css create mode 100644 SandboxiePlus/QtSingleApp/doc/html/images/qt-logo.png create mode 100644 SandboxiePlus/QtSingleApp/doc/html/index.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-loader.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-trivial.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-members.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-obsolete.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.dcf create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.index create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.qhp create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-example-console.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-members.html create mode 100644 SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication.html create mode 100644 SandboxiePlus/QtSingleApp/doc/images/qt-logo.png create mode 100644 SandboxiePlus/QtSingleApp/doc/index.qdoc create mode 100644 SandboxiePlus/QtSingleApp/examples/console/console.pro create mode 100644 SandboxiePlus/QtSingleApp/examples/console/console.qdoc create mode 100644 SandboxiePlus/QtSingleApp/examples/console/main.cpp create mode 100644 SandboxiePlus/QtSingleApp/examples/examples.pro create mode 100644 SandboxiePlus/QtSingleApp/examples/loader/file1.qsl create mode 100644 SandboxiePlus/QtSingleApp/examples/loader/file2.qsl create mode 100644 SandboxiePlus/QtSingleApp/examples/loader/loader.pro create mode 100644 SandboxiePlus/QtSingleApp/examples/loader/loader.qdoc create mode 100644 SandboxiePlus/QtSingleApp/examples/loader/main.cpp create mode 100644 SandboxiePlus/QtSingleApp/examples/trivial/main.cpp create mode 100644 SandboxiePlus/QtSingleApp/examples/trivial/trivial.pro create mode 100644 SandboxiePlus/QtSingleApp/examples/trivial/trivial.qdoc create mode 100644 SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp.sln create mode 100644 SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.pri create mode 100644 SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.qc.pro create mode 100644 SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj create mode 100644 SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj.filters create mode 100644 SandboxiePlus/QtSingleApp/qtsingleapplication.pro create mode 100644 SandboxiePlus/QtSingleApp/src/QtLockedFile create mode 100644 SandboxiePlus/QtSingleApp/src/QtSingleApplication create mode 100644 SandboxiePlus/QtSingleApp/src/qtlocalpeer.cpp create mode 100644 SandboxiePlus/QtSingleApp/src/qtlocalpeer.h create mode 100644 SandboxiePlus/QtSingleApp/src/qtlockedfile.cpp create mode 100644 SandboxiePlus/QtSingleApp/src/qtlockedfile.h create mode 100644 SandboxiePlus/QtSingleApp/src/qtlockedfile_unix.cpp create mode 100644 SandboxiePlus/QtSingleApp/src/qtlockedfile_win.cpp create mode 100644 SandboxiePlus/QtSingleApp/src/qtsingleapplication.cpp create mode 100644 SandboxiePlus/QtSingleApp/src/qtsingleapplication.h create mode 100644 SandboxiePlus/QtSingleApp/src/qtsingleapplication.pri create mode 100644 SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.cpp create mode 100644 SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.h create mode 100644 SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.pri create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Advanced.png create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Connect.png create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Disconnect.png create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Maintenance.png create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Service.png create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Start.png create mode 100644 SandboxiePlus/SandMan/Resources/Actions/Stop.png create mode 100644 SandboxiePlus/SandMan/Resources/SandMan2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index de1def8a15..7c2c97aaec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.2 / 5.41.0] - 2020-06-08 + +### Added +- IniWatcher, no more clicking reload, the ini is now reloaded automatically every time it changes +- Added Mainanance menu to the Sandbox menu, allowing to install/uninstall and start/stop sandboxie driver, service +- SandMan.exe now is packed with Sbie files and when no sbie is installed acts as a portable instalation +- Added option to clean up logs + +### Changed +- sbie driver now first checks the home path for the sbie ini before checking SystemRoot + +### Fixed +- Fixed a resource leak when running sandboxed +- Fixed issue boxed services not starting when the path contained a space +- NtQueryInformationProcess now returns the proper sandboxed path for sandboxed processes + + + ## [0.1 / 5.40.2] - 2020-06-01 ### Added diff --git a/Sandboxie/SboxHostDll/SboxHostDll.rc b/Sandboxie/SboxHostDll/SboxHostDll.rc index 36760e0f3743675f598f62c185aca1f20bc376f8..6d0b64713c089cb66904b19e415f447e83fbc034 100644 GIT binary patch literal 2614 zcmcImO>e3|6y1~XALh|bn>LkNH(eqiB}Fg}n3^;pR7RaV9L#`CoAk%OJ1`>ptnI?i zM!etm+`}C@9W7=p#_77eRh3RhRW2x- zWt)^BZL7asYN`T?l*}n3$Qa=;vfLmZ+lCeR-ZaM3VL$M&@IT|J%jtBG(^Nd?`3jXw zf4h9c*9~^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oSSWxh-H6c-uJd8#k2PF2;e z3fp-sysfI1*G6l}Guepyn*6?$eaYK&f&9P5$_{Fcm2?*)yt5~|$a3b9|6=Af2f~^@ zYD=fIin}cCNs6@Bs6$N8RqZm>lhD~rA?FNrs14*7DZYh|(WINyx*lv9LXw3#MZn}& z@e%PKq*58>S&ie0+<|U0WO3Q9jGN~2A;&{v7m48Er)Zi58s2SLdYNhrUA2r)(3h`I z_jH+`ZFp`1ZS~5NiWR!v7uRJP?5kD0LyQpt_Ers=#HbLwm#q+C4|YmKE`ZkIgPO6A zqsg@*XSS*-eod^K<6f>n8C7*nHQ&wi0x{+ekUdg^{@f{Ul8lcLn_9917ORq>EI+F_ zZBab~ba*2?nXBffvE7EhhKL34tBiHV^$>b+CvF4NjPzcjRlYuzrJDDmbmQ|g$jqNF zbbp!GqL@98X+h`*_{_uSomqlgh0zdmyw?+QfV+~H>sqWec^!*6{T%;{;aBeO`Ed5CH{UC)ld0toLa$|&3-dDY%zS=Md^_5U(q9wvWjylEYcQ{C@)jOk zz<(UMZ}Vin&opwX=8CoY0+Q4{MqXO~i&khn2SBl(U?N}9c$e0@1D{(y;5^T}pxGz2 z-g&L_W4&sBulHJ~zI@O1w#M265AV9ydF+hOJJpYVqWix89Pzp2>Hi$%efzdzpV#K8 TObAdtxd(XoKgB8>Xm0-lr%P~j diff --git a/Sandboxie/apps/com/BITS/resource.rc b/Sandboxie/apps/com/BITS/resource.rc index b39ce15cf9..6a80dc1358 100644 --- a/Sandboxie/apps/com/BITS/resource.rc +++ b/Sandboxie/apps/com/BITS/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/apps/com/Crypto/resource.rc b/Sandboxie/apps/com/Crypto/resource.rc index c8847713a6..251a967c64 100644 --- a/Sandboxie/apps/com/Crypto/resource.rc +++ b/Sandboxie/apps/com/Crypto/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/apps/com/DcomLaunch/resource.rc b/Sandboxie/apps/com/DcomLaunch/resource.rc index 24f72c2bf1..6f39018a41 100644 --- a/Sandboxie/apps/com/DcomLaunch/resource.rc +++ b/Sandboxie/apps/com/DcomLaunch/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/apps/com/RpcSs/resource.rc b/Sandboxie/apps/com/RpcSs/resource.rc index 39fd206e6b..48207125bc 100644 --- a/Sandboxie/apps/com/RpcSs/resource.rc +++ b/Sandboxie/apps/com/RpcSs/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/apps/com/WUAU/resource.rc b/Sandboxie/apps/com/WUAU/resource.rc index abaa2fee16..be61b1f9c3 100644 --- a/Sandboxie/apps/com/WUAU/resource.rc +++ b/Sandboxie/apps/com/WUAU/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/apps/common/Common.vcxproj b/Sandboxie/apps/common/Common.vcxproj index 3f0a216119..80feae4f2f 100644 --- a/Sandboxie/apps/common/Common.vcxproj +++ b/Sandboxie/apps/common/Common.vcxproj @@ -106,6 +106,7 @@ + diff --git a/Sandboxie/apps/ini/resource1.rc b/Sandboxie/apps/ini/resource1.rc index 8d0b602d9b..ae46b749f6 100644 --- a/Sandboxie/apps/ini/resource1.rc +++ b/Sandboxie/apps/ini/resource1.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //--------------------------------------------------------------------------- // SbieIni scripting utility //--------------------------------------------------------------------------- diff --git a/Sandboxie/apps/start/resource.rc b/Sandboxie/apps/start/resource.rc index b95f6c4ff1..e6004d43b3 100644 --- a/Sandboxie/apps/start/resource.rc +++ b/Sandboxie/apps/start/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/apps/start/start.cpp b/Sandboxie/apps/start/start.cpp index 847355b917..1375d99990 100644 --- a/Sandboxie/apps/start/start.cpp +++ b/Sandboxie/apps/start/start.cpp @@ -925,6 +925,13 @@ int Program_Start(void) expanded = MyHeapAlloc(8192 * sizeof(WCHAR)); ExpandEnvironmentStrings(cmdline, expanded, 8192); + if (wcsstr(expanded, L" ") && !wcsstr(expanded, L"\"")) + { + wmemmove(expanded + 1, expanded, wcslen(expanded) + 1); + expanded[0] = L'\"'; + wcscat(expanded, L"\""); + } + ok = CreateProcess( NULL, expanded, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); diff --git a/Sandboxie/common/my_version.h b/Sandboxie/common/my_version.h index 60ce993939..5c63de2cc1 100644 --- a/Sandboxie/common/my_version.h +++ b/Sandboxie/common/my_version.h @@ -20,9 +20,9 @@ #ifndef _MY_VERSION_H #define _MY_VERSION_H -#define MY_VERSION_BINARY 5,40 -#define MY_VERSION_STRING "5.40" -#define MY_VERSION_STRING_EX "5.40.2" +#define MY_VERSION_BINARY 5,41 +#define MY_VERSION_STRING "5.41" +#define MY_VERSION_STRING_EX "5.41.0" // These #defines are used by either Resource Compiler, or by NSIC installer #define SBIE_INSTALLER_PATH "..\\Bin\\" diff --git a/Sandboxie/common/win32_ntddk.h b/Sandboxie/common/win32_ntddk.h index 91457079cd..03378c0b54 100644 --- a/Sandboxie/common/win32_ntddk.h +++ b/Sandboxie/common/win32_ntddk.h @@ -298,19 +298,22 @@ typedef struct _OBJECT_DIRECTORY_INFORMATION { UNICODE_STRING TypeName; } OBJECT_DIRECTORY_INFORMATION, *POBJECT_DIRECTORY_INFORMATION; -__declspec(dllimport) NTSTATUS NtCreateDirectoryObject( +__declspec(dllimport) NTSTATUS __stdcall +NtCreateDirectoryObject( OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes ); -__declspec(dllimport) NTSTATUS NtOpenDirectoryObject( +__declspec(dllimport) NTSTATUS __stdcall +NtOpenDirectoryObject( OUT PHANDLE DirectoryHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes ); -__declspec(dllimport) NTSTATUS NtQueryDirectoryObject( +__declspec(dllimport) NTSTATUS __stdcall +NtQueryDirectoryObject( IN HANDLE DirectoryHandle, OUT PVOID Buffer, IN ULONG Length, @@ -1029,7 +1032,8 @@ NtTerminateThread( IN NTSTATUS ExitStatus ); -__declspec(dllimport) NTSTATUS NtQueryInformationThread( +__declspec(dllimport) NTSTATUS __stdcall +NtQueryInformationThread( IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, @@ -1206,7 +1210,8 @@ NtEnumerateKey( OUT PULONG ResultLength ); -__declspec(dllimport) NTSTATUS NtQueryKey( +__declspec(dllimport) NTSTATUS __stdcall +NtQueryKey( IN HANDLE KeyHandle, IN KEY_INFORMATION_CLASS KeyInformationClass, OUT PVOID KeyInformation, @@ -1418,13 +1423,13 @@ typedef struct _SYSTEM_HANDLE_INFORMATION { #endif -__declspec(dllimport) NTSTATUS NtQuerySystemInformation( +__declspec(dllimport) NTSTATUS __stdcall NtQuerySystemInformation( IN SYSTEM_INFORMATION_CLASS SystemInformationClass, OUT PVOID SystemInformation, IN ULONG SystemInformationLength, OUT PULONG ReturnLength OPTIONAL); -__declspec(dllimport) NTSTATUS NtSetSystemInformation( +__declspec(dllimport) NTSTATUS __stdcall NtSetSystemInformation( IN SYSTEM_INFORMATION_CLASS SystemInformationClass, IN OUT PVOID SystemInformation, IN ULONG SystemInformationLength); @@ -1558,14 +1563,16 @@ typedef struct _ALPC_MESSAGE_VIEW { // end ALPC_INFO structure from LPC-ALPC-paper.pdf -__declspec(dllimport) NTSTATUS NtCreatePort( +__declspec(dllimport) NTSTATUS __stdcall +NtCreatePort( OUT PHANDLE PortHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG MaxConnectInfoLength, IN ULONG MaxMsgLength, IN OUT PULONG Reserved OPTIONAL); -__declspec(dllimport) NTSTATUS NtConnectPort( +__declspec(dllimport) NTSTATUS __stdcall +NtConnectPort( OUT PHANDLE ClientPortHandle, IN PUNICODE_STRING ServerPortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, @@ -1575,7 +1582,8 @@ __declspec(dllimport) NTSTATUS NtConnectPort( IN OUT PVOID ConnectionInfo OPTIONAL, IN OUT PULONG ConnectionInfoLength OPTIONAL); -__declspec(dllimport) NTSTATUS NtSecureConnectPort( +__declspec(dllimport) NTSTATUS __stdcall +NtSecureConnectPort( OUT PHANDLE ClientPortHandle, IN PUNICODE_STRING ServerPortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, @@ -1586,7 +1594,8 @@ __declspec(dllimport) NTSTATUS NtSecureConnectPort( IN OUT PVOID ConnectionInfo OPTIONAL, IN OUT PULONG ConnectionInfoLength OPTIONAL); -__declspec(dllimport) NTSTATUS NtAcceptConnectPort( +__declspec(dllimport) NTSTATUS __stdcall +NtAcceptConnectPort( OUT PHANDLE PortHandle, IN PVOID PortContext OPTIONAL, IN PPORT_MESSAGE ConnectionRequest, @@ -1594,32 +1603,39 @@ __declspec(dllimport) NTSTATUS NtAcceptConnectPort( IN OUT PPORT_VIEW ServerView OPTIONAL, OUT PREMOTE_PORT_VIEW ClientView OPTIONAL); -__declspec(dllimport) NTSTATUS NtCompleteConnectPort( +__declspec(dllimport) NTSTATUS __stdcall +NtCompleteConnectPort( IN HANDLE PortHandle); -__declspec(dllimport) NTSTATUS NtRegisterThreadTerminatePort( +__declspec(dllimport) NTSTATUS __stdcall +NtRegisterThreadTerminatePort( IN HANDLE PortHandle); -__declspec(dllimport) NTSTATUS NtRequestPort( +__declspec(dllimport) NTSTATUS __stdcall +NtRequestPort( IN HANDLE PortHandle, IN PPORT_MESSAGE RequestMessage); -__declspec(dllimport) NTSTATUS NtReplyPort( +__declspec(dllimport) NTSTATUS __stdcall +NtReplyPort( IN HANDLE PortHandle, IN PPORT_MESSAGE ReplyMessage); -__declspec(dllimport) NTSTATUS NtRequestWaitReplyPort( +__declspec(dllimport) NTSTATUS __stdcall +NtRequestWaitReplyPort( IN HANDLE PortHandle, IN PPORT_MESSAGE RequestMessage, OUT PPORT_MESSAGE ReplyMessage); -__declspec(dllimport) NTSTATUS NtReplyWaitReceivePort( +__declspec(dllimport) NTSTATUS __stdcall +NtReplyWaitReceivePort( IN HANDLE PortHandle, OUT PVOID *PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage OPTIONAL, OUT PPORT_MESSAGE ReceiveMessage); -__declspec(dllimport) NTSTATUS NtImpersonateClientOfPort( +__declspec(dllimport) NTSTATUS __stdcall +NtImpersonateClientOfPort( IN HANDLE PortHandle, IN PPORT_MESSAGE PortMessage); @@ -1724,18 +1740,18 @@ typedef NTSTATUS (*P_LdrGetDllHandleEx)( #define SYMBOLIC_LINK_QUERY (0x0001) #define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) -__declspec(dllimport) NTSTATUS NtCreateSymbolicLinkObject( +__declspec(dllimport) NTSTATUS __stdcall NtCreateSymbolicLinkObject( OUT PHANDLE SymbolicLinkHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PUNICODE_STRING LinkTarget); -__declspec(dllimport) NTSTATUS NtOpenSymbolicLinkObject( +__declspec(dllimport) NTSTATUS __stdcall NtOpenSymbolicLinkObject( OUT PHANDLE SymbolicLinkHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); -__declspec(dllimport) NTSTATUS NtQuerySymbolicLinkObject( +__declspec(dllimport) NTSTATUS __stdcall NtQuerySymbolicLinkObject( IN HANDLE SymbolicLinkHandle, IN OUT PUNICODE_STRING LinkTarget, OUT PULONG ReturnedLength); @@ -1774,10 +1790,10 @@ typedef ULONG EVENT_TYPE; //--------------------------------------------------------------------------- -__declspec(dllimport) NTSTATUS NtLoadDriver( +__declspec(dllimport) NTSTATUS __stdcall NtLoadDriver( UNICODE_STRING *RegistryPath); -__declspec(dllimport) NTSTATUS NtUnloadDriver( +__declspec(dllimport) NTSTATUS __stdcall NtUnloadDriver( UNICODE_STRING *RegistryPath); //--------------------------------------------------------------------------- @@ -1790,7 +1806,7 @@ typedef enum _MEMORY_INFORMATION_CLASS { MemoryWorkingSetExInformation } MEMORY_INFORMATION_CLASS; -__declspec(dllimport) NTSTATUS NtAllocateVirtualMemory( +__declspec(dllimport) NTSTATUS __stdcall NtAllocateVirtualMemory( IN HANDLE ProcessHandle, PVOID *BaseAddress, IN ULONG_PTR ZeroBits, @@ -1798,28 +1814,28 @@ __declspec(dllimport) NTSTATUS NtAllocateVirtualMemory( IN ULONG AllocationType, IN ULONG Protect); -__declspec(dllimport) NTSTATUS NtReadVirtualMemory( +__declspec(dllimport) NTSTATUS __stdcall NtReadVirtualMemory( IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T BufferSize, OUT PSIZE_T NumberOfBytesRead OPTIONAL); -__declspec(dllimport) NTSTATUS NtWriteVirtualMemory( +__declspec(dllimport) NTSTATUS __stdcall NtWriteVirtualMemory( IN HANDLE ProcessHandle, OUT PVOID BaseAddress, IN PVOID Buffer, IN SIZE_T BufferSize, OUT PSIZE_T NumberOfBytesWritten OPTIONAL); -__declspec(dllimport) NTSTATUS NtProtectVirtualMemory( +__declspec(dllimport) NTSTATUS __stdcall NtProtectVirtualMemory( IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN OUT PSIZE_T RegionSize, IN ULONG NewProtect, OUT PULONG OldProtect); -__declspec(dllimport) NTSTATUS NtQueryVirtualMemory( +__declspec(dllimport) NTSTATUS __stdcall NtQueryVirtualMemory( IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN MEMORY_INFORMATION_CLASS MemoryInformationClass, @@ -1829,26 +1845,26 @@ __declspec(dllimport) NTSTATUS NtQueryVirtualMemory( //--------------------------------------------------------------------------- -__declspec(dllimport) NTSTATUS NtSetEvent( +__declspec(dllimport) NTSTATUS __stdcall NtSetEvent( IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL); -__declspec(dllimport) NTSTATUS NtFlushInstructionCache( +__declspec(dllimport) NTSTATUS __stdcall NtFlushInstructionCache( IN HANDLE ProcessHandle, IN PVOID BaseAddress OPTIONAL, IN ULONG Length OPTIONAL); //--------------------------------------------------------------------------- -__declspec(dllimport) NTSTATUS NtLoadKey( +__declspec(dllimport) NTSTATUS __stdcall NtLoadKey( POBJECT_ATTRIBUTES TargetObjectAttributes, POBJECT_ATTRIBUTES SourceObjectAttributes); -__declspec(dllimport) NTSTATUS NtSaveKey( +__declspec(dllimport) NTSTATUS __stdcall NtSaveKey( HANDLE KeyHandle, HANDLE FileHandle); -__declspec(dllimport) NTSTATUS NtQueryValueKey( +__declspec(dllimport) NTSTATUS __stdcall NtQueryValueKey( HANDLE KeyHandle, UNICODE_STRING *ValueName, KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, @@ -1856,7 +1872,7 @@ __declspec(dllimport) NTSTATUS NtQueryValueKey( ULONG Length, ULONG *ResultLength); -__declspec(dllimport) NTSTATUS NtQueryMultipleValueKey( +__declspec(dllimport) NTSTATUS __stdcall NtQueryMultipleValueKey( HANDLE KeyHandle, PKEY_VALUE_ENTRY ValueEntries, ULONG EntryCount, @@ -1864,7 +1880,7 @@ __declspec(dllimport) NTSTATUS NtQueryMultipleValueKey( ULONG *Length, ULONG *ResultLength); -__declspec(dllimport) NTSTATUS NtEnumerateValueKey( +__declspec(dllimport) NTSTATUS __stdcall NtEnumerateValueKey( HANDLE KeyHandle, ULONG Index, KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, @@ -1872,7 +1888,7 @@ __declspec(dllimport) NTSTATUS NtEnumerateValueKey( ULONG Length, ULONG *ResultLength); -__declspec(dllimport) NTSTATUS NtNotifyChangeKey( +__declspec(dllimport) NTSTATUS __stdcall NtNotifyChangeKey( HANDLE KeyHandle, HANDLE Event OPTIONAL, PIO_APC_ROUTINE ApcRoutine OPTIONAL, @@ -1884,7 +1900,7 @@ __declspec(dllimport) NTSTATUS NtNotifyChangeKey( ULONG BufferSize, BOOLEAN Asynchronous); -__declspec(dllimport) NTSTATUS NtNotifyChangeMultipleKeys( +__declspec(dllimport) NTSTATUS __stdcall NtNotifyChangeMultipleKeys( HANDLE MasterKeyHandle, ULONG Count, OBJECT_ATTRIBUTES SlaveObjects[], @@ -1900,42 +1916,42 @@ __declspec(dllimport) NTSTATUS NtNotifyChangeMultipleKeys( //--------------------------------------------------------------------------- -__declspec(dllimport) NTSTATUS NtCreateEvent( +__declspec(dllimport) NTSTATUS __stdcall NtCreateEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN EVENT_TYPE EventType, IN BOOLEAN InitialState); -__declspec(dllimport) NTSTATUS NtOpenEvent( +__declspec(dllimport) NTSTATUS __stdcall NtOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); -__declspec(dllimport) NTSTATUS NtCreateMutant( +__declspec(dllimport) NTSTATUS __stdcall NtCreateMutant( OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN InitialOwner); -__declspec(dllimport) NTSTATUS NtOpenMutant( +__declspec(dllimport) NTSTATUS __stdcall NtOpenMutant( OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); -__declspec(dllimport) NTSTATUS NtCreateSemaphore( +__declspec(dllimport) NTSTATUS __stdcall NtCreateSemaphore( OUT PHANDLE SemaphoreHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG InitialCount, IN ULONG MaximumCount); -__declspec(dllimport) NTSTATUS NtOpenSemaphore( +__declspec(dllimport) NTSTATUS __stdcall NtOpenSemaphore( OUT PHANDLE SemaphoreHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); -__declspec(dllimport) NTSTATUS NtCreateSection( +__declspec(dllimport) NTSTATUS __stdcall NtCreateSection( OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, @@ -1944,12 +1960,12 @@ __declspec(dllimport) NTSTATUS NtCreateSection( IN ULONG SectionAttributes, IN HANDLE FileHandle OPTIONAL); -__declspec(dllimport) NTSTATUS NtOpenSection( +__declspec(dllimport) NTSTATUS __stdcall NtOpenSection( OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); -__declspec(dllimport) NTSTATUS NtMapViewOfSection( +__declspec(dllimport) NTSTATUS __stdcall NtMapViewOfSection( IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, @@ -1961,7 +1977,7 @@ __declspec(dllimport) NTSTATUS NtMapViewOfSection( IN ULONG AllocationType, IN ULONG Protect); -__declspec(dllimport) NTSTATUS NtUnmapViewOfSection( +__declspec(dllimport) NTSTATUS __stdcall NtUnmapViewOfSection( IN HANDLE ProcessHandle, IN PVOID BaseAddress); @@ -1976,43 +1992,43 @@ __declspec(dllimport) NTSTATUS NtUnmapViewOfSection( #define TokenElevationTypeFull 2 #define TokenElevationTypeLimited 3 -__declspec(dllimport) NTSTATUS NtOpenProcess( +__declspec(dllimport) NTSTATUS __stdcall NtOpenProcess( OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId); -__declspec(dllimport) NTSTATUS NtOpenThread( +__declspec(dllimport) NTSTATUS __stdcall NtOpenThread( OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId); -__declspec(dllimport) NTSTATUS NtOpenProcessToken( +__declspec(dllimport) NTSTATUS __stdcall NtOpenProcessToken( IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle); -__declspec(dllimport) NTSTATUS NtOpenThreadToken( +__declspec(dllimport) NTSTATUS __stdcall NtOpenThreadToken( IN HANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN BOOLEAN OpenAsSelf, OUT PHANDLE TokenHandle); -__declspec(dllimport) NTSTATUS NtQueryInformationToken( +__declspec(dllimport) NTSTATUS __stdcall NtQueryInformationToken( IN HANDLE TokenHandle, IN TOKEN_INFORMATION_CLASS TokenInformationClass, OUT PVOID TokenInformation, IN ULONG TokenInformationLength, OUT PULONG ReturnLength); -__declspec(dllimport) NTSTATUS NtSetInformationToken( +__declspec(dllimport) NTSTATUS __stdcall NtSetInformationToken( IN HANDLE TokenHandle, IN TOKEN_INFORMATION_CLASS TokenInformationClass, OUT PVOID TokenInformation, IN ULONG TokenInformationLength); -__declspec(dllimport) NTSTATUS NtDuplicateObject( +__declspec(dllimport) NTSTATUS __stdcall NtDuplicateObject( IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle, @@ -2021,7 +2037,7 @@ __declspec(dllimport) NTSTATUS NtDuplicateObject( IN ULONG HandleAttributes, IN ULONG Options); -__declspec(dllimport) NTSTATUS NtDuplicateToken( +__declspec(dllimport) NTSTATUS __stdcall NtDuplicateToken( IN HANDLE ExistingTokenHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, @@ -2029,12 +2045,12 @@ __declspec(dllimport) NTSTATUS NtDuplicateToken( IN TOKEN_TYPE TokenType, OUT PHANDLE NewTokenHandle); -__declspec(dllimport) NTSTATUS NtSetSecurityObject( - IN HANDLE Handle, - IN SECURITY_INFORMATION SecurityInformation, - IN PSECURITY_DESCRIPTOR SecurityDescriptor); +//__declspec(dllimport) NTSTATUS __stdcall NtSetSecurityObject( +// IN HANDLE Handle, +// IN SECURITY_INFORMATION SecurityInformation, +// IN PSECURITY_DESCRIPTOR SecurityDescriptor); -__declspec(dllimport) NTSTATUS NtFilterToken( +__declspec(dllimport) NTSTATUS __stdcall NtFilterToken( IN HANDLE ExistingTokenHandle, IN ULONG Flags, IN PTOKEN_GROUPS SidsToDisable OPTIONAL, @@ -2042,7 +2058,7 @@ __declspec(dllimport) NTSTATUS NtFilterToken( IN PTOKEN_GROUPS RestrictedSids OPTIONAL, OUT PHANDLE NewTokenHandle); -__declspec(dllimport) NTSTATUS NtAdjustPrivilegesToken( +__declspec(dllimport) NTSTATUS __stdcall NtAdjustPrivilegesToken( IN HANDLE TokenHandle, IN BOOLEAN DisableAllPrivileges, IN PTOKEN_PRIVILEGES NewState OPTIONAL, @@ -2050,7 +2066,7 @@ __declspec(dllimport) NTSTATUS NtAdjustPrivilegesToken( OUT PTOKEN_PRIVILEGES PreviousState OPTIONAL, OUT PULONG ReturnLength); -__declspec(dllimport) NTSTATUS NtPrivilegeCheck( +__declspec(dllimport) NTSTATUS __stdcall NtPrivilegeCheck( IN HANDLE TokenHandle, IN OUT PPRIVILEGE_SET RequiredPrivileges, OUT PBOOLEAN Result); @@ -2059,16 +2075,16 @@ typedef NTSTATUS (*P_RtlQueryElevationFlags)(ULONG *Flags); __declspec(dllimport) NTSTATUS RtlQueryElevationFlags(ULONG *Flags); -__declspec(dllimport) NTSTATUS NtContinue( +__declspec(dllimport) NTSTATUS __stdcall NtContinue( PCONTEXT ThreadContext, BOOLEAN RaiseAlert); -__declspec(dllimport) NTSTATUS NtTestAlert(void); +__declspec(dllimport) NTSTATUS __stdcall NtTestAlert(void); -__declspec(dllimport) NTSTATUS NtImpersonateThread( +__declspec(dllimport) NTSTATUS __stdcall NtImpersonateThread( HANDLE ServerThreadHandle, HANDLE ClientThreadHandle, PSECURITY_QUALITY_OF_SERVICE SecurityQos); -__declspec(dllimport) NTSTATUS NtImpersonateAnonymousToken( +__declspec(dllimport) NTSTATUS __stdcall NtImpersonateAnonymousToken( HANDLE ThreadHandle); //--------------------------------------------------------------------------- @@ -2141,15 +2157,15 @@ __declspec(dllimport) NTSTATUS RtlCreateProcessParameters( UNICODE_STRING *ShellInfo, UNICODE_STRING *RuntimeData); -__declspec(dllimport) NTSTATUS NtCreateJobObject( +__declspec(dllimport) NTSTATUS __stdcall NtCreateJobObject( OUT PHANDLE JobHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); -__declspec(dllimport) NTSTATUS NtAssignProcessToJobObject( +__declspec(dllimport) NTSTATUS __stdcall NtAssignProcessToJobObject( HANDLE hJob, HANDLE hProcess); -__declspec(dllimport) NTSTATUS NtSetInformationJobObject( +__declspec(dllimport) NTSTATUS __stdcall NtSetInformationJobObject( IN HANDLE JobHandle, IN JOBOBJECTINFOCLASS JobObjectInformationClass, IN PVOID JobObjectInformation, @@ -2246,14 +2262,14 @@ __declspec(dllimport) void __stdcall RtlRaiseStatus(NTSTATUS Status); //--------------------------------------------------------------------------- -__declspec(dllimport) USHORT RtlCaptureStackBackTrace( - ULONG FramesToSkip, - ULONG FramesToCapture, - PVOID *BackTrace, - ULONG *BackTraceHash -); +//__declspec(dllimport) USHORT RtlCaptureStackBackTrace( +// ULONG FramesToSkip, +// ULONG FramesToCapture, +// PVOID *BackTrace, +// ULONG *BackTraceHash +//); -__declspec(dllimport) NTSTATUS NtRaiseHardError( +__declspec(dllimport) NTSTATUS __stdcall NtRaiseHardError( NTSTATUS ErrorStatus, ULONG NumberOfParameters, ULONG UnicodeBitMask, diff --git a/Sandboxie/core/dll/obj.c b/Sandboxie/core/dll/obj.c index 811f22fd78..51b95c5825 100644 --- a/Sandboxie/core/dll/obj.c +++ b/Sandboxie/core/dll/obj.c @@ -44,6 +44,12 @@ static NTSTATUS Obj_NtQueryVirtualMemory( SIZE_T Length, SIZE_T *ResultLength); +static NTSTATUS Obj_NtQueryInformationProcess( + HANDLE ProcessHandle, + PROCESSINFOCLASS ProcessInformationClass, + PVOID ProcessInformation, + ULONG ProcessInformationLength, + PULONG ReturnLength); //--------------------------------------------------------------------------- // Variables @@ -54,6 +60,8 @@ static P_NtQueryObject __sys_NtQueryObject = NULL; P_NtQueryVirtualMemory __sys_NtQueryVirtualMemory = NULL; + P_NtQueryObject __sys_NtQueryInformationProcess = NULL; + //--------------------------------------------------------------------------- // Obj_Init @@ -67,6 +75,7 @@ _FX BOOLEAN Obj_Init(void) #else SBIEDLL_HOOK(Obj_,NtQueryObject); SBIEDLL_HOOK(Obj_,NtQueryVirtualMemory); + SBIEDLL_HOOK(Obj_,NtQueryInformationProcess); #endif return TRUE; } @@ -401,3 +410,42 @@ _FX NTSTATUS Obj_NtQueryVirtualMemory( SetLastError(LastError); return status; } + +//--------------------------------------------------------------------------- +// Obj_NtQueryVirtualMemory +//--------------------------------------------------------------------------- + + +_FX NTSTATUS Obj_NtQueryInformationProcess( + HANDLE ProcessHandle, + PROCESSINFOCLASS ProcessInformationClass, + PVOID ProcessInformation, + ULONG ProcessInformationLength, + PULONG ReturnLength) +{ + NTSTATUS status; + ULONG outlen; + + status = __sys_NtQueryInformationProcess( + ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, &outlen); + + if (ProcessInformationClass == ProcessImageFileName) + { + // + // since file paths are always shorter without the sandbox prefix we can keep this simple + // + + ULONG tmplen; + PUNICODE_STRING fileName = (PUNICODE_STRING)ProcessInformation; + + tmplen = File_NtQueryObjectName(fileName, fileName->MaximumLength); + + if (tmplen) + outlen = sizeof(UNICODE_STRING) + tmplen; + } + + if (ReturnLength) + *ReturnLength = outlen; + + return status; +} \ No newline at end of file diff --git a/Sandboxie/core/dll/resource.rc b/Sandboxie/core/dll/resource.rc index 99bc0862b3..212b135fe2 100644 --- a/Sandboxie/core/dll/resource.rc +++ b/Sandboxie/core/dll/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // //#define _USING_V110_SDK71_ diff --git a/Sandboxie/core/drv/conf.c b/Sandboxie/core/drv/conf.c index 23b7a165e5..919fe10b14 100644 --- a/Sandboxie/core/drv/conf.c +++ b/Sandboxie/core/drv/conf.c @@ -196,19 +196,19 @@ _FX NTSTATUS Conf_Read(ULONG session_id) return STATUS_INSUFFICIENT_RESOURCES; // - // open the configuration file, try both places + // open the configuration file, try both places, home first // - path_home = FALSE; - swprintf(path, path_sandboxie, SystemRoot); + path_home = TRUE; // = FALSE; + swprintf(path, path_sandboxie, Driver_HomePathDos); // , SystemRoot); status = Stream_Open( &stream, path, FILE_GENERIC_READ, 0, FILE_SHARE_READ, FILE_OPEN, 0); if (status == STATUS_OBJECT_NAME_NOT_FOUND) { - path_home = TRUE; - swprintf(path, path_sandboxie, Driver_HomePathDos); + path_home = FALSE; // = TRUE; + swprintf(path, path_sandboxie, SystemRoot); // , Driver_HomePathDos); status = Stream_Open( &stream, path, @@ -1230,7 +1230,7 @@ _FX NTSTATUS Conf_Api_Reload(PROCESS *proc, ULONG64 *parms) Conf_Data.pool = NULL; List_Init(&Conf_Data.sections); - Conf_Data.home = FALSE; + Conf_Data.home = TRUE; // = FALSE; ExReleaseResourceLite(Conf_Lock); KeLowerIrql(irql); @@ -1371,7 +1371,7 @@ _FX BOOLEAN Conf_Init(void) { Conf_Data.pool = NULL; List_Init(&Conf_Data.sections); - Conf_Data.home = FALSE; + Conf_Data.home = TRUE; // = FALSE; if (! Mem_GetLockResource(&Conf_Lock, TRUE)) return FALSE; diff --git a/Sandboxie/core/drv/syscall_open.c b/Sandboxie/core/drv/syscall_open.c index 91ba2510d1..1dbcd27e75 100644 --- a/Sandboxie/core/drv/syscall_open.c +++ b/Sandboxie/core/drv/syscall_open.c @@ -397,6 +397,7 @@ _FX NTSTATUS Syscall_DuplicateHandle( HANDLE NewHandle; void *TargetProcessObject; + // // if there is a target process handle, keep a record of the // associated process object so we can check it later @@ -476,6 +477,9 @@ _FX NTSTATUS Syscall_DuplicateHandle( status = Syscall_DuplicateHandle_2( (HANDLE)user_args[2], NewHandle, TargetProcessObject, proc); + + if (!NT_SUCCESS(status)) + NtClose(NewHandle); } // diff --git a/Sandboxie/core/svc/resource.rc b/Sandboxie/core/svc/resource.rc index f62bf7634e..8de647e741 100644 --- a/Sandboxie/core/svc/resource.rc +++ b/Sandboxie/core/svc/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/Sandboxie/install/release/resource.rc b/Sandboxie/install/release/resource.rc index b3650c3c22..d9311ef0a7 100644 --- a/Sandboxie/install/release/resource.rc +++ b/Sandboxie/install/release/resource.rc @@ -1,19 +1,3 @@ -// Copyright 2004-2020 Sandboxie Holdings, LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - //Microsoft Developer Studio generated resource script. // diff --git a/SandboxiePlus/MiscHelpers/MiscHelpers.vcxproj b/SandboxiePlus/MiscHelpers/MiscHelpers.vcxproj index 06f973e120..5c109c91a2 100644 --- a/SandboxiePlus/MiscHelpers/MiscHelpers.vcxproj +++ b/SandboxiePlus/MiscHelpers/MiscHelpers.vcxproj @@ -1,10 +1,18 @@  + + Debug + Win32 + Debug x64 + + Release + Win32 + Release x64 @@ -22,11 +30,21 @@ v140 false + + DynamicLibrary + v140 + false + DynamicLibrary v141 false + + DynamicLibrary + v140 + false + @@ -36,10 +54,20 @@ + + + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + @@ -47,10 +75,18 @@ msvc2015_64 core;network;widgets;winextras + + msvc2015_64 + core;network;widgets;winextras + msvc2017_64_dbg core;network;widgets;winextras + + msvc2015 + core;network;widgets;winextras + @@ -75,6 +111,27 @@ true + + + stdafx.h + + + true + Disabled + ProgramDatabase + MultiThreadedDebugDLL + true + Use + stdafx.h + $(IntDir)$(TargetName).pch + MISCHELPERS_LIB;%(PreprocessorDefinitions) + + + Windows + $(OutDir)\$(ProjectName).dll + true + + stdafx.h @@ -95,6 +152,27 @@ false + + + stdafx.h + + + true + + + MultiThreadedDLL + true + Use + stdafx.h + $(IntDir)$(TargetName).pch + MISCHELPERS_LIB;%(PreprocessorDefinitions) + + + Windows + $(OutDir)\$(ProjectName).dll + false + + @@ -118,7 +196,9 @@ Create + Create Create + Create diff --git a/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj b/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj index 393016600c..bce3bbe30e 100644 --- a/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj +++ b/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj @@ -42,7 +42,7 @@ DynamicLibrary - v141 + v140 false @@ -64,6 +64,10 @@ + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + @@ -80,7 +84,7 @@ core - msvc2015_64 + msvc2015 core @@ -177,6 +181,7 @@ false MachineX86 /SUBSYSTEM:WINDOWS + ntdll.lib;%(AdditionalDependencies) @@ -184,6 +189,7 @@ + Create Create @@ -193,11 +199,14 @@ + + + diff --git a/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj.filters b/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj.filters index 7e2367248d..418e655f6f 100644 --- a/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj.filters +++ b/SandboxiePlus/QSbieAPI/QSbieAPI.vcxproj.filters @@ -42,6 +42,9 @@ Sandboxie + + SbieAPI + @@ -50,6 +53,15 @@ SbieAPI + + SbieAPI + + + SbieAPI + + + SbieAPI + diff --git a/SandboxiePlus/QSbieAPI/SbieAPI.cpp b/SandboxiePlus/QSbieAPI/SbieAPI.cpp index cd95e0e0dd..cb6e1d88c3 100644 --- a/SandboxiePlus/QSbieAPI/SbieAPI.cpp +++ b/SandboxiePlus/QSbieAPI/SbieAPI.cpp @@ -24,24 +24,16 @@ typedef long NTSTATUS; #include +#include "SbieDefs.h" + #include "..\..\Sandboxie\common\win32_ntddk.h" -#define SANDBOXIE L"Sandboxie" #include "..\..\Sandboxie\core\drv\api_defs.h" -#define REQUEST_LEN 4096 -#define CONF_LINE_LEN 2000 - #include "..\..\Sandboxie\core\svc\msgids.h" #include "..\..\Sandboxie\core\svc\ProcessWire.h" #include "..\..\Sandboxie\core\svc\sbieiniwire.h" -#define SBIESVC_PORT L"\\RPC Control\\SbieSvcPort" - -#define SBIESTART_EXE L"Start.exe" - -#define SBIEMSG_DLL L"SbieMsg.dll" - struct SSbieAPI { @@ -61,6 +53,8 @@ struct SSbieAPI lastRecordNum = 0; SbieMsgDll = NULL; + + SvcLock = 0; } ~SSbieAPI() { } @@ -72,7 +66,7 @@ struct SSbieAPI } - HANDLE SbieApiHandle = INVALID_HANDLE_VALUE; + HANDLE SbieApiHandle; HANDLE PortHandle; ULONG MaxDataLen; @@ -87,8 +81,20 @@ struct SSbieAPI ULONG lastRecordNum; HMODULE SbieMsgDll; + + mutable volatile LONG SvcLock; + mutable void* SvcReq; + mutable void* SvcRpl; + mutable SB_STATUS SvcStatus; }; +#define SVC_OP_STATE_IDLE 0 +#define SVC_OP_STATE_PREP 1 +#define SVC_OP_STATE_START 2 +#define SVC_OP_STATE_EXEC 3 +#define SVC_OP_STATE_DONE 4 +#define SVC_OP_STATE_EVAL 5 + quint64 FILETIME2ms(quint64 fileTime) { if (fileTime < 116444736000000000ULL) @@ -106,65 +112,302 @@ CSbieAPI::CSbieAPI(QObject* parent) : QThread(parent) { m = new SSbieAPI(); + connect(&m_IniWatcher, SIGNAL(fileChanged(const QString&)), this, SLOT(OnIniChanged(const QString&))); +} + +CSbieAPI::~CSbieAPI() +{ + Disconnect(); + + delete m; +} + +SB_STATUS CSbieAPI::Connect(bool takeOver, bool andLoad) +{ + if (IsConnected()) + return SB_OK; + UNICODE_STRING uni; RtlInitUnicodeString(&uni, API_DEVICE_NAME); OBJECT_ATTRIBUTES objattrs; - InitializeObjectAttributes(&objattrs, &uni, OBJ_CASE_INSENSITIVE, NULL, NULL); + InitializeObjectAttributes(&objattrs, &uni, OBJ_CASE_INSENSITIVE, NULL, NULL); IO_STATUS_BLOCK IoStatusBlock; - NTSTATUS status = NtOpenFile(&m->SbieApiHandle, FILE_GENERIC_READ, &objattrs, &IoStatusBlock, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0); + NTSTATUS status = NtOpenFile(&m->SbieApiHandle, FILE_GENERIC_READ, &objattrs, &IoStatusBlock, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0); - if (status == STATUS_OBJECT_NAME_NOT_FOUND || status == STATUS_NO_SUCH_DEVICE) - status = STATUS_SERVER_DISABLED; + if (status == STATUS_OBJECT_NAME_NOT_FOUND || status == STATUS_NO_SUCH_DEVICE) + status = STATUS_SERVER_DISABLED; if (status != STATUS_SUCCESS) { m->SbieApiHandle = INVALID_HANDLE_VALUE; - return; + return SB_ERR("Failed to connect to driver", status); } - + UpdateDriveLetters(); m_SbiePath = GetSbieHome(); - m->SbieMsgDll = LoadLibraryEx((m_SbiePath.toStdWString() + L"\\" SBIEMSG_DLL).c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE); - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - QString WinDir = env.value("windir"); - m_IniPath = WinDir + "\\Sandboxie.ini"; - - ReloadBoxes(); - m_bTerminate = false; start(); + + bool bHome = false; + m_IniPath = GetIniPath(&bHome); + qDebug() << "Config file:" << m_IniPath << (bHome ? "(home)" : "(system)"); + + if (takeOver) + TakeOver(); + + if (andLoad) + ReloadBoxes(); + + emit StatusChanged(); + return SB_OK; } -CSbieAPI::~CSbieAPI() +SB_STATUS CSbieAPI::Disconnect() { + if (!IsConnected()) + return SB_OK; + m_bTerminate = true; - if(!wait(10*1000)) + if (!wait(10 * 1000)) terminate(); - if (m->SbieApiHandle != INVALID_HANDLE_VALUE) + if (m->SbieApiHandle != INVALID_HANDLE_VALUE) { NtClose(m->SbieApiHandle); + m->SbieApiHandle = INVALID_HANDLE_VALUE; + } - if (m->SbieMsgDll) + if (m->PortHandle) { + NtClose(m->PortHandle); + m->PortHandle = NULL; + } + + if (m->SbieMsgDll) { FreeLibrary(m->SbieMsgDll); + m->SbieMsgDll = NULL; + } - delete m; + m_SandBoxes.clear(); + m_BoxedProxesses.clear(); + + emit StatusChanged(); + return SB_OK; } -bool CSbieAPI::IsValid() const +bool CSbieAPI::IsConnected() const { return m->SbieApiHandle != INVALID_HANDLE_VALUE; } +bool CSbieAPI__IsWow64() +{ + static bool IsWow64 = false; +#ifndef _WIN64 + static bool init = false; + if (!init) + { + ULONG_PTR wow64; + if (NT_SUCCESS(NtQueryInformationProcess(NtCurrentProcess(), ProcessWow64Information, &wow64, sizeof(ULONG_PTR), NULL))) { + IsWow64 = !!wow64; + } + init = true; + } +#endif + return IsWow64; +} + +SB_STATUS CSbieAPI__ConnectPort(SSbieAPI* m) +{ + if (m->PortHandle) + return SB_OK; + + SECURITY_QUALITY_OF_SERVICE QoS; + QoS.Length = sizeof(SECURITY_QUALITY_OF_SERVICE); + QoS.ImpersonationLevel = SecurityImpersonation; + QoS.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING; + QoS.EffectiveOnly = TRUE; + + UNICODE_STRING PortName; + RtlInitUnicodeString(&PortName, SBIESVC_PORT); + NTSTATUS status = NtConnectPort(&m->PortHandle, &PortName, &QoS, NULL, NULL, &m->MaxDataLen, NULL, NULL); + if (!NT_SUCCESS(status)) + return SB_ERR(status); // 2203 + + // Function associate PortHandle with thread, and sends LPC_TERMINATION_MESSAGE to specified port immediatelly after call NtTerminateThread. + //NtRegisterThreadTerminatePort(m->PortHandle); + + m->SizeofPortMsg = sizeof(PORT_MESSAGE); + if (CSbieAPI__IsWow64()) + m->SizeofPortMsg += sizeof(ULONG) * 4; + m->MaxDataLen -= m->SizeofPortMsg; + + return SB_OK; +} + +SB_STATUS CSbieAPI__CallServer(SSbieAPI* m, MSG_HEADER* req, MSG_HEADER** prpl) +{ + if (!m->PortHandle) { + SB_STATUS Status = CSbieAPI__ConnectPort(m); + if (!Status) + return Status; + } + + UCHAR RequestBuff[MAX_PORTMSG_LENGTH]; + PORT_MESSAGE* ReqHeader = (PORT_MESSAGE*)RequestBuff; + UCHAR* ReqData = RequestBuff + m->SizeofPortMsg; + + UCHAR ResponseBuff[MAX_PORTMSG_LENGTH]; + PORT_MESSAGE* ResHeader = (PORT_MESSAGE*)ResponseBuff; + UCHAR* ResData = ResponseBuff + m->SizeofPortMsg; + + UCHAR CurSeqNumber = (UCHAR)m->CallSeqNumber++; + + // Send the request in chunks + UCHAR* Buffer = (UCHAR*)req; + ULONG BuffLen = req->length; + while (BuffLen) + { + ULONG send_len = BuffLen > m->MaxDataLen ? m->MaxDataLen : BuffLen; + + // set header + memset(ReqHeader, 0, m->SizeofPortMsg); + ReqHeader->u1.s1.DataLength = (USHORT)send_len; + ReqHeader->u1.s1.TotalLength = (USHORT)(m->SizeofPortMsg + send_len); + + // set req data + memcpy(ReqData, Buffer, send_len); + + // use highest byte of the length as sequence field + if (Buffer == (UCHAR*)req) + ReqData[3] = CurSeqNumber; + + // advance position + Buffer += send_len; + BuffLen -= send_len; + + NTSTATUS status = NtRequestWaitReplyPort(m->PortHandle, (PORT_MESSAGE*)RequestBuff, (PORT_MESSAGE*)ResponseBuff); + + if (!NT_SUCCESS(status)) + { + NtClose(m->PortHandle); + m->PortHandle = NULL; + return SB_ERR(CSbieAPI::tr("request %1").arg(status, 8, 16), status); // 2203 + } + + if (BuffLen && ResHeader->u1.s1.DataLength) + return SB_ERR(CSbieAPI::tr("early reply")); // 2203 + } + + // the last call to NtRequestWaitReplyPort should return the first chunk of the reply + if (ResHeader->u1.s1.DataLength >= sizeof(MSG_HEADER)) + { + if (ResData[3] != CurSeqNumber) + return SB_ERR(CSbieAPI::tr("mismatched reply")); // 2203 + + // clear highest byte of the size filed + ResData[3] = 0; + BuffLen = ((MSG_HEADER*)ResData)->length; + } + else + BuffLen = 0; + if (BuffLen == 0) + return SB_ERR(CSbieAPI::tr("null reply (msg %1 len %2)").arg(req->msgid, 8, 16).arg(req->length)); // 2203 + + // read remining chunks + MSG_HEADER*& rpl = *prpl; + rpl = (MSG_HEADER*)malloc(BuffLen); + Buffer = (UCHAR*)rpl; + for (;;) + { + NTSTATUS status; + if (ResHeader->u1.s1.DataLength > BuffLen) + status = STATUS_PORT_MESSAGE_TOO_LONG; + else + { + // get data + memcpy(Buffer, ResData, ResHeader->u1.s1.DataLength); + + // adcance position + Buffer += ResHeader->u1.s1.DataLength; + BuffLen -= ResHeader->u1.s1.DataLength; + + // are we done yet? + if (!BuffLen) + break; + + // set header + memset(ReqHeader, 0, m->SizeofPortMsg); + ReqHeader->u1.s1.TotalLength = (USHORT)m->SizeofPortMsg; + + status = NtRequestWaitReplyPort(m->PortHandle, (PORT_MESSAGE*)RequestBuff, (PORT_MESSAGE*)ResponseBuff); + } + + if (!NT_SUCCESS(status)) + { + free(rpl); + rpl = NULL; + + NtClose(m->PortHandle); + m->PortHandle = NULL; + return SB_ERR(CSbieAPI::tr("reply %1").arg(status, 8, 16), status); // 2203 + } + } + + return SB_OK; +} + +SB_STATUS CSbieAPI::CallServer(void* req, void* rpl) const +{ + while (InterlockedCompareExchange(&m->SvcLock, SVC_OP_STATE_PREP, SVC_OP_STATE_IDLE) != SVC_OP_STATE_IDLE) + QThread::msleep(1); + + m->SvcReq = req; + m->SvcRpl = rpl; + m->SvcStatus = SB_OK; + + InterlockedExchange(&m->SvcLock, SVC_OP_STATE_START); + + // Wake threat imminetly + m_ThreadMutex.lock(); + m_ThreadWait.wakeAll(); + m_ThreadMutex.unlock(); + + // worker: SVC_OP_STATE_START -> SVC_OP_STATE_EXEC -> SVC_OP_STATE_DONE + + while (InterlockedCompareExchange(&m->SvcLock, SVC_OP_STATE_EVAL, SVC_OP_STATE_DONE) != SVC_OP_STATE_DONE) + QThread::usleep(100); + + m->SvcReq = NULL; + m->SvcRpl = NULL; + SB_STATUS Status = m->SvcStatus; + + InterlockedExchange(&m->SvcLock, SVC_OP_STATE_IDLE); + + return Status; + + //return CSbieAPI__CallServer(m, (MSG_HEADER*)req, (MSG_HEADER**)rpl); +} + void CSbieAPI::run() { + int Idle = 0; + while (!m_bTerminate) { int Done = 0; + if (InterlockedCompareExchange(&m->SvcLock, SVC_OP_STATE_EXEC, SVC_OP_STATE_START) == SVC_OP_STATE_START) + { + m->SvcStatus = CSbieAPI__CallServer(m, (MSG_HEADER*)m->SvcReq, (MSG_HEADER**)m->SvcRpl); + + InterlockedExchange(&m->SvcLock, SVC_OP_STATE_DONE); + + Done++; + } + if (GetLog()) // this emits sbie message events if there are any Done++; @@ -173,8 +416,17 @@ void CSbieAPI::run() //QMetaObject::invokeMethod(this, "OnMonitorEntry", Qt::AutoConnection, Q_ARG(quint64, ProcessId), Q_ARG(quint32, Type), Q_ARG(const QString&, Value)); } - if (Done == 0) - QThread::msleep(10); + if (Done != 0) + Idle = 0; + else + { + if(Idle < 5) + Idle++; + + m_ThreadMutex.lock(); + m_ThreadWait.wait(&m_ThreadMutex, 10 * Idle); + m_ThreadMutex.unlock(); + } } } @@ -226,6 +478,20 @@ SB_STATUS CSbieAPI::TakeOver() return SB_OK; } +SB_STATUS CSbieAPI::WatchIni(bool bEnable) +{ + if (bEnable) + m_IniWatcher.addPath(m_IniPath); + else + m_IniWatcher.removePath(m_IniPath); + return SB_OK; +} + +void CSbieAPI::OnIniChanged(const QString &path) +{ + ReloadConfig(); +} + void CSbieAPI::UpdateDriveLetters() { m_DriveLetters.clear(); @@ -287,6 +553,28 @@ QString CSbieAPI::GetSbieHome() const return QString::fromWCharArray(DosPath); } +QString CSbieAPI::GetIniPath(bool* IsHome) const +{ + QString IniPath; + + SBIE_INI_GET_PATH_REQ req; + req.h.msgid = MSGID_SBIE_INI_GET_PATH; + req.h.length = sizeof(SBIE_INI_GET_PATH_REQ); + + SBIE_INI_GET_PATH_RPL *rpl = NULL; + SB_STATUS Status = CSbieAPI::CallServer(&req.h, &rpl); + if (!Status || !rpl) + return QString(); + if (rpl->h.status == 0) { + IniPath = QString::fromWCharArray(rpl->path); + if (IsHome) + *IsHome = rpl->is_home_path; + } + free(rpl); + + return IniPath; +} + SB_STATUS CSbieAPI::RunStart(const QString& BoxName, const QString& Command) { if (m_SbiePath.isEmpty()) @@ -330,168 +618,12 @@ SB_STATUS CSbieAPI::ReloadBoxes() return SB_OK; } -bool CSbieAPI__IsWow64() -{ - static bool IsWow64 = false; -#ifndef _WIN64 - static bool init = false; - if (!init) - { - ULONG_PTR wow64; - if (NT_SUCCESS(NtQueryInformationProcess(NtCurrentProcess(), ProcessWow64Information, &wow64, sizeof(ULONG_PTR), NULL))) { - IsWow64 = !!wow64; - } - init = true; - } -#endif - return IsWow64; -} - -SB_STATUS CSbieAPI__ConnectPort(SSbieAPI* m) -{ - if (m->PortHandle) - return SB_OK; - - SECURITY_QUALITY_OF_SERVICE QoS; - QoS.Length = sizeof(SECURITY_QUALITY_OF_SERVICE); - QoS.ImpersonationLevel = SecurityImpersonation; - QoS.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING; - QoS.EffectiveOnly = TRUE; - - UNICODE_STRING PortName; - RtlInitUnicodeString(&PortName, SBIESVC_PORT); - NTSTATUS status = NtConnectPort(&m->PortHandle, &PortName, &QoS, NULL, NULL, &m->MaxDataLen, NULL, NULL); - if (!NT_SUCCESS(status)) - return SB_ERR(status); // 2203 - - // Function associate PortHandle with thread, and sends LPC_TERMINATION_MESSAGE to specified port immediatelly after call NtTerminateThread. - NtRegisterThreadTerminatePort(m->PortHandle); - - m->SizeofPortMsg = sizeof(PORT_MESSAGE); - if (CSbieAPI__IsWow64()) - m->SizeofPortMsg += sizeof(ULONG) * 4; - m->MaxDataLen -= m->SizeofPortMsg; - - return SB_OK; -} - -SB_STATUS CSbieAPI__CallServer(SSbieAPI* m, MSG_HEADER* req, MSG_HEADER* &rpl) +SB_STATUS CSbieAPI::SbieIniSet(void *RequestBuf, void *pPasswordWithinRequestBuf, const QString& SectionName, const QString& SettingName) { - if (!m->PortHandle) { - SB_STATUS Status = CSbieAPI__ConnectPort(m); - if (!Status) - return Status; - } - - UCHAR RequestBuff[MAX_PORTMSG_LENGTH]; - PORT_MESSAGE* ReqHeader = (PORT_MESSAGE*)RequestBuff; - UCHAR* ReqData = RequestBuff + m->SizeofPortMsg; - - UCHAR ResponseBuff[MAX_PORTMSG_LENGTH]; - PORT_MESSAGE* ResHeader = (PORT_MESSAGE*)ResponseBuff; - UCHAR* ResData = ResponseBuff + m->SizeofPortMsg; - - UCHAR CurSeqNumber = (UCHAR)m->CallSeqNumber++; - - // Send the request in chunks - UCHAR* Buffer = (UCHAR*)req; - ULONG BuffLen = req->length; - while (BuffLen) - { - ULONG send_len = BuffLen > m->MaxDataLen ? m->MaxDataLen : BuffLen; - - // set header - memset(ReqHeader, 0, m->SizeofPortMsg); - ReqHeader->u1.s1.DataLength = (USHORT)send_len; - ReqHeader->u1.s1.TotalLength = (USHORT)(m->SizeofPortMsg + send_len); - - // set req data - memcpy(ReqData, Buffer, send_len); - - // use highest byte of the length as sequence field - if (Buffer == (UCHAR*)req) - ReqData[3] = CurSeqNumber; - - // advance position - Buffer += send_len; - BuffLen -= send_len; - - NTSTATUS status = NtRequestWaitReplyPort(m->PortHandle, (PORT_MESSAGE*)RequestBuff, (PORT_MESSAGE*)ResponseBuff); - - if (!NT_SUCCESS(status)) - { - NtClose(m->PortHandle); - m->PortHandle = NULL; - return SB_ERR(CSbieAPI::tr("request %1").arg(status, 8, 16), status); // 2203 - } - - if (BuffLen && ResHeader->u1.s1.DataLength) - return SB_ERR(CSbieAPI::tr("early reply")); // 2203 - } - - // the last call to NtRequestWaitReplyPort should return the first chunk of the reply - if (ResHeader->u1.s1.DataLength >= sizeof(MSG_HEADER)) - { - if (ResData[3] != CurSeqNumber) - return SB_ERR(CSbieAPI::tr("mismatched reply")); // 2203 - - // clear highest byte of the size filed - ResData[3] = 0; - BuffLen = ((MSG_HEADER*)ResData)->length; - } - else - BuffLen = 0; - if (BuffLen == 0) - return SB_ERR(CSbieAPI::tr("null reply (msg %1 len %2)").arg(req->msgid, 8, 16).arg(req->length)); // 2203 - - // read remining chunks - rpl = (MSG_HEADER*)malloc(BuffLen); - Buffer = (UCHAR*)rpl; - for (;;) - { - NTSTATUS status; - if (ResHeader->u1.s1.DataLength > BuffLen) - status = STATUS_PORT_MESSAGE_TOO_LONG; - else - { - // get data - memcpy(Buffer, ResData, ResHeader->u1.s1.DataLength); - - // adcance position - Buffer += ResHeader->u1.s1.DataLength; - BuffLen -= ResHeader->u1.s1.DataLength; - - // are we done yet? - if (!BuffLen) - break; - - // set header - memset(ReqHeader, 0, m->SizeofPortMsg); - ReqHeader->u1.s1.TotalLength = (USHORT)m->SizeofPortMsg; - - status = NtRequestWaitReplyPort(m->PortHandle, (PORT_MESSAGE*)RequestBuff, (PORT_MESSAGE*)ResponseBuff); - } - - if (!NT_SUCCESS(status)) - { - free(rpl); - rpl = NULL; - - NtClose(m->PortHandle); - m->PortHandle = NULL; - return SB_ERR(CSbieAPI::tr("reply %1").arg(status, 8, 16), status); // 2203 - } - } - - return SB_OK; -} - -SB_STATUS CSbieAPI__SbieIniSet(SSbieAPI* m, void *RequestBuf, WCHAR *pPasswordWithinRequestBuf, const QString& SectionName, const QString& SettingName) -{ - m->Password.toWCharArray(pPasswordWithinRequestBuf); // fix-me: potential overflow + m->Password.toWCharArray((WCHAR*)pPasswordWithinRequestBuf); // fix-me: potential overflow MSG_HEADER *rpl = NULL; - SB_STATUS Status = CSbieAPI__CallServer(m, (MSG_HEADER *)RequestBuf, rpl); + SB_STATUS Status = CSbieAPI::CallServer((MSG_HEADER *)RequestBuf, &rpl); SecureZeroMemory(pPasswordWithinRequestBuf, sizeof(WCHAR) * 64); if (!Status || !rpl) return Status; @@ -532,7 +664,7 @@ SB_STATUS CSbieAPI::SbieIniSet(const QString& Section, const QString& Setting, c req->h.msgid = msgid; req->h.length = sizeof(SBIE_INI_SETTING_REQ) + req->value_len * sizeof(WCHAR); - SB_STATUS Status = CSbieAPI__SbieIniSet(m, req, req->password, Section, Setting); + SB_STATUS Status = SbieIniSet(req, req->password, Section, Setting); if (!Status) emit LogMessage(tr("Failed to communicate with Sandboxie Service: %1").arg(Status.GetText())); free(req); @@ -713,8 +845,10 @@ SB_STATUS CSbieAPI::UpdateProcesses(bool bKeep, const CSandBoxPtr& pBox) pBox->m_ProcessList.remove(pProcess->m_ProcessId); m_BoxedProxesses.remove(pProcess->m_ProcessId); } - else if (!pProcess->IsTerminated()) + else if (!pProcess->IsTerminated()) { pProcess->SetTerminated(); + m_BoxedProxesses.remove(pProcess->m_ProcessId); + } } return SB_OK; @@ -821,7 +955,7 @@ SB_STATUS CSbieAPI::TerminateAll(const QString& BoxName) req.boxname[BoxName.size()] = L'\0'; MSG_HEADER *rpl = NULL; - SB_STATUS Status = CSbieAPI__CallServer(m, &req.h, rpl); + SB_STATUS Status = CSbieAPI::CallServer(&req.h, &rpl); if (!Status) emit LogMessage(tr("Failed to communicate with Sandboxie Service: %1").arg(Status.GetText())); if (!Status || !rpl) @@ -834,9 +968,12 @@ SB_STATUS CSbieAPI::TerminateAll(const QString& BoxName) SB_STATUS CSbieAPI::TerminateAll() { - foreach(const CSandBoxPtr& pBox, m_SandBoxes) - pBox->TerminateAll(); - return SB_OK; + SB_STATUS Status = SB_OK; + foreach(const CSandBoxPtr& pBox, m_SandBoxes) { + if (!pBox->TerminateAll()) + Status = SB_ERR(tr("Failed to terminate all processes")); + } + return Status; } SB_STATUS CSbieAPI::Terminate(quint64 ProcessId) @@ -847,7 +984,7 @@ SB_STATUS CSbieAPI::Terminate(quint64 ProcessId) req.pid = ProcessId; MSG_HEADER *rpl = NULL; - SB_STATUS Status = CSbieAPI__CallServer(m, &req.h, rpl); + SB_STATUS Status = CSbieAPI::CallServer(&req.h, &rpl); if (!Status) emit LogMessage(tr("Failed to communicate with Sandboxie Service: %1").arg(Status.GetText())); if (!Status || !rpl) @@ -1012,7 +1149,7 @@ SB_STATUS CSbieAPI::RunSandboxed(const QString& BoxName, const QString& Command, *ptr++ = L'\0'; PROCESS_RUN_SANDBOXED_RPL *rpl; - SB_STATUS Status = CSbieAPI__CallServer(m, &req->h, (MSG_HEADER*&)rpl); + SB_STATUS Status = CSbieAPI::CallServer(&req->h, &rpl); free(req); if (!Status) emit LogMessage(tr("Failed to communicate with Sandboxie Service: %1").arg(Status.GetText())); @@ -1055,6 +1192,8 @@ SB_STATUS CSbieAPI::ReloadConfig(quint32 SessionId) NTSTATUS status = m->IoControl(parms); if (!NT_SUCCESS(status)) return SB_ERR(status); + + emit LogMessage("Sandboxie config has been reloaded."); return SB_OK; } diff --git a/SandboxiePlus/QSbieAPI/SbieAPI.h b/SandboxiePlus/QSbieAPI/SbieAPI.h index 8caaa59835..83402e924a 100644 --- a/SandboxiePlus/QSbieAPI/SbieAPI.h +++ b/SandboxiePlus/QSbieAPI/SbieAPI.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include "qsbieapi_global.h" @@ -61,11 +62,14 @@ class QSBIEAPI_EXPORT CSbieAPI : public QThread CSbieAPI(QObject* parent = 0); virtual ~CSbieAPI(); - virtual bool IsValid() const; + virtual SB_STATUS Connect(bool takeOver = false, bool andLoad = true); + virtual SB_STATUS Disconnect(); + virtual bool IsConnected() const; virtual QString GetVersion(); virtual SB_STATUS TakeOver(); + virtual SB_STATUS WatchIni(bool bEnable = true); virtual QString GetSbiePath() const { return m_SbiePath; } virtual QString GetIniPath() const { return m_IniPath; } @@ -81,6 +85,8 @@ class QSBIEAPI_EXPORT CSbieAPI : public QThread virtual QMap GetAllBoxes() { return m_SandBoxes; } + virtual int TotalProcesses() const { return m_BoxedProxesses.count(); } + virtual SB_STATUS TerminateAll(); enum ESetMode @@ -102,18 +108,22 @@ class QSBIEAPI_EXPORT CSbieAPI : public QThread virtual bool IsMonitoring(); virtual QList GetResLog() const { QReadLocker Lock(&m_ResLogMutex); return m_ResLogList; } + virtual void ClearResLog() { QWriteLocker Lock(&m_ResLogMutex); m_ResLogList.clear(); } signals: + void StatusChanged(); void LogMessage(const QString& Message); private slots: //virtual void OnMonitorEntry(quint64 ProcessId, quint32 Type, const QString& Value); + virtual void OnIniChanged(const QString &path); protected: friend class CSandBox; friend class CBoxedProcess; virtual QString GetSbieHome() const; + virtual QString GetIniPath(bool* IsHome) const; virtual SB_STATUS RunStart(const QString& BoxName, const QString& Command); @@ -147,8 +157,15 @@ private slots: QString m_SbiePath; QString m_IniPath; + QFileSystemWatcher m_IniWatcher; bool m_bTerminate; + private: + mutable QMutex m_ThreadMutex; + mutable QWaitCondition m_ThreadWait; + + SB_STATUS CallServer(void* req, void* rpl) const; + SB_STATUS SbieIniSet(void *RequestBuf, void *pPasswordWithinRequestBuf, const QString& SectionName, const QString& SettingName); struct SSbieAPI* m; }; diff --git a/SandboxiePlus/QSbieAPI/SbieDefs.h b/SandboxiePlus/QSbieAPI/SbieDefs.h new file mode 100644 index 0000000000..d2636515ce --- /dev/null +++ b/SandboxiePlus/QSbieAPI/SbieDefs.h @@ -0,0 +1,20 @@ +#pragma once + +#define SANDBOXIE L"Sandboxie" + +#define REQUEST_LEN 4096 +#define CONF_LINE_LEN 2000 + +#define SBIESVC_PORT L"\\RPC Control\\SbieSvcPort" + +//#define SANDBOXIE_INI L"Sandboxie.ini" + +#define SBIEDRV L"SbieDrv" +#define SBIEDRV_SYS L"SbieDrv.sys" + +#define SBIESVC L"SbieSvc" +#define SBIESVC_EXE L"SbieSvc.exe" + +#define SBIESTART_EXE L"Start.exe" + +#define SBIEMSG_DLL L"SbieMsg.dll" diff --git a/SandboxiePlus/QSbieAPI/SbieError.h b/SandboxiePlus/QSbieAPI/SbieError.h index c096cbc2ba..d7ae37d850 100644 --- a/SandboxiePlus/QSbieAPI/SbieError.h +++ b/SandboxiePlus/QSbieAPI/SbieError.h @@ -1,5 +1,8 @@ #pragma once +#define ERROR_OK (1) +#define OP_ASYNC (2) + class CSbieError { public: diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.cpp b/SandboxiePlus/QSbieAPI/SbieUtils.cpp new file mode 100644 index 0000000000..282178b907 --- /dev/null +++ b/SandboxiePlus/QSbieAPI/SbieUtils.cpp @@ -0,0 +1,182 @@ +#include "stdafx.h" +#include "SbieUtils.h" +#include + +#include +#define WIN32_NO_STATUS +typedef long NTSTATUS; + +#include +#include "SbieDefs.h" + +#include "..\..\Sandboxie\common\win32_ntddk.h" + +int GetServiceStatus(const wchar_t* name) +{ + SC_HANDLE scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_ENUMERATE_SERVICE); + if (!scm) + return -1; + + SC_HANDLE service = OpenService(scm, name, SERVICE_QUERY_STATUS); + if (!service) { + CloseServiceHandle(scm); + return 0; + } + + DWORD dwBytesNeeded; + SERVICE_STATUS_PROCESS sStatus; + BOOL result = QueryServiceStatusEx(service, SC_STATUS_PROCESS_INFO, (LPBYTE)&sStatus, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded); + + CloseServiceHandle(service); + + CloseServiceHandle(scm); + + if (result == 0) + return -1; + return sStatus.dwCurrentState; +} + +bool IsProcessElevatd() +{ + ULONG returnLength; + TOKEN_ELEVATION elevation; + if (NT_SUCCESS(NtQueryInformationToken(/*NtCurrentProcessToken()*/((HANDLE)(LONG_PTR)-4), TokenElevation, &elevation, sizeof(TOKEN_ELEVATION), &returnLength))) + return !!elevation.TokenIsElevated; + return false; +} + +SB_STATUS CSbieUtils::DoAssist() +{ + QStringList Args = QCoreApplication::arguments(); + int AssistPos = Args.indexOf("-assist"); + if(AssistPos == -1) + return SB_OK; + + SB_STATUS Status = ExecOps(Args.mid(AssistPos + 1)); + if (Status.IsError()) + return Status; + return SB_ERR("OK", ERROR_OK); +} + +SB_STATUS CSbieUtils::Start(EComponent Component) +{ + QStringList Ops; + Install(Component, Ops); + Start(Component, Ops); + return ElevateOps(Ops); +} + +void CSbieUtils::Start(EComponent Component, QStringList& Ops) +{ + if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) != SERVICE_RUNNING) + Ops.append(QString::fromWCharArray(L"start|" SBIEDRV)); + if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) != SERVICE_RUNNING) + Ops.append(QString::fromWCharArray(L"start|" SBIESVC)); +} + +SB_STATUS CSbieUtils::Stop(EComponent Component) +{ + QStringList Ops; + Stop(Component, Ops); + return ElevateOps(Ops); +} + +void CSbieUtils::Stop(EComponent Component, QStringList& Ops) +{ + if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) != SERVICE_STOPPED) + Ops.append(QString::fromWCharArray(L"stop|" SBIESVC)); + if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) != SERVICE_STOPPED) + Ops.append(QString::fromWCharArray(L"stop|" SBIEDRV)); +} + +bool CSbieUtils::IsRunning(EComponent Component) +{ + if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) != SERVICE_RUNNING) + return false; + if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) != SERVICE_RUNNING) + return false; + return true; +} + +SB_STATUS CSbieUtils::Install(EComponent Component) +{ + QStringList Ops; + Install(Component, Ops); + return ElevateOps(Ops); +} + +void CSbieUtils::Install(EComponent Component, QStringList& Ops) +{ + QString HomePath = QCoreApplication::applicationDirPath().replace("/", "\\"); // "C:\\Program Files\\Sandboxie " + if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) == 0) + Ops.append(QString::fromWCharArray(L"install|" SBIEDRV L"|") + "\"" + HomePath + "\\" + QString::fromWCharArray(SBIEDRV_SYS) + "\"" + "|type=kernel|start=demand|altitude=86900"); + if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) == 0) + Ops.append(QString::fromWCharArray(L"install|" SBIESVC L"|") + "\"" + HomePath + "\\" + QString::fromWCharArray(SBIESVC_EXE) + "\"" + "|type=own|start=auto|display=\"Sandboxie Service\"|group=UIGroup"); +} + +SB_STATUS CSbieUtils::Uninstall(EComponent Component) +{ + QStringList Ops; + Stop(Component, Ops); + Uninstall(Component, Ops); + return ElevateOps(Ops); +} + +void CSbieUtils::Uninstall(EComponent Component, QStringList& Ops) +{ + if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) != 0) + Ops.append(QString::fromWCharArray(L"delete|" SBIESVC)); + if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) != 0) + Ops.append(QString::fromWCharArray(L"delete|" SBIEDRV)); +} + +bool CSbieUtils::IsInstalled(EComponent Component) +{ + if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) == 0) + return false; + if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) == 0) + return false; + return true; +} + +SB_STATUS CSbieUtils::ElevateOps(const QStringList& Ops) +{ + if (Ops.isEmpty()) + return SB_OK; + + if (IsProcessElevatd()) + return ExecOps(Ops); + + wstring path = QCoreApplication::applicationFilePath().toStdWString(); + wstring params = L"-assist " + Ops.join(" ").toStdWString(); + + SHELLEXECUTEINFO shex; + memset(&shex, 0, sizeof(SHELLEXECUTEINFO)); + shex.cbSize = sizeof(SHELLEXECUTEINFO); + shex.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI; + shex.hwnd = NULL; + shex.lpFile = path.c_str(); + shex.lpParameters = params.c_str(); + shex.nShow = SW_SHOWNORMAL; + shex.lpVerb = L"runas"; + + if (!ShellExecuteEx(&shex)) + return SB_ERR("Admin rights required"); + return SB_ERR(OP_ASYNC); +} + +SB_STATUS CSbieUtils::ExecOps(const QStringList& Ops) +{ + foreach(const QString& Op, Ops) + { + QStringList Args = Op.split("|"); + + QProcess Proc; + Proc.execute("kmdutil.exe", Args); + Proc.waitForFinished(); + int ret = Proc.exitCode(); + if (ret != 0) + return SB_ERR("Failed to execute: " + Args.join(" ")); + } + return SB_OK; +} \ No newline at end of file diff --git a/SandboxiePlus/QSbieAPI/SbieUtils.h b/SandboxiePlus/QSbieAPI/SbieUtils.h new file mode 100644 index 0000000000..993e45944f --- /dev/null +++ b/SandboxiePlus/QSbieAPI/SbieUtils.h @@ -0,0 +1,39 @@ +#pragma once + +#include "qsbieapi_global.h" + +#include "SbieError.h" + +class QSBIEAPI_EXPORT CSbieUtils +{ +public: + + enum EComponent + { + eNone = 0, + eDriver = 0x01, + eService = 0x02, + eAll = 0xFF + }; + + static SB_STATUS DoAssist(); + + static SB_STATUS Start(EComponent Component); + static SB_STATUS Stop(EComponent Component); + static bool IsRunning(EComponent Component); + + static SB_STATUS Install(EComponent Component); + static SB_STATUS Uninstall(EComponent Component); + static bool IsInstalled(EComponent Component); + +private: + static SB_STATUS ElevateOps(const QStringList& Ops); + static SB_STATUS ExecOps(const QStringList& Ops); + + static void Start(EComponent Component, QStringList& Ops); + static void Stop(EComponent Component, QStringList& Ops); + + static void Install(EComponent Component, QStringList& Ops); + static void Uninstall(EComponent Component, QStringList& Ops); +}; + diff --git a/SandboxiePlus/QtSingleApp/INSTALL.TXT b/SandboxiePlus/QtSingleApp/INSTALL.TXT new file mode 100644 index 0000000000..bbb74a9d1f --- /dev/null +++ b/SandboxiePlus/QtSingleApp/INSTALL.TXT @@ -0,0 +1,254 @@ +INSTALLATION INSTRUCTIONS + +These instructions refer to the package you are installing as +some-package.tar.gz or some-package.zip. The .zip file is intended for use +on Windows. + +The directory you choose for the installation will be referred to as +your-install-dir. + +Note to Qt Visual Studio Integration users: In the instructions below, +instead of building from command line with nmake, you can use the menu +command 'Qt->Open Solution from .pro file' on the .pro files in the +example and plugin directories, and then build from within Visual +Studio. + +Unpacking and installation +-------------------------- + +1. Unpacking the archive (if you have not done so already). + + On Unix and Mac OS X (in a terminal window): + + cd your-install-dir + gunzip some-package.tar.gz + tar xvf some-package.tar + + This creates the subdirectory some-package containing the files. + + On Windows: + + Unpack the .zip archive by right-clicking it in explorer and + choosing "Extract All...". If your version of Windows does not + have zip support, you can use the infozip tools available + from www.info-zip.org. + + If you are using the infozip tools (in a command prompt window): + cd your-install-dir + unzip some-package.zip + +2. Configuring the package. + + The configure script is called "configure" on unix/mac and + "configure.bat" on Windows. It should be run from a command line + after cd'ing to the package directory. + + You can choose whether you want to use the component by including + its source code directly into your project, or build the component + as a dynamic shared library (DLL) that is loaded into the + application at run-time. The latter may be preferable for + technical or licensing (LGPL) reasons. If you want to build a DLL, + run the configure script with the argument "-library". Also see + the note about usage below. + + (Components that are Qt plugins, e.g. styles and image formats, + are by default built as a plugin DLL.) + + The configure script will prompt you in some cases for further + information. Answer these questions and carefully read the license text + before accepting the license conditions. The package cannot be used if + you do not accept the license conditions. + +3. Building the component and examples (when required). + + If a DLL is to be built, or if you would like to build the + examples, next give the commands + + qmake + make [or nmake if your are using Microsoft Visual C++] + + The example program(s) can be found in the directory called + "examples" or "example". + + Components that are Qt plugins, e.g. styles and image formats, are + ready to be used as soon as they are built, so the rest of this + installation instruction can be skipped. + +4. Building the Qt Designer plugin (optional). + + Some of the widget components are provided with plugins for Qt + Designer. To build and install the plugin, cd into the + some-package/plugin directory and give the commands + + qmake + make [or nmake if your are using Microsoft Visual C++] + + Restart Qt Designer to make it load the new widget plugin. + + Note: If you are using the built-in Qt Designer from the Qt Visual + Studio Integration, you will need to manually copy the plugin DLL + file, i.e. copy + %QTDIR%\plugins\designer\some-component.dll + to the Qt Visual Studio Integration plugin path, typically: + C:\Program Files\Trolltech\Qt VS Integration\plugins + + Note: If you for some reason are using a Qt Designer that is built + in debug mode, you will need to build the plugin in debug mode + also. Edit the file plugin.pro in the plugin directory, changing + 'release' to 'debug' in the CONFIG line, before running qmake. + + + +Solutions components are intended to be used directly from the package +directory during development, so there is no 'make install' procedure. + + +Using a component in your project +--------------------------------- + +To use this component in your project, add the following line to the +project's .pro file (or do the equivalent in your IDE): + + include(your-install-dir/some-package/src/some-package.pri) + +This adds the package's sources and headers to the SOURCES and HEADERS +project variables respectively (or, if the component has been +configured as a DLL, it adds that library to the LIBS variable), and +updates INCLUDEPATH to contain the package's src +directory. Additionally, the .pri file may include some dependencies +needed by the package. + +To include a header file from the package in your sources, you can now +simply use: + + #include + +or alternatively, in pre-Qt 4 style: + + #include + +Refer to the documentation to see the classes and headers this +components provides. + + + +Install documentation (optional) +-------------------------------- + +The HTML documentation for the package's classes is located in the +your-install-dir/some-package/doc/html/index.html. You can open this +file and read the documentation with any web browser. + +To install the documentation into Qt Assistant (for Qt version 4.4 and +later): + +1. In Assistant, open the Edit->Preferences dialog and choose the + Documentation tab. Click the Add... button and select the file + your-install-dir/some-package/doc/html/some-package.qch + +For Qt versions prior to 4.4, do instead the following: + +1. The directory your-install-dir/some-package/doc/html contains a + file called some-package.dcf. Execute the following commands in a + shell, command prompt or terminal window: + + cd your-install-dir/some-package/doc/html/ + assistant -addContentFile some-package.dcf + +The next time you start Qt Assistant, you can access the package's +documentation. + + +Removing the documentation from assistant +----------------------------------------- + +If you have installed the documentation into Qt Assistant, and want to uninstall it, do as follows, for Qt version 4.4 and later: + +1. In Assistant, open the Edit->Preferences dialog and choose the + Documentation tab. In the list of Registered Documentation, select + the item com.nokia.qtsolutions.some-package_version, and click + the Remove button. + +For Qt versions prior to 4.4, do instead the following: + +1. The directory your-install-dir/some-package/doc/html contains a + file called some-package.dcf. Execute the following commands in a + shell, command prompt or terminal window: + + cd your-install-dir/some-package/doc/html/ + assistant -removeContentFile some-package.dcf + + + +Using the component as a DLL +---------------------------- + +1. Normal components + + The shared library (DLL) is built and placed in the + some-package/lib directory. It is intended to be used directly + from there during development. When appropriate, both debug and + release versions are built, since the run-time linker will in some + cases refuse to load a debug-built DLL into a release-built + application or vice versa. + + The following steps are taken by default to help the dynamic + linker to locate the DLL at run-time (during development): + + Unix: The some-package.pri file will add linker instructions to + add the some-package/lib directory to the rpath of the + executable. (When distributing, or if your system does not support + rpath, you can copy the shared library to another place that is + searched by the dynamic linker, e.g. the "lib" directory of your + Qt installation.) + + Mac: The full path to the library is hardcoded into the library + itself, from where it is copied into the executable at link time, + and ready by the dynamic linker at run-time. (When distributing, + you will want to edit these hardcoded paths in the same way as for + the Qt DLLs. Refer to the document "Deploying an Application on + Mac OS X" in the Qt Reference Documentation.) + + Windows: the .dll file(s) are copied into the "bin" directory of + your Qt installation. The Qt installation will already have set up + that directory to be searched by the dynamic linker. + + +2. Plugins + + For Qt Solutions plugins (e.g. image formats), both debug and + release versions of the plugin are built by default when + appropriate, since in some cases the release Qt library will not + load a debug plugin, and vice versa. The plugins are automatically + copied into the plugins directory of your Qt installation when + built, so no further setup is required. + + Plugins may also be built statically, i.e. as a library that will be + linked into your application executable, and so will not need to + be redistributed as a separate plugin DLL to end users. Static + building is required if Qt itself is built statically. To do it, + just add "static" to the CONFIG variable in the plugin/plugin.pro + file before building. Refer to the "Static Plugins" section in the + chapter "How to Create Qt Plugins" for explanation of how to use a + static plugin in your application. The source code of the example + program(s) will also typically contain the relevant instructions + as comments. + + + +Uninstalling +------------ + + The following command will remove any fils that have been + automatically placed outside the package directory itself during + installation and building + + make distclean [or nmake if your are using Microsoft Visual C++] + + If Qt Assistant documentation or Qt Designer plugins have been + installed, they can be uninstalled manually, ref. above. + + +Enjoy! :) + +- The Qt Solutions Team. diff --git a/SandboxiePlus/QtSingleApp/README.TXT b/SandboxiePlus/QtSingleApp/README.TXT new file mode 100644 index 0000000000..06abb09559 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/README.TXT @@ -0,0 +1,33 @@ +Qt Solutions Component: Single Application + +The QtSingleApplication component provides support for +applications that can be only started once per user. + + + +Version history: + +2.0: - Version 1.3 ported to Qt 4. + +2.1: - Fix compilation problem on Mac. + +2.2: - Really fix the Mac compilation problem. + - Mac: fix crash due to wrong object releasing. + - Mac: Fix memory leak. + +2.3: - Windows: Force creation of internal widget to make it work + with Qt 4.2. + +2.4: - Fix the system for automatic window raising on message + reception. NOTE: minor API change. + +2.5: - Mac: Fix isRunning() to work and report correctly. + +2.6: - - initialize() is now obsolete, no longer necessary to call + it + - - Fixed race condition where multiple instances migth be started + - - QtSingleCoreApplication variant provided for non-GUI (console) + usage + - Complete reimplementation. Visible changes: + - LGPL release. + diff --git a/SandboxiePlus/QtSingleApp/buildlib/buildlib.pro b/SandboxiePlus/QtSingleApp/buildlib/buildlib.pro new file mode 100644 index 0000000000..37dddcdaa0 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/buildlib/buildlib.pro @@ -0,0 +1,13 @@ +TEMPLATE=lib +CONFIG += qt dll qtsingleapplication-buildlib +mac:CONFIG += absolute_library_soname +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all +include(../src/qtsingleapplication.pri) +TARGET = $$QTSINGLEAPPLICATION_LIBNAME +DESTDIR = $$QTSINGLEAPPLICATION_LIBDIR +win32 { + DLLDESTDIR = $$[QT_INSTALL_BINS] + QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${QTSINGLEAPPLICATION_LIBNAME}.dll +} +target.path = $$DESTDIR +INSTALLS += target diff --git a/SandboxiePlus/QtSingleApp/common.pri b/SandboxiePlus/QtSingleApp/common.pri new file mode 100644 index 0000000000..bae27173d5 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/common.pri @@ -0,0 +1,6 @@ +exists(config.pri):infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtsingleapplication-uselib +TEMPLATE += fakelib +QTSINGLEAPPLICATION_LIBNAME = $$qtLibraryTarget(QtSolutions_SingleApplication-head) +TEMPLATE -= fakelib +QTSINGLEAPPLICATION_LIBDIR = $$PWD/lib +unix:qtsingleapplication-uselib:!qtsingleapplication-buildlib:QMAKE_RPATHDIR += $$QTSINGLEAPPLICATION_LIBDIR diff --git a/SandboxiePlus/QtSingleApp/configure b/SandboxiePlus/QtSingleApp/configure new file mode 100644 index 0000000000..3c4edfff2b --- /dev/null +++ b/SandboxiePlus/QtSingleApp/configure @@ -0,0 +1,25 @@ +#!/bin/sh + +if [ "x$1" != "x" -a "x$1" != "x-library" ]; then + echo "Usage: $0 [-library]" + echo + echo "-library: Build the component as a dynamic library (DLL). Default is to" + echo " include the component source code directly in the application." + echo + exit 0 +fi + +rm -f config.pri +if [ "x$1" = "x-library" ]; then + echo "Configuring to build this component as a dynamic library." + echo "SOLUTIONS_LIBRARY = yes" > config.pri +fi + +echo +echo "This component is now configured." +echo +echo "To build the component library (if requested) and example(s)," +echo "run qmake and your make command." +echo +echo "To remove or reconfigure, run make distclean." +echo diff --git a/SandboxiePlus/QtSingleApp/configure.bat b/SandboxiePlus/QtSingleApp/configure.bat new file mode 100644 index 0000000000..69efec3520 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/configure.bat @@ -0,0 +1,80 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +:: Contact: http://www.qt-project.org/legal +:: +:: This file is part of the Qt Solutions component. +:: +:: $QT_BEGIN_LICENSE:BSD$ +:: You may use this file under the terms of the BSD license as follows: +:: +:: "Redistribution and use in source and binary forms, with or without +:: modification, are permitted provided that the following conditions are +:: met: +:: * Redistributions of source code must retain the above copyright +:: notice, this list of conditions and the following disclaimer. +:: * Redistributions in binary form must reproduce the above copyright +:: notice, this list of conditions and the following disclaimer in +:: the documentation and/or other materials provided with the +:: distribution. +:: * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +:: of its contributors may be used to endorse or promote products derived +:: from this software without specific prior written permission. +:: +:: +:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +:: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +:: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +:: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +:: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +:: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +:: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +:: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +:: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +:: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +:: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +:: +:: $QT_END_LICENSE$ +:: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +@echo off + +rem +rem "Main" +rem + +if not "%1"=="" ( + if not "%1"=="-library" ( + call :PrintUsage + goto EOF + ) +) + +if exist config.pri. del config.pri +if "%1"=="-library" ( + echo Configuring to build this component as a dynamic library. + echo SOLUTIONS_LIBRARY = yes > config.pri +) + +echo . +echo This component is now configured. +echo . +echo To build the component library (if requested) and example(s), +echo run qmake and your make or nmake command. +echo . +echo To remove or reconfigure, run make (nmake) distclean. +echo . +goto EOF + +:PrintUsage +echo Usage: configure.bat [-library] +echo . +echo -library: Build the component as a dynamic library (DLL). Default is to +echo include the component source directly in the application. +echo A DLL may be preferable for technical or licensing (LGPL) reasons. +echo . +goto EOF + + +:EOF diff --git a/SandboxiePlus/QtSingleApp/doc/html/classic.css b/SandboxiePlus/QtSingleApp/doc/html/classic.css new file mode 100644 index 0000000000..b8cae8e1ed --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/classic.css @@ -0,0 +1,284 @@ +BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { + font-family: Arial, Geneva, Helvetica, sans-serif; +} +H1 { + text-align: center; + font-size: 160%; +} +H2 { + font-size: 120%; +} +H3 { + font-size: 100%; +} + +h3.fn,span.fn +{ + background-color: #eee; + border-width: 1px; + border-style: solid; + border-color: #ddd; + font-weight: bold; + padding: 6px 0px 6px 10px; + margin: 42px 0px 0px 0px; +} + +hr { + border: 0; + color: #a0a0a0; + background-color: #ccc; + height: 1px; + width: 100%; + text-align: left; + margin: 34px 0px 34px 0px; +} + +table.valuelist { + border-width: 1px 1px 1px 1px; + border-style: solid; + border-color: #dddddd; + border-collapse: collapse; + background-color: #f0f0f0; +} + +table.indextable { + border-width: 1px 1px 1px 1px; + border-style: solid; + border-collapse: collapse; + background-color: #f0f0f0; + border-color:#555; + font-size: 100%; +} + +table td.largeindex { + border-width: 1px 1px 1px 1px; + border-collapse: collapse; + background-color: #f0f0f0; + border-color:#555; + font-size: 120%; +} + +table.valuelist th { + border-width: 1px 1px 1px 2px; + padding: 4px; + border-style: solid; + border-color: #666; + color:white; + background-color:#666; +} + +th.titleheader { + border-width: 1px 0px 1px 0px; + padding: 2px; + border-style: solid; + border-color: #666; + color:white; + background-color:#555; + background-image:url('images/gradient.png')}; + background-repeat: repeat-x; + font-size: 100%; +} + + +th.largeheader { + border-width: 1px 0px 1px 0px; + padding: 4px; + border-style: solid; + border-color: #444; + color:white; + background-color:#555555; + font-size: 120%; +} + +p { + + margin-left: 4px; + margin-top: 8px; + margin-bottom: 8px; +} + +a:link +{ + color: #0046ad; + text-decoration: none +} + +a:visited +{ + color: #672967; + text-decoration: none +} + +a.obsolete +{ + color: #661100; + text-decoration: none +} + +a.compat +{ + color: #661100; + text-decoration: none +} + +a.obsolete:visited +{ + color: #995500; + text-decoration: none +} + +a.compat:visited +{ + color: #995500; + text-decoration: none +} + +body +{ + background: #ffffff; + color: black +} + +table.generic, table.annotated +{ + border-width: 1px; + border-color:#bbb; + border-style:solid; + border-collapse:collapse; +} + +table td.memItemLeft { + width: 180px; + padding: 2px 0px 0px 8px; + margin: 4px; + border-width: 1px; + border-color: #E0E0E0; + border-style: none; + font-size: 100%; + white-space: nowrap +} + +table td.memItemRight { + padding: 2px 8px 0px 8px; + margin: 4px; + border-width: 1px; + border-color: #E0E0E0; + border-style: none; + font-size: 100%; +} + +table tr.odd { + background: #f0f0f0; + color: black; +} + +table tr.even { + background: #e4e4e4; + color: black; +} + +table.annotated th { + padding: 3px; + text-align: left +} + +table.annotated td { + padding: 3px; +} + +table tr pre +{ + padding-top: 0px; + padding-bottom: 0px; + padding-left: 0px; + padding-right: 0px; + border: none; + background: none +} + +tr.qt-style +{ + background: #96E066; + color: black +} + +body pre +{ + padding: 0.2em; + border: #e7e7e7 1px solid; + background: #f1f1f1; + color: black +} + +table tr.qt-code pre +{ + padding: 0.2em; + border: #e7e7e7 1px solid; + background: #f1f1f1; + color: black +} + +span.preprocessor, span.preprocessor a +{ + color: darkblue; +} + +span.comment +{ + color: darkred; + font-style: italic +} + +span.string,span.char +{ + color: darkgreen; +} + +.title +{ + text-align: center +} + +.subtitle +{ + font-size: 0.8em +} + +.small-subtitle +{ + font-size: 0.65em +} + +.qmlitem { + padding: 0; +} + +.qmlname { + white-space: nowrap; +} + +.qmltype { + text-align: center; + font-size: 160%; +} + +.qmlproto { + background-color: #eee; + border-width: 1px; + border-style: solid; + border-color: #ddd; + font-weight: bold; + padding: 6px 10px 6px 10px; + margin: 42px 0px 0px 0px; +} + +.qmlreadonly { + float: right; + color: red +} + +.qmldoc { +} + +*.qmlitem p { +} diff --git a/SandboxiePlus/QtSingleApp/doc/html/images/qt-logo.png b/SandboxiePlus/QtSingleApp/doc/html/images/qt-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..794162f5af58e7b38beebf472842fc9703ede19b GIT binary patch literal 4075 zcmb7H30qUw7R5$_N(2N2A__tfM8-gsp~yw0Ae4$j8GNEd2*JKmajJr%mxxR@0%4Fz zh&Z7IL~)=h5Fh~p1k*Z!Q$rYws0mUD$xZHghoL{<@qG#R<9@8O_u6}}y-voqt$vFa zEnlRep|RM1i_Z@D+Z}#3FZc?6-{g7xqM@N%>+iGihxm(;DgY3k-aPn11Axfo`?a#C zAK~-zfCHNU|HHlK<;yfyk@$a{ZO2UtDrwAOWqQqF>+KCnlgTxU%*`*|IM=l`i8yl@ zKf*|b$+MVjW(ND93}8Tt@DL)A=u5Op*Saz6YdjlB%g9R<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fn8t~ ziA4$|31yN=F2Hdd8*@GSTQWN(qt&Og{Pl@N&=A6(+d32|NV9~rd<;pi%Q&!n^TjT{ zz{17?S~;;J7lDp`I(`fqRW28WNNTB3tbXeGwDS>X{6cat072$%rcoe+7c)w3* zdP+9npWyLl-7$3>a4$Ht)4Moy zS8?dZv)|>cj9Q*^)rM9(H(K>CnHdX@WWEPTD)-(ovehhtMPJB_*5K-xs|kfmrZ?R5 q^n7^PJomUfU@U$1kN?*do1n4%(BY1g{cSVe#sAx_KDRc}&ioHDn>RrK literal 0 HcmV?d00001 diff --git a/SandboxiePlus/QtSingleApp/doc/html/index.html b/SandboxiePlus/QtSingleApp/doc/html/index.html new file mode 100644 index 0000000000..af9dab10a9 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/index.html @@ -0,0 +1,48 @@ + + + + + + Single Application + + + + + + + +
  Home

Single Application
+

+ +

Description

+

The QtSingleApplication component provides support for applications that can be only started once per user.

+

For some applications it is useful or even critical that they are started only once by any user. Future attempts to start the application should activate any already running instance, and possibly perform requested actions, e.g. loading a file, in that instance.

+

The QtSingleApplication class provides an interface to detect a running instance, and to send command strings to that instance. For console (non-GUI) applications, the QtSingleCoreApplication variant is provided, which avoids dependency on QtGui.

+ +

Classes

+ + +

Examples

+ + +

Tested platforms

+
    +
  • Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005
  • +
  • Qt 4.4, 4.5 / Linux / gcc
  • +
  • Qt 4.4, 4.5 / MacOS X 10.5 / gcc
  • +
+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-loader.html b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-loader.html new file mode 100644 index 0000000000..6a3663298c --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-loader.html @@ -0,0 +1,175 @@ + + + + + + Loading Documents + + + + + + + +
  Home

Loading Documents
+

+

The application in this example loads or prints the documents passed as commandline parameters to further instances of this application.

+
 /****************************************************************************
+ **
+ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the Qt Solutions component.
+ **
+ ** You may use this file under the terms of the BSD license as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ **   * Redistributions of source code must retain the above copyright
+ **     notice, this list of conditions and the following disclaimer.
+ **   * Redistributions in binary form must reproduce the above copyright
+ **     notice, this list of conditions and the following disclaimer in
+ **     the documentation and/or other materials provided with the
+ **     distribution.
+ **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+ **     the names of its contributors may be used to endorse or promote
+ **     products derived from this software without specific prior written
+ **     permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ **
+ ****************************************************************************/
+
+ #include <qtsingleapplication.h>
+ #include <QtCore/QFile>
+ #include <QtGui/QMainWindow>
+ #include <QtGui/QPrinter>
+ #include <QtGui/QPainter>
+ #include <QtGui/QTextEdit>
+ #include <QtGui/QMdiArea>
+ #include <QtCore/QTextStream>
+
+ class MainWindow : public QMainWindow
+ {
+     Q_OBJECT
+ public:
+     MainWindow();
+
+ public slots:
+     void handleMessage(const QString& message);
+
+ signals:
+     void needToShow();
+
+ private:
+     QMdiArea *workspace;
+ };
+

The user interface in this application is a QMainWindow subclass with a QMdiArea as the central widget. It implements a slot handleMessage() that will be connected to the messageReceived() signal of the QtSingleApplication class.

+
 MainWindow::MainWindow()
+ {
+     workspace = new QMdiArea(this);
+
+     setCentralWidget(workspace);
+ }
+

The MainWindow constructor creates a minimal user interface.

+
 void MainWindow::handleMessage(const QString& message)
+ {
+     enum Action {
+         Nothing,
+         Open,
+         Print
+     } action;
+
+     action = Nothing;
+     QString filename = message;
+     if (message.toLower().startsWith("/print ")) {
+         filename = filename.mid(7);
+         action = Print;
+     } else if (!message.isEmpty()) {
+         action = Open;
+     }
+     if (action == Nothing) {
+         emit needToShow();
+         return;
+     }
+
+     QFile file(filename);
+     QString contents;
+     if (file.open(QIODevice::ReadOnly))
+         contents = file.readAll();
+     else
+         contents = "[[Error: Could not load file " + filename + "]]";
+
+     QTextEdit *view = new QTextEdit;
+     view->setPlainText(contents);
+
+     switch(action) {
+

The handleMessage() slot interprets the message passed in as a filename that can be prepended with /print to indicate that the file should just be printed rather than loaded.

+
     case Print:
+         {
+             QPrinter printer;
+             view->print(&printer);
+             delete view;
+         }
+         break;
+
+     case Open:
+         {
+             workspace->addSubWindow(view);
+             view->setWindowTitle(message);
+             view->show();
+             emit needToShow();
+         }
+         break;
+     default:
+         break;
+     };
+ }
+

Loading the file will also activate the window.

+
 #include "main.moc"
+
+ int main(int argc, char **argv)
+ {
+     QtSingleApplication instance("File loader QtSingleApplication example", argc, argv);
+     QString message;
+     for (int a = 1; a < argc; ++a) {
+         message += argv[a];
+         if (a < argc-1)
+             message += " ";
+     }
+
+     if (instance.sendMessage(message))
+         return 0;
+

The main entry point function creates a QtSingleApplication object, and creates a message to send to a running instance of the application. If the message was sent successfully the process exits immediately.

+
     MainWindow mw;
+     mw.handleMessage(message);
+     mw.show();
+
+     QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+                      &mw, SLOT(handleMessage(const QString&)));
+
+     instance.setActivationWindow(&mw, false);
+     QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow()));
+
+     return instance.exec();
+ }
+

If the message could not be sent the application starts up. Note that false is passed to the call to setActivationWindow() to prevent automatic activation for every message received, e.g. when the application should just print a file. Instead, the message handling function determines whether activation is requested, and signals that by emitting the needToShow() signal. This is then simply connected directly to QtSingleApplication's activateWindow() slot.

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-trivial.html b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-trivial.html new file mode 100644 index 0000000000..5e60cfa4f5 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-example-trivial.html @@ -0,0 +1,101 @@ + + + + + + A Trivial Example + + + + + + + +
  Home

A Trivial Example
+

+

The application in this example has a log-view that displays messages sent by further instances of the same application.

+

The example demonstrates the use of the QtSingleApplication class to detect and communicate with a running instance of the application using the sendMessage() API. The messageReceived() signal is used to display received messages in a QTextEdit log.

+
 /****************************************************************************
+ **
+ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the Qt Solutions component.
+ **
+ ** You may use this file under the terms of the BSD license as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ **   * Redistributions of source code must retain the above copyright
+ **     notice, this list of conditions and the following disclaimer.
+ **   * Redistributions in binary form must reproduce the above copyright
+ **     notice, this list of conditions and the following disclaimer in
+ **     the documentation and/or other materials provided with the
+ **     distribution.
+ **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+ **     the names of its contributors may be used to endorse or promote
+ **     products derived from this software without specific prior written
+ **     permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ **
+ ****************************************************************************/
+
+ #include <qtsingleapplication.h>
+ #include <QtGui/QTextEdit>
+
+ class TextEdit : public QTextEdit
+ {
+     Q_OBJECT
+ public:
+     TextEdit(QWidget *parent = 0)
+         : QTextEdit(parent)
+     {}
+ public slots:
+     void append(const QString &str)
+     {
+         QTextEdit::append(str);
+     }
+ };
+
+ #include "main.moc"
+
+ int main(int argc, char **argv)
+ {
+     QtSingleApplication instance(argc, argv);
+

The example has only the main entry point function. A QtSingleApplication object is created immediately.

+
     if (instance.sendMessage("Wake up!"))
+         return 0;
+

If another instance of this application is already running, sendMessage() will succeed, and this instance just exits immediately.

+
     TextEdit logview;
+     logview.setReadOnly(true);
+     logview.show();
+

Otherwise the instance continues as normal and creates the user interface.

+
     instance.setActivationWindow(&logview);
+
+     QObject::connect(&instance, SIGNAL(messageReceived(const QString&)),
+                      &logview, SLOT(append(const QString&)));
+
+     return instance.exec();
+

The logview object is also set as the application's activation window. Every time a message is received, the window will be raised and activated automatically.

+

The messageReceived() signal is also connected to the QTextEdit's append() slot. Every message received from further instances of this application will be displayed in the log.

+

Finally the event loop is entered.

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-members.html b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-members.html new file mode 100644 index 0000000000..c995ce3f88 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-members.html @@ -0,0 +1,235 @@ + + + + + + List of All Members for QtSingleApplication + + + + + + + +
  Home

List of All Members for QtSingleApplication

+

This is the complete list of members for QtSingleApplication, including inherited members.

+

+ +
+

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-obsolete.html b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-obsolete.html new file mode 100644 index 0000000000..0d07dfae33 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication-obsolete.html @@ -0,0 +1,31 @@ + + + + + + Obsolete Members for QtSingleApplication + + + + + + + +
  Home

Obsolete Members for QtSingleApplication

+

The following class members are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

+

+

Public Functions

+ + +
void initialize ( bool dummy = true )   (obsolete)
+
+

Member Function Documentation

+

void QtSingleApplication::initialize ( bool dummy = true )

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.dcf b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.dcf new file mode 100644 index 0000000000..d81f87fbb7 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.dcf @@ -0,0 +1,40 @@ + + +
+
+ QtSingleApplication + activateWindow + activationWindow + id + isRunning + messageReceived + sendMessage + setActivationWindow +
+
+
+
+ QtSingleCoreApplication + id + isRunning + messageReceived + sendMessage +
+
+
+
+
+ A non-GUI example +
+
+ A Trivial Example +
+
+ Loading Documents +
+
+ Single Application +
+
+
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.html b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.html new file mode 100644 index 0000000000..2754a3b9ea --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.html @@ -0,0 +1,162 @@ + + + + + + QtSingleApplication Class Reference + + + + + + + +
  Home

QtSingleApplication Class Reference

+

The QtSingleApplication class provides an API to detect and communicate with running instances of an application. More...

+
 #include <QtSingleApplication>

Inherits QApplication.

+ +
+ +

Public Functions

+ + + + + + + + + + + +
QtSingleApplication ( int & argc, char ** argv, bool GUIenabled = true )
QtSingleApplication ( const QString & appId, int & argc, char ** argv )
QtSingleApplication ( int & argc, char ** argv, Type type )
QtSingleApplication ( Display * dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
QtSingleApplication ( Display * dpy, int & argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
QtSingleApplication ( Display * dpy, const QString & appId, int argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )
QWidget * activationWindow () const
QString id () const
bool isRunning ()
void setActivationWindow ( QWidget * aw, bool activateOnMessage = true )
+ +
+ +

Public Slots

+ + + +
void activateWindow ()
bool sendMessage ( const QString & message, int timeout = 5000 )
+ +
+ +

Signals

+ + +
void messageReceived ( const QString & message )
+ +

Additional Inherited Members

+ + +
+

Detailed Description

+

The QtSingleApplication class provides an API to detect and communicate with running instances of an application.

+

This class allows you to create applications where only one instance should be running at a time. I.e., if the user tries to launch another instance, the already running instance will be activated instead. Another usecase is a client-server system, where the first started instance will assume the role of server, and the later instances will act as clients of that server.

+

By default, the full path of the executable file is used to determine whether two processes are instances of the same application. You can also provide an explicit identifier string that will be compared instead.

+

The application should create the QtSingleApplication object early in the startup phase, and call isRunning() to find out if another instance of this application is already running. If isRunning() returns false, it means that no other instance is running, and this instance has assumed the role as the running instance. In this case, the application should continue with the initialization of the application user interface before entering the event loop with exec(), as normal.

+

The messageReceived() signal will be emitted when the running application receives messages from another instance of the same application. When a message is received it might be helpful to the user to raise the application so that it becomes visible. To facilitate this, QtSingleApplication provides the setActivationWindow() function and the activateWindow() slot.

+

If isRunning() returns true, another instance is already running. It may be alerted to the fact that another instance has started by using the sendMessage() function. Also data such as startup parameters (e.g. the name of the file the user wanted this new instance to open) can be passed to the running instance with this function. Then, the application should terminate (or enter client mode).

+

If isRunning() returns true, but sendMessage() fails, that is an indication that the running instance is frozen.

+

Here's an example that shows how to convert an existing application to use QtSingleApplication. It is very simple and does not make use of all QtSingleApplication's functionality (see the examples for that).

+
 // Original
+ int main(int argc, char **argv)
+ {
+     QApplication app(argc, argv);
+
+     MyMainWidget mmw;
+     mmw.show();
+     return app.exec();
+ }
+
+ // Single instance
+ int main(int argc, char **argv)
+ {
+     QtSingleApplication app(argc, argv);
+
+     if (app.isRunning())
+         return !app.sendMessage(someDataString);
+
+     MyMainWidget mmw;
+     app.setActivationWindow(&mmw);
+     mmw.show();
+     return app.exec();
+ }
+

Once this QtSingleApplication instance is destroyed (normally when the process exits or crashes), when the user next attempts to run the application this instance will not, of course, be encountered. The next instance to call isRunning() or sendMessage() will assume the role as the new running instance.

+

For console (non-GUI) applications, QtSingleCoreApplication may be used instead of this class, to avoid the dependency on the QtGui library.

+

See also QtSingleCoreApplication.

+
+

Member Function Documentation

+

QtSingleApplication::QtSingleApplication ( int & argc, char ** argv, bool GUIenabled = true )

+

Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). argc, argv, and GUIenabled are passed on to the QAppliation constructor.

+

If you are creating a console application (i.e. setting GUIenabled to false), you may consider using QtSingleCoreApplication instead.

+

QtSingleApplication::QtSingleApplication ( const QString & appId, int & argc, char ** argv )

+

Creates a QtSingleApplication object with the application identifier appId. argc and argv are passed on to the QAppliation constructor.

+

QtSingleApplication::QtSingleApplication ( int & argc, char ** argv, Type type )

+

Creates a QtSingleApplication object. The application identifier will be QCoreApplication::applicationFilePath(). argc, argv, and type are passed on to the QAppliation constructor.

+

QtSingleApplication::QtSingleApplication ( Display * dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )

+

Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). dpy, visual, and cmap are passed on to the QApplication constructor.

+

QtSingleApplication::QtSingleApplication ( Display * dpy, int & argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )

+

Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be QCoreApplication::applicationFilePath(). dpy, argc, argv, visual, and cmap are passed on to the QApplication constructor.

+

QtSingleApplication::QtSingleApplication ( Display * dpy, const QString & appId, int argc, char ** argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0 )

+

Special constructor for X11, ref. the documentation of QApplication's corresponding constructor. The application identifier will be appId. dpy, argc, argv, visual, and cmap are passed on to the QApplication constructor.

+

void QtSingleApplication::activateWindow ()   [slot]

+

De-minimizes, raises, and activates this application's activation window. This function does nothing if no activation window has been set.

+

This is a convenience function to show the user that this application instance has been activated when he has tried to start another instance.

+

This function should typically be called in response to the messageReceived() signal. By default, that will happen automatically, if an activation window has been set.

+

See also setActivationWindow(), messageReceived(), and initialize().

+

QWidget * QtSingleApplication::activationWindow () const

+

Returns the applications activation window if one has been set by calling setActivationWindow(), otherwise returns 0.

+

See also setActivationWindow().

+

QString QtSingleApplication::id () const

+

Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application.

+

bool QtSingleApplication::isRunning ()

+

Returns true if another instance of this application is running; otherwise false.

+

This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session).

+

See also sendMessage().

+

void QtSingleApplication::messageReceived ( const QString & message )   [signal]

+

This signal is emitted when the current instance receives a message from another instance of this application.

+

See also sendMessage(), setActivationWindow(), and activateWindow().

+

bool QtSingleApplication::sendMessage ( const QString & message, int timeout = 5000 )   [slot]

+

Tries to send the text message to the currently running instance. The QtSingleApplication object in the running instance will emit the messageReceived() signal when it receives the message.

+

This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds, this function return false.

+

See also isRunning() and messageReceived().

+

void QtSingleApplication::setActivationWindow ( QWidget * aw, bool activateOnMessage = true )

+

Sets the activation window of this application to aw. The activation window is the widget that will be activated by activateWindow(). This is typically the application's main window.

+

If activateOnMessage is true (the default), the window will be activated automatically every time a message is received, just prior to the messageReceived() signal being emitted.

+

See also activationWindow(), activateWindow(), and messageReceived().

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.index b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.index new file mode 100644 index 0000000000..56052c2a2d --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.index @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.qhp b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.qhp new file mode 100644 index 0000000000..ff42d9df48 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsingleapplication.qhp @@ -0,0 +1,53 @@ + + + com.nokia.qtsolutions.qtsingleapplication_head + qdoc + + qt + solutions + qtsingleapplication + + + qt + solutions + qtsingleapplication + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + qtsingleapplication.html + index.html + qtsingleapplication-example-trivial.html + qtsinglecoreapplication.html + qtsingleapplication-example-loader.html + qtsinglecoreapplication-example-console.html + classic.css + images/qt-logo.png + + + diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-example-console.html b/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-example-console.html new file mode 100644 index 0000000000..18a9ae89bf --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-example-console.html @@ -0,0 +1,118 @@ + + + + + + A non-GUI example + + + + + + + +
  Home

A non-GUI example
+

+

This example shows how to use the single-application functionality in a console application. It does not require the QtGui library at all.

+

The only differences from the GUI application usage demonstrated in the other examples are:

+

1) The .pro file should include qtsinglecoreapplication.pri instead of qtsingleapplication.pri

+

2) The class name is QtSingleCoreApplication instead of QtSingleApplication.

+

3) No calls are made regarding window activation, for obvious reasons.

+

console.pro:

+
 TEMPLATE   = app
+ CONFIG    += console
+ SOURCES   += main.cpp
+ include(../../src/qtsinglecoreapplication.pri)
+ QT -= gui
+

main.cpp:

+
 /****************************************************************************
+ **
+ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+ ** Contact: http://www.qt-project.org/legal
+ **
+ ** This file is part of the Qt Solutions component.
+ **
+ ** You may use this file under the terms of the BSD license as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ **   * Redistributions of source code must retain the above copyright
+ **     notice, this list of conditions and the following disclaimer.
+ **   * Redistributions in binary form must reproduce the above copyright
+ **     notice, this list of conditions and the following disclaimer in
+ **     the documentation and/or other materials provided with the
+ **     distribution.
+ **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+ **     the names of its contributors may be used to endorse or promote
+ **     products derived from this software without specific prior written
+ **     permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ **
+ ****************************************************************************/
+
+ #include "qtsinglecoreapplication.h"
+ #include <QtCore/QDebug>
+
+ void report(const QString& msg)
+ {
+     qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg));
+ }
+
+ class MainClass : public QObject
+ {
+     Q_OBJECT
+ public:
+     MainClass()
+         : QObject()
+         {}
+
+ public slots:
+     void handleMessage(const QString& message)
+         {
+             report( "Message received: \"" + message + "\"");
+         }
+ };
+
+ int main(int argc, char **argv)
+ {
+     report("Starting up");
+
+     QtSingleCoreApplication app(argc, argv);
+
+     if (app.isRunning()) {
+         QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid()));
+         bool sentok = app.sendMessage(msg, 2000);
+         QString rep("Another instance is running, so I will exit.");
+         rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen.";
+         report(rep);
+         return 0;
+     } else {
+         report("No other instance is running; so I will.");
+         MainClass mainObj;
+         QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
+                          &mainObj, SLOT(handleMessage(const QString&)));
+         return app.exec();
+     }
+ }
+
+ #include "main.moc"
+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-members.html b/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-members.html new file mode 100644 index 0000000000..69fb858167 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication-members.html @@ -0,0 +1,126 @@ + + + + + + List of All Members for QtSingleCoreApplication + + + + + + + +
  Home

List of All Members for QtSingleCoreApplication

+

This is the complete list of members for QtSingleCoreApplication, including inherited members.

+

+ +
+

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication.html b/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication.html new file mode 100644 index 0000000000..a20cf2f4f3 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/html/qtsinglecoreapplication.html @@ -0,0 +1,98 @@ + + + + + + QtSingleCoreApplication Class Reference + + + + + + + +
  Home

QtSingleCoreApplication Class Reference

+

A variant of the QtSingleApplication class for non-GUI applications. More...

+
 #include <QtSingleCoreApplication>

Inherits QCoreApplication.

+ +
+ +

Public Functions

+ + + + + +
QtSingleCoreApplication ( int & argc, char ** argv )
QtSingleCoreApplication ( const QString & appId, int & argc, char ** argv )
QString id () const
bool isRunning ()
+ +
+ +

Public Slots

+ + +
bool sendMessage ( const QString & message, int timeout = 5000 )
+ +
+ +

Signals

+ + +
void messageReceived ( const QString & message )
+ +

Additional Inherited Members

+ + +
+

Detailed Description

+

A variant of the QtSingleApplication class for non-GUI applications.

+

This class is a variant of QtSingleApplication suited for use in console (non-GUI) applications. It is an extension of QCoreApplication (instead of QApplication). It does not require the QtGui library.

+

The API and usage is identical to QtSingleApplication, except that functions relating to the "activation window" are not present, for obvious reasons. Please refer to the QtSingleApplication documentation for explanation of the usage.

+

A QtSingleCoreApplication instance can communicate to a QtSingleApplication instance if they share the same application id. Hence, this class can be used to create a light-weight command-line tool that sends commands to a GUI application.

+

See also QtSingleApplication.

+
+

Member Function Documentation

+

QtSingleCoreApplication::QtSingleCoreApplication ( int & argc, char ** argv )

+

Creates a QtSingleCoreApplication object. The application identifier will be QCoreApplication::applicationFilePath(). argc and argv are passed on to the QCoreAppliation constructor.

+

QtSingleCoreApplication::QtSingleCoreApplication ( const QString & appId, int & argc, char ** argv )

+

Creates a QtSingleCoreApplication object with the application identifier appId. argc and argv are passed on to the QCoreAppliation constructor.

+

QString QtSingleCoreApplication::id () const

+

Returns the application identifier. Two processes with the same identifier will be regarded as instances of the same application.

+

bool QtSingleCoreApplication::isRunning ()

+

Returns true if another instance of this application is running; otherwise false.

+

This function does not find instances of this application that are being run by a different user (on Windows: that are running in another session).

+

See also sendMessage().

+

void QtSingleCoreApplication::messageReceived ( const QString & message )   [signal]

+

This signal is emitted when the current instance receives a message from another instance of this application.

+

See also sendMessage().

+

bool QtSingleCoreApplication::sendMessage ( const QString & message, int timeout = 5000 )   [slot]

+

Tries to send the text message to the currently running instance. The QtSingleCoreApplication object in the running instance will emit the messageReceived() signal when it receives the message.

+

This function returns true if the message has been sent to, and processed by, the current instance. If there is no instance currently running, or if the running instance fails to process the message within timeout milliseconds, this function return false.

+

See also isRunning() and messageReceived().

+


+ + + + +
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt Solutions
+ diff --git a/SandboxiePlus/QtSingleApp/doc/images/qt-logo.png b/SandboxiePlus/QtSingleApp/doc/images/qt-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..794162f5af58e7b38beebf472842fc9703ede19b GI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g}jC$Hn#DMbo7N33_#+g?0+xMxRr?;Byt5b~@dLMm;1 ze5~)!>viIY+s=2Ee3&l7G)pmwNo=-cBny4bxM)QF^d?{P)|%3ve=A>X6K-B@U}a_H zOT7L}G+AfXbrSoisiiIF0u%+2db#@~M(Wq6y$+2={pg^R8H9+@sqsm;DyGF_(0&g6 z$lDZ%-k!xJ4tt8q-szN#99aFSM8e)*`E#2gvIw2+m!aZc%~@u2EW2N_-V2FxYN0dArh*_+owvm^SqV) zl9P3ucft8P7%CCJsY&l<>BQ&=Hdf>4rA!>_;h63Jxdrt4dOUn!tKQ4GUa<;tbv?u5Kfn8t~ ziA4$|31yN=F2Hdd8*@GSTQWN(qt&Og{Pl@N&=A6(+d32|NV9~rd<;pi%Q&!n^TjT{ zz{17?S~;;J7lDp`I(`fqRW28WNNTB3tbXeGwDS>X{6cat072$%rcoe+7c)w3* zdP+9npWyLl-7$3>a4$Ht)4Moy zS8?dZv)|>cj9Q*^)rM9(H(K>CnHdX@WWEPTD)-(ovehhtMPJB_*5K-xs|kfmrZ?R5 q^n7^PJomUfU@U$1kN?*do1n4%(BY1g{cSVe#sAx_KDRc}&ioHDn>RrK literal 0 HcmV?d00001 diff --git a/SandboxiePlus/QtSingleApp/doc/index.qdoc b/SandboxiePlus/QtSingleApp/doc/index.qdoc new file mode 100644 index 0000000000..6a2a768a73 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/doc/index.qdoc @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page index.html + \title Single Application + + \section1 Description + + The QtSingleApplication component provides support + for applications that can be only started once per user. + + + + For some applications it is useful or even critical that they are started + only once by any user. Future attempts to start the application should + activate any already running instance, and possibly perform requested + actions, e.g. loading a file, in that instance. + + The QtSingleApplication class provides an interface to detect a running + instance, and to send command strings to that instance. + For console (non-GUI) applications, the QtSingleCoreApplication variant is provided, which avoids dependency on QtGui. + + + + + \section1 Classes + \list + \i QtSingleApplication \i QtSingleCoreApplication\endlist + + \section1 Examples + \list + \i \link qtsingleapplication-example-trivial.html A Trivial Example \endlink \i \link qtsingleapplication-example-loader.html Loading Documents \endlink \i \link qtsinglecoreapplication-example-console.html A Non-GUI Example \endlink \endlist + + + + + + + \section1 Tested platforms + \list + \i Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005 + \i Qt 4.4, 4.5 / Linux / gcc + \i Qt 4.4, 4.5 / MacOS X 10.5 / gcc + \endlist + + + + +*/ diff --git a/SandboxiePlus/QtSingleApp/examples/console/console.pro b/SandboxiePlus/QtSingleApp/examples/console/console.pro new file mode 100644 index 0000000000..e0390e2335 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/console/console.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +CONFIG += console +SOURCES += main.cpp +include(../../src/qtsinglecoreapplication.pri) +QT -= gui diff --git a/SandboxiePlus/QtSingleApp/examples/console/console.qdoc b/SandboxiePlus/QtSingleApp/examples/console/console.qdoc new file mode 100644 index 0000000000..77b0d736e8 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/console/console.qdoc @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! \page qtsinglecoreapplication-example-console.html + \title A non-GUI example + + This example shows how to use the single-application functionality + in a console application. It does not require the \c QtGui library + at all. + + The only differences from the GUI application usage demonstrated + in the other examples are: + + 1) The \c.pro file should include \c qtsinglecoreapplication.pri + instead of \c qtsingleapplication.pri + + 2) The class name is \c QtSingleCoreApplication instead of \c + QtSingleApplication. + + 3) No calls are made regarding window activation, for obvious reasons. + + console.pro: + \quotefile console/console.pro + + main.cpp: + \quotefile console/main.cpp + +*/ diff --git a/SandboxiePlus/QtSingleApp/examples/console/main.cpp b/SandboxiePlus/QtSingleApp/examples/console/main.cpp new file mode 100644 index 0000000000..652feb931b --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/console/main.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtsinglecoreapplication.h" +#include + + +void report(const QString& msg) +{ + qDebug("[%i] %s", (int)QCoreApplication::applicationPid(), qPrintable(msg)); +} + +class MainClass : public QObject +{ + Q_OBJECT +public: + MainClass() + : QObject() + {} + +public slots: + void handleMessage(const QString& message) + { + report( "Message received: \"" + message + "\""); + } +}; + +int main(int argc, char **argv) +{ + report("Starting up"); + + QtSingleCoreApplication app(argc, argv); + + if (app.isRunning()) { + QString msg(QString("Hi master, I am %1.").arg(QCoreApplication::applicationPid())); + bool sentok = app.sendMessage(msg, 2000); + QString rep("Another instance is running, so I will exit."); + rep += sentok ? " Message sent ok." : " Message sending failed; the other instance may be frozen."; + report(rep); + return 0; + } else { + report("No other instance is running; so I will."); + MainClass mainObj; + QObject::connect(&app, SIGNAL(messageReceived(const QString&)), + &mainObj, SLOT(handleMessage(const QString&))); + return app.exec(); + } +} + + +#include "main.moc" diff --git a/SandboxiePlus/QtSingleApp/examples/examples.pro b/SandboxiePlus/QtSingleApp/examples/examples.pro new file mode 100644 index 0000000000..36b8fd3831 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/examples.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = trivial \ + loader \ + console diff --git a/SandboxiePlus/QtSingleApp/examples/loader/file1.qsl b/SandboxiePlus/QtSingleApp/examples/loader/file1.qsl new file mode 100644 index 0000000000..50fcd26d6c --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/loader/file1.qsl @@ -0,0 +1 @@ +File 1 diff --git a/SandboxiePlus/QtSingleApp/examples/loader/file2.qsl b/SandboxiePlus/QtSingleApp/examples/loader/file2.qsl new file mode 100644 index 0000000000..4475433e27 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/loader/file2.qsl @@ -0,0 +1 @@ +File 2 diff --git a/SandboxiePlus/QtSingleApp/examples/loader/loader.pro b/SandboxiePlus/QtSingleApp/examples/loader/loader.pro new file mode 100644 index 0000000000..3e52586b32 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/loader/loader.pro @@ -0,0 +1,6 @@ +greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport +TEMPLATE = app + +include(../../src/qtsingleapplication.pri) + +SOURCES += main.cpp diff --git a/SandboxiePlus/QtSingleApp/examples/loader/loader.qdoc b/SandboxiePlus/QtSingleApp/examples/loader/loader.qdoc new file mode 100644 index 0000000000..bfd15d0623 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/loader/loader.qdoc @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! \page qtsingleapplication-example-loader.html + \title Loading Documents + + The application in this example loads or prints the documents + passed as commandline parameters to further instances of this + application. + + \quotefromfile loader/main.cpp + \printuntil }; + The user interface in this application is a QMainWindow subclass + with a QMdiArea as the central widget. It implements a slot + \c handleMessage() that will be connected to the messageReceived() + signal of the QtSingleApplication class. + + \printuntil } + The MainWindow constructor creates a minimal user interface. + + \printto case Print: + The handleMessage() slot interprets the message passed in as a + filename that can be prepended with \e /print to indicate that + the file should just be printed rather than loaded. + + \printto #include + Loading the file will also activate the window. + + \printto mw + The \c main entry point function creates a QtSingleApplication + object, and creates a message to send to a running instance + of the application. If the message was sent successfully the + process exits immediately. + + \printuntil } + If the message could not be sent the application starts up. Note + that \c false is passed to the call to setActivationWindow() to + prevent automatic activation for every message received, e.g. when + the application should just print a file. Instead, the message + handling function determines whether activation is requested, and + signals that by emitting the needToShow() signal. This is then + simply connected directly to QtSingleApplication's + activateWindow() slot. +*/ diff --git a/SandboxiePlus/QtSingleApp/examples/loader/main.cpp b/SandboxiePlus/QtSingleApp/examples/loader/main.cpp new file mode 100644 index 0000000000..f55e57ac36 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/loader/main.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + MainWindow(); + +public slots: + void handleMessage(const QString& message); + +signals: + void needToShow(); + +private: + QMdiArea *workspace; +}; + +MainWindow::MainWindow() +{ + workspace = new QMdiArea(this); + + setCentralWidget(workspace); +} + +void MainWindow::handleMessage(const QString& message) +{ + enum Action { + Nothing, + Open, + Print + } action; + + action = Nothing; + QString filename = message; + if (message.toLower().startsWith("/print ")) { + filename = filename.mid(7); + action = Print; + } else if (!message.isEmpty()) { + action = Open; + } + if (action == Nothing) { + emit needToShow(); + return; + } + + QFile file(filename); + QString contents; + if (file.open(QIODevice::ReadOnly)) + contents = file.readAll(); + else + contents = "[[Error: Could not load file " + filename + "]]"; + + QTextEdit *view = new QTextEdit; + view->setPlainText(contents); + + switch(action) { + case Print: + { + QPrinter printer; + view->print(&printer); + delete view; + } + break; + + case Open: + { + workspace->addSubWindow(view); + view->setWindowTitle(message); + view->show(); + emit needToShow(); + } + break; + default: + break; + }; +} + +#include "main.moc" + +int main(int argc, char **argv) +{ + QtSingleApplication instance("File loader QtSingleApplication example", argc, argv); + QString message; + for (int a = 1; a < argc; ++a) { + message += argv[a]; + if (a < argc-1) + message += " "; + } + + if (instance.sendMessage(message)) + return 0; + + MainWindow mw; + mw.handleMessage(message); + mw.show(); + + QObject::connect(&instance, SIGNAL(messageReceived(const QString&)), + &mw, SLOT(handleMessage(const QString&))); + + instance.setActivationWindow(&mw, false); + QObject::connect(&mw, SIGNAL(needToShow()), &instance, SLOT(activateWindow())); + + return instance.exec(); +} diff --git a/SandboxiePlus/QtSingleApp/examples/trivial/main.cpp b/SandboxiePlus/QtSingleApp/examples/trivial/main.cpp new file mode 100644 index 0000000000..69e102f3fb --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/trivial/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class TextEdit : public QTextEdit +{ + Q_OBJECT +public: + TextEdit(QWidget *parent = 0) + : QTextEdit(parent) + {} +public slots: + void append(const QString &str) + { + QTextEdit::append(str); + } +}; + +#include "main.moc" + + + +int main(int argc, char **argv) +{ + QtSingleApplication instance(argc, argv); + if (instance.sendMessage("Wake up!")) + return 0; + + TextEdit logview; + logview.setReadOnly(true); + logview.show(); + + instance.setActivationWindow(&logview); + + QObject::connect(&instance, SIGNAL(messageReceived(const QString&)), + &logview, SLOT(append(const QString&))); + + return instance.exec(); +} diff --git a/SandboxiePlus/QtSingleApp/examples/trivial/trivial.pro b/SandboxiePlus/QtSingleApp/examples/trivial/trivial.pro new file mode 100644 index 0000000000..673497a408 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/trivial/trivial.pro @@ -0,0 +1,5 @@ +TEMPLATE = app + +include(../../src/qtsingleapplication.pri) + +SOURCES += main.cpp diff --git a/SandboxiePlus/QtSingleApp/examples/trivial/trivial.qdoc b/SandboxiePlus/QtSingleApp/examples/trivial/trivial.qdoc new file mode 100644 index 0000000000..9491cb65e5 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/examples/trivial/trivial.qdoc @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! \page qtsingleapplication-example-trivial.html + \title A Trivial Example + + The application in this example has a log-view that displays + messages sent by further instances of the same application. + + The example demonstrates the use of the QtSingleApplication + class to detect and communicate with a running instance of + the application using the sendMessage() API. The messageReceived() + signal is used to display received messages in a QTextEdit log. + + \quotefromfile trivial/main.cpp + \printuntil instance + The example has only the \c main entry point function. + A QtSingleApplication object is created immediately. + + \printuntil return + If another instance of this application is already running, + sendMessage() will succeed, and this instance just exits + immediately. + + \printuntil show() + Otherwise the instance continues as normal and creates the + user interface. + + \printuntil return instance.exec(); + The \c logview object is also set as the application's activation + window. Every time a message is received, the window will be raised + and activated automatically. + + The messageReceived() signal is also connected to the QTextEdit's + append() slot. Every message received from further instances of + this application will be displayed in the log. + + Finally the event loop is entered. +*/ diff --git a/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp.sln b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp.sln new file mode 100644 index 0000000000..b6c9271a96 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qtsingleapp", "qtsingleapp\qtsingleapp.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.ActiveCfg = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.Build.0 = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.Build.0 = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.pri b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.pri new file mode 100644 index 0000000000..1a14cb0532 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.pri @@ -0,0 +1,11 @@ +# ---------------------------------------------------- +# This file is generated by the Qt Visual Studio Add-in. +# ------------------------------------------------------ + +HEADERS += ../../src/qtlockedfile.h \ + ../../src/qtlocalpeer.h \ + ../../src/qtsingleapplication.h \ + ../../src/qtsinglecoreapplication.h +SOURCES += ../../src/qtlocalpeer.cpp \ + ../../src/qtsingleapplication.cpp \ + ../../src/qtsinglecoreapplication.cpp diff --git a/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.qc.pro b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.qc.pro new file mode 100644 index 0000000000..276c5ef9ac --- /dev/null +++ b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.qc.pro @@ -0,0 +1,30 @@ +# ---------------------------------------------------- +# This file is generated by the Qt Visual Studio Add-in. +# ------------------------------------------------------ + +TEMPLATE = lib +TARGET = qtsingleapp +QT += core network widgets +DEFINES += QT_LARGEFILE_SUPPORT QTSERVICE_LIB QT_WIDGETS_LIB QT_QTSINGLEAPPLICATION_EXPORT +!mac:unix:QMAKE_LFLAGS += -Wl,-rpath,'\$\$ORIGIN' +mac:QMAKE_CXXFLAGS += -std=c++11 + +!win32:QMAKE_LFLAGS +=-rdynamic + + + +CONFIG(release, debug|release):{ +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO +QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO +} +CONFIG(debug, debug|release):DESTDIR = ../../../Debug +CONFIG(release, debug|release):DESTDIR = ../../../Release +INCLUDEPATH += . +DEPENDPATH += . +#MOC_DIR += ./GeneratedFiles +#OBJECTS_DIR += ./ObjectFiles +#UI_DIR += ./GeneratedFiles +#RCC_DIR += ./GeneratedFiles + + +include(qtsingleapp.pri) diff --git a/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj new file mode 100644 index 0000000000..43a4f9e927 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj @@ -0,0 +1,225 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B12702AD-ABFB-343A-A199-8E24837244A3} + QtVS_v302 + 8.1 + QtSingleApp + + + + DynamicLibrary + v140 + + + DynamicLibrary + v140 + + + DynamicLibrary + v140 + + + DynamicLibrary + v140 + + + + $(MSBuildProjectDirectory)\QtMsBuild + + + + + + + + + + + + + + + + + + + + + + + + msvc2015_64 + core;network;widgets + + + msvc2015 + core;network;widgets + + + msvc2015_64 + core;network;widgets + + + msvc2015 + core;network;widgets + + + + + + <_ProjectFileVersion>11.0.51106.1 + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + UNICODE;WIN32;QT_DLL;QTSINGLEAPP_LIB;QT_QTSINGLEAPPLICATION_EXPORT;QT_QTLOCKEDFILE_EXPORT;QT_QTLOCALPEER_EXPORT;%(PreprocessorDefinitions) + .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + true + + + Windows + $(OutDir)\$(ProjectName).dll + %(AdditionalLibraryDirectories) + true + %(AdditionalDependencies) + + + Moc'ing %(Identity)... + output + .\GeneratedFiles\$(ConfigurationName) + moc_%(Filename).cpp + + + + + UNICODE;WIN32;QT_DLL;QTSINGLEAPP_LIB;QT_QTSINGLEAPPLICATION_EXPORT;QT_QTLOCKEDFILE_EXPORT;QT_QTLOCALPEER_EXPORT;%(PreprocessorDefinitions) + .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + false + true + + + Windows + $(OutDir)\$(ProjectName).dll + %(AdditionalLibraryDirectories) + true + %(AdditionalDependencies) + + + Moc'ing %(Identity)... + output + .\GeneratedFiles\$(ConfigurationName) + moc_%(Filename).cpp + + + + + UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QTSINGLEAPP_LIB;QT_QTSINGLEAPPLICATION_EXPORT;QT_QTLOCKEDFILE_EXPORT;QT_QTLOCALPEER_EXPORT;%(PreprocessorDefinitions) + .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;%(AdditionalIncludeDirectories) + + MultiThreadedDLL + false + true + + + Windows + $(OutDir)\$(ProjectName).dll + %(AdditionalLibraryDirectories) + false + %(AdditionalDependencies) + + + Moc'ing %(Identity)... + output + .\GeneratedFiles\$(ConfigurationName) + moc_%(Filename).cpp + + + + + UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QTSINGLEAPP_LIB;QT_QTSINGLEAPPLICATION_EXPORT;QT_QTLOCKEDFILE_EXPORT;QT_QTLOCALPEER_EXPORT;%(PreprocessorDefinitions) + .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;%(AdditionalIncludeDirectories) + + MultiThreadedDLL + false + Disabled + true + + + Windows + $(OutDir)\$(ProjectName).dll + %(AdditionalLibraryDirectories) + false + %(AdditionalDependencies) + + + Moc'ing %(Identity)... + output + .\GeneratedFiles\$(ConfigurationName) + moc_%(Filename).cpp + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj.filters b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj.filters new file mode 100644 index 0000000000..20b003bb27 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/qtsingleapp/qtsingleapp/qtsingleapp.vcxproj.filters @@ -0,0 +1,70 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;cxx;c;def + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + + {0370bece-a6ef-499b-b4a5-282c729f4010} + cpp;moc + False + + + {1e783a90-ac03-44eb-9d18-6763465fa3e2} + cpp;moc + False + + + + + Header Files + + + + + Source Files + + + + + Source Files + + + + + Source Files + + + + + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/SandboxiePlus/QtSingleApp/qtsingleapplication.pro b/SandboxiePlus/QtSingleApp/qtsingleapplication.pro new file mode 100644 index 0000000000..07257c5d44 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/qtsingleapplication.pro @@ -0,0 +1,5 @@ +TEMPLATE=subdirs +CONFIG += ordered +include(common.pri) +qtsingleapplication-uselib:SUBDIRS=buildlib +SUBDIRS+=examples diff --git a/SandboxiePlus/QtSingleApp/src/QtLockedFile b/SandboxiePlus/QtSingleApp/src/QtLockedFile new file mode 100644 index 0000000000..16b48ba9dd --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/QtLockedFile @@ -0,0 +1 @@ +#include "qtlockedfile.h" diff --git a/SandboxiePlus/QtSingleApp/src/QtSingleApplication b/SandboxiePlus/QtSingleApp/src/QtSingleApplication new file mode 100644 index 0000000000..d111bf72d8 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/QtSingleApplication @@ -0,0 +1 @@ +#include "qtsingleapplication.h" diff --git a/SandboxiePlus/QtSingleApp/src/qtlocalpeer.cpp b/SandboxiePlus/QtSingleApp/src/qtlocalpeer.cpp new file mode 100644 index 0000000000..269bb884af --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtlocalpeer.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtlocalpeer.h" +#include +#include +#include + +#if defined(Q_OS_WIN) +#include +#include +typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*); +static PProcessIdToSessionId pProcessIdToSessionId = 0; +#endif +#if defined(Q_OS_UNIX) +#include +#include +#include +#endif + +//namespace QtLP_Private { +#include "qtlockedfile.cpp" +#if defined(Q_OS_WIN) +#include "qtlockedfile_win.cpp" +#else +#include "qtlockedfile_unix.cpp" +#endif +//} + +const char* QtLocalPeer::ack = "ack"; + +QtLocalPeer::QtLocalPeer(const QString &appId, QObject* parent) + : QObject(parent), id(appId) +{ + QString prefix = id; + + id = QCoreApplication::applicationFilePath(); +#if defined(Q_OS_WIN) + id = id.toLower(); +#endif + + if (prefix.isEmpty()) { + prefix = id.section(QLatin1Char('/'), -1); + + prefix.remove(QRegExp("[^a-zA-Z]")); + prefix.truncate(6); + } + else + id.prepend(prefix + "="); + + QByteArray idc = id.toUtf8(); + quint16 idNum = qChecksum(idc.constData(), idc.size()); + socketName = QLatin1String("qtsingleapp-") + prefix + + QLatin1Char('-') + QString::number(idNum, 16); + +#if defined(Q_OS_WIN) + if (!pProcessIdToSessionId) { + QLibrary lib("kernel32"); + pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId"); + } + if (pProcessIdToSessionId) { + DWORD sessionId = 0; + pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); + socketName += QLatin1Char('-') + QString::number(sessionId, 16); + } +#else + socketName += QLatin1Char('-') + QString::number(::getuid(), 16); +#endif + + server = new QLocalServer(this); + QString lockName = QDir(QDir::tempPath()).absolutePath() + + QLatin1Char('/') + socketName + + QLatin1String("-lockfile"); + lockFile.setFileName(lockName); + lockFile.open(QIODevice::ReadWrite); +} + + + +bool QtLocalPeer::isClient() +{ + if (lockFile.isLocked()) + return false; + + if (!lockFile.lock(QtLockedFile::WriteLock, false)) + return true; + + bool res = server->listen(socketName); +#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) + // ### Workaround + if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { + QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); + res = server->listen(socketName); + } +#endif + if (!res) + qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); + QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); + return false; +} + + +bool QtLocalPeer::sendMessage(const QString &message, int timeout) +{ + if (!isClient()) + return false; + + QLocalSocket socket; + bool connOk = false; + for(int i = 0; i < 2; i++) { + // Try twice, in case the other instance is just starting up + socket.connectToServer(socketName); + connOk = socket.waitForConnected(timeout/2); + if (connOk || i) + break; + int ms = 250; +#if defined(Q_OS_WIN) + Sleep(DWORD(ms)); +#else + struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; + nanosleep(&ts, NULL); +#endif + } + if (!connOk) + return false; + + QByteArray uMsg(message.toUtf8()); + QDataStream ds(&socket); + ds.writeBytes(uMsg.constData(), uMsg.size()); + bool res = socket.waitForBytesWritten(timeout); + if (res) { + res &= socket.waitForReadyRead(timeout); // wait for ack + if (res) + res &= (socket.read(qstrlen(ack)) == ack); + } + return res; +} + + +void QtLocalPeer::receiveConnection() +{ + QLocalSocket* socket = server->nextPendingConnection(); + if (!socket) + return; + + while (socket->bytesAvailable() < (int)sizeof(quint32)) + socket->waitForReadyRead(); + QDataStream ds(socket); + QByteArray uMsg; + quint32 remaining; + ds >> remaining; + uMsg.resize(remaining); + int got = 0; + char* uMsgBuf = uMsg.data(); + do { + got = ds.readRawData(uMsgBuf, remaining); + remaining -= got; + uMsgBuf += got; + } while (remaining && got >= 0 && socket->waitForReadyRead(2000)); + if (got < 0) { + qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData()); + delete socket; + return; + } + QString message(QString::fromUtf8(uMsg)); + socket->write(ack, qstrlen(ack)); + socket->waitForBytesWritten(1000); + socket->waitForDisconnected(1000); // make sure client reads ack + delete socket; + emit messageReceived(message); //### (might take a long time to return) +} diff --git a/SandboxiePlus/QtSingleApp/src/qtlocalpeer.h b/SandboxiePlus/QtSingleApp/src/qtlocalpeer.h new file mode 100644 index 0000000000..3b681a442c --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtlocalpeer.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTLOCALPEER_H +#define QTLOCALPEER_H + +#include +#include +#include + +#include "qtlockedfile.h" + +#if defined(Q_OS_WIN) +# if !defined(QT_QTLOCALPEER_EXPORT) && !defined(QT_QTLOCALPEER_IMPORT) +# define QT_QTLOCALPEER_EXPORT +# elif defined(QT_QTLOCALPEER_IMPORT) +# if defined(QT_QTLOCALPEER_EXPORT) +# undef QT_QTLOCALPEER_EXPORT +# endif +# define QT_QTLOCALPEER_EXPORT __declspec(dllimport) +# elif defined(QT_QTLOCALPEER_EXPORT) +# undef QT_QTLOCALPEER_EXPORT +# define QT_QTLOCALPEER_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTLOCALPEER_EXPORT +#endif + +class QT_QTLOCALPEER_EXPORT QtLocalPeer : public QObject +{ + Q_OBJECT + +public: + QtLocalPeer(const QString &appId = QString(), QObject *parent = 0); + bool isClient(); + bool sendMessage(const QString &message, int timeout = 5000); + QString applicationId() const + { return id; } + +Q_SIGNALS: + void messageReceived(const QString &message); + +protected Q_SLOTS: + void receiveConnection(); + +protected: + QString id; + QString socketName; + QLocalServer* server; + QtLockedFile lockFile; + +private: + static const char* ack; +}; + +#endif // QTLOCALPEER_H diff --git a/SandboxiePlus/QtSingleApp/src/qtlockedfile.cpp b/SandboxiePlus/QtSingleApp/src/qtlockedfile.cpp new file mode 100644 index 0000000000..c142a863a9 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtlockedfile.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtlockedfile.h" + +/*! + \class QtLockedFile + + \brief The QtLockedFile class extends QFile with advisory locking + functions. + + A file may be locked in read or write mode. Multiple instances of + \e QtLockedFile, created in multiple processes running on the same + machine, may have a file locked in read mode. Exactly one instance + may have it locked in write mode. A read and a write lock cannot + exist simultaneously on the same file. + + The file locks are advisory. This means that nothing prevents + another process from manipulating a locked file using QFile or + file system functions offered by the OS. Serialization is only + guaranteed if all processes that access the file use + QLockedFile. Also, while holding a lock on a file, a process + must not open the same file again (through any API), or locks + can be unexpectedly lost. + + The lock provided by an instance of \e QtLockedFile is released + whenever the program terminates. This is true even when the + program crashes and no destructors are called. +*/ + +/*! \enum QtLockedFile::LockMode + + This enum describes the available lock modes. + + \value ReadLock A read lock. + \value WriteLock A write lock. + \value NoLock Neither a read lock nor a write lock. +*/ + +/*! + Constructs an unlocked \e QtLockedFile object. This constructor + behaves in the same way as \e QFile::QFile(). + + \sa QFile::QFile() +*/ +QtLockedFile::QtLockedFile() + : QFile() +{ +#ifdef Q_OS_WIN + wmutex = 0; + rmutex = 0; +#endif + m_lock_mode = NoLock; +} + +/*! + Constructs an unlocked QtLockedFile object with file \a name. This + constructor behaves in the same way as \e QFile::QFile(const + QString&). + + \sa QFile::QFile() +*/ +QtLockedFile::QtLockedFile(const QString &name) + : QFile(name) +{ +#ifdef Q_OS_WIN + wmutex = 0; + rmutex = 0; +#endif + m_lock_mode = NoLock; +} + +/*! + Opens the file in OpenMode \a mode. + + This is identical to QFile::open(), with the one exception that the + Truncate mode flag is disallowed. Truncation would conflict with the + advisory file locking, since the file would be modified before the + write lock is obtained. If truncation is required, use resize(0) + after obtaining the write lock. + + Returns true if successful; otherwise false. + + \sa QFile::open(), QFile::resize() +*/ +bool QtLockedFile::open(OpenMode mode) +{ + if (mode & QIODevice::Truncate) { + qWarning("QtLockedFile::open(): Truncate mode not allowed."); + return false; + } + return QFile::open(mode); +} + +/*! + Returns \e true if this object has a in read or write lock; + otherwise returns \e false. + + \sa lockMode() +*/ +bool QtLockedFile::isLocked() const +{ + return m_lock_mode != NoLock; +} + +/*! + Returns the type of lock currently held by this object, or \e + QtLockedFile::NoLock. + + \sa isLocked() +*/ +QtLockedFile::LockMode QtLockedFile::lockMode() const +{ + return m_lock_mode; +} + +/*! + \fn bool QtLockedFile::lock(LockMode mode, bool block = true) + + Obtains a lock of type \a mode. The file must be opened before it + can be locked. + + If \a block is true, this function will block until the lock is + aquired. If \a block is false, this function returns \e false + immediately if the lock cannot be aquired. + + If this object already has a lock of type \a mode, this function + returns \e true immediately. If this object has a lock of a + different type than \a mode, the lock is first released and then a + new lock is obtained. + + This function returns \e true if, after it executes, the file is + locked by this object, and \e false otherwise. + + \sa unlock(), isLocked(), lockMode() +*/ + +/*! + \fn bool QtLockedFile::unlock() + + Releases a lock. + + If the object has no lock, this function returns immediately. + + This function returns \e true if, after it executes, the file is + not locked by this object, and \e false otherwise. + + \sa lock(), isLocked(), lockMode() +*/ + +/*! + \fn QtLockedFile::~QtLockedFile() + + Destroys the \e QtLockedFile object. If any locks were held, they + are released. +*/ diff --git a/SandboxiePlus/QtSingleApp/src/qtlockedfile.h b/SandboxiePlus/QtSingleApp/src/qtlockedfile.h new file mode 100644 index 0000000000..67fc60c69b --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtlockedfile.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTLOCKEDFILE_H +#define QTLOCKEDFILE_H + +#include +#ifdef Q_OS_WIN +#include +#endif + +#if defined(Q_OS_WIN) +# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) +# define QT_QTLOCKEDFILE_EXPORT +# elif defined(QT_QTLOCKEDFILE_IMPORT) +# if defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# endif +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) +# elif defined(QT_QTLOCKEDFILE_EXPORT) +# undef QT_QTLOCKEDFILE_EXPORT +# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTLOCKEDFILE_EXPORT +#endif + +//namespace QtLP_Private { + +class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile +{ +public: + enum LockMode { NoLock = 0, ReadLock, WriteLock }; + + QtLockedFile(); + QtLockedFile(const QString &name); + ~QtLockedFile(); + + bool open(OpenMode mode); + + bool lock(LockMode mode, bool block = true); + bool unlock(); + bool isLocked() const; + LockMode lockMode() const; + +private: +#ifdef Q_OS_WIN + Qt::HANDLE wmutex; + Qt::HANDLE rmutex; + QVector rmutexes; + QString mutexname; + + Qt::HANDLE getMutexHandle(int idx, bool doCreate); + bool waitMutex(Qt::HANDLE mutex, bool doBlock); + +#endif + LockMode m_lock_mode; +}; +//} +#endif diff --git a/SandboxiePlus/QtSingleApp/src/qtlockedfile_unix.cpp b/SandboxiePlus/QtSingleApp/src/qtlockedfile_unix.cpp new file mode 100644 index 0000000000..976c1b9ee6 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtlockedfile_unix.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "qtlockedfile.h" + +bool QtLockedFile::lock(LockMode mode, bool block) +{ + if (!isOpen()) { + qWarning("QtLockedFile::lock(): file is not opened"); + return false; + } + + if (mode == NoLock) + return unlock(); + + if (mode == m_lock_mode) + return true; + + if (m_lock_mode != NoLock) + unlock(); + + struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; + int cmd = block ? F_SETLKW : F_SETLK; + int ret = fcntl(handle(), cmd, &fl); + + if (ret == -1) { + if (errno != EINTR && errno != EAGAIN) + qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + return false; + } + + + m_lock_mode = mode; + return true; +} + + +bool QtLockedFile::unlock() +{ + if (!isOpen()) { + qWarning("QtLockedFile::unlock(): file is not opened"); + return false; + } + + if (!isLocked()) + return true; + + struct flock fl; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_UNLCK; + int ret = fcntl(handle(), F_SETLKW, &fl); + + if (ret == -1) { + qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); + return false; + } + + m_lock_mode = NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); +} + diff --git a/SandboxiePlus/QtSingleApp/src/qtlockedfile_win.cpp b/SandboxiePlus/QtSingleApp/src/qtlockedfile_win.cpp new file mode 100644 index 0000000000..5e2126204b --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtlockedfile_win.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtlockedfile.h" +#include +#include + +#define MUTEX_PREFIX "QtLockedFile mutex " +// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS +#define MAX_READERS MAXIMUM_WAIT_OBJECTS + +#if QT_VERSION >= 0x050000 +#define QT_WA(unicode, ansi) unicode +#endif + +Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) +{ + if (mutexname.isEmpty()) { + QFileInfo fi(*this); + mutexname = QString::fromLatin1(MUTEX_PREFIX) + + fi.absoluteFilePath().toLower(); + } + QString mname(mutexname); + if (idx >= 0) + mname += QString::number(idx); + + Qt::HANDLE mutex; + if (doCreate) { + QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); + if (!mutex) { + qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); + return 0; + } + } + else { + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, + { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); + if (!mutex) { + if (GetLastError() != ERROR_FILE_NOT_FOUND) + qErrnoWarning("QtLockedFile::lock(): OpenMutex failed"); + return 0; + } + } + return mutex; +} + +bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock) +{ + Q_ASSERT(mutex); + DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0); + switch (res) { + case WAIT_OBJECT_0: + case WAIT_ABANDONED: + return true; + break; + case WAIT_TIMEOUT: + break; + default: + qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed"); + } + return false; +} + + + +bool QtLockedFile::lock(LockMode mode, bool block) +{ + if (!isOpen()) { + qWarning("QtLockedFile::lock(): file is not opened"); + return false; + } + + if (mode == NoLock) + return unlock(); + + if (mode == m_lock_mode) + return true; + + if (m_lock_mode != NoLock) + unlock(); + + if (!wmutex && !(wmutex = getMutexHandle(-1, true))) + return false; + + if (!waitMutex(wmutex, block)) + return false; + + if (mode == ReadLock) { + int idx = 0; + for (; idx < MAX_READERS; idx++) { + rmutex = getMutexHandle(idx, false); + if (!rmutex || waitMutex(rmutex, false)) + break; + CloseHandle(rmutex); + } + bool ok = true; + if (idx >= MAX_READERS) { + qWarning("QtLockedFile::lock(): too many readers"); + rmutex = 0; + ok = false; + } + else if (!rmutex) { + rmutex = getMutexHandle(idx, true); + if (!rmutex || !waitMutex(rmutex, false)) + ok = false; + } + if (!ok && rmutex) { + CloseHandle(rmutex); + rmutex = 0; + } + ReleaseMutex(wmutex); + if (!ok) + return false; + } + else { + Q_ASSERT(rmutexes.isEmpty()); + for (int i = 0; i < MAX_READERS; i++) { + Qt::HANDLE mutex = getMutexHandle(i, false); + if (mutex) + rmutexes.append(mutex); + } + if (rmutexes.size()) { + DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(), + TRUE, block ? INFINITE : 0); + if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) { + if (res != WAIT_TIMEOUT) + qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed"); + m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky + unlock(); + return false; + } + } + } + + m_lock_mode = mode; + return true; +} + +bool QtLockedFile::unlock() +{ + if (!isOpen()) { + qWarning("QtLockedFile::unlock(): file is not opened"); + return false; + } + + if (!isLocked()) + return true; + + if (m_lock_mode == ReadLock) { + ReleaseMutex(rmutex); + CloseHandle(rmutex); + rmutex = 0; + } + else { + foreach(Qt::HANDLE mutex, rmutexes) { + ReleaseMutex(mutex); + CloseHandle(mutex); + } + rmutexes.clear(); + ReleaseMutex(wmutex); + } + + m_lock_mode = QtLockedFile::NoLock; + return true; +} + +QtLockedFile::~QtLockedFile() +{ + if (isOpen()) + unlock(); + if (wmutex) + CloseHandle(wmutex); +} diff --git a/SandboxiePlus/QtSingleApp/src/qtsingleapplication.cpp b/SandboxiePlus/QtSingleApp/src/qtsingleapplication.cpp new file mode 100644 index 0000000000..77ba3e63af --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtsingleapplication.cpp @@ -0,0 +1,347 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtsingleapplication.h" +#include "qtlocalpeer.h" +#include + + +/*! + \class QtSingleApplication qtsingleapplication.h + \brief The QtSingleApplication class provides an API to detect and + communicate with running instances of an application. + + This class allows you to create applications where only one + instance should be running at a time. I.e., if the user tries to + launch another instance, the already running instance will be + activated instead. Another usecase is a client-server system, + where the first started instance will assume the role of server, + and the later instances will act as clients of that server. + + By default, the full path of the executable file is used to + determine whether two processes are instances of the same + application. You can also provide an explicit identifier string + that will be compared instead. + + The application should create the QtSingleApplication object early + in the startup phase, and call isRunning() to find out if another + instance of this application is already running. If isRunning() + returns false, it means that no other instance is running, and + this instance has assumed the role as the running instance. In + this case, the application should continue with the initialization + of the application user interface before entering the event loop + with exec(), as normal. + + The messageReceived() signal will be emitted when the running + application receives messages from another instance of the same + application. When a message is received it might be helpful to the + user to raise the application so that it becomes visible. To + facilitate this, QtSingleApplication provides the + setActivationWindow() function and the activateWindow() slot. + + If isRunning() returns true, another instance is already + running. It may be alerted to the fact that another instance has + started by using the sendMessage() function. Also data such as + startup parameters (e.g. the name of the file the user wanted this + new instance to open) can be passed to the running instance with + this function. Then, the application should terminate (or enter + client mode). + + If isRunning() returns true, but sendMessage() fails, that is an + indication that the running instance is frozen. + + Here's an example that shows how to convert an existing + application to use QtSingleApplication. It is very simple and does + not make use of all QtSingleApplication's functionality (see the + examples for that). + + \code + // Original + int main(int argc, char **argv) + { + QApplication app(argc, argv); + + MyMainWidget mmw; + mmw.show(); + return app.exec(); + } + + // Single instance + int main(int argc, char **argv) + { + QtSingleApplication app(argc, argv); + + if (app.isRunning()) + return !app.sendMessage(someDataString); + + MyMainWidget mmw; + app.setActivationWindow(&mmw); + mmw.show(); + return app.exec(); + } + \endcode + + Once this QtSingleApplication instance is destroyed (normally when + the process exits or crashes), when the user next attempts to run the + application this instance will not, of course, be encountered. The + next instance to call isRunning() or sendMessage() will assume the + role as the new running instance. + + For console (non-GUI) applications, QtSingleCoreApplication may be + used instead of this class, to avoid the dependency on the QtGui + library. + + \sa QtSingleCoreApplication +*/ + + +void QtSingleApplication::sysInit(const QString &appId) +{ + actWin = 0; + peer = new QtLocalPeer(appId, this); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc, \a + argv, and \a GUIenabled are passed on to the QAppliation constructor. + + If you are creating a console application (i.e. setting \a + GUIenabled to false), you may consider using + QtSingleCoreApplication instead. +*/ + +QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled) + : QApplication(argc, argv, GUIenabled) +{ + sysInit(); +} + + +/*! + Creates a QtSingleApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QAppliation constructor. +*/ + +QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv) + : QApplication(argc, argv) +{ + sysInit(appId); +} + +#if QT_VERSION < 0x050000 + +/*! + Creates a QtSingleApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc, \a + argv, and \a type are passed on to the QAppliation constructor. +*/ +QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type) + : QApplication(argc, argv, type) +{ + sysInit(); +} + + +# if defined(Q_WS_X11) +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be QCoreApplication::applicationFilePath(). \a dpy, \a visual, + and \a cmap are passed on to the QApplication constructor. +*/ +QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, visual, cmap) +{ + sysInit(); +} + +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a + argv, \a visual, and \a cmap are passed on to the QApplication + constructor. +*/ +QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, argc, argv, visual, cmap) +{ + sysInit(); +} + +/*! + Special constructor for X11, ref. the documentation of + QApplication's corresponding constructor. The application identifier + will be \a appId. \a dpy, \a argc, \a + argv, \a visual, and \a cmap are passed on to the QApplication + constructor. +*/ +QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap) + : QApplication(dpy, argc, argv, visual, cmap) +{ + sysInit(appId); +} +# endif // Q_WS_X11 +#endif // QT_VERSION < 0x050000 + + +/*! + Returns true if another instance of this application is running; + otherwise false. + + This function does not find instances of this application that are + being run by a different user (on Windows: that are running in + another session). + + \sa sendMessage() +*/ + +bool QtSingleApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleApplication object in the running instance + will emit the messageReceived() signal when it receives the + message. + + This function returns true if the message has been sent to, and + processed by, the current instance. If there is no instance + currently running, or if the running instance fails to process the + message within \a timeout milliseconds, this function return false. + + \sa isRunning(), messageReceived() +*/ +bool QtSingleApplication::sendMessage(const QString &message, int timeout) +{ + return peer->sendMessage(message, timeout); +} + + +/*! + Returns the application identifier. Two processes with the same + identifier will be regarded as instances of the same application. +*/ +QString QtSingleApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + Sets the activation window of this application to \a aw. The + activation window is the widget that will be activated by + activateWindow(). This is typically the application's main window. + + If \a activateOnMessage is true (the default), the window will be + activated automatically every time a message is received, just prior + to the messageReceived() signal being emitted. + + \sa activateWindow(), messageReceived() +*/ + +void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessage) +{ + actWin = aw; + if (activateOnMessage) + connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); + else + disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); +} + + +/*! + Returns the applications activation window if one has been set by + calling setActivationWindow(), otherwise returns 0. + + \sa setActivationWindow() +*/ +QWidget* QtSingleApplication::activationWindow() const +{ + return actWin; +} + + +/*! + De-minimizes, raises, and activates this application's activation window. + This function does nothing if no activation window has been set. + + This is a convenience function to show the user that this + application instance has been activated when he has tried to start + another instance. + + This function should typically be called in response to the + messageReceived() signal. By default, that will happen + automatically, if an activation window has been set. + + \sa setActivationWindow(), messageReceived(), initialize() +*/ +void QtSingleApplication::activateWindow() +{ + if (actWin) { + actWin->setWindowState(actWin->windowState() & ~Qt::WindowMinimized); + actWin->raise(); + actWin->activateWindow(); + } +} + + +/*! + \fn void QtSingleApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage(), setActivationWindow(), activateWindow() +*/ + + +/*! + \fn void QtSingleApplication::initialize(bool dummy = true) + + \obsolete +*/ diff --git a/SandboxiePlus/QtSingleApp/src/qtsingleapplication.h b/SandboxiePlus/QtSingleApp/src/qtsingleapplication.h new file mode 100644 index 0000000000..049406f72c --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtsingleapplication.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTSINGLEAPPLICATION_H +#define QTSINGLEAPPLICATION_H + +#include + +class QtLocalPeer; + +#if defined(Q_OS_WIN) +# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) +# define QT_QTSINGLEAPPLICATION_EXPORT +# elif defined(QT_QTSINGLEAPPLICATION_IMPORT) +# if defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# endif +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) +# elif defined(QT_QTSINGLEAPPLICATION_EXPORT) +# undef QT_QTSINGLEAPPLICATION_EXPORT +# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTSINGLEAPPLICATION_EXPORT +#endif + +class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication +{ + Q_OBJECT + +public: + QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); + QtSingleApplication(const QString &id, int &argc, char **argv); +#if QT_VERSION < 0x050000 + QtSingleApplication(int &argc, char **argv, Type type); +# if defined(Q_WS_X11) + QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); + QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); + QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); +# endif // Q_WS_X11 +#endif // QT_VERSION < 0x050000 + + bool isRunning(); + QString id() const; + + void setActivationWindow(QWidget* aw, bool activateOnMessage = true); + QWidget* activationWindow() const; + + // Obsolete: + void initialize(bool dummy = true) + { isRunning(); Q_UNUSED(dummy) } + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + void activateWindow(); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + void sysInit(const QString &appId = QString()); + QtLocalPeer *peer; + QWidget *actWin; +}; + +#endif // QTSINGLEAPPLICATION_H diff --git a/SandboxiePlus/QtSingleApp/src/qtsingleapplication.pri b/SandboxiePlus/QtSingleApp/src/qtsingleapplication.pri new file mode 100644 index 0000000000..6f2bced94d --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtsingleapplication.pri @@ -0,0 +1,17 @@ +include(../common.pri) +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +QT *= network +greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets + +qtsingleapplication-uselib:!qtsingleapplication-buildlib { + LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME +} else { + SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp + HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h +} + +win32 { + contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT + else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT +} diff --git a/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.cpp b/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.cpp new file mode 100644 index 0000000000..cf123ce2ed --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include "qtsinglecoreapplication.h" +#include "qtlocalpeer.h" + +/*! + \class QtSingleCoreApplication qtsinglecoreapplication.h + \brief A variant of the QtSingleApplication class for non-GUI applications. + + This class is a variant of QtSingleApplication suited for use in + console (non-GUI) applications. It is an extension of + QCoreApplication (instead of QApplication). It does not require + the QtGui library. + + The API and usage is identical to QtSingleApplication, except that + functions relating to the "activation window" are not present, for + obvious reasons. Please refer to the QtSingleApplication + documentation for explanation of the usage. + + A QtSingleCoreApplication instance can communicate to a + QtSingleApplication instance if they share the same application + id. Hence, this class can be used to create a light-weight + command-line tool that sends commands to a GUI application. + + \sa QtSingleApplication +*/ + +/*! + Creates a QtSingleCoreApplication object. The application identifier + will be QCoreApplication::applicationFilePath(). \a argc and \a + argv are passed on to the QCoreAppliation constructor. +*/ + +QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer("", this); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Creates a QtSingleCoreApplication object with the application + identifier \a appId. \a argc and \a argv are passed on to the + QCoreAppliation constructor. +*/ +QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) + : QCoreApplication(argc, argv) +{ + peer = new QtLocalPeer(appId, this); + connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); +} + + +/*! + Returns true if another instance of this application is running; + otherwise false. + + This function does not find instances of this application that are + being run by a different user (on Windows: that are running in + another session). + + \sa sendMessage() +*/ + +bool QtSingleCoreApplication::isRunning() +{ + return peer->isClient(); +} + + +/*! + Tries to send the text \a message to the currently running + instance. The QtSingleCoreApplication object in the running instance + will emit the messageReceived() signal when it receives the + message. + + This function returns true if the message has been sent to, and + processed by, the current instance. If there is no instance + currently running, or if the running instance fails to process the + message within \a timeout milliseconds, this function return false. + + \sa isRunning(), messageReceived() +*/ + +bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) +{ + return peer->sendMessage(message, timeout); +} + + +/*! + Returns the application identifier. Two processes with the same + identifier will be regarded as instances of the same application. +*/ + +QString QtSingleCoreApplication::id() const +{ + return peer->applicationId(); +} + + +/*! + \fn void QtSingleCoreApplication::messageReceived(const QString& message) + + This signal is emitted when the current instance receives a \a + message from another instance of this application. + + \sa sendMessage() +*/ diff --git a/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.h b/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.h new file mode 100644 index 0000000000..b87fffe41f --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Solutions component. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTSINGLECOREAPPLICATION_H +#define QTSINGLECOREAPPLICATION_H + +#include + +class QtLocalPeer; + +class QtSingleCoreApplication : public QCoreApplication +{ + Q_OBJECT + +public: + QtSingleCoreApplication(int &argc, char **argv); + QtSingleCoreApplication(const QString &id, int &argc, char **argv); + + bool isRunning(); + QString id() const; + +public Q_SLOTS: + bool sendMessage(const QString &message, int timeout = 5000); + + +Q_SIGNALS: + void messageReceived(const QString &message); + + +private: + QtLocalPeer* peer; +}; + +#endif // QTSINGLECOREAPPLICATION_H diff --git a/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.pri b/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.pri new file mode 100644 index 0000000000..d2d6cc3e14 --- /dev/null +++ b/SandboxiePlus/QtSingleApp/src/qtsinglecoreapplication.pri @@ -0,0 +1,10 @@ +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD +HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h +SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp + +QT *= network + +win32:contains(TEMPLATE, lib):contains(CONFIG, shared) { + DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport) +} diff --git a/SandboxiePlus/SandMan/Resources/Actions/Advanced.png b/SandboxiePlus/SandMan/Resources/Actions/Advanced.png new file mode 100644 index 0000000000000000000000000000000000000000..c792ceefd8cbf2e9e0927011132df972500f7bef GIT binary patch literal 2967 zcmV;I3uyF-P)%N>)3&v z5iDRB-pu`d_m6vn0q)7YCztJ(-F#-wA368=J-_F9&U1cm=Lz)EOE10j^8Xi$BK#M# zRbwy(s0RK#d;0*eL-6$5D{RZfHZY7~NyXa_v)IH83`sQh8%%O{(#}NDQ&0eg%vL37 zR$+|FBib6kjJ-d!-$pSaD#H?rpBh9;a97v+f=xQf-ETG8sX}#m`2>c3S)+n9yL=es zi+6lj=o_CXJ5E{IamqaLNgo#a;*c+@C0@Pye%;&?#|mLsLh&;nV!bEs^2Oo67!imn zUmOm^9kI(u4NE9qsJ?D9;M!TLG>=`tK*2h_PyL?N)}BkYVvhR9&aeiU1RMoMyzwL3 z7sa`J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6oBb_qdevhAhhP+2&=QHh2 z^^ZB$_>L=l#}ytlPP_BmE$kl?-xZeykpocXGcyq7foKU}Yaj-c`ONIO3B?g8bM=%+ z0Z1g|`{Ds#;E9GHO@p7=_dl4tRsSpFNw)tU6Upcgw=>C%zXJAssEX!f63zK6|B1Nv z-M&l&*7e+!!kKfY<^zj>65QE)0!{$mUe;{iFH~2g3<$DMKM+fkNpoNd9LxO7$ z%$9C4^BuDT2Z7`DD7vBsV2LkIB&oqvlVm9n%i zR`{7$Z=Tn|T;GA`cr1$ZP(%QVoqvnPkMnpSjs;>&_Bt9|cJ3*0AzYFf0FZ39_dGEp za2yOA2fZ|3NH$wRNAX?h@#3Y}HTcC~;WpaFuq*S8 zuUMAftWjhRX9oiBK<04v#Bufk^eLs%6XSsgfx*BZoMYmHuUKn$dP4*7PgR+P&fmV= zvxQEv?Ypvagesk7Dpi1Wv4Hw7?aW=N@>rGn$2nW6@`toX)$F$L!!)N&OOC|Ya5P}_(SXwIb?cFU=jOEOktF7vquv*X0vOYHlg5VW z@9yhxP8PLlr{J6_FoT!AU2WBcw2z7>rT|DRo3Yc{7wu4;I=UU47ksl-ZC|dorYCRE za>3$kZDYW& zDzJY6v=6}goCFk}Gm$f3K!Kahi^Kl67(NDs1)zhM zxbU67V6kzrw#q*2Fma7MCIG)4c!ma9-T*WJ#2pi|X5=i=fF8U8H`bjy+DC046~BYE zX3WBv^KTXU#~UWv#(nGcC?S<92H&liY|ppCExT7TowH1?XVG?=iJ~aAbkmqRm?C$Wd)|bXg5N3If zUBIM~m84$iQ2oae)&w-2FZ;p}m0O%Oa!dr?_0rszM|W~8i3YHeNW<{ zqO2C*8@1nZSC#dEtyile@L8!ml`4o9AMP8u-`>opGc*9ZhbeyKG>c74CzAE%-9zX9!?qn3HlFu?!- N002ovPDHLkV1nye({2C& literal 0 HcmV?d00001 diff --git a/SandboxiePlus/SandMan/Resources/Actions/Connect.png b/SandboxiePlus/SandMan/Resources/Actions/Connect.png new file mode 100644 index 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^O?m&+?F)$r)3k7ZR`w)dp{VB*a}?S*m& z%0!?~E7fcT7NE>8+V+3s2NNyft@HHsgkzXfE;qseRSFPJ!9TK6pc<$`s79$&p&}8Z pV#KG%)+M*29qnjGJKE8<_+J+Wu*r-Co9O@m002ovPDHLkV1no3sgD2v literal 0 HcmV?d00001 diff --git a/SandboxiePlus/SandMan/Resources/Actions/Disconnect.png b/SandboxiePlus/SandMan/Resources/Actions/Disconnect.png new file mode 100644 index 0000000000000000000000000000000000000000..0b6eb427c5ab9862905c29dbef184712a662ad1d GIT binary patch literal 3565 zcmVJEoeat{{KS$8l9Z^ch*BaLroZh z(a#`Hpc6tKh5?lZl>!wA?}%r;H{ST{G5PFd`*zX<=y|*K5@RYb5jdlnX1)+(iFp=( z@`QYP0^K`=6D)wqw`MR-gns}ot+Q{iLts5nX0Snp9e64d*;Lkkjbyi_lh)8NRJw{W z*o*>%0-#HsVW1Sp?2jIm=TD@^O%ot)uFrPHn{b6d2M-@RSg`pC`QqH^Rv?Z?fPpFY z*8?6p=x(%OD<&y0}Z|sLV3+&$yAAbNfH2{>py^zbIWI`kXE}ClJ6Icd(nMiQKrX{ko zu5G|Hn`*{FVB1+=lfQhqgv|>t8hZWEvfJ-x8_;?9CD0?kzU{yPD1I?1g20#!i)2+} z_FR-s1J6h`P|uvhg9q5KP!_52CpAvr+K%&^6iqXbx1WJ(bnem~zI_I?3+w;7Wy3|i zKn=t*GK#$*63OU*fxxx~+dbQWv&87!gjkw|n5UyR=#&k)wa2!fk_~|eflg8EMaux= z6E$$grAN1om|^YJ__i8o$R|ZX^rfN_a%vzqJo0bHj${TXY>8wq3Mmlgt5M^O zX~QSlO?97Na)WhDe8ZD!v{%pT>z2sY<^~oO>z2p|YLtId4KKY3*)_@Z&#i^`KYJ)|Qsa+38(gq$nTMuo~m zjE$wglf8BAqbAzl)EaAna{yY!;MDd|xgYjaA2RdIt3^^6rN2l5jQWA~G2v~%5GpXb z9oAfiGUIrHkH^iu{t?%U@MECgQO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LbHU7)s;=?~TsCKZ%U@XZYwFmg6 zuVwzYkL2s71egxR7g&ejAh#jh2eboffEP&inR68V)fjwl^yX-_3{5JQj$>|cAFjeP z(u9rzA6vk}F`H!D3+Gy2=XeO?iWGgH!7~brM!nB}NBK66>FYd(8%#l%fYA!Tj1{8% zXv}-^X~{X(BXmqL=!LLLVD**nv$`pLo$%ial=QZ%5bgoKbC~^IKsm7985=_7E3Z_9 zvE*T8Rt}I`; literal 0 HcmV?d00001 diff --git a/SandboxiePlus/SandMan/Resources/Actions/Maintenance.png b/SandboxiePlus/SandMan/Resources/Actions/Maintenance.png new file mode 100644 index 0000000000000000000000000000000000000000..eab34a9de070a289316f35c8ced82f028e829cb0 GIT binary patch literal 2268 zcmV<22qX82P)<_$@}BJd+s^so_Ef<=ia#kUFbp=y3mFHUr5veUwmA@i?U8& zVD5W`k5Fp=wN`!`h2OyWT9HUI5%_@$BNYY-^!#v*6x8jud8)ug;3ME25w;nJT_;z| zm8f$8aH0-yv#fKKfkq+sag~8Ctc${H$UJ?pTbknzY;j<+QAW5*Pou$Oe0et+Ww=qM zI+o4a%F!W@>7=N0ffxobc#}W1RwVcF6&nCXzvT5s#X_?@>7&6!2DzN{0c+?M${IWeU6+H z^>P$A3R*wnQ658h30OArQN4V0z5Fb!F4054bNA5i^D%0Uj!7ubxk}cBhmY0E+P2Au z;nT5S^w@e?lTfC*N~?jDcg@kSgq=_H5D0M5Qm%WIF3Sr>F-BSSZoTY`$|tD*Z|h~Z zfftODaI>r|t%--|A)uT>xnuNfZLfv}gj2=Fj-I7o#xfQ-o9@o@1^JfSWvpw#RRU{;HePZ2yD9rz3kl0N zOV1{T0ifeo2p#{Hp*~%pYZ~RWQK+7w)%ktjctpSM%Q_u2-Vu)YG=ocP6e9=tN)~Mg z!BP4NU@|lp;k^l11RNYcy(42^)~2BGnNK;}tvdky!{`*x0JeBLP?+^f?;e$03Zm(s zX6eUC5SRfB$m>3>u&HkgOM}K&cE`zj`h+U;%jy9JK1R7Y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xo)1gzn-Aav zhcwq~LMG*eN=w>Lp+fb9Wso;5%dtO3@5k`_vg zHNf_OIL{iO3HByv4TxMw*n?ze1G}1#{B+nmassPVKZIQzxh5t5A~bW^Z4hx{lL|W> zw)+8*o+elW{_zH=x5To*eiqy z1+u`l=Bj@IC-fU|7FgUoE)aNneo)V=vYRbw(xB^vI|$(DYtKYomfo6`djhu#CrpXs z?zw?m(6vb39FvPUZisLSm@E{oI`$FX;pm^)aj!-l#xM-SFpPTh8}0<+ogY6WNB{r; M07*qoM6N<$g3;R~82|tP literal 0 HcmV?d00001 diff --git a/SandboxiePlus/SandMan/Resources/SandMan.qrc b/SandboxiePlus/SandMan/Resources/SandMan.qrc index d1b40015af..b52c274758 100644 --- a/SandboxiePlus/SandMan/Resources/SandMan.qrc +++ b/SandboxiePlus/SandMan/Resources/SandMan.qrc @@ -1,11 +1,12 @@ - SandMan.png + SandMan.png sandbox-empty.png sandbox-full.png dll32.png exe32.png close.png + SandMan2.png Actions/SetLogging.png @@ -17,5 +18,12 @@ Actions/reload_ini.png Actions/edit_ini.png Actions/log_api.png + Actions/Maintenance.png + Actions/Connect.png + Actions/Disconnect.png + Actions/Start.png + Actions/Stop.png + Actions/Advanced.png + Actions/Service.png diff --git a/SandboxiePlus/SandMan/Resources/SandMan2.png b/SandboxiePlus/SandMan/Resources/SandMan2.png new file mode 100644 index 0000000000000000000000000000000000000000..baf2b6f3477422a2cecd2a2efbba0285e009dfab GIT binary patch literal 8164 zcmb7JWmJ?=w;mCsB&0h;0Rac;bm;CFI;6Y1L68ms0claGp`<%Rhi-(SduWNF`;Oly z{kW-M6>001pmPEt(M+vs;Twl@*HvHSJLaSigBnmH|Y zD4WqLSt(ObX?{!L7=nt?7%}${l>jJ)Drql;s)v0dug}VCjaK$nUQ!d+wH*~x?o*_J zRA=_HHJYUP>9ZE&Yjxh_{ml7i&Apb0yVt|}^aDfwM}y7#LR^cxySv0leE;8%J8EEt zP1r4WGVhH$N=lXSwK>YmT>-%>+Y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&;BIL6I>uLQu*;- z$F@u-X02_J@sPS=PU3#vzi_DwO8+|?+v-1un{W*AW|ncPP4DdcaM%B&meG{IR-K`H zbXs##|2teu@4a#1lIJhFLp)r9|KdF4MaTS`Vng{U#&3wC+b6T<_c|RPbaX87%s&Wp zp#Q?a@A2)=E8iD1d~enI$KLL2!t;qi0vgr%lqpzbxUWhRqtc(AUv=cWpF)N^hKQs7}Pf+WR z^Wq(7drC=5Brd^9|>uOit7w{+^b1hG@UxT#Znl&0B55Jo*!MeV;PbNKN8```2b fb$-YIvG%pdyR_tzm|FpzKVEWD%97>cZ{Ge7k(beU literal 0 HcmV?d00001 diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index a489b44a73..3fe6ec6c10 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "SandMan.h" +#include "../MiscHelpers/Common/Common.h" #include "../MiscHelpers/Common/ExitDialog.h" #include "../MiscHelpers/Common/SortFilterProxyModel.h" #include "Views/SbieView.h" @@ -7,6 +8,7 @@ #include #include "ApiLog.h" #include "./Dialogs/MultiErrorDialog.h" +#include "../QSbieAPI/SbieUtils.h" CSbieAPI* theAPI = NULL; @@ -15,7 +17,7 @@ CSbieAPI* theAPI = NULL; #include #include -BOOLEAN OnWM_Notify(NMHDR *Header, LRESULT *Result); +//BOOLEAN OnWM_Notify(NMHDR *Header, LRESULT *Result); class CNativeEventFilter : public QAbstractNativeEventFilter { @@ -31,9 +33,9 @@ class CNativeEventFilter : public QAbstractNativeEventFilter if (msg->message == WM_NOTIFY) { - LRESULT ret; - if (OnWM_Notify((NMHDR*)msg->lParam, &ret)) - *result = ret; + //LRESULT ret; + //if (OnWM_Notify((NMHDR*)msg->lParam, &ret)) + // *result = ret; return true; } else if (msg->message == WM_DEVICECHANGE) @@ -77,12 +79,15 @@ CSandMan::CSandMan(QWidget *parent) m_bExit = false; theAPI = new CSbieAPI(this); + connect(theAPI, SIGNAL(StatusChanged()), this, SLOT(OnStatusChanged())); QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion()); - appTitle.append(tr(" - Driver: v%1").arg(theAPI->GetVersion())); this->setWindowTitle(appTitle); - theAPI->TakeOver(); + m_ApiLog = NULL; + + m_bConnectPending = false; + m_bStopPending = false; m_pMainWidget = new QWidget(); m_pMainLayout = new QVBoxLayout(m_pMainWidget); @@ -193,17 +198,43 @@ CSandMan::CSandMan(QWidget *parent) m_pApiLog->setEnabled(false); // + connect(menuBar(), SIGNAL(hovered(QAction*)), this, SLOT(OnMenuHover(QAction*))); + m_pMenuFile = menuBar()->addMenu(tr("&Sandbox")); - m_pMenuNew = m_pMenuFile->addAction(QIcon(":/Actions/NewBox"), tr("Create New Box"), this, SLOT(OnNewBox())); + m_pNew = m_pMenuFile->addAction(QIcon(":/Actions/NewBox"), tr("Create New Box"), this, SLOT(OnNewBox())); + m_pMenuFile->addSeparator(); + m_pEmptyAll = m_pMenuFile->addAction(QIcon(":/Actions/EmptyAll"), tr("Terminate All Processes"), this, SLOT(OnEmptyAll())); m_pMenuFile->addSeparator(); - m_pMenuEmptyAll = m_pMenuFile->addAction(QIcon(":/Actions/EmptyAll"), tr("Terminate All Processes"), this, SLOT(OnEmptyAll())); + m_pMaintenance = m_pMenuFile->addMenu(QIcon(":/Actions/Maintenance"), tr("&Maintenance")); + m_pConnect = m_pMaintenance->addAction(QIcon(":/Actions/Connect"), tr("Connect"), this, SLOT(OnMaintenance())); + m_pDisconnect = m_pMaintenance->addAction(QIcon(":/Actions/Disconnect"), tr("Disconnect"), this, SLOT(OnMaintenance())); + m_pMaintenance->addSeparator(); + m_pStopAll = m_pMaintenance->addAction(QIcon(":/Actions/Stop"), tr("Stop All"), this, SLOT(OnMaintenance())); + m_pMaintenance->addSeparator(); + m_pMaintenanceItems = m_pMaintenance->addMenu(QIcon(":/Actions/Advanced"), tr("&Advanced")); + m_pInstallDrv = m_pMaintenanceItems->addAction(tr("Install Driver"), this, SLOT(OnMaintenance())); + m_pStartDrv = m_pMaintenanceItems->addAction(tr("Start Driver"), this, SLOT(OnMaintenance())); + m_pStopDrv = m_pMaintenanceItems->addAction(tr("Stop Driver"), this, SLOT(OnMaintenance())); + m_pUninstallDrv = m_pMaintenanceItems->addAction(tr("Uninstall Driver"), this, SLOT(OnMaintenance())); + m_pMaintenanceItems->addSeparator(); + m_pInstallSvc = m_pMaintenanceItems->addAction(tr("Install Service"), this, SLOT(OnMaintenance())); + m_pStartSvc = m_pMaintenanceItems->addAction(tr("Start Service"), this, SLOT(OnMaintenance())); + m_pStopSvc = m_pMaintenanceItems->addAction(tr("Stop Service"), this, SLOT(OnMaintenance())); + m_pUninstallSvc = m_pMaintenanceItems->addAction(tr("Uninstall Service"), this, SLOT(OnMaintenance())); + m_pMenuFile->addSeparator(); - m_pMenuExit = m_pMenuFile->addAction(QIcon(":/Actions/Exit"), tr("Exit"), this, SLOT(OnExit())); + m_pExit = m_pMenuFile->addAction(QIcon(":/Actions/Exit"), tr("Exit"), this, SLOT(OnExit())); m_pMenuView = menuBar()->addMenu(tr("&View")); - m_pCleanUp = m_pMenuView->addAction(QIcon(":/Actions/Clean"), tr("Clean Up"), this, SLOT(OnCleanUp())); - m_pKeepTerminated = m_pMenuView->addAction(QIcon(":/Actions/Keep"), tr("Keep closed"), this, SLOT(OnSetKeep())); + m_pCleanUpMenu = m_pMenuView->addMenu(QIcon(":/Actions/Clean"), tr("Clean Up")); + m_pCleanUpProcesses = m_pCleanUpMenu->addAction(tr("Cleanup Processes"), this, SLOT(OnCleanUp())); + m_pCleanUpMenu->addSeparator(); + m_pCleanUpMsgLog = m_pCleanUpMenu->addAction(tr("Cleanup Message Log"), this, SLOT(OnCleanUp())); + m_pCleanUpResLog = m_pCleanUpMenu->addAction(tr("Cleanup Resource Log"), this, SLOT(OnCleanUp())); + m_pCleanUpApiLog = m_pCleanUpMenu->addAction(tr("Cleanup Api Call Log"), this, SLOT(OnCleanUp())); + + m_pKeepTerminated = m_pMenuView->addAction(QIcon(":/Actions/Keep"), tr("Keep terminated"), this, SLOT(OnSetKeep())); m_pKeepTerminated->setCheckable(true); m_pMenuOptions = menuBar()->addMenu(tr("&Options")); @@ -218,11 +249,11 @@ CSandMan::CSandMan(QWidget *parent) m_pMenuHelp = menuBar()->addMenu(tr("&Help")); - m_pMenuSupport = m_pMenuHelp->addAction(tr("Support Sandboxie-Plus on Patreon"), this, SLOT(OnAbout())); + m_pSupport = m_pMenuHelp->addAction(tr("Support Sandboxie-Plus on Patreon"), this, SLOT(OnAbout())); m_pMenuHelp->addSeparator(); - m_pMenuAboutQt = m_pMenuHelp->addAction(tr("About the Qt Framework"), this, SLOT(OnAbout())); + m_pAboutQt = m_pMenuHelp->addAction(tr("About the Qt Framework"), this, SLOT(OnAbout())); //m_pMenuHelp->addSeparator(); - m_pMenuAbout = m_pMenuHelp->addAction(QIcon(":/SandMan.png"), tr("About Sandboxie-Plus"), this, SLOT(OnAbout())); + m_pAbout = m_pMenuHelp->addAction(QIcon(":/SandMan.png"), tr("About Sandboxie-Plus"), this, SLOT(OnAbout())); @@ -230,7 +261,18 @@ CSandMan::CSandMan(QWidget *parent) //m_pToolBar->addAction(m_pMenuEmptyAll); //m_pToolBar->addSeparator(); m_pToolBar->addAction(m_pKeepTerminated); - m_pToolBar->addAction(m_pCleanUp); + //m_pToolBar->addAction(m_pCleanUp); + + m_pCleanUpButton = new QToolButton(); + m_pCleanUpButton->setIcon(MakeActionIcon(":/Actions/Clean")); + m_pCleanUpButton->setToolTip(tr("Cleanup")); + m_pCleanUpButton->setPopupMode(QToolButton::MenuButtonPopup); + m_pCleanUpButton->setMenu(m_pCleanUpMenu); + //QObject::connect(m_pCleanUpButton, SIGNAL(triggered(QAction*)), , SLOT()); + QObject::connect(m_pCleanUpButton, SIGNAL(pressed()), this, SLOT(OnCleanUp())); + m_pToolBar->addWidget(m_pCleanUpButton); + + m_pToolBar->addSeparator(); m_pToolBar->addAction(m_pEditIni); m_pToolBar->addSeparator(); @@ -260,10 +302,11 @@ CSandMan::CSandMan(QWidget *parent) m_pTrayIcon = new QSystemTrayIcon(Icon, this); m_pTrayIcon->setToolTip("Sandboxie-Plus"); connect(m_pTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(OnSysTray(QSystemTrayIcon::ActivationReason))); + m_bIconEmpty = false; m_pTrayMenu = new QMenu(); m_pTrayMenu->addSeparator(); - m_pTrayMenu->addAction(m_pMenuExit); + m_pTrayMenu->addAction(m_pExit); bool bAutoRun = QApplication::arguments().contains("-autorun"); @@ -291,15 +334,17 @@ CSandMan::CSandMan(QWidget *parent) m_pKeepTerminated->setChecked(theConf->GetBool("Options/pKeepTerminated")); - // connect last so if there were unpurged messages they end up no ware + connect(theAPI, SIGNAL(LogMessage(const QString&)), this, SLOT(OnLogMessage(const QString&))); - m_ApiLog = NULL; + if (CSbieUtils::IsRunning(CSbieUtils::eAll) || theConf->GetBool("Options/StartIfStopped", true)) + ConnectSbie(); - statusBar()->showMessage("Ready", 3000); + if (theConf->GetBool("Options/WatchIni", true)) + theAPI->WatchIni(); - m_uTimerID = startTimer(250); + m_uTimerID = startTimer(250); } CSandMan::~CSandMan() @@ -352,19 +397,92 @@ void CSandMan::closeEvent(QCloseEvent *e) } } + if (IsFullyPortable() && theAPI->IsConnected()) + { + int PortableStop = theConf->GetInt("Options/PortableStop", -1); + if (PortableStop == -1) + { + bool State = false; + PortableStop = CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Sandboxie-Plus was running in portable mode, now it has to clean up the created services, this will prompt for administrative privileges.") + , tr("Don't show this message again."), &State, QDialogButtonBox::Ok | QDialogButtonBox::Cancel, QDialogButtonBox::Ok, QMessageBox::Information) == QDialogButtonBox::Ok ? 1 : 0; + + if (!PortableStop) + { + e->ignore(); + return; + } + + if (State) + theConf->SetValue("Options/PortableStop", PortableStop); + } + + StopSbie(true); + } + QApplication::quit(); } +bool CSandMan::IsFullyPortable() +{ + QString SbiePath = theAPI->GetSbiePath(); + QString AppPath = QApplication::applicationDirPath().replace("/", "\\"); + return (theConf->IsPortable() && SbiePath.compare(AppPath, Qt::CaseInsensitive) == 0); +} + +void CSandMan::OnMessage(const QString& Message) +{ + if (Message == "ShowWnd") + { + if (!isVisible()) + show(); + setWindowState(Qt::WindowActive); + SetForegroundWindow(MainWndHandle); + } + else if (Message.left(6) == "Status") + { + QString Status = Message.mid(7); + if (Status != "OK") + { + if(m_bStopPending) + QMessageBox::warning(NULL, tr("Sandboxie-Plus - Error"), tr("Failed to stop all sandboxie components")); + else if(m_bConnectPending) + QMessageBox::warning(NULL, tr("Sandboxie-Plus - Error"), tr("Failed to start required sandboxie components")); + + OnLogMessage(tr("Maintenance operation %1").arg(Status)); + CheckResults(QList() << SB_ERR(Status)); + } + else + { + OnLogMessage(tr("Maintenance operation Successful")); + if (m_bConnectPending) + theAPI->Connect(true); + } + m_bConnectPending = false; + m_bStopPending = false; + } +} + void CSandMan::timerEvent(QTimerEvent* pEvent) { if (pEvent->timerId() != m_uTimerID) return; - theAPI->ReloadBoxes(); - theAPI->UpdateProcesses(m_pKeepTerminated->isChecked()); + if (theAPI->IsConnected()) + { + theAPI->ReloadBoxes(); + theAPI->UpdateProcesses(m_pKeepTerminated->isChecked()); + } m_pBoxView->Refresh(); + if (m_bIconEmpty != (theAPI->TotalProcesses() == 0)) + { + m_bIconEmpty = (theAPI->TotalProcesses() == 0); + QIcon Icon; + Icon.addFile(m_bIconEmpty ? ":/SandMan2.png" : ":/SandMan.png"); + m_pTrayIcon->setIcon(Icon); + } + /*QList Added = m_pBoxModel->Sync(theAPI->GetAllBoxes()); if (m_pBoxModel->IsTree()) @@ -400,6 +518,64 @@ void CSandMan::OnSelectionChanged() m_pResMonModel->Sync(ResourceLog, Pids); } +void CSandMan::OnStatusChanged() +{ + QString appTitle = tr("Sandboxie-Plus v%1").arg(GetVersion()); + if (theAPI->IsConnected()) + { + appTitle.append(tr(" - Driver: v%1").arg(theAPI->GetVersion())); + //appTitle.append(tr(" - %1").arg(theAPI->GetIniPath())); + + if (theAPI->GetAllBoxes().count() == 0) { + OnLogMessage(tr("No sandboxes found; creating: %1").arg("DefaultBox")); + theAPI->CreateBox("DefaultBox"); + } + + if(IsFullyPortable()) + appTitle.append(tr(" - Portable")); + + OnLogMessage(tr("Sbie Directory: %1").arg(theAPI->GetSbiePath())); + OnLogMessage(tr("Loaded Config: %1").arg(theAPI->GetIniPath())); + } + else + { + appTitle.append(tr(" - Driver NOT connected").arg(theAPI->GetVersion())); + } + this->setWindowTitle(appTitle); +} + +void CSandMan::OnMenuHover(QAction* action) +{ + //if (!menuBar()->actions().contains(action)) + // return; // ignore sub menus + + + if (menuBar()->actions().at(0) == action) + { + bool bConnected = theAPI->IsConnected(); + m_pConnect->setEnabled(!bConnected); + m_pDisconnect->setEnabled(bConnected); + + m_pMaintenanceItems->setEnabled(!bConnected); + + bool DrvInstalled = CSbieUtils::IsInstalled(CSbieUtils::eDriver); + bool DrvLoaded = CSbieUtils::IsRunning(CSbieUtils::eDriver); + m_pInstallDrv->setEnabled(!DrvInstalled); + m_pStartDrv->setEnabled(!DrvLoaded); + m_pStopDrv->setEnabled(DrvLoaded); + m_pUninstallDrv->setEnabled(DrvInstalled); + + bool SvcInstalled = CSbieUtils::IsInstalled(CSbieUtils::eService); + bool SvcStarted = CSbieUtils::IsRunning(CSbieUtils::eService); + m_pInstallSvc->setEnabled(!SvcInstalled); + m_pStartSvc->setEnabled(!SvcStarted && DrvInstalled); + m_pStopSvc->setEnabled(SvcStarted); + m_pUninstallSvc->setEnabled(SvcInstalled); + + //m_pMenuStopAll - always enabled + } +} + void CSandMan::OnLogMessage(const QString& Message) { QTreeWidgetItem* pItem = new QTreeWidgetItem(); // Time|Message @@ -450,9 +626,115 @@ void CSandMan::OnEmptyAll() theAPI->TerminateAll(); } +SB_STATUS CSandMan::ConnectSbie() +{ + SB_STATUS Status; + + if (!CSbieUtils::IsRunning(CSbieUtils::eAll)) + { + if (!CSbieUtils::IsInstalled(CSbieUtils::eAll)) + { + int PortableStart = theConf->GetInt("Options/PortableStart", -1); + if (PortableStart == -1) + { + bool State = false; + PortableStart = CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("Sandboxie-Plus was started in portable mode and it needs to create nececery services, this will prompt for administrative privileges.") + , tr("Don't show this message again."), &State, QDialogButtonBox::Ok | QDialogButtonBox::Cancel, QDialogButtonBox::Ok, QMessageBox::Information) == QDialogButtonBox::Ok ? 1 : 0; + + if (State) + theConf->SetValue("Options/PortableStart", PortableStart); + } + + if(!PortableStart) + return SB_OK; + } + + Status = CSbieUtils::Start(CSbieUtils::eAll); + } + + if (Status.GetStatus() == OP_ASYNC) + m_bConnectPending = true; + else if (!Status.IsError()) + Status = theAPI->Connect(true); + + return Status; +} + +SB_STATUS CSandMan::DisconnectSbie() +{ + return theAPI->Disconnect(); +} + +SB_STATUS CSandMan::StopSbie(bool andRemove) +{ + SB_STATUS Status; + + if (theAPI->IsConnected()) { + Status = theAPI->TerminateAll(); + theAPI->Disconnect(); + } + if (!Status.IsError()) { + if(andRemove) + Status = CSbieUtils::Uninstall(CSbieUtils::eAll); // it stops it first ofcause + else + Status = CSbieUtils::Stop(CSbieUtils::eAll); + if (Status.GetStatus() == OP_ASYNC) + m_bStopPending = true; + } + + return Status; +} + +void CSandMan::OnMaintenance() +{ + SB_STATUS Status; + if (sender() == m_pConnect) + Status = ConnectSbie(); + else if (sender() == m_pDisconnect) + Status = DisconnectSbie(); + else if (sender() == m_pStopAll) + Status = StopSbie(); + + // advanced + else if (sender() == m_pInstallDrv) + Status = CSbieUtils::Install(CSbieUtils::eDriver); + else if (sender() == m_pStartDrv) + Status = CSbieUtils::Start(CSbieUtils::eDriver); + else if (sender() == m_pStopDrv) + Status = CSbieUtils::Stop(CSbieUtils::eDriver); + else if (sender() == m_pUninstallDrv) + Status = CSbieUtils::Uninstall(CSbieUtils::eDriver); + + else if (sender() == m_pInstallSvc) + Status = CSbieUtils::Install(CSbieUtils::eService); + else if(sender() == m_pStartSvc) + Status = CSbieUtils::Start(CSbieUtils::eService); + else if(sender() == m_pStopSvc) + Status = CSbieUtils::Stop(CSbieUtils::eService); + else if (sender() == m_pUninstallSvc) + Status = CSbieUtils::Uninstall(CSbieUtils::eService); + + if (Status.GetStatus() == OP_ASYNC) { + statusBar()->showMessage(tr("Executing maintenance operation, please wait...")); + return; + } + + CheckResults(QList() << Status); +} + void CSandMan::OnCleanUp() { - theAPI->UpdateProcesses(false); + if (sender() == m_pCleanUpMsgLog || sender() == m_pCleanUpButton) + m_pMessageLog->GetTree()->clear(); + + if (sender() == m_pCleanUpResLog || sender() == m_pCleanUpButton) + theAPI->ClearResLog(); + + if (sender() == m_pCleanUpApiLog || sender() == m_pCleanUpButton) + m_pApiLog->GetTree()->clear(); + + if (sender() == m_pCleanUpProcesses || sender() == m_pCleanUpButton) + theAPI->UpdateProcesses(false); } void CSandMan::OnSetKeep() @@ -488,6 +770,9 @@ void CSandMan::OnEditIni() //WaitForSingleObject(si.hProcess, INFINITE); //CloseHandle(si.hProcess); + if (theConf->GetBool("Options/WatchIni", true)) + return; // if the ini s watched dont double reload + QWinEventNotifier* processFinishedNotifier = new QWinEventNotifier(si.hProcess); processFinishedNotifier->setEnabled(true); connect(processFinishedNotifier, &QWinEventNotifier::activated, this, [processFinishedNotifier, this, si]() { @@ -501,7 +786,6 @@ void CSandMan::OnEditIni() void CSandMan::OnReloadIni() { theAPI->ReloadConfig(); - statusBar()->showMessage(tr("Sandboxie config has been reloaded."), 3000); } void CSandMan::OnSetMonitoring() @@ -592,11 +876,7 @@ void CSandMan::OnSysTray(QSystemTrayIcon::ActivationReason Reason) return; } setWindowState(Qt::WindowActive); - //WINDOWPLACEMENT placement = { sizeof(placement) }; - //GetWindowPlacement(PhMainWndHandle, &placement); - //if (placement.showCmd == SW_MINIMIZE || placement.showCmd == SW_SHOWMINIMIZED) - // ShowWindowAsync(PhMainWndHandle, SW_RESTORE); - //SetForegroundWindow(PhMainWndHandle); + SetForegroundWindow(MainWndHandle); } ); } #endif @@ -620,7 +900,7 @@ QString CSandMan::GetVersion() void CSandMan::OnAbout() { - if (sender() == m_pMenuAbout) + if (sender() == m_pAbout) { QString AboutCaption = tr( "

About Sandboxie-Plus

" @@ -649,7 +929,7 @@ void CSandMan::OnAbout() msgBox->exec(); } - else if (sender() == m_pMenuAboutQt) + else if (sender() == m_pAboutQt) QMessageBox::aboutQt(this); else QDesktopServices::openUrl(QUrl("https://www.patreon.com/DavidXanatos")); @@ -657,7 +937,7 @@ void CSandMan::OnAbout() ////////////////////////////////////////////////////////////////////////////////////////// // - +/* #include #include @@ -695,16 +975,16 @@ BOOLEAN OnWM_Notify(NMHDR *Header, LRESULT *Result) *Result = RF_CANCEL; return TRUE; } - /*else if (Header->code == RFN_LIMITEDRUNAS) - { - - }*/ + //else if (Header->code == RFN_LIMITEDRUNAS) + //{ + // + //} return FALSE; } extern "C" { - NTSYSCALLAPI NTSTATUS NTAPI LdrGetProcedureAddress(IN PVOID DllHandle, IN VOID* /*PANSI_STRING*/ ProcedureName OPTIONAL, IN ULONG ProcedureNumber OPTIONAL, OUT PVOID *ProcedureAddress, IN BOOLEAN RunInitRoutines); + NTSYSCALLAPI NTSTATUS NTAPI LdrGetProcedureAddress(IN PVOID DllHandle, IN VOID* ProcedureName OPTIONAL, IN ULONG ProcedureNumber OPTIONAL, OUT PVOID *ProcedureAddress, IN BOOLEAN RunInitRoutines); //NTSTATUS(NTAPI *LdrGetProcedureAddress)(HMODULE ModuleHandle, PANSI_STRING FunctionName, WORD Oridinal, PVOID *FunctionAddress); } @@ -717,7 +997,7 @@ BOOLEAN NTAPI ShowRunFileDialog(HWND WindowHandle, HICON WindowIcon, LPCWSTR Wor if (HMODULE shell32Handle = LoadLibrary(L"shell32.dll")) { RunFileDlg_I dialog = NULL; - if (LdrGetProcedureAddress(shell32Handle, NULL, 61, (void**)&dialog, TRUE) == 0 /*STATUS_SUCCESS*/) + if (LdrGetProcedureAddress(shell32Handle, NULL, 61, (void**)&dialog, TRUE) == 0) result = !!dialog(WindowHandle, WindowIcon, WorkingDirectory, WindowTitle, WindowDescription, Flags); FreeLibrary(shell32Handle); @@ -732,4 +1012,5 @@ QString ShowRunDialog(const QString& BoxName) wstring boxName = BoxName.toStdWString(); ShowRunFileDialog(MainWndHandle, NULL, NULL, boxName.c_str(), L"Enter the path of a program that will be created in a sandbox.", 0); // RFF_OPTRUNAS); return g_RunDialogCommand; -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/SandboxiePlus/SandMan/SandMan.h b/SandboxiePlus/SandMan/SandMan.h index 22ff999781..dff98bfad2 100644 --- a/SandboxiePlus/SandMan/SandMan.h +++ b/SandboxiePlus/SandMan/SandMan.h @@ -8,7 +8,7 @@ #include "Models/ResMonModel.h" #define VERSION_MJR 0 -#define VERSION_MIN 1 +#define VERSION_MIN 2 #define VERSION_REV 0 #define VERSION_UPD 0 @@ -31,13 +31,24 @@ class CSandMan : public QMainWindow static void CheckResults(QList Results); protected: + SB_STATUS ConnectSbie(); + SB_STATUS DisconnectSbie(); + SB_STATUS StopSbie(bool andRemove = false); + + bool IsFullyPortable(); + void closeEvent(QCloseEvent *e); void timerEvent(QTimerEvent* pEvent); int m_uTimerID; + bool m_bConnectPending; + bool m_bStopPending; CApiLog* m_ApiLog; public slots: + void OnMessage(const QString&); + + void OnStatusChanged(); void OnLogMessage(const QString& Message); void OnApiLogEntry(const QString& Message); @@ -48,8 +59,11 @@ private slots: //void OnColumnsChanged(); //void OnMenu(const QPoint& Point); + void OnMenuHover(QAction* action); + void OnNewBox(); void OnEmptyAll(); + void OnMaintenance(); void OnCleanUp(); void OnSetKeep(); @@ -89,12 +103,30 @@ private slots: QMenu* m_pMenuFile; - QAction* m_pMenuNew; - QAction* m_pMenuEmptyAll; - QAction* m_pMenuExit; + QAction* m_pNew; + QAction* m_pEmptyAll; + QMenu* m_pMaintenance; + QAction* m_pConnect; + QAction* m_pDisconnect; + QMenu* m_pMaintenanceItems; + QAction* m_pInstallDrv; + QAction* m_pStartDrv; + QAction* m_pStopDrv; + QAction* m_pUninstallDrv; + QAction* m_pInstallSvc; + QAction* m_pStartSvc; + QAction* m_pStopSvc; + QAction* m_pUninstallSvc; + QAction* m_pStopAll; + QAction* m_pExit; QMenu* m_pMenuView; - QAction* m_pCleanUp; + QMenu* m_pCleanUpMenu; + QAction* m_pCleanUpProcesses; + QAction* m_pCleanUpMsgLog; + QAction* m_pCleanUpResLog; + QAction* m_pCleanUpApiLog; + QToolButton* m_pCleanUpButton; QAction* m_pKeepTerminated; QMenu* m_pMenuOptions; @@ -104,12 +136,13 @@ private slots: QAction* m_pEnableLogging; QMenu* m_pMenuHelp; - QAction* m_pMenuAbout; - QAction* m_pMenuSupport; - QAction* m_pMenuAboutQt; + QAction* m_pAbout; + QAction* m_pSupport; + QAction* m_pAboutQt; QSystemTrayIcon* m_pTrayIcon; QMenu* m_pTrayMenu; + bool m_bIconEmpty; bool m_bExit; }; diff --git a/SandboxiePlus/SandMan/SandMan.vcxproj b/SandboxiePlus/SandMan/SandMan.vcxproj index 51cb71f6cf..f081bead6e 100644 --- a/SandboxiePlus/SandMan/SandMan.vcxproj +++ b/SandboxiePlus/SandMan/SandMan.vcxproj @@ -70,6 +70,11 @@ $(SolutionDir)$(Platform)\$(Configuration)\;$(LibraryPath) + + $(SolutionDir)$(Platform)\$(Configuration)\;$(LibraryPath) + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + @@ -86,7 +91,7 @@ core;gui;network;widgets;winextras - msvc2015_64 + msvc2015 core;gui;network;widgets;winextras @@ -111,7 +116,7 @@ Windows $(OutDir)\$(ProjectName).exe true - QSbieAPI.lib;MiscHelpers.lib;ntdll.lib;%(AdditionalDependencies) + QSbieAPI.lib;MiscHelpers.lib;ntdll.lib;QtSingleApp.lib;%(AdditionalDependencies) @@ -136,6 +141,7 @@ true MachineX86 /SUBSYSTEM:WINDOWS + QSbieAPI.lib;MiscHelpers.lib;ntdll.lib;QtSingleApp.lib;%(AdditionalDependencies) @@ -156,7 +162,7 @@ Windows $(OutDir)\$(ProjectName).exe false - QSbieAPI.lib;MiscHelpers.lib;ntdll.lib;%(AdditionalDependencies) + QSbieAPI.lib;MiscHelpers.lib;ntdll.lib;QtSingleApp.lib;%(AdditionalDependencies) @@ -181,6 +187,7 @@ false MachineX86 /SUBSYSTEM:WINDOWS + QSbieAPI.lib;MiscHelpers.lib;ntdll.lib;QtSingleApp.lib;%(AdditionalDependencies) diff --git a/SandboxiePlus/SandMan/Views/SbieView.cpp b/SandboxiePlus/SandMan/Views/SbieView.cpp index a9bfe8486f..59e27176a1 100644 --- a/SandboxiePlus/SandMan/Views/SbieView.cpp +++ b/SandboxiePlus/SandMan/Views/SbieView.cpp @@ -126,8 +126,6 @@ void CSbieView::OnMenu(const QPoint& Point) CPanelView::OnMenu(Point); } -QString ShowRunDialog(const QString& BoxName); - void CSbieView::OnSandBoxAction() { QList Results; @@ -184,16 +182,20 @@ void CSbieView::OnSandBoxAction() void CSbieView::OnProcessAction() { + QList Results; + QAction* Action = qobject_cast(sender()); foreach(const CBoxedProcessPtr& pProcess, CSbieView::GetSelectedProcesses()) { if (Action == m_pMenuTerminate) - pProcess->Terminate(); + Results.append(pProcess->Terminate()); else if (Action == m_pMenuSuspend) - pProcess->SetSuspend(true); + Results.append(pProcess->SetSuspend(true)); else if (Action == m_pMenuResume) - pProcess->SetSuspend(false); + Results.append(pProcess->SetSuspend(false)); } + + CSandMan::CheckResults(Results); } void CSbieView::ProcessSelection(const QItemSelection& selected, const QItemSelection& deselected) diff --git a/SandboxiePlus/SandMan/main.cpp b/SandboxiePlus/SandMan/main.cpp index 154952f591..388eb1c477 100644 --- a/SandboxiePlus/SandMan/main.cpp +++ b/SandboxiePlus/SandMan/main.cpp @@ -2,18 +2,31 @@ #include "SandMan.h" #include #include "../QSbieAPI/SbieAPI.h" +#include "../QtSingleApp/src/qtsingleapplication.h" +#include "../QSbieAPI/SbieUtils.h" CSettings* theConf = NULL; int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QtSingleApplication app(argc, argv); + + SB_STATUS Status = CSbieUtils::DoAssist(); + if (Status.GetStatus()) { + app.sendMessage("Status:" + Status.GetText()); + return 0; + } + + if (app.sendMessage("ShowWnd")) + return 0; theConf = new CSettings("Sandboxie-Plus"); //QThreadPool::globalInstance()->setMaxThreadCount(theConf->GetInt("Options/MaxThreadPool", 10)); CSandMan* pWnd = new CSandMan(); + QObject::connect(&app, SIGNAL(messageReceived(const QString&)), pWnd, SLOT(OnMessage(const QString&))); + pWnd->show(); int ret = app.exec(); diff --git a/SandboxiePlus/SandboxiePlus.sln b/SandboxiePlus/SandboxiePlus.sln index 40533b8afa..37cc7741f9 100644 --- a/SandboxiePlus/SandboxiePlus.sln +++ b/SandboxiePlus/SandboxiePlus.sln @@ -7,6 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SandMan", "SandMan\SandMan. ProjectSection(ProjectDependencies) = postProject {7AB8215A-59A4-4B8B-8090-16C87A860429} = {7AB8215A-59A4-4B8B-8090-16C87A860429} {1433EC85-BDA4-402E-BEC1-48611206A64A} = {1433EC85-BDA4-402E-BEC1-48611206A64A} + {B12702AD-ABFB-343A-A199-8E24837244A3} = {B12702AD-ABFB-343A-A199-8E24837244A3} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QSbieAPI", "QSbieAPI\QSbieAPI.vcxproj", "{1433EC85-BDA4-402E-BEC1-48611206A64A}" @@ -19,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\TODO.md = ..\TODO.md EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtSingleApp", "QtSingleApp\qtsingleapp\qtsingleapp\qtsingleapp.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -37,16 +40,28 @@ Global {B7A8576D-A08A-4A97-84E8-013DAF4D4F1F}.Release|x86.Build.0 = Release|Win32 {1433EC85-BDA4-402E-BEC1-48611206A64A}.Debug|x64.ActiveCfg = Debug|x64 {1433EC85-BDA4-402E-BEC1-48611206A64A}.Debug|x64.Build.0 = Debug|x64 - {1433EC85-BDA4-402E-BEC1-48611206A64A}.Debug|x86.ActiveCfg = Debug|x64 + {1433EC85-BDA4-402E-BEC1-48611206A64A}.Debug|x86.ActiveCfg = Debug|Win32 + {1433EC85-BDA4-402E-BEC1-48611206A64A}.Debug|x86.Build.0 = Debug|Win32 {1433EC85-BDA4-402E-BEC1-48611206A64A}.Release|x64.ActiveCfg = Release|x64 {1433EC85-BDA4-402E-BEC1-48611206A64A}.Release|x64.Build.0 = Release|x64 - {1433EC85-BDA4-402E-BEC1-48611206A64A}.Release|x86.ActiveCfg = Release|x64 + {1433EC85-BDA4-402E-BEC1-48611206A64A}.Release|x86.ActiveCfg = Release|Win32 + {1433EC85-BDA4-402E-BEC1-48611206A64A}.Release|x86.Build.0 = Release|Win32 {7AB8215A-59A4-4B8B-8090-16C87A860429}.Debug|x64.ActiveCfg = Debug|x64 {7AB8215A-59A4-4B8B-8090-16C87A860429}.Debug|x64.Build.0 = Debug|x64 - {7AB8215A-59A4-4B8B-8090-16C87A860429}.Debug|x86.ActiveCfg = Debug|x64 + {7AB8215A-59A4-4B8B-8090-16C87A860429}.Debug|x86.ActiveCfg = Debug|Win32 + {7AB8215A-59A4-4B8B-8090-16C87A860429}.Debug|x86.Build.0 = Debug|Win32 {7AB8215A-59A4-4B8B-8090-16C87A860429}.Release|x64.ActiveCfg = Release|x64 {7AB8215A-59A4-4B8B-8090-16C87A860429}.Release|x64.Build.0 = Release|x64 - {7AB8215A-59A4-4B8B-8090-16C87A860429}.Release|x86.ActiveCfg = Release|x64 + {7AB8215A-59A4-4B8B-8090-16C87A860429}.Release|x86.ActiveCfg = Release|Win32 + {7AB8215A-59A4-4B8B-8090-16C87A860429}.Release|x86.Build.0 = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.Build.0 = Debug|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE