This commit is contained in:
DavidXanatos 2023-01-22 15:16:31 +01:00
parent baa4166706
commit 09c20e4e92
9 changed files with 52 additions and 36 deletions

View File

@ -10,7 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- fixed issue with Hebrew language (Classic UI) [#2608](https://github.com/sandboxie-plus/Sandboxie/issues/2608)
- fixed issue with startmenu integration and snapshots

View File

@ -21,8 +21,8 @@
#ifndef _MY_VERSION_H
#define _MY_VERSION_H
#define MY_VERSION_BINARY 5,61,6
#define MY_VERSION_STRING "5.61.6"
#define MY_VERSION_BINARY 5,61,7
#define MY_VERSION_STRING "5.61.7"
#define MY_ABI_VERSION 0x56000
// These #defines are used by either Resource Compiler or NSIS installer

View File

@ -283,11 +283,11 @@ QString CSandBox::Expand(const QString& Value)
return Value2;
}
QList<SBoxSnapshot> CSandBox::GetSnapshots(QString* pCurrent, QString* pDefault) const
QMap<QString, SBoxSnapshot> CSandBox::GetSnapshots(QString* pCurrent, QString* pDefault) const
{
QSettings ini(m_FilePath + "\\Snapshots.ini", QSettings::IniFormat);
QList<SBoxSnapshot> Snapshots;
QMap<QString, SBoxSnapshot> Snapshots;
foreach(const QString& Snapshot, ini.childGroups())
{
@ -302,7 +302,7 @@ QList<SBoxSnapshot> CSandBox::GetSnapshots(QString* pCurrent, QString* pDefault)
BoxSnapshot.InfoStr = ini.value(Snapshot + "/Description").toString();
BoxSnapshot.SnapDate = QDateTime::fromSecsSinceEpoch(ini.value(Snapshot + "/SnapshotDate").toULongLong());
Snapshots.append(BoxSnapshot);
Snapshots.insert(BoxSnapshot.ID, BoxSnapshot);
}
if(pCurrent)

View File

@ -69,7 +69,7 @@ public:
virtual QString Expand(const QString& Value);
virtual QList<SBoxSnapshot> GetSnapshots(QString* pCurrent = NULL, QString* pDefault = NULL) const;
virtual QMap<QString, SBoxSnapshot> GetSnapshots(QString* pCurrent = NULL, QString* pDefault = NULL) const;
virtual void SetDefaultSnapshot(QString Default);
virtual QString GetDefaultSnapshot(QString* pCurrent = NULL) const;
virtual SB_PROGRESS TakeSnapshot(const QString& Name);

View File

@ -1950,10 +1950,13 @@ QString CSbieAPI::GetBoxedPath(const QString& BoxName, const QString& Path)
//#pragma comment(lib, "mpr.lib")
QString CSbieAPI::GetBoxedPath(CSandBox* pBox, const QString& Path)
QString CSbieAPI::GetBoxedPath(CSandBox* pBox, const QString& Path, const QString& Snapshot)
{
QString BoxRoot = pBox->m_FilePath;
if (!Snapshot.isEmpty())
BoxRoot += QString("\\snapshot-%1").arg(Snapshot);
//WCHAR Buffer[4096];
//DWORD dwBufferLength = sizeof(Buffer)/sizeof(WCHAR );
//UNIVERSAL_NAME_INFO * unameinfo = (UNIVERSAL_NAME_INFO *) &Buffer;

View File

@ -78,7 +78,7 @@ public:
virtual bool GetProcessExemption(quint32 process_id, quint32 action_id);
virtual QString GetBoxedPath(const QString& BoxName, const QString& Path);
virtual QString GetBoxedPath(CSandBox* pBox, const QString& Path);
virtual QString GetBoxedPath(CSandBox* pBox, const QString& Path, const QString& Snapshot = QString());
virtual QString GetRealPath(CSandBox* pBox, const QString& Path);
enum ESetMode

View File

@ -448,6 +448,16 @@ void CSandBoxPlus::ScanStartMenu()
bool bAdded = false;
auto OldStartMenu = ListToSet(m_StartMenu.keys());
QStringList SnapshotList;
SnapshotList.append("");
QString CurSnapshot;
QMap<QString, SBoxSnapshot> Snapshots = GetSnapshots(&CurSnapshot);
while(!CurSnapshot.isEmpty()) {
SnapshotList.append(CurSnapshot);
CurSnapshot = Snapshots[CurSnapshot].Parent;
}
int csidls[] = { CSIDL_DESKTOPDIRECTORY, CSIDL_COMMON_DESKTOPDIRECTORY, CSIDL_STARTMENU, CSIDL_COMMON_STARTMENU };
for (int i = 0; i < ARRAYSIZE(csidls); i++)
{
@ -455,36 +465,39 @@ void CSandBoxPlus::ScanStartMenu()
if (SHGetFolderPath(NULL, csidls[i], NULL, SHGFP_TYPE_CURRENT, path) != S_OK)
continue;
QString BoxPath = theAPI->GetBoxedPath(this, QString::fromWCharArray(path));
QStringList Files = ListDir(BoxPath, QStringList() << "*.lnk" << "*.url" << "*.pif", i >= 2); // no subdir scan for desktop as people like to put junk there
foreach(QString File, Files)
foreach (const QString& Snapshot, SnapshotList)
{
QString Path = (i >= 2 ? "" : "Desktop/") + File;
QString BoxPath = theAPI->GetBoxedPath(this, QString::fromWCharArray(path), Snapshot);
QStringList Files = ListDir(BoxPath, QStringList() << "*.lnk" << "*.url" << "*.pif", i >= 2); // no subdir scan for desktop as people like to put junk there
foreach(QString File, Files)
{
QString Path = (i >= 2 ? "" : "Desktop/") + File;
if (!OldStartMenu.remove(Path))
bAdded = true;
if (!OldStartMenu.remove(Path))
bAdded = true;
StrPair PathName = Split2(Path, "/", true);
StrPair NameExt = Split2(PathName.second, ".", true);
if (NameExt.second.toLower() != "lnk")
continue; // todo url
StrPair PathName = Split2(Path, "/", true);
StrPair NameExt = Split2(PathName.second, ".", true);
if (NameExt.second.toLower() != "lnk")
continue; // todo url
QString LinkPath = BoxPath + "\\" + File.replace("/", "\\");
QVariantMap Link = ResolveShortcut(LinkPath);
if (!Link.contains("Path"))
continue;
QString LinkPath = BoxPath + "\\" + File.replace("/", "\\");
QVariantMap Link = ResolveShortcut(LinkPath);
if (!Link.contains("Path"))
continue;
SLink* pLink = &m_StartMenu[Path];
pLink->Folder = PathName.first;
pLink->Name = NameExt.first;
pLink->Target = Link["Path"].toString();
pLink->Icon = Link["IconPath"].toString();
pLink->IconIndex = Link["IconIndex"].toInt();
SLink* pLink = &m_StartMenu[Path];
pLink->Folder = PathName.first;
pLink->Name = NameExt.first;
pLink->Target = Link["Path"].toString();
pLink->Icon = Link["IconPath"].toString();
pLink->IconIndex = Link["IconIndex"].toInt();
if (!pLink->Target.isEmpty() && !QFile::exists(pLink->Target) && !IsBoxexPath(pLink->Target))
pLink->Target = theAPI->GetBoxedPath(this, pLink->Target);
if (!pLink->Icon.isEmpty() && !QFile::exists(pLink->Icon) && !IsBoxexPath(pLink->Icon))
pLink->Icon = theAPI->GetBoxedPath(this, pLink->Icon);
if (!pLink->Target.isEmpty() && !QFile::exists(pLink->Target) && !IsBoxexPath(pLink->Target))
pLink->Target = theAPI->GetBoxedPath(this, pLink->Target, Snapshot);
if (!pLink->Icon.isEmpty() && !QFile::exists(pLink->Icon) && !IsBoxexPath(pLink->Icon))
pLink->Icon = theAPI->GetBoxedPath(this, pLink->Icon, Snapshot);
}
}
}

View File

@ -93,8 +93,8 @@ void CSnapshotsWindow::closeEvent(QCloseEvent *e)
void CSnapshotsWindow::UpdateSnapshots(bool AndSelect)
{
m_SnapshotMap.clear();
QList<SBoxSnapshot> SnapshotList = m_pBox->GetSnapshots(&m_CurSnapshot, &m_DefaultSnapshot);
foreach(const SBoxSnapshot& Snapshot, SnapshotList)
QMap<QString, SBoxSnapshot> Snapshots = m_pBox->GetSnapshots(&m_CurSnapshot, &m_DefaultSnapshot);
foreach(const SBoxSnapshot& Snapshot, Snapshots)
{
QVariantMap BoxSnapshot;
BoxSnapshot["ID"] = Snapshot.ID;

View File

@ -2,7 +2,7 @@
#define VERSION_MJR 1
#define VERSION_MIN 6
#define VERSION_REV 6
#define VERSION_REV 7
#define VERSION_UPD 0
#ifndef STR