diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b35f941..9d193eab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [1.3.5 / 5.58.5] - 2022-09-19 +### Changed +- improved recovery window behavioure [#2266](https://github.com/sandboxie-plus/Sandboxie/issues/2266) + ### Fixed - fixed issues with stale data in Sandboxie-Plus.ini [#2248](https://github.com/sandboxie-plus/Sandboxie/pull/2248) (thanks okrc) - fixed issue with dummy manifests [#2252](https://github.com/sandboxie-plus/Sandboxie/issues/2252) diff --git a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp index f6b78006..56862c3d 100644 --- a/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp +++ b/SandboxiePlus/SandMan/Windows/SettingsWindow.cpp @@ -346,8 +346,9 @@ bool CSettingsWindow::eventFilter(QObject *source, QEvent *event) Qt::CheckState CSettingsWindow__IsContextMenu() { - QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\PackagedCom\\Package", QSettings::NativeFormat); - foreach(const QString & Key, settings.childGroups()) { + //QSettings Package("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\PackagedCom\\Package", QSettings::NativeFormat); + QSettings Package("HKEY_CURRENT_USER\\Software\\Classes\\PackagedCom\\Package", QSettings::NativeFormat); + foreach(const QString & Key, Package.childGroups()) { if (Key.indexOf("SandboxieShell") == 0) return Qt::Checked; } @@ -362,11 +363,15 @@ Qt::CheckState CSettingsWindow__IsContextMenu() void CSettingsWindow__AddContextMenu(bool bAlwaysClassic) { - QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); - if (settings.value("CurrentBuild").toInt() >= 22000 && !bAlwaysClassic) // Windows 11 + QSettings CurrentVersion("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); + if (CurrentVersion.value("CurrentBuild").toInt() >= 22000 && !bAlwaysClassic) // Windows 11 { + QSettings MyReg("HKEY_CURRENT_USER\\SOFTWARE\\Xanasoft\\Sandboxie-Plus\\SbieShellExt\\Lang", QSettings::NativeFormat); + MyReg.setValue("Open Sandboxed", CSettingsWindow::tr("Open Sandboxed")); + MyReg.setValue("Explore Sandboxed", CSettingsWindow::tr("Explore Sandboxed")); + + QDir::setCurrent(QCoreApplication::applicationDirPath()); QProcess Proc; - Proc.setWorkingDirectory(QCoreApplication::applicationDirPath()); Proc.execute("rundll32.exe", QStringList() << "SbieShellExt.dll,RegisterPackage"); Proc.waitForFinished(); return; @@ -379,11 +384,11 @@ void CSettingsWindow__AddContextMenu(bool bAlwaysClassic) void CSettingsWindow__RemoveContextMenu() { - QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); - if (settings.value("CurrentBuild").toInt() >= 22000) // Windows 11 + QSettings CurrentVersion("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); + if (CurrentVersion.value("CurrentBuild").toInt() >= 22000) // Windows 11 { + QDir::setCurrent(QCoreApplication::applicationDirPath()); QProcess Proc; - Proc.setWorkingDirectory(QCoreApplication::applicationDirPath()); Proc.execute("rundll32.exe", QStringList() << "SbieShellExt.dll,RemovePackage"); Proc.waitForFinished(); } diff --git a/SandboxiePlus/SbieShell/SbieShellExt/dllmain.cpp b/SandboxiePlus/SbieShell/SbieShellExt/dllmain.cpp index 4791c7ec..3ebea13c 100644 --- a/SandboxiePlus/SbieShell/SbieShellExt/dllmain.cpp +++ b/SandboxiePlus/SbieShell/SbieShellExt/dllmain.cpp @@ -14,6 +14,40 @@ using namespace Microsoft::WRL; std::wstring g_path; + +LONG GetDWORDRegKey(HKEY hKey, const std::wstring& strValueName, DWORD& nValue) +{ + DWORD dwBufferSize(sizeof(DWORD)); + DWORD nResult(0); + LONG nError = ::RegQueryValueExW(hKey, + strValueName.c_str(), + 0, + NULL, + reinterpret_cast(&nResult), + &dwBufferSize); + if (ERROR_SUCCESS == nError) + { + nValue = nResult; + } + return nError; +} + +LONG GetStringRegKey(HKEY hKey, const std::wstring& strValueName, std::wstring& strValue) +{ + WCHAR szBuffer[512]; + DWORD dwBufferSize = sizeof(szBuffer); + ULONG nError; + nError = RegQueryValueExW(hKey, strValueName.c_str(), 0, NULL, (LPBYTE)szBuffer, &dwBufferSize); + if (ERROR_SUCCESS == nError) + { + strValue = szBuffer; + } + return nError; +} + +std::wstring g_ExploreSandboxed = L"Explore Sandboxed"; +std::wstring g_OpenSandboxed = L"Open Sandboxed"; + BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved @@ -29,6 +63,14 @@ BOOL APIENTRY DllMain( HMODULE hModule, *ptr = L'\0'; g_path = std::wstring(path); + HKEY hKey; + LONG lRes = RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Xanasoft\\Sandboxie-Plus\\SbieShellExt\\Lang", 0, KEY_READ, &hKey); + bool bExistsAndSuccess(lRes == ERROR_SUCCESS); + bool bDoesNotExistsSpecifically(lRes == ERROR_FILE_NOT_FOUND); + GetStringRegKey(hKey, L"Explore Sandboxed", g_ExploreSandboxed); + GetStringRegKey(hKey, L"Open Sandboxed", g_OpenSandboxed); + CloseHandle(hKey); + break; } case DLL_THREAD_ATTACH: @@ -154,14 +196,14 @@ protected: class __declspec(uuid("EA3E972D-62C7-4309-8F15-883263041E99")) ExploreCommandHandler final : public TestExplorerCommandBase { public: - const wchar_t* Title() override { return L"Explore Sandboxed"; } + const wchar_t* Title() override { return g_ExploreSandboxed.c_str(); } ECommand GetCommand() { return eExplore; } }; class __declspec(uuid("3FD2D9EE-DAF9-404A-9B7E-13B2DCD63950")) OpenCommandHandler final : public TestExplorerCommandBase { public: - const wchar_t* Title() override { return L"Open Sandboxed"; } + const wchar_t* Title() override { return g_OpenSandboxed.c_str(); } ECommand GetCommand() { return eOpen; } };