This commit is contained in:
DavidXanatos 2024-11-15 13:41:40 +01:00
parent 38ef212284
commit 74e98031c8
2 changed files with 83 additions and 3 deletions

View File

@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [1.15.2 / 5.70.2] - 2024-10-
## [1.15.2 / 5.70.2] - 2024-11-
### Added
- added "NetworkAdapterMAC=0,AA-BB-CC-DD-EE-FF" to set MAC address for each box (thanks Yeyixiao)
@ -17,12 +17,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- added Hide Tray Icon [#4075](https://github.com/sandboxie-plus/Sandboxie/issues/4075)
### Fixed
- fixed Sign the .tmp file that gets dropped when installing or updating Sandboxie Plus [#2643](https://github.com/sandboxie-plus/Sandboxie/issues/2643)
- fixed Sign the .tmp file that gets dropped when installing or updating Sandboxie Plus [#2643](https://github.com/sandboxie-plus/Sandboxie/issues/2643) [#4343](https://github.com/sandboxie-plus/Sandboxie/issues/4343)
- fixed issue with DLL unloading
- fixed Files Resource Access - Browse for Folder - allows access to excluded folders [#4007](https://github.com/sandboxie-plus/Sandboxie/issues/4007)
- fixed "ForceDisableAdminOnly" is weird [#4233](https://github.com/sandboxie-plus/Sandboxie/issues/4233)
- fixed deadlock on no op condition when renaming file or folder [#4304](https://github.com/sandboxie-plus/Sandboxie/issues/4304)
- fixed Could not move file or folder [#4329](https://github.com/sandboxie-plus/Sandboxie/issues/4329)
- "Run Sandboxed" from the quick-previewer should have only one option [#4339](https://github.com/sandboxie-plus/Sandboxie/issues/4339)
### Changed
- validated compatibility with Windows build 27749 and updated DynData
@ -30,6 +31,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [1.15.1 / 5.70.1] - 2024-10-29
### Changed

View File

@ -103,6 +103,7 @@ void CFileView::OnAboutToBeModified()
#include <Shlobj.h>
#include <atlbase.h>
#define MENU_SANDBOX -1
#define MENU_RECOVER 1
#define MENU_RECOVER_TO_ANY 2
#define MENU_CREATE_SHORTCUT 3
@ -134,6 +135,57 @@ void addItemToShellContextMenu(HMENU hMenu, const wchar_t *name, int ID, bool bC
InsertMenuItem(hMenu, 0, TRUE, &menu_item_info);
}
void RemoveMenuItemByVerb(HMENU hMenu, IContextMenu* pContextMenu, UINT idCmdFirst, UINT idCmdLast, const std::wstring& verbToRemove)
{
int itemCount = GetMenuItemCount(hMenu);
for (int i = itemCount - 1; i >= 0; --i)
{
MENUITEMINFO menuItemInfo = { 0 };
menuItemInfo.cbSize = sizeof(MENUITEMINFO);
menuItemInfo.fMask = MIIM_ID | MIIM_SUBMENU;
if (GetMenuItemInfo(hMenu, i, TRUE, &menuItemInfo))
{
if (menuItemInfo.hSubMenu)
{
// Recursive call for submenus
RemoveMenuItemByVerb(menuItemInfo.hSubMenu, pContextMenu, idCmdFirst, idCmdLast, verbToRemove);
// Remove the submenu if it's empty
if (GetMenuItemCount(menuItemInfo.hSubMenu) == 0)
{
DeleteMenu(hMenu, i, MF_BYPOSITION);
}
}
else
{
UINT cmdID = menuItemInfo.wID;
if (cmdID >= idCmdFirst && cmdID < idCmdLast)
{
// Retrieve the verb associated with this command ID
wchar_t verbBuffer[256] = { 0 };
HRESULT hr = pContextMenu->GetCommandString(
cmdID - idCmdFirst, // Adjust for idCmdFirst
GCS_VERBW,
NULL,
(LPSTR)verbBuffer,
sizeof(verbBuffer) / sizeof(wchar_t)
);
if (SUCCEEDED(hr))
{
if (_wcsicmp(verbBuffer, verbToRemove.c_str()) == 0)
{
// Remove the menu item
DeleteMenu(hMenu, i, MF_BYPOSITION);
}
}
}
}
}
}
}
int openShellContextMenu(const QStringList& Files, void* parentWindow, const CSandBoxPtr& pBox, QString* pPin = NULL)
{
CComPtr<IShellFolder> pDesktop;
@ -182,8 +234,15 @@ int openShellContextMenu(const QStringList& Files, void* parentWindow, const CSa
HMENU hMenu = CreatePopupMenu();
if (!hMenu)
return 0;
if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1, 0x7FFF, CMF_NORMAL)))
UINT idCmdFirst = 1;
HRESULT hrMenu = pContextMenu->QueryContextMenu(hMenu, 0, idCmdFirst, 0x7FFF, CMF_NORMAL);
if (SUCCEEDED(hrMenu))
{
UINT nMenuItems = HRESULT_CODE(hrMenu);
UINT idCmdLast = idCmdFirst + nMenuItems;
RemoveMenuItemByVerb(hMenu, pContextMenu, idCmdFirst, idCmdLast, L"open");
addSeparatorToShellContextMenu(hMenu);
std::wstring Str1 = CFileView::tr("Create Shortcut").toStdWString();
@ -235,6 +294,17 @@ int openShellContextMenu(const QStringList& Files, void* parentWindow, const CSa
DestroyMenu(hMenu);
return iCmd & 0x0FFF;
}
wchar_t verbBuffer[256] = {0};
HRESULT hr = pContextMenu->GetCommandString(iCmd - 1, GCS_VERBW, NULL, (LPSTR)verbBuffer, sizeof(verbBuffer) / sizeof(wchar_t));
if (SUCCEEDED(hr)) {
qDebug() << verbBuffer;
if (_wcsicmp(verbBuffer, L"sandbox") == 0) {
DestroyMenu(hMenu);
return MENU_SANDBOX;
}
}
CMINVOKECOMMANDINFOEX info = { 0 };
info.cbSize = sizeof(info);
@ -285,6 +355,14 @@ void CFileView::OnFileMenu(const QPoint&)
QString RecoveryFolder;
switch (iCmd)
{
case MENU_SANDBOX:{
if (!Files.isEmpty()) {
QString WrkDir = QFileInfo(Files.first()).absoluteDir().path().replace("/", "\\");
foreach(const QString & Command, Files)
theGUI->RunStart(m_pBox->GetName(), Command, CSbieAPI::eStartDefault, WrkDir);
}
break;
}
case MENU_RECOVER_TO_ANY:
RecoveryFolder = QFileDialog::getExistingDirectory(this, CFileView::tr("Select Directory")).replace("/", "\\");
if (RecoveryFolder.isEmpty())