From 503f11c0634f301bb412d73ac492908d468035b8 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Mon, 29 May 2023 20:13:22 +0200 Subject: [PATCH] 1.9.6 --- CHANGELOG.md | 2 ++ SandboxiePlus/SandMan/SandMan.cpp | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49612682..c0008f17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - added full stack trace to all trace messages +- added Add option to launch the default notepad editor as non-admin [#2987](https://github.com/sandboxie-plus/Sandboxie/issues/2987) ### Fixed - fixed an issue with token manipulation in the SbieDrv driver @@ -22,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - fixed SandMan: Timestamp of the Sandboxie.ini [#2985](https://github.com/sandboxie-plus/Sandboxie/issues/2985) + ## [1.9.5 / 5.64.5] - 2023-05-26 ### Added diff --git a/SandboxiePlus/SandMan/SandMan.cpp b/SandboxiePlus/SandMan/SandMan.cpp index 9ebe4e2b..4485fa9c 100644 --- a/SandboxiePlus/SandMan/SandMan.cpp +++ b/SandboxiePlus/SandMan/SandMan.cpp @@ -2841,17 +2841,15 @@ void CSandMan::OnEditIni() { QString ini = ((QAction*)sender())->property("ini").toString(); - std::wstring Editor = theConf->GetString("Options/Editor", "notepad.exe").toStdWString(); - std::wstring IniPath; - + QString IniPath; bool bPlus; if (bPlus = (ini == "plus")) { - IniPath = L"\"" + QString(theConf->GetConfigDir() + "/Sandboxie-Plus.ini").replace("/", "\\").toStdWString() + L"\""; + IniPath = QString(theConf->GetConfigDir() + "/Sandboxie-Plus.ini").replace("/", "\\"); } else if (ini == "tmpl") { - IniPath = L"\"" + (theAPI->GetSbiePath() + "\\Templates.ini").toStdWString() + L"\""; + IniPath = theAPI->GetSbiePath() + "\\Templates.ini"; if (theConf->GetBool("Options/NoEditWarn", true)) { bool State = false; @@ -2866,7 +2864,7 @@ void CSandMan::OnEditIni() } else //if (ini == "sbie") { - IniPath = L"\"" + theAPI->GetIniPath().toStdWString() + L"\""; + IniPath = theAPI->GetIniPath(); if (theConf->GetBool("Options/NoEditInfo", true)) { bool State = false; @@ -2881,13 +2879,26 @@ void CSandMan::OnEditIni() } } + bool bIsWritable = bPlus; + if (!bIsWritable) { + QFile File(IniPath); + if (File.open(QFile::ReadWrite)) { + bIsWritable = true; + File.close(); + } + // todo: warn user about file not being protected + } + + std::wstring Editor = theConf->GetString("Options/Editor", "notepad.exe").toStdWString(); + std::wstring iniPath = L"\"" + IniPath.toStdWString() + L"\""; + SHELLEXECUTEINFO si = { 0 }; si.cbSize = sizeof(SHELLEXECUTEINFO); si.fMask = SEE_MASK_NOCLOSEPROCESS; si.hwnd = NULL; - si.lpVerb = bPlus ? NULL : L"runas"; // plus ini does not require admin privileges + si.lpVerb = bIsWritable ? NULL : L"runas"; // plus ini does not require admin privileges si.lpFile = Editor.c_str(); - si.lpParameters = IniPath.c_str(); + si.lpParameters = iniPath.c_str(); si.lpDirectory = NULL; si.nShow = SW_SHOW; si.hInstApp = NULL;