This commit is contained in:
DavidXanatos 2023-08-04 17:47:12 +02:00
parent ad7a232d33
commit 7f043d73a2
3 changed files with 52 additions and 17 deletions

View File

@ -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

View File

@ -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;
SLink* pLink = &m_StartMenu[FoundLink.SubPath.toLower()];
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();
}
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);

View File

@ -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;