This commit is contained in:
DavidXanatos 2023-12-21 16:42:14 +01:00
parent 731a5796bf
commit 8d82b43791
7 changed files with 70 additions and 60 deletions

View File

@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [1.12.6 / 5.67.6] - 2023-12-
### Changed
todo: improve behaviorue of toolbar customization menu
- improve behaviorue of toolbar customization menu
### Fixed
- fixed Sandboxie-Plus 1.12.4 + failed to start start.exe in confidential box [#3514](https://github.com/sandboxie-plus/Sandboxie/issues/3514)

View File

@ -266,11 +266,13 @@ extern const WCHAR *Dll_HomeDosPath;
//extern ULONG Dll_HomeDosPathLen;
extern const WCHAR *Dll_BoxFilePath;
extern const WCHAR *Dll_BoxFileRawPath; // not reparsed nt path
extern const WCHAR *Dll_BoxFileDosPath;
extern const WCHAR *Dll_BoxKeyPath;
extern const WCHAR *Dll_BoxIpcPath;
extern ULONG Dll_BoxFilePathLen;
extern ULONG Dll_BoxFileRawPathLen;
extern ULONG Dll_BoxFileDosPathLen;
extern ULONG Dll_BoxKeyPathLen;
extern ULONG Dll_BoxIpcPathLen;

View File

@ -74,11 +74,13 @@ const WCHAR *Dll_HomeDosPath = NULL;
//ULONG Dll_HomeDosPathLen = 0;
const WCHAR *Dll_BoxFilePath = NULL;
const WCHAR *Dll_BoxFileRawPath = NULL;
const WCHAR *Dll_BoxFileDosPath = NULL;
const WCHAR *Dll_BoxKeyPath = NULL;
const WCHAR *Dll_BoxIpcPath = NULL;
ULONG Dll_BoxFilePathLen = 0;
ULONG Dll_BoxFileRawPathLen = 0;
ULONG Dll_BoxFileDosPathLen = 0;
ULONG Dll_BoxKeyPathLen = 0;
ULONG Dll_BoxIpcPathLen = 0;

View File

@ -649,14 +649,29 @@ _FX NTSTATUS File_GetTruePathImpl(ULONG* p_length, WCHAR **OutTruePath, ULONG *O
WCHAR* name;
const FILE_DRIVE *drive;
struct {
const WCHAR* Path;
ULONG PathLen;
} BoxFilePaths[3] = {
Dll_BoxFilePath, Dll_BoxFilePathLen,
Dll_BoxFileRawPath, Dll_BoxFileRawPathLen,
File_AltBoxPath, File_AltBoxPathLen // ToDo: deprecated, remove - raw path is more reliable and covers all cases
}, *Dll_BoxFile;
check_sandbox_prefix:
if (*p_length >= Dll_BoxFilePathLen &&
for (int i = 0; i < ARRAYSIZE(BoxFilePaths) && !*p_is_boxed_path; i++) {
Dll_BoxFile = &BoxFilePaths[i];
if (!Dll_BoxFile->Path)
continue;
if (*p_length >= Dll_BoxFile->PathLen &&
0 == Dll_NlsStrCmp(
*OutTruePath, Dll_BoxFilePath, Dll_BoxFilePathLen))
*OutTruePath, Dll_BoxFile->Path, Dll_BoxFile->PathLen))
{
*OutTruePath += Dll_BoxFilePathLen;
*p_length -= Dll_BoxFilePathLen;
*OutTruePath += Dll_BoxFile->PathLen;
*p_length -= Dll_BoxFile->PathLen;
if (! *p_length) {
//
@ -671,25 +686,6 @@ check_sandbox_prefix:
*p_is_boxed_path = TRUE;
}
if (File_AltBoxPath &&
*p_length >= File_AltBoxPathLen &&
0 == Dll_NlsStrCmp(
*OutTruePath, File_AltBoxPath, File_AltBoxPathLen))
{
*OutTruePath += File_AltBoxPathLen;
*p_length -= File_AltBoxPathLen;
if (! *p_length) {
//
// caller specified just the sandbox prefix
//
*OutTruePath = NULL;
return STATUS_BAD_INITIAL_PC;
}
if (OutFlags)
*OutFlags |= FGN_IS_BOXED_PATH;
*p_is_boxed_path = TRUE;
}
//

View File

@ -189,23 +189,24 @@ _FX BOOLEAN File_Init(void)
// implement workaround, see SbieDll_TranslateNtToDosPath
//
ULONG BoxFilePathLen = 0;
if (NT_SUCCESS(SbieApi_QueryProcessInfoStr(0, 'root', NULL, &BoxFilePathLen)))
ULONG BoxFileRawPathLen;
if (NT_SUCCESS(SbieApi_QueryProcessInfoStr(0, 'root', NULL, &BoxFileRawPathLen)))
{
WCHAR* BoxFilePathConf = Dll_AllocTemp(BoxFilePathLen);
if (NT_SUCCESS(SbieApi_QueryProcessInfoStr(0, 'root', BoxFilePathConf, &BoxFilePathLen)))
Dll_BoxFileRawPath = Dll_AllocTemp(BoxFileRawPathLen);
if (NT_SUCCESS(SbieApi_QueryProcessInfoStr(0, 'root', (WCHAR*)Dll_BoxFileRawPath, &BoxFileRawPathLen)))
{
if (SbieDll_TranslateNtToDosPath(BoxFilePathConf))
{
Dll_BoxFileDosPathLen = wcslen(BoxFilePathConf);
Dll_BoxFileDosPath = Dll_Alloc((Dll_BoxFileDosPathLen + 1) * sizeof(WCHAR));
wcscpy((WCHAR*)Dll_BoxFileDosPath, BoxFilePathConf);
Dll_BoxFileRawPathLen = wcslen(Dll_BoxFileRawPath);
Dll_BoxFileDosPath = Dll_Alloc(BoxFileRawPathLen);
wcscpy((WCHAR*)Dll_BoxFileDosPath, Dll_BoxFileRawPath);
if (!SbieDll_TranslateNtToDosPath((WCHAR*)Dll_BoxFileDosPath)) {
Dll_Free((WCHAR *)Dll_BoxFileDosPath);
Dll_BoxFileDosPath = NULL;
}
}
Dll_Free(BoxFilePathConf);
}
}
else
if(Dll_BoxFileDosPath)
Dll_BoxFileDosPathLen = wcslen(Dll_BoxFileDosPath);
File_InitSnapshots();

View File

@ -506,7 +506,7 @@ check:
//DbgPrint("IRP_MJ_CREATE: %S\n", root->file_root);
//
// csrss.exe needs acces to binaries of starting up processes,
// csrss.exe needs acces to binaries of starting up processes.
//
if (Util_IsCsrssProcess(PsGetCurrentProcessId()))

View File

@ -885,38 +885,47 @@ void CSandMan::OnToolBarMenuItemClicked(const QString& scriptName)
void CSandMan::CreateToolBarConfigMenu(const QList<ToolBarAction>& actions, const QSet<QString>& currentItems)
{
auto m_pToolBarContextMenu = new QMenu(tr("Toolbar Items"), m_pToolBar);
m_pToolBarContextMenu->addAction(tr("Reset Toolbar"), this, &CSandMan::OnResetToolBarMenuConfig);
m_pToolBarContextMenu->addSeparator();
for (auto sa : actions)
static QMenu* m_pToolBarContextMenu = NULL;
if (!m_pToolBarContextMenu)
{
if (sa.scriptName == nullptr) {
m_pToolBarContextMenu->addSeparator();
continue;
}
m_pToolBarContextMenu = new QMenu(tr("Toolbar Items"), this);
QString text = sa.scriptName;
if (!sa.nameOverride.isEmpty())
text = sa.nameOverride;
else if (sa.action)
text = sa.action->text(); // tr: already localised
else
qDebug() << "ERROR: Missing display name for " << sa.scriptName;
m_pToolBarContextMenu->addAction(tr("Reset Toolbar"), this, &CSandMan::OnResetToolBarMenuConfig);
m_pToolBarContextMenu->addSeparator();
auto scriptName = sa.scriptName;
auto menuAction = m_pToolBarContextMenu->addAction(text, this, [scriptName, this]() {
OnToolBarMenuItemClicked(scriptName);
for (auto sa : actions)
{
if (sa.scriptName == nullptr) {
m_pToolBarContextMenu->addSeparator();
continue;
}
);
menuAction->setCheckable(true);
menuAction->setChecked(currentItems.contains(sa.scriptName));
QString text = sa.scriptName;
if (!sa.nameOverride.isEmpty())
text = sa.nameOverride;
else if (sa.action)
text = sa.action->text(); // tr: already localised
else
qDebug() << "ERROR: Missing display name for " << sa.scriptName;
auto scriptName = sa.scriptName;
//auto menuAction = m_pToolBarContextMenu->addAction(text, this, [scriptName, this]() {
auto menuAction = new QCheckBox(text);
QWidgetAction* menuEntry = new QWidgetAction(this);
menuEntry->setDefaultWidget(menuAction);
m_pToolBarContextMenu->addAction(menuEntry);
connect(menuAction, &QCheckBox::clicked, this, [scriptName, this]() {
OnToolBarMenuItemClicked(scriptName);
}
);
//menuAction->setCheckable(true);
menuAction->setChecked(currentItems.contains(sa.scriptName));
}
}
m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
QObject::connect(m_pToolBar, &QToolBar::customContextMenuRequested, this,
[m_pToolBarContextMenu, this](const QPoint& p) {
[&](const QPoint& p) {
m_pToolBarContextMenu->exec(mapToGlobal(p));
}
);