From 7f043d73a230d189bcdcfe4ca3ec1f3f1547f09a Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:47:12 +0200 Subject: [PATCH] 1.10.2g --- CHANGELOG.md | 3 ++ SandboxiePlus/SandMan/SbiePlusAPI.cpp | 64 ++++++++++++++++++++------- SandboxiePlus/SandMan/SbiePlusAPI.h | 2 + 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab73fbf0..5cb16425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [1.10.3 / 5.65.3] - 2023-08-?? +### Added +- Display Steam games shortcuts in Run Menu [#3151](https://github.com/sandboxie-plus/Sandboxie/issues/3151) + ### Changed - improved business certificate handling diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.cpp b/SandboxiePlus/SandMan/SbiePlusAPI.cpp index 20a146b8..bd96eaee 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.cpp +++ b/SandboxiePlus/SandMan/SbiePlusAPI.cpp @@ -458,7 +458,7 @@ void CSandBoxPlus::ScanStartMenu() foreach (const QString& Snapshot, SnapshotList) { 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 + QStringList Files = ListDir(BoxPath, QStringList() << "*.lnk" << "*.url", i >= 2); // no subdir scan for desktop as people like to put junk there foreach(QString File, Files) { QString RealPath = theAPI->GetRealPath(this, BoxPath + "\\" + QString(File).replace("/", "\\")); @@ -490,27 +490,57 @@ void CSandBoxPlus::ScanStartMenu() if (!OldStartMenu.remove(FoundLink.SubPath.toLower())) bChanged = true; + SLink* pLink = NULL; + StrPair PathName = Split2(FoundLink.SubPath, "/", true); StrPair NameExt = Split2(PathName.second, ".", true); - if (NameExt.second.toLower() != "lnk") - continue; // todo url + if (NameExt.second.toLower() == "lnk") + { + QVariantMap Link = ResolveShortcut(FoundLink.LinkPath); + if (!Link.contains("Path")) + continue; - QVariantMap Link = ResolveShortcut(FoundLink.LinkPath); - if (!Link.contains("Path")) - continue; + pLink = &m_StartMenu[FoundLink.SubPath.toLower()]; + pLink->Folder = PathName.first; + pLink->Name = NameExt.first; + if (!pLink->Target.isEmpty() && pLink->Target != Link["Path"].toString()) + bChanged = true; - SLink* pLink = &m_StartMenu[FoundLink.SubPath.toLower()]; - pLink->Folder = PathName.first; - pLink->Name = NameExt.first; - if(!pLink->Target.isEmpty() && pLink->Target != Link["Path"].toString()) - bChanged = true; - pLink->Target = Link["Path"].toString(); - pLink->Arguments = Link["Arguments"].toString(); - pLink->Icon = Link["IconPath"].toString(); - pLink->IconIndex = Link["IconIndex"].toInt(); - pLink->WorkDir = Link["WorkingDir"].toString(); + pLink->Target = Link["Path"].toString(); + pLink->Arguments = Link["Arguments"].toString(); + pLink->Icon = Link["IconPath"].toString(); + pLink->IconIndex = Link["IconIndex"].toInt(); + pLink->WorkDir = Link["WorkingDir"].toString(); + } + else if (NameExt.second.toLower() == "url") + { + std::wstring urlFile = FoundLink.LinkPath.toStdWString(); - if (!pLink->Target.isEmpty() && !QFile::exists(pLink->Target) && !IsBoxexPath(pLink->Target)) + auto ReadIni = [&urlFile](const wchar_t* Section, const wchar_t* Key) { + wchar_t strBuffer[0x1000]; + DWORD Read = GetPrivateProfileStringW(Section, Key, L"", strBuffer, ARRSIZE(strBuffer), urlFile.c_str()); + return QString::fromWCharArray(strBuffer, Read); + }; + + QString Url = ReadIni(L"InternetShortcut", L"URL"); + if (Url.isEmpty()) + continue; + + pLink = &m_StartMenu[FoundLink.SubPath.toLower()]; + pLink->Folder = PathName.first; + pLink->Name = NameExt.first; + if (!pLink->Target.isEmpty() && pLink->Target != Url) + bChanged = true; + + pLink->Url = true; + pLink->Target = Url; + //pLink->Arguments = ; + pLink->Icon = ReadIni(L"InternetShortcut", L"IconFile"); + pLink->IconIndex = ReadIni(L"InternetShortcut", L"IconIndex").toInt(); + //pLink->WorkDir = ; + } + + if (!pLink->Url && !pLink->Target.isEmpty() && !QFile::exists(pLink->Target) && !IsBoxexPath(pLink->Target)) pLink->Target = theAPI->GetBoxedPath(this, pLink->Target, FoundLink.Snapshot); if (!pLink->WorkDir.isEmpty() && !QFile::exists(pLink->WorkDir) && !IsBoxexPath(pLink->WorkDir)) pLink->WorkDir = theAPI->GetBoxedPath(this, pLink->WorkDir, FoundLink.Snapshot); diff --git a/SandboxiePlus/SandMan/SbiePlusAPI.h b/SandboxiePlus/SandMan/SbiePlusAPI.h index 51d307c9..8249430c 100644 --- a/SandboxiePlus/SandMan/SbiePlusAPI.h +++ b/SandboxiePlus/SandMan/SbiePlusAPI.h @@ -161,8 +161,10 @@ public: SB_STATUS DeleteContentAsync(bool DeleteSnapshots = true, bool bOnAutoDelete = false); struct SLink { + SLink() :Url(false), IconIndex(0) {} QString Folder; QString Name; + bool Url; QString Target; QString Arguments; QString Icon;