Merge branch 'master' into next

This commit is contained in:
DavidXanatos 2022-05-15 14:59:34 +02:00
commit 7d8e3fc177
29 changed files with 1947 additions and 449 deletions

View File

@ -75,6 +75,9 @@ jobs:
- name: Build Sandboxie-Plus 64 bit
run: SandboxiePlus\qmake_plus.cmd x64
- name: Build SbieShell 64 bit
run: msbuild /t:restore,build -p:RestorePackagesConfig=true SandboxiePlus\SbieShell\SbieShell.sln /p:Configuration="Release" /p:Platform=x64
- name: Build Sandboxie-Plus 32 bit
run: SandboxiePlus\qmake_plus.cmd Win32

View File

@ -29,7 +29,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.22 / 5.55.22] - 2022-05-xx
### Added
- added auto update download and silent install option to sandman.exe
- added auto update download and silent install option to sandman.exe [#917](https://github.com/sandboxie-plus/Sandboxie/issues/917)
- trace monitor mode can now also save to file [#1851](https://github.com/sandboxie-plus/Sandboxie/issues/1851)
- trace log now shows ipc object type information
- added support for windows 11 context menus
### Fixed
- fixed sandman crash issue [#1846](https://github.com/sandboxie-plus/Sandboxie/issues/1846)

View File

@ -118,6 +118,9 @@ IF %archPath% == x64 (
mkdir %instPath%\32\
copy /y %~dp0..\Sandboxie\Bin\Win32\SbieRelease\SbieSvc.exe %instPath%\32\
copy /y %~dp0..\Sandboxie\Bin\Win32\SbieRelease\SbieDll.dll %instPath%\32\
copy /y %~dp0..\SandboxiePlus\x64\Release\SbieShellExt.dll %instPath%\
copy /y %~dp0..\SandboxiePlus\x64\Release\SbieShellPkg.msix %instPath%\
)
copy /y %~dp0..\Sandboxie\install\Templates.ini %instPath%\

View File

@ -1062,7 +1062,15 @@ _FX NTSTATUS Ipc_CheckGenericObject(
}
RtlStringCbPrintfW(access_str, sizeof(access_str), L"(I%c) %08X", letter, GrantedAccess);
Log_Debug_Msg(mon_type, access_str, Name->Buffer);
//Log_Debug_Msg(mon_type, access_str, Name->Buffer);
if (Session_MonitorCount) {
POBJECT_TYPE ObjectType = pObGetObjectType(Object);
const WCHAR* strings[4] = { Name->Buffer, access_str, ObjectType ? ObjectType->Name.Buffer : NULL, NULL };
Session_MonitorPutEx(mon_type, strings, NULL, PsGetCurrentProcessId(), PsGetCurrentThreadId());
}
}
}

View File

@ -706,6 +706,9 @@ _FX NTSTATUS Session_Api_MonitorPut2(PROCESS *proc, ULONG64 *parms)
ULONG log_type;
WCHAR *log_data;
WCHAR *name;
const WCHAR *type_pipe = L"Pipe";
const WCHAR *type_file = L"File";
const WCHAR *type_name = NULL;
NTSTATUS status;
ULONG log_len;
@ -783,8 +786,10 @@ _FX NTSTATUS Session_Api_MonitorPut2(PROCESS *proc, ULONG64 *parms)
Obj_ObjectTypes[i], KernelMode, NULL,
&object);
if (status != STATUS_OBJECT_TYPE_MISMATCH)
if (status != STATUS_OBJECT_TYPE_MISMATCH) {
type_name = Obj_ObjectTypes[i]->Name.Buffer;
break;
}
}
// DbgPrint("IPC Status = %08X Object = %08X for Open <%S>\n", status, object, name);
@ -795,7 +800,7 @@ _FX NTSTATUS Session_Api_MonitorPut2(PROCESS *proc, ULONG64 *parms)
// to get the name assigned to it at time of creation
//
if ((log_type & MONITOR_TYPE_MASK) == MONITOR_PIPE) {
else if ((log_type & MONITOR_TYPE_MASK) == MONITOR_PIPE) {
OBJECT_ATTRIBUTES objattrs;
IO_STATUS_BLOCK IoStatusBlock;
@ -834,6 +839,8 @@ _FX NTSTATUS Session_Api_MonitorPut2(PROCESS *proc, ULONG64 *parms)
status = STATUS_OBJECT_NAME_NOT_FOUND;
}
type_name = type_pipe;
//DbgPrint("PIPE Status3 = %08X Object = %08X for Open <%S>\n", status, object, name);
}
@ -885,7 +892,7 @@ _FX NTSTATUS Session_Api_MonitorPut2(PROCESS *proc, ULONG64 *parms)
name[1] = L'\0';
}*/
const WCHAR* strings[2] = { name, NULL };
const WCHAR* strings[4] = { name, L"", type_name, NULL };
Session_MonitorPutEx(log_type | MONITOR_USER, strings, NULL, proc->pid, PsGetCurrentThreadId());
}

View File

@ -143,7 +143,7 @@ void CPanelView::RecursiveCopyPanel(const QModelIndex& ModelIndex, QList<QString
}
}
void CPanelView::OnCopyPanel()
QList<QStringList> CPanelView::DumpPanel()
{
QAbstractItemModel* pModel = GetModel();
@ -153,7 +153,13 @@ void CPanelView::OnCopyPanel()
QModelIndex ModelIndex = pModel->index(i, 0);
RecursiveCopyPanel(ModelIndex, Rows);
}
FormatAndCopy(Rows);
return Rows;
}
void CPanelView::OnCopyPanel()
{
FormatAndCopy(DumpPanel());
}
void CPanelView::FormatAndCopy(QList<QStringList> Rows, bool Headder)

View File

@ -14,6 +14,8 @@ public:
static void SetMaxCellWidth(int iMaxWidth) { m_MaxCellWidth = iMaxWidth; }
static void SetCellSeparator(const QString& Sep) { m_CellSeparator = Sep; }
virtual QList<QStringList> DumpPanel();
static QString m_CopyCell;
static QString m_CopyRow;
static QString m_CopyPanel;

View File

@ -65,6 +65,7 @@ CTraceEntry::CTraceEntry(quint32 ProcessId, quint32 ThreadId, quint32 Type, cons
m_ThreadId = ThreadId;
m_Name = LogData.length() > 0 ? LogData.at(0) : QString("(empty)");
m_Message = LogData.length() > 1 ? LogData.at(1) : QString();
m_SubType = LogData.length() > 2 ? LogData.at(2) : QString();
m_Type.Flags = Type;
m_TimeStamp = QDateTime::currentDateTime(); // ms resolution
@ -136,6 +137,9 @@ QString CTraceEntry::GetTypeStr() const
if(Type.isEmpty())
Type = "Unknown: " + QString::number(m_Type.Type);
if(!m_SubType.isEmpty())
Type.append(" / " + m_SubType);
if (m_Type.User)
Type.append(" (U)");
else

View File

@ -67,6 +67,7 @@ public:
protected:
QString m_Name;
QString m_Message;
QString m_SubType;
quint32 m_ProcessId;
quint32 m_ThreadId;
QDateTime m_TimeStamp;

View File

@ -361,9 +361,15 @@ bool CSbieUtils::CreateShortcut(CSbieAPI* pApi, QString LinkPath, const QString
QString StartArgs;
if (bRunElevated)
StartArgs += "/elevated ";
StartArgs += "/box:" + boxname;
if (!arguments.isEmpty())
StartArgs += " \"" + arguments + "\"";
if (!boxname.isEmpty())
StartArgs += "/box:" + boxname;
if (!arguments.isEmpty()) {
if (!StartArgs.isEmpty()) StartArgs += " ";
if(arguments.contains(" "))
StartArgs += "\"" + arguments + "\"";
else
StartArgs += arguments;
}
IUnknown *pUnknown;
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IUnknown, (void **)&pUnknown);
@ -381,7 +387,7 @@ bool CSbieUtils::CreateShortcut(CSbieAPI* pApi, QString LinkPath, const QString
if (!workdir.isEmpty())
pShellLink->SetWorkingDirectory(workdir.toStdWString().c_str());
if (!LinkName.isEmpty()) {
QString desc = QString("%1 [%2]").arg(LinkName).arg(boxname);
QString desc = QString("%1 [%2]").arg(LinkName).arg(boxname.isEmpty() ? "DefaultBox" : boxname);
pShellLink->SetDescription(desc.toStdWString().c_str());
}

View File

@ -21,7 +21,6 @@
#include "Views/TraceView.h"
#include "Windows/SelectBoxWindow.h"
#include "../UGlobalHotkey/uglobalhotkeys.h"
#include "Wizards/SetupWizard.h"
#include "Helpers/WinAdmin.h"
CSbiePlusAPI* theAPI = NULL;
@ -356,7 +355,6 @@ void CSandMan::CreateMenus()
m_pStopSvc = m_pMaintenanceItems->addAction(tr("Stop Service"), this, SLOT(OnMaintenance()));
m_pUninstallSvc = m_pMaintenanceItems->addAction(tr("Uninstall Service"), this, SLOT(OnMaintenance()));
m_pMaintenance->addSeparator();
m_pSetupWizard = m_pMaintenance->addAction(CSandMan::GetIcon("Software"), tr("Setup Wizard"), this, SLOT(OnMaintenance()));
if(IsFullyPortable())
m_pUninstallAll = m_pMaintenance->addAction(CSandMan::GetIcon("Uninstall"), tr("Uninstall All"), this, SLOT(OnMaintenance()));
@ -1175,18 +1173,6 @@ void CSandMan::OnStatusChanged()
OnLogMessage(tr("Default sandbox not found; creating: %1").arg("DefaultBox"));
theAPI->CreateBox("DefaultBox");
}
int BusinessUse = theConf->GetInt("Options/BusinessUse", 2);
if (g_CertInfo.business && BusinessUse == 0) // if we have a Business cert switch to that use case
theConf->SetValue("Options/BusinessUse", 1);
int WizardLevel = theConf->GetBool("Options/WizardLevel", 0);
if (WizardLevel == 0) {
if (CSetupWizard::ShowWizard())
UpdateSettings();
else // if user canceled mark that and not show again
theConf->SetValue("Options/WizardLevel", -1);
}
}
else
{
@ -1737,16 +1723,10 @@ void CSandMan::OnMaintenance()
AutorunEnable(false);
CSbieUtils::RemoveContextMenu();
CSettingsWindow__RemoveContextMenu();
CSbieUtils::RemoveContextMenu2();
}
else if (sender() == m_pSetupWizard) {
if (CSetupWizard::ShowWizard())
UpdateSettings();
return;
}
HandleMaintenance(Status);
}

View File

@ -455,7 +455,6 @@ void CTraceView::OnSetMode()
m_pTraceTree->setEnabled(!m_pMonitorMode->isChecked());
m_pTraceStatus->setEnabled(!m_pMonitorMode->isChecked());
m_pSaveToFile->setEnabled(!m_pMonitorMode->isChecked());
m_FullRefresh = true;
@ -556,27 +555,36 @@ void CTraceView::SaveToFile()
return;
}
QVector<CTraceEntryPtr> ResourceLog = theAPI->GetTrace();
for (int i = 0; i < ResourceLog.count(); i++)
if (m_pMonitorMode->isChecked())
{
CTraceEntryPtr pEntry = ResourceLog.at(i);
QList<QStringList> Rows = m_pMonitor->DumpPanel();
foreach(const QStringList& Row, Rows)
File.write(Row.join("\t").toLatin1() + "\n");
}
else
{
QVector<CTraceEntryPtr> ResourceLog = theAPI->GetTrace();
for (int i = 0; i < ResourceLog.count(); i++)
{
CTraceEntryPtr pEntry = ResourceLog.at(i);
//int iFilter = CTraceView__Filter(pEntry, this);
//if (!iFilter)
// continue;
//int iFilter = CTraceView__Filter(pEntry, this);
//if (!iFilter)
// continue;
QStringList Line;
Line.append(pEntry->GetTimeStamp().toString("hh:mm:ss.zzz"));
QString Name = pEntry->GetProcessName();
Line.append(Name.isEmpty() ? tr("Unknown") : Name);
Line.append(QString("%1").arg(pEntry->GetProcessId()));
Line.append(QString("%1").arg(pEntry->GetThreadId()));
Line.append(pEntry->GetTypeStr());
Line.append(pEntry->GetStautsStr());
Line.append(pEntry->GetName());
Line.append(pEntry->GetMessage());
QStringList Line;
Line.append(pEntry->GetTimeStamp().toString("hh:mm:ss.zzz"));
QString Name = pEntry->GetProcessName();
Line.append(Name.isEmpty() ? tr("Unknown") : Name);
Line.append(QString("%1").arg(pEntry->GetProcessId()));
Line.append(QString("%1").arg(pEntry->GetThreadId()));
Line.append(pEntry->GetTypeStr());
Line.append(pEntry->GetStautsStr());
Line.append(pEntry->GetName());
Line.append(pEntry->GetMessage());
File.write(Line.join("\t").toLatin1() + "\n");
File.write(Line.join("\t").toLatin1() + "\n");
}
}
File.close();

View File

@ -215,6 +215,12 @@ void CSettingsWindow::closeEvent(QCloseEvent *e)
Qt::CheckState CSettingsWindow__IsContextMenu()
{
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\PackagedCom\\Package", QSettings::NativeFormat);
foreach(const QString & Key, settings.childGroups()) {
if (Key.indexOf("SandboxieShell") == 0)
return Qt::Checked;
}
QString cmd = CSbieUtils::GetContextMenuStartCmd();
if (cmd.contains("SandMan.exe", Qt::CaseInsensitive))
return Qt::Checked; // set up and sandman
@ -225,11 +231,33 @@ Qt::CheckState CSettingsWindow__IsContextMenu()
void CSettingsWindow__AddContextMenu()
{
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat);
if (settings.value("CurrentBuild") >= 22000) // Windows 11
{
QProcess Proc;
Proc.execute("rundll32.exe", QStringList() << QCoreApplication::applicationDirPath().replace("/", "\\") + "\\SbieShellExt.dll,RegisterPackage");
Proc.waitForFinished();
return;
}
CSbieUtils::AddContextMenu(QApplication::applicationDirPath().replace("/", "\\") + "\\SandMan.exe",
CSettingsWindow::tr("Run &Sandboxed"), //CSettingsWindow::tr("Explore &Sandboxed"),
QApplication::applicationDirPath().replace("/", "\\") + "\\Start.exe");
}
void CSettingsWindow__RemoveContextMenu()
{
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat);
if (settings.value("CurrentBuild") >= 22000) // Windows 11
{
QProcess Proc;
Proc.execute("rundll32.exe", QStringList() << QCoreApplication::applicationDirPath().replace("/", "\\") + "\\SbieShellExt.dll,RemovePackage");
Proc.waitForFinished();
}
CSbieUtils::RemoveContextMenu();
}
void CSettingsWindow__AddBrowserIcon()
{
QString Path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).replace("/", "\\");
@ -405,7 +433,7 @@ void CSettingsWindow::SaveSettings()
if (ui.chkShellMenu->isChecked())
CSettingsWindow__AddContextMenu();
else
CSbieUtils::RemoveContextMenu();
CSettingsWindow__RemoveContextMenu();
}
if (ui.chkShellMenu2->isChecked() != CSbieUtils::HasContextMenu2()) {
@ -545,23 +573,77 @@ void CSettingsWindow::SaveSettings()
QPalette palette = QApplication::palette();
QString CertPath = theAPI->GetSbiePath() + "\\Certificate.dat";
if (!Certificate.isEmpty()) {
auto Args = GetArguments(Certificate, L'\n', L':');
bool bLooksOk = true;
if (Args.value("NAME").isEmpty()) // mandatory
bLooksOk = false;
//if (Args.value("UPDATEKEY").isEmpty())
// bLooksOk = false;
if (Args.value("SIGNATURE").isEmpty()) // absolutely mandatory
bLooksOk = false;
if (bLooksOk) {
QString TempPath = QDir::tempPath() + "/Sbie+Certificate.dat";
QFile CertFile(TempPath);
if (CertFile.open(QFile::WriteOnly)) {
CertFile.write(Certificate);
CertFile.close();
}
WindowsMoveFile(TempPath.replace("/", "\\"), CertPath.replace("/", "\\"));
}
else {
Certificate.clear();
QMessageBox::critical(this, "Sandboxie-Plus", tr("This does not look like a certificate, please enter the entire certificate not just a portion of it."));
}
}
else if(!g_Certificate.isEmpty()){
WindowsMoveFile(CertPath.replace("/", "\\"), "");
}
if (theGUI->m_DarkTheme)
palette.setColor(QPalette::Text, Qt::black);
ui.lblCertExp->setVisible(false);
bool bRet = ApplyCertificate(Certificate, this);
if (Certificate.isEmpty())
{
palette.setColor(QPalette::Base, Qt::white);
else if (!bRet)
palette.setColor(QPalette::Base, QColor(255, 192, 192));
else if (g_CertInfo.expired || g_CertInfo.outdated) {
palette.setColor(QPalette::Base, QColor(255, 255, 192));
ui.lblCertExp->setVisible(true);
}
else if (!theAPI->ReloadCert().IsError())
{
g_FeatureFlags = theAPI->GetFeatureFlags();
theGUI->UpdateCertState();
if (g_CertInfo.expired || g_CertInfo.outdated) {
if(g_CertInfo.expired)
QMessageBox::information(this, "Sandboxie-Plus", tr("This certificate is unfortunately expired."));
else
QMessageBox::information(this, "Sandboxie-Plus", tr("This certificate is unfortunately outdated."));
palette.setColor(QPalette::Base, QColor(255, 255, 192));
ui.lblCertExp->setVisible(true);
}
else {
QMessageBox::information(this, "Sandboxie-Plus", tr("Thank you for supporting the development of Sandboxie-Plus."));
palette.setColor(QPalette::Base, QColor(192, 255, 192));
}
}
else
palette.setColor(QPalette::Base, QColor(192, 255, 192));
{
QMessageBox::critical(this, "Sandboxie-Plus", tr("This support certificate is not valid."));
palette.setColor(QPalette::Base, QColor(255, 192, 192));
Certificate.clear();
g_CertInfo.State = 0;
}
g_Certificate = Certificate;
ui.txtCertificate->setPalette(palette);
}
@ -578,71 +660,6 @@ void CSettingsWindow::SaveSettings()
emit OptionsChanged();
}
bool CSettingsWindow::ApplyCertificate(const QByteArray &Certificate, QWidget* widget)
{
QString CertPath = theAPI->GetSbiePath() + "\\Certificate.dat";
if (!Certificate.isEmpty()) {
auto Args = GetArguments(Certificate, L'\n', L':');
bool bLooksOk = true;
if (Args.value("NAME").isEmpty()) // mandatory
bLooksOk = false;
//if (Args.value("UPDATEKEY").isEmpty())
// bLooksOk = false;
if (Args.value("SIGNATURE").isEmpty()) // absolutely mandatory
bLooksOk = false;
if (bLooksOk) {
QString TempPath = QDir::tempPath() + "/Sbie+Certificate.dat";
QFile CertFile(TempPath);
if (CertFile.open(QFile::WriteOnly)) {
CertFile.write(Certificate);
CertFile.close();
}
WindowsMoveFile(TempPath.replace("/", "\\"), CertPath.replace("/", "\\"));
}
else {
QMessageBox::critical(widget, "Sandboxie-Plus", tr("This does not look like a certificate, please enter the entire certificate not just a portion of it."));
return false;
}
}
else if(!g_Certificate.isEmpty()){
WindowsMoveFile(CertPath.replace("/", "\\"), "");
}
if (Certificate.isEmpty())
return false;
if (!theAPI->ReloadCert().IsError())
{
g_FeatureFlags = theAPI->GetFeatureFlags();
theGUI->UpdateCertState();
if (g_CertInfo.expired || g_CertInfo.outdated) {
if(g_CertInfo.expired)
QMessageBox::information(widget, "Sandboxie-Plus", tr("This certificate is unfortunately expired."));
else
QMessageBox::information(widget, "Sandboxie-Plus", tr("This certificate is unfortunately outdated."));
}
else {
QMessageBox::information(widget, "Sandboxie-Plus", tr("Thank you for supporting the development of Sandboxie-Plus."));
}
g_Certificate = Certificate;
return true;
}
else
{
QMessageBox::critical(widget, "Sandboxie-Plus", tr("This support certificate is not valid."));
g_CertInfo.State = 0;
g_Certificate.clear();
return false;
}
}
void CSettingsWindow::apply()
{
if (!ui.btnEditIni->isEnabled())

View File

@ -24,8 +24,6 @@ public:
virtual void accept() {}
virtual void reject();
static bool ApplyCertificate(const QByteArray &Certificate, QWidget* widget);
static void LoadCertificate();
signals:
@ -90,6 +88,7 @@ private:
};
void CSettingsWindow__AddContextMenu();
void CSettingsWindow__RemoveContextMenu();
void CSettingsWindow__AddBrowserIcon();
void WindowsMoveFile(const QString& from, const QString& to);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29021.104
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{49D9D73C-85D3-4EE8-901F-5FEC9C17D7EE}"
ProjectSection(SolutionItems) = preProject
SbieShellPkg\AppxManifest.xml = SbieShellPkg\AppxManifest.xml
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SbieShellExt", "SbieShellExt\SbieShellExt.vcxproj", "{16746B0C-5840-4ED4-AEDF-1ABB617827FD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SbieShell", "SbieShell\SbieShell.vcxproj", "{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}"
ProjectSection(ProjectDependencies) = postProject
{16746B0C-5840-4ED4-AEDF-1ABB617827FD} = {16746B0C-5840-4ED4-AEDF-1ABB617827FD}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|Any CPU.ActiveCfg = Debug|ARM
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|Any CPU.Build.0 = Debug|ARM
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|ARM.ActiveCfg = Debug|ARM
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|ARM.Build.0 = Debug|ARM
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|ARM64.ActiveCfg = Debug|ARM64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|ARM64.Build.0 = Debug|ARM64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|x64.ActiveCfg = Debug|x64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|x64.Build.0 = Debug|x64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|x86.ActiveCfg = Debug|Win32
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Debug|x86.Build.0 = Debug|Win32
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|Any CPU.ActiveCfg = Release|Win32
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|ARM.ActiveCfg = Release|ARM
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|ARM.Build.0 = Release|ARM
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|ARM64.ActiveCfg = Release|ARM64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|ARM64.Build.0 = Release|ARM64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|x64.ActiveCfg = Release|x64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|x64.Build.0 = Release|x64
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|x86.ActiveCfg = Release|Win32
{16746B0C-5840-4ED4-AEDF-1ABB617827FD}.Release|x86.Build.0 = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|Any CPU.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|Any CPU.Build.0 = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|ARM.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|ARM.Build.0 = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|ARM64.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|ARM64.Build.0 = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|x64.ActiveCfg = Debug|x64
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|x64.Build.0 = Debug|x64
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|x86.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|x86.Build.0 = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|Any CPU.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|ARM.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|ARM64.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|x64.ActiveCfg = Release|x64
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|x64.Build.0 = Release|x64
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|x86.ActiveCfg = Release|Win32
{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EAC535F2-5E51-4F68-AA53-B42E305FDCF8}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="SandboxieShell.app"/>
<msix xmlns="urn:schemas-microsoft-com:msix.v1"
publisher="CN=xanasoft.com"
packageName="SandboxieShell"
applicationId="SandboxieShell"
/>
</assembly>

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}</ProjectGuid>
<RootNamespace>CustomActions</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
<ProjectName>SbieShell</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;CUSTOMACTIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;CUSTOMACTIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;CUSTOMACTIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;CUSTOMACTIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<Manifest Include="SbieShell.manifest" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Manifest Include="SbieShell.manifest" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,194 @@
#include <windows.h>
//#include <appmodel.h>
#include <winrt/Windows.Management.Deployment.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.h>
//#pragma comment(lib, "windowsapp.lib")
HMODULE g_combase = NULL;
extern "C"
{
int32_t __stdcall WINRT_GetRestrictedErrorInfo(void** info) noexcept {
typedef int32_t(__stdcall* FUNC)(void** info);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "GetRestrictedErrorInfo");
return Func(info);
}
int32_t __stdcall WINRT_RoGetActivationFactory(void* classId, winrt::guid const& iid, void** factory) noexcept {
typedef int32_t(__stdcall* FUNC)(void* classId, winrt::guid const& iid, void** factory);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "RoGetActivationFactory");
return Func(classId, iid, factory);
}
int32_t __stdcall WINRT_RoOriginateLanguageException(int32_t error, void* message, void* exception) noexcept {
typedef int32_t(__stdcall* FUNC)(int32_t error, void* message, void* exception);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "RoOriginateLanguageException");
return Func(error, message, exception);
}
int32_t __stdcall WINRT_SetRestrictedErrorInfo(void* info) noexcept {
typedef int32_t(__stdcall* FUNC)(void* info);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "SetRestrictedErrorInfo");
return Func(info);
}
int32_t __stdcall WINRT_WindowsCreateString(wchar_t const* sourceString, uint32_t length, void** string) noexcept {
typedef int32_t(__stdcall* FUNC)(wchar_t const* sourceString, uint32_t length, void** string);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsCreateString");
return Func(sourceString, length, string);
}
int32_t __stdcall WINRT_WindowsCreateStringReference(wchar_t const* sourceString, uint32_t length, void* hstringHeader, void** string) noexcept {
typedef int32_t(__stdcall* FUNC)(wchar_t const* sourceString, uint32_t length, void* hstringHeader, void** string);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsCreateStringReference");
return Func(sourceString, length, hstringHeader, string);
}
int32_t __stdcall WINRT_WindowsDeleteString(void* string) noexcept {
typedef int32_t(__stdcall* FUNC)(void* string);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsDeleteString");
return Func(string);
}
int32_t __stdcall WINRT_WindowsPreallocateStringBuffer(uint32_t length, wchar_t** charBuffer, void** bufferHandle) noexcept {
typedef int32_t(__stdcall* FUNC)(uint32_t length, wchar_t** charBuffer, void** bufferHandle);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsPreallocateStringBuffer");
return Func(length, charBuffer, bufferHandle);
}
int32_t __stdcall WINRT_WindowsDeleteStringBuffer(void* bufferHandle) noexcept {
typedef int32_t(__stdcall* FUNC)(void* bufferHandle);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsDeleteStringBuffer");
return Func(bufferHandle);
}
int32_t __stdcall WINRT_WindowsPromoteStringBuffer(void* bufferHandle, void** string) noexcept {
typedef int32_t(__stdcall* FUNC)(void* bufferHandle, void** string);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsPromoteStringBuffer");
return Func(bufferHandle, string);
}
wchar_t const* __stdcall WINRT_WindowsGetStringRawBuffer(void* string, uint32_t* length) noexcept {
typedef wchar_t const* (__stdcall* FUNC)(void* string, uint32_t* length);
static FUNC Func = NULL;
if (Func == NULL) Func = (FUNC)GetProcAddress(g_combase, "WindowsGetStringRawBuffer");
return Func(string, length);
}
}
int RegisterSparsePackage(const std::wstring& sparseExtPath, const std::wstring& sparsePackagePath)
{
winrt::Windows::Management::Deployment::PackageManager manager;
winrt::Windows::Management::Deployment::AddPackageOptions options;
winrt::Windows::Foundation::Uri externalUri(sparseExtPath.c_str());
winrt::Windows::Foundation::Uri packageUri(sparsePackagePath.c_str());
options.ExternalLocationUri(externalUri);
auto deploymentOperation = manager.AddPackageByUriAsync(packageUri, options);
auto deployResult = deploymentOperation.get();
if (!SUCCEEDED(deployResult.ExtendedErrorCode()))
{
// Deployment failed
std::wstring error = L"AddPackageByUriAsync failed (Errorcode: ";
error += std::to_wstring(deployResult.ExtendedErrorCode());
error += L"):\n";
error += deployResult.ErrorText();
return -1;
}
return 0;
}
int UnregisterSparsePackage(const std::wstring & sparsePackageName)
{
winrt::Windows::Management::Deployment::PackageManager manager;
winrt::Windows::Foundation::Collections::IIterable<winrt::Windows::ApplicationModel::Package> packages;
try
{
packages = manager.FindPackagesForUser(L"");
}
catch (winrt::hresult_error const& ex)
{
std::wstring error = L"FindPackagesForUser failed (Errorcode: ";
error += std::to_wstring(ex.code().value);
error += L"):\n";
error += ex.message();
return -1;
}
for (const auto& package : packages)
{
if (package.Id().Name() != sparsePackageName)
continue;
winrt::hstring fullName = package.Id().FullName();
auto deploymentOperation = manager.RemovePackageAsync(fullName, winrt::Windows::Management::Deployment::RemovalOptions::None);
auto deployResult = deploymentOperation.get();
if (SUCCEEDED(deployResult.ExtendedErrorCode()))
break;
// Undeployment failed
std::wstring error = L"RemovePackageAsync failed (Errorcode: ";
error += std::to_wstring(deployResult.ExtendedErrorCode());
error += L"):\n";
error += deployResult.ErrorText();
return -1;
}
return 0;
}
int wmain(int argc, wchar_t* argv[])
{
/*g_combase = LoadLibraryW(L"combase.dll");
if (argc < 2)
{
//wchar_t PackageName[MAX_PATH];
//UINT32 Length = MAX_PATH;
//NTSTATUS status = GetCurrentPackageFullName(&Length, PackageName);
//if (status >= 0)
// printf("%S", PackageName);
return 0;
}
if (wcsicmp(argv[1], L"-install") == 0)
{
wchar_t path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
wchar_t* ptr = wcsrchr(path, L'\\');
*ptr = L'\0';
std::wstring sparseExtPath = path;
wcscat(path, L"\\SbieShellPkg.msix");
std::wstring sparsePackagePath = path;
return RegisterSparsePackage(sparseExtPath, sparsePackagePath);
}
else if (wcsicmp(argv[1], L"-uninstall") == 0)
{
std::wstring sparsePackageName = L"SandboxieShell";
return UnregisterSparsePackage(sparsePackageName);
}*/
HMODULE ext = LoadLibraryW(L"SbieShellExt.dll");
typedef int (*FUNC)();
if (wcsicmp(argv[1], L"-install") == 0)
{
FUNC func = (FUNC)GetProcAddress(ext, "RegisterPackage");
func();
}
else if (wcsicmp(argv[1], L"-uninstall") == 0)
{
FUNC func = (FUNC)GetProcAddress(ext, "RemovePackage");
func();
}
return 0;
}

View File

@ -0,0 +1,348 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{16746b0c-5840-4ed4-aedf-1abb617827fd}</ProjectGuid>
<RootNamespace>PhotoStoreContextMenu</RootNamespace>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
<CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
<CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(ProjectDir)\..\..\$(Platform)\$(Configuration)</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<CustomBuildStep>
<Command>"$(WindowsSdkDir)bin\$(TargetPlatformVersion)\x64\makeappx.exe" pack /d $(SolutionDir)\SbieShellPkg /p $(ProjectDir)\..\..\$(Platform)\$(Configuration)\SbieShellPkg.msix /nv </Command>
<Outputs>$(ProjectDir)\..\..\$(Platform)\$(Configuration)\SbieShellPkg.msix</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
<CustomBuildStep>
<Command>"$(WindowsSdkDir)bin\$(TargetPlatformVersion)\x64\makeappx.exe" pack /d $(SolutionDir)\SbieShellPkg /p $(ProjectDir)\..\..\$(Platform)\$(Configuration)\SbieShellPkg.msix /nv</Command>
<Outputs>$(ProjectDir)\..\..\$(Platform)\$(Configuration)\SbieShellPkg.msix</Outputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;PHOTOSTORECONTEXTMENU_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>Source.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,5 @@
LIBRARY
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllGetActivationFactory PRIVATE

View File

@ -0,0 +1,462 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <wrl/module.h>
#include <wrl/implements.h>
#include <wrl/client.h>
#include <shobjidl_core.h>
#include <wil\resource.h>
#include <string>
#include <vector>
#include <sstream>
#include <shellapi.h>
using namespace Microsoft::WRL;
std::wstring g_path;
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
wchar_t path[MAX_PATH];
GetModuleFileName(hModule, path, MAX_PATH);
wchar_t* ptr = wcsrchr(path, L'\\');
*ptr = L'\0';
g_path = std::wstring(path);
break;
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
class TestExplorerCommandBase : public RuntimeClass<RuntimeClassFlags<ClassicCom>, IExplorerCommand, IObjectWithSite>
{
public:
virtual const wchar_t* Title() = 0;
virtual const EXPCMDFLAGS Flags() { return ECF_DEFAULT; }
virtual const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) { return ECS_ENABLED; }
// IExplorerCommand
IFACEMETHODIMP GetTitle(_In_opt_ IShellItemArray* items, _Outptr_result_nullonfailure_ PWSTR* name)
{
*name = nullptr;
auto title = wil::make_cotaskmem_string_nothrow(Title());
RETURN_IF_NULL_ALLOC(title);
*name = title.release();
return S_OK;
}
IFACEMETHODIMP GetIcon(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* icon)// { *icon = nullptr; return E_NOTIMPL; }
{
std::wstring bpPath = g_path + L"\\SandMan.exe,-0";
auto iconPath = wil::make_cotaskmem_string_nothrow(bpPath.c_str());
RETURN_IF_NULL_ALLOC(iconPath);
*icon = iconPath.release();
return S_OK;
}
IFACEMETHODIMP GetToolTip(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* infoTip) { *infoTip = nullptr; return E_NOTIMPL; }
IFACEMETHODIMP GetCanonicalName(_Out_ GUID* guidCommandName) { *guidCommandName = GUID_NULL; return S_OK; }
IFACEMETHODIMP GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState)
{
*cmdState = State(selection);
return S_OK;
}
enum ECommand {
eExplore,
eOpen,
};
virtual ECommand GetCommand() = 0;
IFACEMETHODIMP Invoke(_In_opt_ IShellItemArray* selection, _In_opt_ IBindCtx*) noexcept try
{
/*HWND parent = nullptr;
if (m_site)
{
ComPtr<IOleWindow> oleWindow;
RETURN_IF_FAILED(m_site.As(&oleWindow));
RETURN_IF_FAILED(oleWindow->GetWindow(&parent));
}
std::wostringstream title;
title << Title();
if (selection)
{
DWORD count;
RETURN_IF_FAILED(selection->GetCount(&count));
title << L" (" << count << L" selected items)";
}
else
{
title << L"(no selected items)";
}
MessageBox(parent, title.str().c_str(), L"TestCommand", MB_OK);*/
if (selection)
{
DWORD fileCount = 0;
RETURN_IF_FAILED(selection->GetCount(&fileCount));
for (DWORD i = 0; i < fileCount; i++)
{
IShellItem* shellItem = nullptr;
selection->GetItemAt(i, &shellItem);
LPWSTR itemName = nullptr;
shellItem->GetDisplayName(SIGDN_FILESYSPATH, &itemName);
if (itemName)
{
std::wstring file = g_path + L"\\SandMan.exe";
std::wstring params = L"/box:__ask__";
if(GetCommand() == eExplore)
params += L" C:\\WINDOWS\\explorer.exe";
params += L" \"";
params += itemName;
params += L"\"";
SHELLEXECUTEINFO shExecInfo = { sizeof(SHELLEXECUTEINFO) };
shExecInfo.hwnd = nullptr;
shExecInfo.lpVerb = L"open";
shExecInfo.lpFile = file.c_str();
shExecInfo.lpParameters = params.c_str();
shExecInfo.nShow = SW_NORMAL;
ShellExecuteEx(&shExecInfo);
CoTaskMemFree(itemName);
}
}
}
return S_OK;
}
CATCH_RETURN();
IFACEMETHODIMP GetFlags(_Out_ EXPCMDFLAGS* flags) { *flags = Flags(); return S_OK; }
IFACEMETHODIMP EnumSubCommands(_COM_Outptr_ IEnumExplorerCommand** enumCommands) { *enumCommands = nullptr; return E_NOTIMPL; }
// IObjectWithSite
IFACEMETHODIMP SetSite(_In_ IUnknown* site) noexcept { m_site = site; return S_OK; }
IFACEMETHODIMP GetSite(_In_ REFIID riid, _COM_Outptr_ void** site) noexcept { return m_site.CopyTo(riid, site); }
protected:
ComPtr<IUnknown> m_site;
};
class __declspec(uuid("EA3E972D-62C7-4309-8F15-883263041E99")) ExploreCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"Explore Sandboxed"; }
ECommand GetCommand() { return eExplore; }
};
class __declspec(uuid("3FD2D9EE-DAF9-404A-9B7E-13B2DCD63950")) OpenCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"Open Sandboxed"; }
ECommand GetCommand() { return eOpen; }
};
CoCreatableClass(ExploreCommandHandler)
CoCreatableClass(OpenCommandHandler)
CoCreatableClassWrlCreatorMapInclude(ExploreCommandHandler)
CoCreatableClassWrlCreatorMapInclude(OpenCommandHandler)
/*
class TestExplorerCommandBase : public RuntimeClass<RuntimeClassFlags<ClassicCom>, IExplorerCommand, IObjectWithSite>
{
public:
virtual const wchar_t* Title() = 0;
virtual const EXPCMDFLAGS Flags() { return ECF_DEFAULT; }
virtual const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) { return ECS_ENABLED; }
// IExplorerCommand
IFACEMETHODIMP GetTitle(_In_opt_ IShellItemArray* items, _Outptr_result_nullonfailure_ PWSTR* name)
{
*name = nullptr;
auto title = wil::make_cotaskmem_string_nothrow(Title());
RETURN_IF_NULL_ALLOC(title);
*name = title.release();
return S_OK;
}
IFACEMETHODIMP GetIcon(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* icon) { *icon = nullptr; return E_NOTIMPL; }
IFACEMETHODIMP GetToolTip(_In_opt_ IShellItemArray*, _Outptr_result_nullonfailure_ PWSTR* infoTip) { *infoTip = nullptr; return E_NOTIMPL; }
IFACEMETHODIMP GetCanonicalName(_Out_ GUID* guidCommandName) { *guidCommandName = GUID_NULL; return S_OK; }
IFACEMETHODIMP GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState)
{
*cmdState = State(selection);
return S_OK;
}
IFACEMETHODIMP Invoke(_In_opt_ IShellItemArray* selection, _In_opt_ IBindCtx*) noexcept try
{
HWND parent = nullptr;
if (m_site)
{
ComPtr<IOleWindow> oleWindow;
RETURN_IF_FAILED(m_site.As(&oleWindow));
RETURN_IF_FAILED(oleWindow->GetWindow(&parent));
}
std::wostringstream title;
title << Title();
if (selection)
{
DWORD count;
RETURN_IF_FAILED(selection->GetCount(&count));
title << L" (" << count << L" selected items)";
}
else
{
title << L"(no selected items)";
}
MessageBox(parent, title.str().c_str(), L"TestCommand", MB_OK);
return S_OK;
}
CATCH_RETURN();
IFACEMETHODIMP GetFlags(_Out_ EXPCMDFLAGS* flags) { *flags = Flags(); return S_OK; }
IFACEMETHODIMP EnumSubCommands(_COM_Outptr_ IEnumExplorerCommand** enumCommands) { *enumCommands = nullptr; return E_NOTIMPL; }
// IObjectWithSite
IFACEMETHODIMP SetSite(_In_ IUnknown* site) noexcept { m_site = site; return S_OK; }
IFACEMETHODIMP GetSite(_In_ REFIID riid, _COM_Outptr_ void** site) noexcept { return m_site.CopyTo(riid, site); }
protected:
ComPtr<IUnknown> m_site;
};
class __declspec(uuid("3282E233-C5D3-4533-9B25-44B8AAAFACFA")) TestExplorerCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"ShellDemo Command1"; }
const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) override { return ECS_DISABLED; }
};
class __declspec(uuid("817CF159-A4B5-41C8-8E8D-0E23A6605395")) TestExplorerCommand2Handler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"ShellDemo ExplorerCommand2"; }
};
class SubExplorerCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"SubCommand"; }
};
class CheckedSubExplorerCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"CheckedSubCommand"; }
const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) override { return ECS_CHECKBOX | ECS_CHECKED; }
};
class RadioCheckedSubExplorerCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"RadioCheckedSubCommand"; }
const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) override { return ECS_CHECKBOX | ECS_RADIOCHECK; }
};
class HiddenSubExplorerCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"HiddenSubCommand"; }
const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) override { return ECS_HIDDEN; }
};
class EnumCommands : public RuntimeClass<RuntimeClassFlags<ClassicCom>, IEnumExplorerCommand>
{
public:
EnumCommands()
{
m_commands.push_back(Make<SubExplorerCommandHandler>());
m_commands.push_back(Make<CheckedSubExplorerCommandHandler>());
m_commands.push_back(Make<RadioCheckedSubExplorerCommandHandler>());
m_commands.push_back(Make<HiddenSubExplorerCommandHandler>());
m_current = m_commands.cbegin();
}
// IEnumExplorerCommand
IFACEMETHODIMP Next(ULONG celt, __out_ecount_part(celt, *pceltFetched) IExplorerCommand** apUICommand, __out_opt ULONG* pceltFetched)
{
ULONG fetched{ 0 };
wil::assign_to_opt_param(pceltFetched, 0ul);
for (ULONG i = 0; (i < celt) && (m_current != m_commands.cend()); i++)
{
m_current->CopyTo(&apUICommand[0]);
m_current++;
fetched++;
}
wil::assign_to_opt_param(pceltFetched, fetched);
return (fetched == celt) ? S_OK : S_FALSE;
}
IFACEMETHODIMP Skip(ULONG celt) { return E_NOTIMPL; }
IFACEMETHODIMP Reset()
{
m_current = m_commands.cbegin();
return S_OK;
}
IFACEMETHODIMP Clone(__deref_out IEnumExplorerCommand** ppenum) { *ppenum = nullptr; return E_NOTIMPL; }
private:
std::vector<ComPtr<IExplorerCommand>> m_commands;
std::vector<ComPtr<IExplorerCommand>>::const_iterator m_current;
};
class __declspec(uuid("1476525B-BBC2-4D04-B175-7E7D72F3DFF8")) TestExplorerCommand3Handler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"ShellDemo CommandWithSubCommands"; }
const EXPCMDFLAGS Flags() override { return ECF_HASSUBCOMMANDS; }
IFACEMETHODIMP EnumSubCommands(_COM_Outptr_ IEnumExplorerCommand** enumCommands)
{
*enumCommands = nullptr;
auto e = Make<EnumCommands>();
return e->QueryInterface(IID_PPV_ARGS(enumCommands));
}
};
class __declspec(uuid("30DEEDF6-63EA-4042-A7D8-0A9E1B17BB99")) TestExplorerCommand4Handler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"ShellDemo Command4"; }
};
class __declspec(uuid("50419A05-F966-47BA-B22B-299A95492348")) TestExplorerHiddenCommandHandler final : public TestExplorerCommandBase
{
public:
const wchar_t* Title() override { return L"ShellDemo HiddenCommand"; }
const EXPCMDSTATE State(_In_opt_ IShellItemArray* selection) override { return ECS_HIDDEN; }
};
CoCreatableClass(TestExplorerCommandHandler)
CoCreatableClass(TestExplorerCommand2Handler)
CoCreatableClass(TestExplorerCommand3Handler)
CoCreatableClass(TestExplorerCommand4Handler)
CoCreatableClass(TestExplorerHiddenCommandHandler)
CoCreatableClassWrlCreatorMapInclude(TestExplorerCommandHandler)
CoCreatableClassWrlCreatorMapInclude(TestExplorerCommand2Handler)
CoCreatableClassWrlCreatorMapInclude(TestExplorerCommand3Handler)
CoCreatableClassWrlCreatorMapInclude(TestExplorerCommand4Handler)
CoCreatableClassWrlCreatorMapInclude(TestExplorerHiddenCommandHandler)
*/
STDAPI DllGetActivationFactory(_In_ HSTRING activatableClassId, _COM_Outptr_ IActivationFactory** factory)
{
return Module<ModuleType::InProc>::GetModule().GetActivationFactory(activatableClassId, factory);
}
STDAPI DllCanUnloadNow()
{
return Module<InProc>::GetModule().GetObjectCount() == 0 ? S_OK : S_FALSE;
}
STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_ void** instance)
{
return Module<InProc>::GetModule().GetClassObject(rclsid, riid, instance);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////7
//
#include <winrt/Windows.Management.Deployment.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.ApplicationModel.h>
#pragma comment(lib, "windowsapp.lib")
int RegisterSparsePackage(const std::wstring& sparseExtPath, const std::wstring& sparsePackagePath)
{
winrt::Windows::Management::Deployment::PackageManager manager;
winrt::Windows::Management::Deployment::AddPackageOptions options;
winrt::Windows::Foundation::Uri externalUri(sparseExtPath.c_str());
winrt::Windows::Foundation::Uri packageUri(sparsePackagePath.c_str());
options.ExternalLocationUri(externalUri);
auto deploymentOperation = manager.AddPackageByUriAsync(packageUri, options);
auto deployResult = deploymentOperation.get();
if (!SUCCEEDED(deployResult.ExtendedErrorCode()))
{
// Deployment failed
std::wstring error = L"AddPackageByUriAsync failed (Errorcode: ";
error += std::to_wstring(deployResult.ExtendedErrorCode());
error += L"):\n";
error += deployResult.ErrorText();
return -1;
}
return 0;
}
int UnregisterSparsePackage(const std::wstring& sparsePackageName)
{
winrt::Windows::Management::Deployment::PackageManager manager;
winrt::Windows::Foundation::Collections::IIterable<winrt::Windows::ApplicationModel::Package> packages;
try
{
packages = manager.FindPackagesForUser(L"");
}
catch (winrt::hresult_error const& ex)
{
std::wstring error = L"FindPackagesForUser failed (Errorcode: ";
error += std::to_wstring(ex.code().value);
error += L"):\n";
error += ex.message();
return -1;
}
for (const auto& package : packages)
{
if (package.Id().Name() != sparsePackageName)
continue;
winrt::hstring fullName = package.Id().FullName();
auto deploymentOperation = manager.RemovePackageAsync(fullName, winrt::Windows::Management::Deployment::RemovalOptions::None);
auto deployResult = deploymentOperation.get();
if (SUCCEEDED(deployResult.ExtendedErrorCode()))
break;
// Undeployment failed
std::wstring error = L"RemovePackageAsync failed (Errorcode: ";
error += std::to_wstring(deployResult.ExtendedErrorCode());
error += L"):\n";
error += deployResult.ErrorText();
return -1;
}
return 0;
}
extern "C" __declspec(dllexport) int RegisterPackage()
{
std::wstring sparseExtPath = g_path;
std::wstring sparsePackagePath = g_path + L"\\SbieShellPkg.msix";
return RegisterSparsePackage(sparseExtPath, sparsePackagePath);
}
extern "C" __declspec(dllexport) int RemovePackage()
{
std::wstring sparsePackageName = L"SandboxieShell";
return UnregisterSparsePackage(sparsePackageName);
}

View File

@ -0,0 +1,5 @@
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.201120.3" targetFramework="native" />
</packages>

View File

@ -0,0 +1,5 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

View File

@ -0,0 +1,13 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#endif //PCH_H

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4"
xmlns:desktop5="http://schemas.microsoft.com/appx/manifest/desktop/windows10/5"
xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
IgnorableNamespaces="uap uap2 uap3 rescap desktop desktop4 desktop5 uap10 com">
<Identity Name="SandboxieShell" ProcessorArchitecture="neutral" Publisher="CN=xanasoft.com" Version="1.0.0.0" />
<Properties>
<DisplayName>SandboxieShell</DisplayName>
<PublisherDisplayName>Sparse Package</PublisherDisplayName>
<Logo>Assets\storelogo.png</Logo>
<uap10:AllowExternalContent>true</uap10:AllowExternalContent>
</Properties>
<Resources>
<Resource Language="en-us" />
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.18950.0" MaxVersionTested="10.0.19000.0" />
</Dependencies>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="unvirtualizedResources"/>
</Capabilities>
<Applications>
<Application Id="SandboxieShell" Executable="SbieShell.exe" uap10:TrustLevel="mediumIL" uap10:RuntimeBehavior="win32App">
<uap:VisualElements AppListEntry="none" DisplayName="SandboxieShell" Description="Sandboxie-Plus Shell Extension" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
</uap:VisualElements>
<Extensions>
<desktop4:Extension Category="windows.fileExplorerContextMenus">
<desktop4:FileExplorerContextMenus>
<desktop5:ItemType Type="Directory">
<desktop5:Verb Id="BowPad" Clsid="EA3E972D-62C7-4309-8F15-883263041E99" />
</desktop5:ItemType>
<desktop5:ItemType Type="Directory\Background">
<desktop5:Verb Id="BowPad" Clsid="EA3E972D-62C7-4309-8F15-883263041E99" />
</desktop5:ItemType>
<desktop5:ItemType Type="*">
<desktop5:Verb Id="BowPad" Clsid="3FD2D9EE-DAF9-404A-9B7E-13B2DCD63950" />
</desktop5:ItemType>
</desktop4:FileExplorerContextMenus>
</desktop4:Extension>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="BowPad Context Menu Handler">
<com:Class Id="EA3E972D-62C7-4309-8F15-883263041E99" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
<com:SurrogateServer DisplayName="BowPad Context Menu Handler">
<com:Class Id="3FD2D9EE-DAF9-404A-9B7E-13B2DCD63950" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
</Extensions>
<!-- Extensions>
<uap:Extension Category="windows.shareTarget">
<uap:ShareTarget Description="Send to Sandboxie-Plus">
<uap:SupportedFileTypes>
<uap:FileType>.jpg</uap:FileType>
<uap:FileType>.png</uap:FileType>
<uap:FileType>.gif</uap:FileType>
</uap:SupportedFileTypes>
<uap:DataFormat>StorageItems</uap:DataFormat>
<uap:DataFormat>Bitmap</uap:DataFormat>
</uap:ShareTarget>
</uap:Extension>
<desktop4:Extension Category="windows.fileExplorerContextMenus">
<desktop4:FileExplorerContextMenus>
<desktop5:ItemType Type="Directory\Background">
<desktop5:Verb Id="Command1" Clsid="3282E233-C5D3-4533-9B25-44B8AAAFACFA" />
</desktop5:ItemType>
<desktop5:ItemType Type="*">
<desktop5:Verb Id="Command4" Clsid="30DEEDF6-63EA-4042-A7D8-0A9E1B17BB99" />
</desktop5:ItemType>
<desktop5:ItemType Type=".txt">
<desktop5:Verb Id="Command1" Clsid="3282E233-C5D3-4533-9B25-44B8AAAFACFA" />
<desktop5:Verb Id="Command2" Clsid="817CF159-A4B5-41C8-8E8D-0E23A6605395" />
<desktop5:Verb Id="Command3" Clsid="1476525B-BBC2-4D04-B175-7E7D72F3DFF8" />
<desktop5:Verb Id="Command5" Clsid="50419A05-F966-47BA-B22B-299A95492348" />
</desktop5:ItemType>
</desktop4:FileExplorerContextMenus>
</desktop4:Extension>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="Context menu verb handler">
<com:Class Id="3282E233-C5D3-4533-9B25-44B8AAAFACFA" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
<com:SurrogateServer DisplayName="Context menu verb handler">
<com:Class Id="817CF159-A4B5-41C8-8E8D-0E23A6605395" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
<com:SurrogateServer DisplayName="Context menu verb handler">
<com:Class Id="1476525B-BBC2-4D04-B175-7E7D72F3DFF8" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
<com:SurrogateServer DisplayName="Context menu verb handler">
<com:Class Id="30DEEDF6-63EA-4042-A7D8-0A9E1B17BB99" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
<com:SurrogateServer DisplayName="Context menu verb handler">
<com:Class Id="50419A05-F966-47BA-B22B-299A95492348" Path="SbieShellExt.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
</Extensions -->
</Application>
</Applications>
</Package>