This commit is contained in:
DavidXanatos 2022-06-27 08:33:15 +02:00
parent 6ec1069a17
commit 3c0030e3ff
10 changed files with 303 additions and 199 deletions

View File

@ -51,10 +51,23 @@ struct SBoxBorder
const WCHAR *Sandboxie_WindowClassName = L"Sandboxie_BorderWindow";
CBoxBorder::CBoxBorder(CSbieAPI* pApi, QObject* parent) : QObject(parent)
CBoxBorder::CBoxBorder(CSbieAPI* pApi, QObject* parent) : QThread(parent)
{
m_Api = pApi;
m_Running = true;
start();
}
CBoxBorder::~CBoxBorder()
{
m_Running = false;
if (!wait(10 * 1000))
terminate();
}
void CBoxBorder::run()
{
m = new SBoxBorder;
m->pCurrentBox = NULL;
@ -106,12 +119,175 @@ CBoxBorder::CBoxBorder(CSbieAPI* pApi, QObject* parent) : QObject(parent)
SetLayeredWindowAttributes(m->BorderWnd, 0, 192, LWA_ALPHA);
::ShowWindow(m->BorderWnd, SW_HIDE);
m_uTimerID = startTimer(100);
}
CBoxBorder::~CBoxBorder()
{
killTimer(m_uTimerID);
while (m_Running)
{
msleep(100);
HWND hWnd = GetForegroundWindow();
if (!hWnd)
continue;
ULONG Style = GetWindowLong(hWnd, GWL_STYLE);
if (!(Style & WS_VISIBLE))
continue;
ULONG pid = 0;
GetWindowThreadProcessId(hWnd, &pid);
CSandBoxPtr pProcessBox = m_Api->GetBoxByProcessId(pid);
if (m->pCurrentBox != pProcessBox.data())
{
m->pCurrentBox = pProcessBox.data();
if(!m->pCurrentBox)
m->BorderMode = 0;
else
{
m->BorderMode = 1;
m->BorderColor = RGB(255, 255, 0);
m->BorderWidth = 6;
QStringList BorderCfg = pProcessBox->GetText("BorderColor").split(",");
if (BorderCfg.first().left(1) == L'#')
{
bool ok = false;
m->BorderColor = BorderCfg.first().mid(1).toInt(&ok, 16);
if(!ok)
m->BorderColor = RGB(255, 255, 0);
else
{
if (BorderCfg.count() >= 2)
{
QString StrMode = BorderCfg.at(1);
if (StrMode.compare("ttl", Qt::CaseInsensitive) == 0)
m->BorderMode = 2;
else if (StrMode.compare("off", Qt::CaseInsensitive) == 0)
m->BorderMode = 0;
}
if (BorderCfg.count() >= 3)
{
m->BorderWidth = BorderCfg.at(2).toInt();
if (!m->BorderWidth)
m->BorderWidth = 6;
}
}
}
HBRUSH hbr = CreateSolidBrush(m->BorderColor);
SetClassLongPtr(m->BorderWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbr);
if (m->BorderBrush)
DeleteObject(m->BorderBrush);
m->BorderBrush = hbr;
}
}
if (m->BorderMode == 0) // no border enabled or unsandboxed
{
m->ActiveWnd = NULL;
m->ActivePid = 0;
if (m->IsBorderVisible)
{
::ShowWindow(m->BorderWnd, SW_HIDE);
m->IsBorderVisible = FALSE;
}
}
else
{
RECT rect;
GetActiveWindowRect(hWnd, &rect);
if (NothingChanged(hWnd, &rect, pid))
continue;
if (m->IsBorderVisible)
::ShowWindow(m->BorderWnd, SW_HIDE);
m->IsBorderVisible = FALSE;
m->ActiveWnd = hWnd;
m->ActivePid = pid;
memcpy(&m->ActiveRect, &rect, sizeof(RECT));
m->TitleState = 0;
if (rect.right - rect.left <= 2 || rect.bottom - rect.top <= 2)
continue;
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
if (!hMonitor)
continue;
MONITORINFO Monitor;
memset(&Monitor, 0, sizeof(MONITORINFO));
Monitor.cbSize = sizeof(MONITORINFO);
if (!GetMonitorInfo(hMonitor, &Monitor))
continue;
const RECT *Desktop = &Monitor.rcMonitor;
if (rect.left <= Desktop->left && rect.top <= Desktop->top &&
rect.right >= Desktop->right && rect.bottom >= Desktop->bottom &&
(Style & WS_CAPTION) != WS_CAPTION)
continue;
if (m->BorderMode == 2) {
if(!IsMounseOnTitle(hWnd, &rect, Desktop))
continue;
}
int ax = rect.left;
if (rect.left < Desktop->left && (Desktop->left - rect.left) < (m->BorderWidth + 4))
ax = Desktop->left;
int ay = rect.top;
if (rect.top < Desktop->top && (Desktop->top - rect.top) < (m->BorderWidth + 4))
ay = Desktop->top;
int aw = -ax;
if (rect.right > Desktop->right && (rect.right - Desktop->right) < (m->BorderWidth + 4))
aw += Desktop->right;
else
aw += rect.right;
int ah = -ay;
if (rect.bottom > Desktop->bottom && (rect.bottom - Desktop->bottom) < (m->BorderWidth + 4))
ah += Desktop->bottom;
else
ah += rect.bottom;
//
// in windows 10 and 11 if this is truly fullscreen the taskbar does not appear when hidden
// if its 1 px less on any side it works normally, so we pick bottom as thets where the taskbar usualyl is
// but with the taskbar to the side it woudl also work
//
if (rect.bottom == Monitor.rcWork.bottom)
ah -= 1;
POINT Points[10];
int PointCount = 0;
#define ADD_POINT(xx,yy) \
Points[PointCount].x = (xx); \
Points[PointCount].y = (yy); \
PointCount++;
#define ADD_SQUARE(_w,_h,_b) \
ADD_POINT(0 + _b, 0 + _b); \
ADD_POINT(_w - _b, 0 + _b); \
ADD_POINT(_w - _b, _h - _b); \
ADD_POINT(0 + _b, _h - _b); \
ADD_POINT(0 + _b, 0 + _b);
ADD_SQUARE(aw, ah, 0);
ADD_SQUARE(aw, ah, m->BorderWidth);
HRGN hrgn = CreatePolygonRgn(Points, PointCount, ALTERNATE);
SetWindowRgn(m->BorderWnd, hrgn, TRUE);
SetWindowPos(m->BorderWnd, NULL, ax, ay, aw, ah, SWP_SHOWWINDOW | SWP_NOACTIVATE);
m->IsBorderVisible = TRUE;
}
}
if (m->BorderWnd)
{
@ -122,174 +298,6 @@ CBoxBorder::~CBoxBorder()
delete m;
}
void CBoxBorder::timerEvent(QTimerEvent* pEvent)
{
if (pEvent->timerId() != m_uTimerID)
return;
HWND hWnd = GetForegroundWindow();
if (!hWnd)
return;
ULONG Style = GetWindowLong(hWnd, GWL_STYLE);
if (!(Style & WS_VISIBLE))
return;
ULONG pid = 0;
GetWindowThreadProcessId(hWnd, &pid);
CSandBoxPtr pProcessBox = m_Api->GetBoxByProcessId(pid);
if (m->pCurrentBox != pProcessBox.data())
{
m->pCurrentBox = pProcessBox.data();
if(!m->pCurrentBox)
m->BorderMode = 0;
else
{
m->BorderMode = 1;
m->BorderColor = RGB(255, 255, 0);
m->BorderWidth = 6;
QStringList BorderCfg = pProcessBox->GetText("BorderColor").split(",");
if (BorderCfg.first().left(1) == L'#')
{
bool ok = false;
m->BorderColor = BorderCfg.first().mid(1).toInt(&ok, 16);
if(!ok)
m->BorderColor = RGB(255, 255, 0);
else
{
if (BorderCfg.count() >= 2)
{
QString StrMode = BorderCfg.at(1);
if (StrMode.compare("ttl", Qt::CaseInsensitive) == 0)
m->BorderMode = 2;
else if (StrMode.compare("off", Qt::CaseInsensitive) == 0)
m->BorderMode = 0;
}
if (BorderCfg.count() >= 3)
{
m->BorderWidth = BorderCfg.at(2).toInt();
if (!m->BorderWidth)
m->BorderWidth = 6;
}
}
}
HBRUSH hbr = CreateSolidBrush(m->BorderColor);
SetClassLongPtr(m->BorderWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbr);
if (m->BorderBrush)
DeleteObject(m->BorderBrush);
m->BorderBrush = hbr;
}
}
if (m->BorderMode == 0) // no border enabled or unsandboxed
{
m->ActiveWnd = NULL;
m->ActivePid = 0;
if (m->IsBorderVisible)
{
::ShowWindow(m->BorderWnd, SW_HIDE);
m->IsBorderVisible = FALSE;
}
}
else
{
RECT rect;
GetActiveWindowRect(hWnd, &rect);
if (NothingChanged(hWnd, &rect, pid))
return;
if (m->IsBorderVisible)
::ShowWindow(m->BorderWnd, SW_HIDE);
m->IsBorderVisible = FALSE;
m->ActiveWnd = hWnd;
m->ActivePid = pid;
memcpy(&m->ActiveRect, &rect, sizeof(RECT));
m->TitleState = 0;
if (rect.right - rect.left <= 2 || rect.bottom - rect.top <= 2)
return;
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL);
if (!hMonitor)
return;
MONITORINFO Monitor;
memset(&Monitor, 0, sizeof(MONITORINFO));
Monitor.cbSize = sizeof(MONITORINFO);
if (!GetMonitorInfo(hMonitor, &Monitor))
return;
const RECT *Desktop = &Monitor.rcMonitor;
if (rect.left <= Desktop->left && rect.top <= Desktop->top &&
rect.right >= Desktop->right && rect.bottom >= Desktop->bottom &&
(Style & WS_CAPTION) != WS_CAPTION)
return;
if (m->BorderMode == 2) {
if(!IsMounseOnTitle(hWnd, &rect, Desktop))
return;
}
int ax = rect.left;
if (rect.left < Desktop->left && (Desktop->left - rect.left) < (m->BorderWidth + 4))
ax = Desktop->left;
int ay = rect.top;
if (rect.top < Desktop->top && (Desktop->top - rect.top) < (m->BorderWidth + 4))
ay = Desktop->top;
int aw = -ax;
if (rect.right > Desktop->right && (rect.right - Desktop->right) < (m->BorderWidth + 4))
aw += Desktop->right;
else
aw += rect.right;
int ah = -ay;
if (rect.bottom > Desktop->bottom && (rect.bottom - Desktop->bottom) < (m->BorderWidth + 4))
ah += Desktop->bottom;
else
ah += rect.bottom;
//
// in windows 10 and 11 if this is truly fullscreen the taskbar does not appear when hidden
// if its 1 px less on any side it works normally, so we pick bottom as thets where the taskbar usualyl is
// but with the taskbar to the side it woudl also work
//
if (rect.bottom == Monitor.rcWork.bottom)
ah -= 1;
POINT Points[10];
int PointCount = 0;
#define ADD_POINT(xx,yy) \
Points[PointCount].x = (xx); \
Points[PointCount].y = (yy); \
PointCount++;
#define ADD_SQUARE(_w,_h,_b) \
ADD_POINT(0 + _b, 0 + _b); \
ADD_POINT(_w - _b, 0 + _b); \
ADD_POINT(_w - _b, _h - _b); \
ADD_POINT(0 + _b, _h - _b); \
ADD_POINT(0 + _b, 0 + _b);
ADD_SQUARE(aw, ah, 0);
ADD_SQUARE(aw, ah, m->BorderWidth);
HRGN hrgn = CreatePolygonRgn(Points, PointCount, ALTERNATE);
SetWindowRgn(m->BorderWnd, hrgn, TRUE);
SetWindowPos(m->BorderWnd, NULL, ax, ay, aw, ah, SWP_SHOWWINDOW | SWP_NOACTIVATE);
m->IsBorderVisible = TRUE;
}
}
bool CBoxBorder::NothingChanged(struct HWND__* hWnd, struct tagRECT* rect, quint32 pid)
{

View File

@ -22,7 +22,7 @@
class CSbieAPI;
class QSBIEAPI_EXPORT CBoxBorder: public QObject
class QSBIEAPI_EXPORT CBoxBorder: public QThread
{
Q_OBJECT
public:
@ -30,8 +30,8 @@ public:
virtual ~CBoxBorder();
protected:
void timerEvent(QTimerEvent* pEvent);
int m_uTimerID;
void run();
bool m_Running;
CSbieAPI* m_Api;

View File

@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2020, David Xanatos
* Copyright (c) 2020-2022, David Xanatos
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -59,6 +59,7 @@ CBoxedProcess::~CBoxedProcess()
//delete m;
}
typedef enum _PEB_OFFSET
{
PhpoCurrentDirectory,
@ -73,6 +74,7 @@ typedef enum _PEB_OFFSET
PhpoWow64 = 0x10000
} PEB_OFFSET;
typedef struct _STRING32
{
USHORT Length;
@ -80,14 +82,50 @@ typedef struct _STRING32
ULONG Buffer;
} UNICODE_STRING32, * PUNICODE_STRING32;
//typedef struct _STRING64 {
// USHORT Length;
// USHORT MaximumLength;
// PVOID64 Buffer;
//} UNICODE_STRING64, * PUNICODE_STRING64;
//// PROCESS_BASIC_INFORMATION for pure 32 and 64-bit processes
//typedef struct _PROCESS_BASIC_INFORMATION {
// PVOID Reserved1;
// PVOID PebBaseAddress;
// PVOID Reserved2[2];
// ULONG_PTR UniqueProcessId;
// PVOID Reserved3;
//} PROCESS_BASIC_INFORMATION;
// PROCESS_BASIC_INFORMATION for 32-bit process on WOW64
typedef struct _PROCESS_BASIC_INFORMATION_WOW64 {
PVOID Reserved1[2];
PVOID64 PebBaseAddress;
PVOID Reserved2[4];
ULONG_PTR UniqueProcessId[2];
PVOID Reserved3[2];
} PROCESS_BASIC_INFORMATION_WOW64;
typedef NTSTATUS (NTAPI *_NtQueryInformationProcess)(IN HANDLE ProcessHandle, ULONG ProcessInformationClass,
OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL );
//typedef NTSTATUS (NTAPI *_NtReadVirtualMemory)(IN HANDLE ProcessHandle, IN PVOID BaseAddress,
// OUT PVOID Buffer, IN SIZE_T Size, OUT PSIZE_T NumberOfBytesRead);
typedef NTSTATUS (NTAPI *_NtWow64ReadVirtualMemory64)(IN HANDLE ProcessHandle,IN PVOID64 BaseAddress,
OUT PVOID Buffer, IN ULONG64 Size, OUT PULONG64 NumberOfBytesRead);
QString CBoxedProcess__GetPebString(HANDLE ProcessHandle, PEB_OFFSET Offset)
{
BOOL is64BitOperatingSystem = FALSE;
BOOL is64BitOperatingSystem;
BOOL isWow64Process = FALSE;
#ifdef _WIN64
is64BitOperatingSystem = TRUE;
#else // ! _WIN64
IsWow64Process(GetCurrentProcess(), &isWow64Process);
isWow64Process = CSbieAPI::IsWow64();
is64BitOperatingSystem = isWow64Process;
#endif _WIN64
@ -95,7 +133,6 @@ QString CBoxedProcess__GetPebString(HANDLE ProcessHandle, PEB_OFFSET Offset)
IsWow64Process(ProcessHandle, &isTargetWow64Process);
BOOL isTarget64BitProcess = is64BitOperatingSystem && !isTargetWow64Process;
ULONG processParametersOffset = isTarget64BitProcess ? 0x20 : 0x10;
ULONG offset = 0;
@ -131,7 +168,27 @@ QString CBoxedProcess__GetPebString(HANDLE ProcessHandle, PEB_OFFSET Offset)
}
else if (isWow64Process) //Os : 64Bit, Cur 32, Tar 64
{
return QString(); // not supported
static _NtQueryInformationProcess query = (_NtQueryInformationProcess)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtWow64QueryInformationProcess64");
static _NtWow64ReadVirtualMemory64 read = (_NtWow64ReadVirtualMemory64)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtWow64ReadVirtualMemory64");
PROCESS_BASIC_INFORMATION_WOW64 pbi;
if (!NT_SUCCESS(query(ProcessHandle, ProcessBasicInformation, &pbi, sizeof(PROCESS_BASIC_INFORMATION_WOW64), NULL)))
return QString();
ULONGLONG procParams;
if (!NT_SUCCESS(read(ProcessHandle, (PVOID64)((ULONGLONG)pbi.PebBaseAddress + processParametersOffset), &procParams, sizeof(ULONGLONG), NULL)))
return QString();
UNICODE_STRING64 us;
if (!NT_SUCCESS(read(ProcessHandle, (PVOID64)(procParams + offset), &us, sizeof(UNICODE_STRING64), NULL)))
return QString();
if ((us.Buffer == 0) || (us.Length == 0))
return QString();
s.resize(us.Length / 2);
if (!NT_SUCCESS(read(ProcessHandle, (PVOID64)us.Buffer, (PVOID64)s.c_str(), s.length() * 2, NULL)))
return QString();
}
else // Os,Cur,Tar : 64 or 32
{
@ -218,12 +275,12 @@ bool CBoxedProcess::InitProcessInfoEx()
return true;
}
extern "C"
{
NTSYSCALLAPI NTSTATUS NTAPI NtTerminateProcess(_In_opt_ HANDLE ProcessHandle, _In_ NTSTATUS ExitStatus);
NTSYSCALLAPI NTSTATUS NTAPI NtSuspendProcess(_In_ HANDLE ProcessHandle);
NTSYSCALLAPI NTSTATUS NTAPI NtResumeProcess(_In_ HANDLE ProcessHandle);
}
//extern "C"
//{
// NTSYSCALLAPI NTSTATUS NTAPI NtTerminateProcess(_In_opt_ HANDLE ProcessHandle, _In_ NTSTATUS ExitStatus);
// NTSYSCALLAPI NTSTATUS NTAPI NtSuspendProcess(_In_ HANDLE ProcessHandle);
// NTSYSCALLAPI NTSTATUS NTAPI NtResumeProcess(_In_ HANDLE ProcessHandle);
//}
#include <TlHelp32.h>

View File

@ -59,9 +59,14 @@ SB_STATUS CSbieIni::SetBool(const QString& Setting, bool Value)
return SetText(Setting, Value ? "y" : "n");
}
QString CSbieIni::GetText(const QString& Setting, const QString& Default, bool bWithGlobal, bool bNoExpand) const
QString CSbieIni::GetText(const QString& Setting, const QString& Default, bool bWithGlobal, bool bNoExpand, bool withTemplates) const
{
int flags = (bWithGlobal ? 0 : CONF_GET_NO_GLOBAL) | (bNoExpand ? CONF_GET_NO_EXPAND : 0);
int flags = (bWithGlobal ? 0 : CONF_GET_NO_GLOBAL);
if (!withTemplates)
flags |= CONF_GET_NO_TEMPLS;
if (bNoExpand)
flags |= CONF_GET_NO_EXPAND;
QString Value = m_pAPI->SbieIniGet(m_Name, Setting, flags);
if (Value.isNull()) Value = Default;
return Value;
@ -136,6 +141,7 @@ SB_STATUS CSbieIni::UpdateTextList(const QString &Setting, const QStringList& Li
QStringList CSbieIni::GetTemplates() const
{
QStringList Templates;
Templates.append("GlobalSettings");
for (int tmpl_index = 0; ; tmpl_index++)
{
@ -154,7 +160,7 @@ QStringList CSbieIni::GetTextListTmpl(const QString &Setting, const QString& Tem
for (int index = 0; ; index++)
{
QString Value = m_pAPI->SbieIniGet("Template_" + Template, Setting, index | CONF_GET_NO_GLOBAL | CONF_GET_NO_EXPAND);
QString Value = m_pAPI->SbieIniGet((Template != "GlobalSettings") ? "Template_" + Template : Template, Setting, index | CONF_GET_NO_GLOBAL | CONF_GET_NO_EXPAND);
if (Value.isNull())
break;
TextList.append(Value);

View File

@ -20,7 +20,7 @@ public:
virtual SB_STATUS SetNum64(const QString& Setting, __int64 Value);
virtual SB_STATUS SetBool(const QString& Setting, bool Value);
virtual QString GetText(const QString& Setting, const QString& Default = QString(), bool bWithGlobal = false, bool bNoExpand = true) const;
virtual QString GetText(const QString& Setting, const QString& Default = QString(), bool bWithGlobal = false, bool bNoExpand = true, bool withTemplates = false) const;
virtual int GetNum(const QString& Setting, int Default = 0, bool bWithGlobal = false) const;
virtual __int64 GetNum64(const QString& Setting, __int64 Default = 0, bool bWithGlobal = false) const;
virtual bool GetBool(const QString& Setting, bool Default = false, bool bWithGlobal = false) const;

View File

@ -191,6 +191,13 @@ void CSbieTemplates::CollectServices()
void CSbieTemplates::CollectProducts()
{
BOOL is64BitOperatingSystem;
#ifdef _WIN64
is64BitOperatingSystem = TRUE;
#else // ! _WIN64
is64BitOperatingSystem = CSbieAPI::IsWow64();
#endif _WIN64
m_Products.clear();
ULONG DesiredAccess = KEY_READ;
@ -219,7 +226,9 @@ void CSbieTemplates::CollectProducts()
break;
DesiredAccess |= KEY_WOW64_32KEY;
#else // ! _WIN64
break;
if (!is64BitOperatingSystem || (DesiredAccess & KEY_WOW64_64KEY))
break;
DesiredAccess |= KEY_WOW64_64KEY;
#endif _WIN64
}
}

View File

@ -43,6 +43,7 @@ public:
virtual SB_STATUS Connect(bool takeOver, bool withQueue);
virtual SB_STATUS Disconnect();
virtual bool IsConnected() const;
static bool IsWow64();
virtual QString GetVersion();

View File

@ -268,6 +268,8 @@ CSandMan::~CSandMan()
if(m_pEnableMonitoring->isChecked())
theAPI->EnableMonitor(false);
delete m_pBoxBorder;
killTimer(m_uTimerID);
m_pTrayIcon->hide();
@ -1152,7 +1154,7 @@ void CSandMan::OnStatusChanged()
{
if (m_SbieTemplates->RunCheck())
{
CSettingsWindow* pSettingsWindow = new CSettingsWindow();
CSettingsWindow* pSettingsWindow = new CSettingsWindow(this);
//connect(pSettingsWindow, SIGNAL(OptionsChanged()), this, SLOT(UpdateSettings()));
pSettingsWindow->showCompat();
}
@ -2040,6 +2042,8 @@ void CSandMan::OnResetMsgs()
theConf->SetValue("Options/AutoCleanupTemplates", -1);
theConf->SetValue("Options/WarnTerminateAll", -1);
theConf->SetValue("Options/WarnTerminate", -1);
theConf->SetValue("Options/InfoMkLink", -1);
}
theAPI->GetUserSettings()->UpdateTextList("SbieCtrl_HideMessage", QStringList(), true);

View File

@ -94,9 +94,10 @@ CSbieView::CSbieView(QWidget* parent) : CPanelView(parent)
m_pMenuRunCmd = m_pMenuRun->addAction(CSandMan::GetIcon("Cmd"), tr("Command Prompt"), this, SLOT(OnSandBoxAction()));
m_pMenuRunTools = m_pMenuRun->addMenu(CSandMan::GetIcon("Maintenance"), tr("Boxed Tools"));
m_pMenuRunCmdAdmin = m_pMenuRunTools->addAction(CSandMan::GetIcon("Cmd"), tr("Command Prompt (as Admin)"), this, SLOT(OnSandBoxAction()));
#ifdef _WIN64
m_pMenuRunCmd32 = m_pMenuRunTools->addAction(CSandMan::GetIcon("Cmd"), tr("Command Prompt (32-bit)"), this, SLOT(OnSandBoxAction()));
#ifndef _WIN64
if(CSbieAPI::IsWow64())
#endif
m_pMenuRunCmd32 = m_pMenuRunTools->addAction(CSandMan::GetIcon("Cmd"), tr("Command Prompt (32-bit)"), this, SLOT(OnSandBoxAction()));
m_pMenuRunExplorer = m_pMenuRunTools->addAction(CSandMan::GetIcon("Explore"), tr("Windows Explorer"), this, SLOT(OnSandBoxAction()));
m_pMenuRunRegEdit = m_pMenuRunTools->addAction(CSandMan::GetIcon("RegEdit"), tr("Registry Editor"), this, SLOT(OnSandBoxAction()));
m_pMenuRunAppWiz = m_pMenuRunTools->addAction(CSandMan::GetIcon("Software"), tr("Programs and Features"), this, SLOT(OnSandBoxAction()));
@ -870,10 +871,8 @@ void CSbieView::OnSandBoxAction(QAction* Action)
Results.append(SandBoxes.first()->RunStart("cmd.exe"));
else if (Action == m_pMenuRunCmdAdmin)
Results.append(SandBoxes.first()->RunStart("cmd.exe", true));
#ifdef _WIN64
else if (Action == m_pMenuRunCmd32)
Results.append(SandBoxes.first()->RunStart("C:\\WINDOWS\\SysWOW64\\cmd.exe"));
#endif
else if (Action == m_pMenuPresetsShowUAC)
{
SandBoxes.first()->SetBool("DropAdminRights", false);
@ -1146,6 +1145,16 @@ void CSbieView::OnSandBoxAction(QAction* Action)
}
else if (Action == m_pMenuMkLink)
{
if (theConf->GetInt("Options/InfoMkLink", -1) == -1)
{
bool State = false;
CCheckableMessageBox::question(this, "Sandboxie-Plus", tr("The Sandboxie Start Menu will now be displayed. Select an application from the menu, and Sandboxie will create a new"
"shortcut icon on your real desktop, which you can use to invoke the selected application under the supervision of Sandboxie.")
, tr("Don't show this message again."), &State, QDialogButtonBox::Ok, QDialogButtonBox::Ok, QMessageBox::Information);
if (State)
theConf->SetValue("Options/InfoMkLink", 1);
}
QString BoxName = SandBoxes.first()->GetName();
QString LinkPath, IconPath, WorkDir;
quint32 IconIndex;

View File

@ -17,10 +17,20 @@ int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
//SetProcessDPIAware();
//SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
//SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
typedef DPI_AWARENESS_CONTEXT(WINAPI* P_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext);
P_SetThreadDpiAwarenessContext pSetThreadDpiAwarenessContext = (P_SetThreadDpiAwarenessContext)GetProcAddress(GetModuleHandle(L"user32.dll"), "SetThreadDpiAwarenessContext");
if(pSetThreadDpiAwarenessContext) // not rpesent on windows 7
pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
#endif // Q_OS_WIN
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
qsrand(QTime::currentTime().msec());
QtSingleApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);