This commit is contained in:
DavidXanatos 2023-07-19 21:15:18 +02:00
parent 90f6ee5984
commit 03077cc9cc
11 changed files with 126 additions and 80 deletions

View File

@ -9,12 +9,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [1.10.1 / 5.65.1] - 2023-07-??
### Changed
- reworked Nt Object Handle handling
### Fixed
- fixed "Disable Security Isolation" causes a game to stop playing audio [#2893](https://github.com/sandboxie-plus/Sandboxie/issues/2893)
- fixed NtQueryDirectoryObject not implemented [#2734](https://github.com/sandboxie-plus/Sandboxie/issues/2734)
- fixed issue with working directory for run menu entries
- fixed CreateMutex, GetLastError error ( Ipc_GetName ) [#3112](https://github.com/sandboxie-plus/Sandboxie/issues/3112)
### Changed
- reworked Nt Object Handle handling

View File

@ -518,6 +518,7 @@ _FX void Ipc_CreateObjects(void)
WCHAR *backslash;
WCHAR *buffer = NULL;
WCHAR *BNOLINKS = NULL;
WCHAR *GLOBAL = NULL;
WCHAR *buffer2 = NULL;
HANDLE handle;
WCHAR str[64];
@ -631,6 +632,10 @@ _FX void Ipc_CreateObjects(void)
wcscpy(buffer, buffer2);
wcscat(buffer, L"\\Global");
GLOBAL = Dll_Alloc((wcslen(buffer) + 32) * sizeof(WCHAR));
wcscpy(GLOBAL, buffer);
status = SbieApi_CreateDirOrLink(buffer, buffer2);
if (! NT_SUCCESS(status)) {
@ -676,7 +681,7 @@ _FX void Ipc_CreateObjects(void)
wcscpy(buffer, CopyPath);
wcscat(buffer, L"\\Global");
status = SbieApi_CreateDirOrLink(buffer, CopyPath);
status = SbieApi_CreateDirOrLink(buffer, GLOBAL);
if (! NT_SUCCESS(status)) {
errlvl = 41;
@ -713,6 +718,8 @@ finish:
Dll_Free(buffer);
if(BNOLINKS)
Dll_Free(BNOLINKS);
if(GLOBAL)
Dll_Free(GLOBAL);
if(buffer2)
Dll_Free(buffer2);

View File

@ -869,11 +869,6 @@
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Icon</string>
</property>
</column>
<column>
<property name="text">
<string>Command Line</string>

View File

@ -665,11 +665,6 @@
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Icon</string>
</property>
</column>
<column>
<property name="text">
<string>Command Line</string>

View File

@ -6,6 +6,7 @@
#include "../MiscHelpers/Common/TreeItemModel.h"
#include "../MiscHelpers/Common/OtherFunctions.h"
#include "../QSbieAPI/SbieUtils.h"
#include "../Windows/SettingsWindow.h"
CFileView::CFileView(QWidget *parent)
: QWidget(parent)
@ -198,7 +199,8 @@ int openShellContextMenu(const QStringList& Files, void* parentWindow, const CSa
QString FoundPin;
QString FileName = Files.first();
foreach(const QString & RunOption, RunOptions) {
QString CmdFile = pBoxPlus->GetCommandFile(Split2(RunOption, "|").second);
QVariantMap Entry = GetRunEntry(RunOption);
QString CmdFile = pBoxPlus->GetCommandFile(Entry["Command"].toString());
if(CmdFile.compare(FileName, Qt::CaseInsensitive) == 0) {
FoundPin = RunOption;
break;

View File

@ -13,6 +13,7 @@
#include "../Views/FileView.h"
#include "../Wizards/NewBoxWizard.h"
#include "../Helpers/WinHelper.h"
#include "../Windows/SettingsWindow.h"
#include "qt_windows.h"
#include "qwindowdefs_win.h"
@ -616,7 +617,8 @@ void CSbieView::UpdateProcMenu(const CBoxedProcessPtr& pProcess, int iProcessCou
QString FoundPin;
QString FileName = pProcess->GetFileName();
foreach(const QString& RunOption, RunOptions) {
QString CmdFile = pBoxPlus->GetCommandFile(Split2(RunOption, "|").second);
QVariantMap Entry = GetRunEntry(RunOption);
QString CmdFile = pBoxPlus->GetCommandFile(Entry["Command"].toString());
if(CmdFile.compare(FileName, Qt::CaseInsensitive) == 0) {
FoundPin = RunOption;
break;
@ -626,6 +628,7 @@ void CSbieView::UpdateProcMenu(const CBoxedProcessPtr& pProcess, int iProcessCou
if (m_pMenuPreset) {
m_pMenuPinToRun->setChecked(!FoundPin.isEmpty());
m_pMenuPinToRun->setData(FoundPin);
//m_pMenuPinToRun->setProperty("WorkingDir", pProcess-> // todo
m_pMenuAllowInternet->setChecked(pProcess.objectCast<CSbieProcess>()->HasInternetAccess());
@ -1788,7 +1791,8 @@ void CSbieView::OnMenuContextMenu(const QPoint& point)
QString FoundPin;
QString FileName = pBoxPlus->GetCommandFile(LinkTarget);
foreach(const QString& RunOption, RunOptions) {
QString CmdFile = pBoxPlus->GetCommandFile(Split2(RunOption, "|").second);
QVariantMap Entry = GetRunEntry(RunOption);
QString CmdFile = pBoxPlus->GetCommandFile(Entry["Command"].toString());
if(CmdFile.compare(FileName, Qt::CaseInsensitive) == 0) {
FoundPin = RunOption;
break;
@ -1796,8 +1800,14 @@ void CSbieView::OnMenuContextMenu(const QPoint& point)
}
m_pCtxPinToRun->setChecked(!FoundPin.isEmpty());
if (FoundPin.isEmpty())
m_pCtxPinToRun->setData(pAction->text() + "|\"" + pBoxPlus->MakeBoxCommand(LinkTarget) + "\"");
if (FoundPin.isEmpty()) {
QVariantMap Entry;
Entry["Name"] = pAction->text();
Entry["Icon"] = pAction->property("Icon").toString() + "," + pAction->property("IconIndex").toString();
Entry["WorkingDir"] = pBoxPlus->MakeBoxCommand(pAction->property("WorkingDir").toString());
Entry["Command"] = "\"" + pBoxPlus->MakeBoxCommand(LinkTarget) + "\"";
m_pCtxPinToRun->setData(MakeRunEntry(Entry));
}
else
m_pCtxPinToRun->setData(FoundPin);
m_pCtxMkLink->setData(LinkTarget);
@ -1841,6 +1851,8 @@ void CSbieView::UpdateStartMenu(CSandBoxPlus* pBoxEx)
if(Icon.isNull()) Icon = m_IconProvider.icon(QFileInfo(Link.Target));
pAction->setIcon(Icon);
pAction->setData(Link.Target);
pAction->setProperty("Icon", Link.Icon);
pAction->setProperty("IconIndex", Link.IconIndex);
pAction->setProperty("WorkingDir", Link.WorkDir);
}
}
@ -1857,28 +1869,27 @@ void CSbieView::UpdateRunMenu(const CSandBoxPtr& pBox)
QStringList RunOptions = pBox->GetTextList("RunCommand", true, false, true);
foreach(const QString& RunOption, RunOptions)
{
StrPair NameCmd = Split2(RunOption, "|");
StrPair NameIcon = Split2(NameCmd.first, ",");
QVariantMap Entry = GetRunEntry(RunOption);
QMenu* pMenu;
StrPair FolderName = Split2(NameIcon.first, "\\", true);
StrPair FolderName = Split2(Entry["Name"].toString(), "\\", true);
if (FolderName.second.isEmpty()) {
FolderName.second = FolderName.first;
pMenu = m_pMenuRun;
} else
pMenu = GetMenuFolder(FolderName.first.replace("\\", "/"), m_pMenuRun, m_RunFolders);
StrPair IconIndex = Split2(NameIcon.second, ",", true);
StrPair IconIndex = Split2(Entry["Icon"].toString(), ",", true);
QAction* pAction = pMenu->addAction(FolderName.second, this, SLOT(OnSandBoxAction()));
if (IconIndex.first.isEmpty())
pAction->setIcon(m_IconProvider.icon(QFileInfo(pBoxEx->GetCommandFile(NameCmd.second))));
pAction->setIcon(m_IconProvider.icon(QFileInfo(pBoxEx->GetCommandFile(Entry["Command"].toString()))));
else if(IconIndex.second.isEmpty())
pAction->setIcon(LoadWindowsIcon(pBoxEx->GetCommandFile(NameCmd.second), IconIndex.first.toInt()));
pAction->setIcon(LoadWindowsIcon(pBoxEx->GetCommandFile(Entry["Command"].toString()), IconIndex.first.toInt()));
else
pAction->setIcon(LoadWindowsIcon(pBoxEx->GetCommandFile(IconIndex.first), IconIndex.second.toInt()));
pAction->setData(NameCmd.second);
pAction->setData(Entry["Command"].toString());
pAction->setProperty("WorkingDir", Entry["WorkingDir"]);
}
if (!m_pMenuRunStart)

View File

@ -264,12 +264,7 @@ void COptionsWindow::LoadGeneral()
ui.treeRun->clear();
foreach(const QString& Value, m_pBox->GetTextList("RunCommand", m_Template))
{
StrPair NameCmd = Split2(Value, "|");
StrPair NameIcon = Split2(NameCmd.first, ",");
QTreeWidgetItem* pItem = new QTreeWidgetItem();
AddRunItem(NameIcon.first, NameIcon.second, NameCmd.second);
}
AddRunItem(ui.treeRun, GetRunEntry(Value));
QString Action = m_pBox->GetText("DblClickAction");
int pos = -1;
@ -369,14 +364,9 @@ void COptionsWindow::SaveGeneral()
QStringList RunCommands;
for (int i = 0; i < ui.treeRun->topLevelItemCount(); i++) {
QTreeWidgetItem* pItem = ui.treeRun->topLevelItem(i);
if(pItem->text(1).isEmpty())
RunCommands.prepend(pItem->text(0) + "|" + pItem->text(2));
else
RunCommands.prepend(pItem->text(0) + "," + pItem->text(1) + "|" + pItem->text(2));
for (int i = 0; i < ui.treeRun->topLevelItemCount(); i++)
RunCommands.prepend(MakeRunEntry(ui.treeRun->topLevelItem(i)));
}
//WriteTextList("RunCommand", RunCommands);
m_pBox->DelValue("RunCommand");
foreach(const QString& Value, RunCommands)
@ -900,7 +890,12 @@ void COptionsWindow::OnBrowsePath()
return;
CSandBoxPlus* pBoxEx = qobject_cast<CSandBoxPlus*>(m_pBox.data());
AddRunItem(Name, "", "\"" + (pBoxEx ? pBoxEx->MakeBoxCommand(Value) : Value) + "\"");
QVariantMap Entry;
Entry["Name"] = Name;
Entry["Command"] = "\"" + (pBoxEx ? pBoxEx->MakeBoxCommand(Value) : Value) + "\"";
AddRunItem(ui.treeRun, Entry);
m_GeneralChanged = true;
OnOptChanged();
}
@ -915,18 +910,12 @@ void COptionsWindow::OnAddCommand()
if (Name.isEmpty())
return;
AddRunItem(Name, "", Value);
OnRunChanged();
}
QVariantMap Entry;
Entry["Name"] = Name;
Entry["Command"] = Value;
AddRunItem(ui.treeRun, Entry);
void COptionsWindow::AddRunItem(const QString& Name, const QString& Icon, const QString& Command)
{
QTreeWidgetItem* pItem = new QTreeWidgetItem();
pItem->setText(0, Name);
pItem->setText(1, Icon);
pItem->setText(2, Command);
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
ui.treeRun->addTopLevelItem(pItem);
OnRunChanged();
}
void COptionsWindow::OnCommandUp()

View File

@ -351,8 +351,6 @@ protected:
void SaveConfig();
void UpdateCurrentTab();
void AddRunItem(const QString& Name, const QString& Icon, const QString& Command);
void CreateGeneral();
void LoadGeneral();
void SaveGeneral();

View File

@ -14,6 +14,8 @@
#include "../Wizards/TemplateWizard.h"
#include "../AddonManager.h"
#include <qfontdialog.h>
#include <QJsonDocument>
#include <QJsonObject>
#include <windows.h>
@ -698,7 +700,10 @@ void CSettingsWindow::OnBrowsePath()
if (Name.isEmpty())
return;
AddRunItem(Name, "", "\"" + Value + "\"");
QVariantMap Entry;
Entry["Name"] = Name;
Entry["Command"] = "\"" + Value + "\"";
AddRunItem(ui.treeRun, Entry);
}
void CSettingsWindow::OnAddCommand()
@ -711,18 +716,12 @@ void CSettingsWindow::OnAddCommand()
if (Name.isEmpty())
return;
AddRunItem(Name, "", Value);
OnRunChanged();
}
QVariantMap Entry;
Entry["Name"] = Name;
Entry["Command"] = Value;
AddRunItem(ui.treeRun, Entry);
void CSettingsWindow::AddRunItem(const QString& Name, const QString& Icon, const QString& Command)
{
QTreeWidgetItem* pItem = new QTreeWidgetItem();
pItem->setText(0, Name);
pItem->setText(1, Icon);
pItem->setText(2, Command);
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
ui.treeRun->addTopLevelItem(pItem);
OnRunChanged();
}
void CSettingsWindow::OnCommandUp()
@ -899,11 +898,7 @@ void CSettingsWindow::LoadSettings()
ui.treeRun->clear();
foreach(const QString& Value, theAPI->GetGlobalSettings()->GetTextList("RunCommand", false))
{
StrPair NameCmd = Split2(Value, "|");
StrPair NameIcon = Split2(NameCmd.first, ",");
AddRunItem(NameIcon.first, NameIcon.second, NameCmd.second);
}
AddRunItem(ui.treeRun, GetRunEntry(Value));
m_RunChanged = false;
ui.cmbDefault->clear();
@ -1258,13 +1253,9 @@ void CSettingsWindow::SaveSettings()
m_RunChanged = false;
QStringList RunCommands;
for (int i = 0; i < ui.treeRun->topLevelItemCount(); i++) {
QTreeWidgetItem* pItem = ui.treeRun->topLevelItem(i);
if (pItem->text(1).isEmpty())
RunCommands.prepend(pItem->text(0) + "|" + pItem->text(2));
else
RunCommands.prepend(pItem->text(0) + "," + pItem->text(1) + "|" + pItem->text(2));
}
for (int i = 0; i < ui.treeRun->topLevelItemCount(); i++)
RunCommands.prepend(MakeRunEntry(ui.treeRun->topLevelItem(i)));
//WriteTextList("RunCommand", RunCommands);
theAPI->GetGlobalSettings()->DelValue("RunCommand");
foreach(const QString & Value, RunCommands)
@ -1936,6 +1927,57 @@ void CSettingsWindow::SaveIniSection()
LoadIniSection();
}
QVariantMap GetRunEntry(const QString& sEntry)
{
QVariantMap Entry;
if (sEntry.left(1) == "{")
{
Entry = QJsonDocument::fromJson(sEntry.toUtf8()).toVariant().toMap();
}
else
{
StrPair NameCmd = Split2(sEntry, "|");
StrPair NameIcon = Split2(NameCmd.first, ",");
Entry["Name"] = NameIcon.first;
Entry["Icon"] = NameIcon.second;
Entry["Command"] = NameCmd.second;
}
return Entry;
}
void AddRunItem(QTreeWidget* treeRun, const QVariantMap& Entry)
{
QTreeWidgetItem* pItem = new QTreeWidgetItem();
pItem->setText(0, Entry["Name"].toString());
pItem->setData(0, Qt::UserRole, Entry);
pItem->setText(1, Entry["Command"].toString());
pItem->setFlags(pItem->flags() | Qt::ItemIsEditable);
treeRun->addTopLevelItem(pItem);
}
QString MakeRunEntry(QTreeWidgetItem* pItem)
{
QVariantMap Entry = pItem->data(0, Qt::UserRole).toMap();
Entry["Name"] = pItem->text(0);
Entry["Command"] = pItem->text(1);
return MakeRunEntry(Entry);
}
QString MakeRunEntry(const QVariantMap& Entry)
{
if (!Entry["WorkingDir"].toString().isEmpty() || !Entry["Icon"].toString().isEmpty()) {
QJsonDocument doc(QJsonValue::fromVariant(Entry).toObject());
QString sEntry = QString::fromUtf8(doc.toJson(QJsonDocument::Compact));
return sEntry;
}
//if(!Entry["Icon"].toString().isEmpty())
// return Entry["Name"].toString() + "," + Entry["Icon"].toString() + "|" + Entry["Command"].toString();
return Entry["Name"].toString() + "|" + Entry["Command"].toString();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update
//

View File

@ -151,8 +151,6 @@ protected:
void AddMessageItem(const QString& ID, const QString& Text = QString());
void AddRunItem(const QString& Name, const QString& Icon, const QString& Command);
void AddWarnEntry(const QString& Name, int type);
void LoadSettings();
@ -187,6 +185,11 @@ private:
Ui::SettingsWindow ui;
};
QVariantMap GetRunEntry(const QString& sEntry);
void AddRunItem(QTreeWidget* treeRun, const QVariantMap& Entry);
QString MakeRunEntry(QTreeWidgetItem* pItem);
QString MakeRunEntry(const QVariantMap& Entry);
void WindowsMoveFile(const QString& from, const QString& to);
extern quint32 g_FeatureFlags;

View File

@ -3,7 +3,7 @@
#define VERSION_MJR 1
#define VERSION_MIN 10
#define VERSION_REV 1
#define VERSION_UPD 0
#define VERSION_UPD 3
#ifndef STR
#define STR2(X) #X