This commit is contained in:
DavidXanatos 2023-07-04 19:25:16 +02:00
parent b99dcc97b0
commit 417673e7ea
19 changed files with 398 additions and 37 deletions

View File

@ -21,12 +21,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- [SbieHide.dll](https://github.com/VeroFess/SbieHide) - a third-party DLL to hide SbieDll.dll
- [LogAPI.dll](https://bsa.isoftware.nl/) - an API logging library used for Buster Sandbox Analyzer
- added option to set the update interval to 1, 7, 14 and 30 days
- added whants new dialog to sbiectrl.exe shown after instalation prising the new features of the plus ui
### Changed
- setup wizard has now a dedicated update configuration page
- split the support page into Sandboxie Support and Sandboxie Updater tabs
- when the troubleshooting.7z file is available, the script engine will be used to match compatibility templates
- this allows a better granularity in template selection by using the AppCompatibility.js script
- improved session agent startup to be mroe flexible
- improved SBIEMSG help handling
### Fixed
- fixed uninstall issue in the Sandboxie Classic installer [d1863ff](https://github.com/sandboxie-plus/Sandboxie/commit/d1863ffadfe105c695de71c9e841c2fd568116fe)

View File

@ -30,6 +30,7 @@ copy %~dp0..\sandboxie\install\ParseVersion.bat %~dp0\Assets\Classic\install\
copy %~dp0..\sandboxie\install\Registry.nsh %~dp0\Assets\Classic\install\
copy %~dp0..\sandboxie\install\SandboxieVS.nsi %~dp0\Assets\Classic\install\
copy %~dp0..\sandboxie\install\Warning.ini %~dp0\Assets\Classic\install\
copy %~dp0..\sandboxie\install\whatsnew.html %~dp0\Assets\Classic\install\
mkdir %~dp0\Assets\Classic\msgs
mkdir %~dp0\Assets\Classic\msgs\SbieRelease
copy %~dp0..\sandboxie\msgs\SbieRelease\NsisText_Albanian.txt %~dp0\Assets\Classic\msgs\SbieRelease\

View File

@ -150,12 +150,22 @@ void CRunBrowser::OpenHelp(CWnd *pParentWnd, const CString &topic)
CRunBrowser x(pParentWnd, GetTopicUrl(topic));
}
//---------------------------------------------------------------------------
// OpenForum
// EscapeForURL
//---------------------------------------------------------------------------
void CRunBrowser::OpenForum(CWnd *pParentWnd)
CString CRunBrowser::EscapeForURL(const CString& value)
{
CRunBrowser x(pParentWnd, L"https://sandboxie-plus.com/go.php?to=sbie-forum");
CString escapedValue;
DWORD bufferSize = (DWORD)(value.GetLength() * 3 + 1);
LPWSTR escapedBuffer = new WCHAR[bufferSize];
HRESULT hr = UrlEscapeW(value, escapedBuffer, &bufferSize, URL_ESCAPE_PERCENT | URL_ESCAPE_SEGMENT_ONLY);
if (hr == S_OK)
escapedValue = CString(escapedBuffer, bufferSize);
delete[] escapedBuffer;
return escapedValue;
}

View File

@ -65,8 +65,8 @@ public:
static CString GetTopicUrl(const CString &topic);
static void OpenHelp(CWnd *pParentWnd, const CString &topic);
static void OpenForum(CWnd *pParentWnd);
static CString EscapeForURL(const CString& value);
};

View File

@ -644,9 +644,13 @@ void CMessageDialog::DiscardMessages(
void CMessageDialog::OnHelp()
{
CString sbie = GetSBIExxxx(NULL, NULL);
if (! sbie.IsEmpty())
CRunBrowser::OpenHelp(this, sbie);
CString Detail;
CString sbie = GetSBIExxxx(NULL, &Detail);
if (!sbie.IsEmpty()) {
CString url = L"https://sandboxie-plus.com/go.php?to=sbie-" + sbie + "&detail=" + CRunBrowser::EscapeForURL(Detail);
CRunBrowser x(this, url);
//CRunBrowser::OpenHelp(this, sbie);
}
}

View File

@ -83,12 +83,15 @@ BOOL CMyApp::InitInstance()
BOOL ForceVisible = FALSE;
BOOL ForceSync = FALSE;
BOOL PostSetup = FALSE;
WCHAR *CommandLine = GetCommandLine();
if (CommandLine) {
if (wcsstr(CommandLine, L"/open"))
ForceVisible = TRUE;
if (wcsstr(CommandLine, L"/sync"))
ForceSync = TRUE;
if (wcsstr(CommandLine, L"/postsetup"))
PostSetup = TRUE;
if (wcsstr(CommandLine, L"/uninstall")) {
CShellDialog::Sync(TRUE);
return TRUE;
@ -259,7 +262,7 @@ BOOL CMyApp::InitInstance()
// create main window
//
m_pMainWnd = new CMyFrame(ForceVisible, ForceSync);
m_pMainWnd = new CMyFrame(ForceVisible, ForceSync, PostSetup);
m_pMainWnd->UpdateWindow();
return TRUE;

View File

@ -147,6 +147,7 @@ BEGIN_MESSAGE_MAP(CMyFrame, CFrameWnd)
ON_COMMAND(ID_HELP_FORUM, OnCmdHelpForum)
ON_COMMAND(ID_HELP_UPDATE, OnCmdHelpUpdate)
ON_COMMAND(ID_HELP_UPGRADE, OnCmdHelpUpgrade)
ON_COMMAND(ID_HELP_WHATSNEW, OnCmdHelpWhatsNew)
ON_COMMAND(ID_HELP_MIGRATION, OnCmdHelpMigrate)
ON_COMMAND(ID_HELP_GET_CERT, OnCmdHelpGetCert)
ON_COMMAND(ID_HELP_SET_CERT, OnCmdHelpSetCert)
@ -196,7 +197,7 @@ IMPLEMENT_MENUXP(CMyFrame, CFrameWnd)
//---------------------------------------------------------------------------
CMyFrame::CMyFrame(BOOL ForceVisible, BOOL ForceSync)
CMyFrame::CMyFrame(BOOL ForceVisible, BOOL ForceSync, BOOL PostSetup)
{
m_mondlg = NULL;
m_msgdlg = NULL;
@ -204,6 +205,7 @@ CMyFrame::CMyFrame(BOOL ForceVisible, BOOL ForceSync)
m_view = m_view_old = 0;
m_hidden = FALSE;
m_ShowWhatsNew = PostSetup;
//CUserSettings::GetInstance().GetBool(_ShowWelcome, m_ShowWelcome, TRUE);
CUserSettings::GetInstance().GetBool(_AlwaysOnTop, m_AlwaysOnTop, FALSE);
@ -998,6 +1000,7 @@ void CMyFrame::OnCmdHelpSupport()
CRunBrowser x(this, L"https://sandboxie-plus.com/go.php?to=donate");
}
//---------------------------------------------------------------------------
// OnCmdHelpContribution
//---------------------------------------------------------------------------
@ -1008,6 +1011,7 @@ void CMyFrame::OnCmdHelpContribution()
CRunBrowser x(this, L"https://sandboxie-plus.com/go.php?to=sbie-contribute");
}
//---------------------------------------------------------------------------
// OnCmdHelpTopics
//---------------------------------------------------------------------------
@ -1018,6 +1022,7 @@ void CMyFrame::OnCmdHelpTopics()
CRunBrowser::OpenHelp(this, L"HelpTopics");
}
//---------------------------------------------------------------------------
// OnCmdHelpTutorial
//---------------------------------------------------------------------------
@ -1039,7 +1044,7 @@ void CMyFrame::OnCmdHelpTutorial()
void CMyFrame::OnCmdHelpForum()
{
CRunBrowser::OpenForum(this);
CRunBrowser x(this, L"https://sandboxie-plus.com/go.php?to=sbie-forum");
}
//---------------------------------------------------------------------------
@ -1063,6 +1068,33 @@ void CMyFrame::OnCmdHelpUpgrade()
CRunBrowser x(this, L"https://sandboxie-plus.com/go.php?to=sbie-plus&tip=upgrade");
}
//---------------------------------------------------------------------------
// OnCmdHelpWhatsNew
//---------------------------------------------------------------------------
extern "C" void OpenWebView(const WCHAR * url, const WCHAR * title);
void CMyFrame::OnCmdHelpWhatsNew()
{
CString url;
url.Format(L"https://sandboxie-plus.com/go.php?to=sbie-whatsnew&language=%d&version=%S", SbieDll_GetLanguage(NULL), MY_VERSION_STRING);
WCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, sizeof(path) / sizeof(WCHAR) - 4);
WCHAR* ptr = wcsrchr(path, L'\\');
if (ptr) ptr[1] = L'\0';
CString file = CString(path) + L"whatsnew.html";
if (PathFileExists(file)) {
file.Replace(L"\\", L"/");
url = L"file:///" + file;
}
CMyMsg text(MSG_3469);
OpenWebView(url, text);
}
//---------------------------------------------------------------------------
// OnCmdHelpMigrate
//---------------------------------------------------------------------------
@ -1073,6 +1105,15 @@ void CMyFrame::OnCmdHelpMigrate()
{
CString url;
url.Format(L"https://sandboxie-plus.com/go.php?to=sbie-migration&language=%d", SbieDll_GetLanguage(NULL));
/*WCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, sizeof(path) / sizeof(WCHAR) - 4);
WCHAR* ptr = wcsrchr(path, L'\\');
if (ptr) ptr[1] = L'\0';
CString url = L"file:///" + CString(path);
url.Replace(L"\\", L"/");
url.Append(L"static/plus-migration.html");*/
CMyMsg text(MSG_3468);
OpenWebView(url, text);
}
@ -2105,6 +2146,18 @@ void CMyFrame::OnTimer(UINT_PTR nIDEvent)
return;
}*/
//
// show whats new
//
if (m_ShowWhatsNew && (! inModalState)) {
m_ShowWhatsNew = FALSE;
OnCmdHelpWhatsNew();
return;
}
//
// resync shortcuts? usually Sandboxie Control does not resync
// the Run Sandboxed shortcuts on startup, except when the

View File

@ -55,6 +55,7 @@ class CMyFrame : public CFrameWnd
CPoint m_TrayPoint;
BOOL m_hidden;
BOOL m_ShowWhatsNew;
//BOOL m_ShowWelcome;
BOOL m_ReSyncShortcuts;
BOOL m_AutoRunSoftCompat;
@ -126,6 +127,7 @@ class CMyFrame : public CFrameWnd
afx_msg void OnCmdHelpForum();
afx_msg void OnCmdHelpUpdate();
afx_msg void OnCmdHelpUpgrade();
afx_msg void OnCmdHelpWhatsNew();
afx_msg void OnCmdHelpMigrate();
afx_msg void OnCmdHelpGetCert();
afx_msg void OnCmdHelpSetCert();
@ -161,7 +163,7 @@ class CMyFrame : public CFrameWnd
public:
CMyFrame(BOOL ForceVisible, BOOL ForceSync);
CMyFrame(BOOL ForceVisible, BOOL ForceSync, BOOL PostSetup);
~CMyFrame();
static CWnd *m_GettingStartedWindow;

View File

@ -128,7 +128,8 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "3452", ID_HELP_TOPICS
MENUITEM "3453", ID_HELP_TUTORIAL
MENUITEM "3468", ID_HELP_MIGRATION
MENUITEM "3469", ID_HELP_WHATSNEW
//MENUITEM "3468", ID_HELP_MIGRATION
MENUITEM "3457", ID_HELP_FORUM
MENUITEM SEPARATOR
MENUITEM "3454", ID_HELP_UPDATE

View File

@ -31,7 +31,9 @@
#include "common/my_version.h"
#include "common/json/JSON.h"
#include "common/win32_ntddk.h"
#include "core/drv/api_defs.h"
#define UPDATE_INTERVAL (7 * 24 * 60 * 60)
//---------------------------------------------------------------------------
// Variables
@ -269,9 +271,58 @@ BOOLEAN CUpdater::QueryUpdateData(UPDATER_DATA* Context)
#endif
StrLang, Context->Manual ? L"0" : L"1");
if (!Context->Manual)
Path.AppendFormat(L"&interval=%d", UPDATE_INTERVAL);
CString update_key;
CSbieIni::GetInstance().GetText(_GlobalSettings, L"UpdateKey", update_key);
//CSbieIni::GetInstance().GetText(_GlobalSettings, L"UpdateKey", update_key);
WCHAR CertPath[MAX_PATH];
SbieApi_GetHomePath(NULL, 0, CertPath, MAX_PATH);
wcscat(CertPath, L"\\Certificate.dat");
HANDLE hFile = CreateFile(CertPath, FILE_GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
char CertData[0x1000];
DWORD bytesRead = 0;
if (ReadFile(hFile, CertData, sizeof(CertData), &bytesRead, NULL)) {
CertData[bytesRead] = 0;
CString sCertData = CString(CertData);
int pos = sCertData.Find(L"UPDATEKEY:");
if (pos != -1) {
pos += 10;
int end = sCertData.Find(L"\n", pos);
if (end == -1) end = sCertData.GetLength();
update_key = sCertData.Mid(pos, end - pos).Trim();
}
}
CloseHandle(hFile);
}
if (!update_key.IsEmpty())
update_key += "-";
QWORD RandID = 0;
SbieApi_Call(API_GET_SECURE_PARAM, 3, L"RandID", (ULONG_PTR)&RandID, sizeof(RandID));
if (RandID == 0) {
srand(GetTickCount());
RandID = QWORD(rand() & 0xFFFF) | (QWORD(rand() & 0xFFFF) << 16) | (QWORD(rand() & 0xFFFF) << 32) | (QWORD(rand() & 0xFFFF) << 48);
SbieApi_Call(API_SET_SECURE_PARAM, 3, L"RandID", (ULONG_PTR)&RandID, sizeof(RandID));
}
CString Section;
CString UserName;
BOOL IsAdmin;
CSbieIni::GetInstance().GetUser(Section, UserName, IsAdmin);
DWORD Hash = wcstoul(Section.Mid(13), NULL, 16);
QWORD HashID = RandID ^ (QWORD((Hash & 0xFFFF) ^ ((Hash >> 16) & 0xFFFF)) << 48); // fold the hash in half and xor it with the first 16 bit of RandID
wchar_t sHash[17];
wsprintf(sHash, L"%08X%08X", DWORD(HashID >> 32), DWORD(HashID));
update_key += sHash;
Path += L"&update_key=" + update_key;
if (!DownloadUpdateData(L"sandboxie-plus.com", Path, &jsonString, NULL)) {
@ -507,7 +558,7 @@ ULONG CUpdater::UpdaterServiceThread(void *lpParameter)
__int64 NextUpdateCheck;
CUserSettings::GetInstance().GetNum64(_NextUpdateCheck, NextUpdateCheck, 0);
if (NextUpdateCheck != -1)
CUserSettings::GetInstance().SetNum64(_NextUpdateCheck, time(NULL) + 7 * 24 * 60 * 60);
CUserSettings::GetInstance().SetNum64(_NextUpdateCheck, time(NULL) + UPDATE_INTERVAL);
if (pContext->Manual)
CMyApp::MsgBox(NULL, MSG_3629, MB_OK);

View File

@ -54,6 +54,7 @@
#define ID_HELP_UPDATE 40044
#define ID_HELP_UPGRADE 40046
#define ID_HELP_MIGRATION 40047
#define ID_HELP_WHATSNEW 40049
#define ID_HELP_CONTRIBUTION 40048
#define ID_HELP_GET_CERT 40054
#define ID_HELP_SET_CERT 40055

View File

@ -433,6 +433,10 @@ BOOL Parse_Command_Line(void)
if (_wcsnicmp(cmd, L"open_agent:", 11) == 0) {
cmd += 11;
tmp = Eat_String(cmd);
if (*cmd == L'\"') {
cmd++;
tmp--;
}
ULONG len = ULONG(tmp - cmd) * sizeof(WCHAR);
memcpy((WCHAR*)&buffer[req.length], cmd, len);
req.length += len;

View File

@ -737,11 +737,11 @@ _FX BOOL Proc_CreateAppContainerToken(
//---------------------------------------------------------------------------
// Proc_FindArgumentEnd
// SbieDll_FindArgumentEnd
//---------------------------------------------------------------------------
_FX const WCHAR* Proc_FindArgumentEnd(const WCHAR* arguments)
_FX const WCHAR* SbieDll_FindArgumentEnd(const WCHAR* arguments)
{
//
// when suplying: "aaaa \"bb cc\"ddd\"e\\"f\" gg hh \\"ii \"jjjj kkkk"
@ -1206,7 +1206,7 @@ _FX BOOL Proc_CreateProcessInternalW(
const WCHAR* lpArguments = NULL;
if (lpCommandLine)
lpArguments = Proc_FindArgumentEnd(lpCommandLine);
lpArguments = SbieDll_FindArgumentEnd(lpCommandLine);
WCHAR *mybuf = Dll_Alloc((wcslen(lpApplicationName) + 2 + (lpArguments ? wcslen(lpArguments) + 8192 : 0) + 1) * sizeof(WCHAR));
if (mybuf) {
@ -1232,7 +1232,7 @@ _FX BOOL Proc_CreateProcessInternalW(
WCHAR* temp = Dll_Alloc(sizeof(WCHAR) * 8192);
for (const WCHAR* ptr = lpArguments; *ptr != L'\0';) {
WCHAR* end = (WCHAR*)Proc_FindArgumentEnd(ptr);
WCHAR* end = (WCHAR*)SbieDll_FindArgumentEnd(ptr);
ULONG len = (ULONG)(end - ptr);
if (len > 0) {
WCHAR savechar = *end;
@ -2391,7 +2391,7 @@ _FX BOOLEAN SbieDll_RunFromHome(
len = MAX_PATH * 2 + wcslen(pgmName);
if (pgmArgs)
len += wcslen(pgmArgs);
len += 1 + wcslen(pgmArgs);
path = Dll_AllocTemp(len * sizeof(WCHAR));
ptr = wcsrchr(pgmName, L'.');

View File

@ -233,6 +233,8 @@ SBIEDLL_EXPORT BOOLEAN SbieDll_GetBorderColor(const WCHAR* box_name, COLORREF*
SBIEDLL_EXPORT BOOLEAN SbieDll_IsReservedFileName(const WCHAR* name);
SBIEDLL_EXPORT const WCHAR* SbieDll_FindArgumentEnd(const WCHAR* arguments);
SBIEDLL_EXPORT void DbgPrint(const char* format, ...);
SBIEDLL_EXPORT void DbgTrace(const char* format, ...);

View File

@ -2237,7 +2237,7 @@ MSG_HEADER *SbieIniServer::RunSbieCtrl(MSG_HEADER *msg, HANDLE idProcess, bool i
NTSTATUS status = STATUS_UNSUCCESSFUL;
HANDLE hToken = NULL;
BOOL ok = TRUE;
WCHAR ctrlName[64] = { 0 };
WCHAR ctrlCmd[128] = { 0 };
//
// get token from caller session or caller process. note that on
@ -2311,19 +2311,19 @@ MSG_HEADER *SbieIniServer::RunSbieCtrl(MSG_HEADER *msg, HANDLE idProcess, bool i
bool ok2 = SetUserSettingsSectionName(hToken);
if (ok2) {
SbieApi_QueryConfAsIs(
m_sectionname, _Setting2, 0, ctrlName, sizeof(ctrlName) - 2);
m_sectionname, _Setting2, 0, ctrlCmd, sizeof(ctrlCmd) - 2);
}
else {
wcscpy(m_sectionname + 13, L"Default"); // UserSettings_Default
SbieApi_QueryConfAsIs(
m_sectionname, _Setting2, 0, ctrlName, sizeof(ctrlName) - 2);
m_sectionname, _Setting2, 0, ctrlCmd, sizeof(ctrlCmd) - 2);
}
} else if (msg->length > sizeof(MSG_HEADER)) {
ULONG len = (ULONG)(msg->length - sizeof(MSG_HEADER));
memcpy(ctrlName, (UCHAR*)msg + sizeof(MSG_HEADER), len);
ctrlName[len / sizeof(WCHAR)] = L'\0';
memcpy(ctrlCmd, (UCHAR*)msg + sizeof(MSG_HEADER), len);
ctrlCmd[len / sizeof(WCHAR)] = L'\0';
}
//
@ -2334,17 +2334,24 @@ MSG_HEADER *SbieIniServer::RunSbieCtrl(MSG_HEADER *msg, HANDLE idProcess, bool i
STARTUPINFO si;
PROCESS_INFORMATION pi;
WCHAR *args = NULL;
if (isSandboxed) {
if (*ctrlName)
args = L" -autorun";
} else {
if (!*ctrlName)
args = L" /open /sync";
//
// split the agent executable name from the arguments
//
WCHAR* end = (WCHAR*)SbieDll_FindArgumentEnd(ctrlCmd);
if (*end) {
*end++ = 0;
args = end;
}
if (SbieDll_RunFromHome(*ctrlName ? ctrlName : SBIECTRL_EXE, args, &si, NULL)) {
//
// run the agent executable from the sbie home directory,
// when none was specified fallback to SBIECTRL_EXE
//
if (SbieDll_RunFromHome(*ctrlCmd ? ctrlCmd : SBIECTRL_EXE, args, &si, NULL)) {
WCHAR *CmdLine = (WCHAR *)si.lpReserved;

View File

@ -1092,6 +1092,8 @@ WriteLoop:
File /oname=${SBIEINI_EXE} "${BIN_ROOT}\SbieIni.exe"
File "whatsnew.html"
;File "${BIN_ROOT}\License.exe"
File "LICENSE.TXT"
@ -1210,6 +1212,8 @@ Function DeleteProgramFiles
Delete "$INSTDIR\${SBIEINI_EXE}"
Delete "$INSTDIR\${SBIEINI_EXE}.sig" ; leftover
Delete "$INSTDIR\whatsnew.html"
Delete "$INSTDIR\LICENSE.EXE"
Delete "$INSTDIR\LICENSE.TXT"
@ -1680,7 +1684,8 @@ Function .onGUIEnd
StrCmp $LaunchControl "Y" 0 Done
ExecWait '"$INSTDIR\${START_EXE}" run_sbie_ctrl' $0
; ExecWait '"$INSTDIR\${START_EXE}" run_sbie_ctrl' $0
ExecWait '"$INSTDIR\${START_EXE}" open_agent:"${SBIECTRL_EXE} /open /sync /postsetup"' $0
Done:

File diff suppressed because one or more lines are too long

View File

@ -1351,6 +1351,10 @@ Upgrade to Sandboxie-Plus
Sandboxie-Plus Migration Guide
.
3469;txt;01
Whats new in Sandboxie-Plus
.
3471;txt;01
&Terminate Programs
.

View File

@ -2102,8 +2102,9 @@ void CSandMan::OnStatusChanged()
if (SbiePath.compare(QApplication::applicationDirPath().replace("/", "\\"), Qt::CaseInsensitive) == 0)
{
if (theAPI->GetUserSettings()->GetText("SbieCtrl_AutoStartAgent").isEmpty())
theAPI->GetUserSettings()->SetText("SbieCtrl_AutoStartAgent", "SandMan.exe");
QString AgentCmd = theAPI->GetUserSettings()->GetText("SbieCtrl_AutoStartAgent");
if (AgentCmd.isEmpty() || AgentCmd == "SandMan.exe")
theAPI->GetUserSettings()->SetText("SbieCtrl_AutoStartAgent", "SandMan.exe -autorun");
QString cmd = CSbieUtils::GetContextMenuStartCmd();
if (!cmd.isEmpty() && !cmd.contains("SandMan.exe", Qt::CaseInsensitive))