Skip to content

Commit

Permalink
Build 0.4.1 / 5.43.5
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidXanatos committed Sep 12, 2020
1 parent 701788a commit 90f739b
Show file tree
Hide file tree
Showing 19 changed files with 347 additions and 138 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).


## [0.4.1 / 5.43.5] - 2020-09-12

### Added
- added core version compatybility check to sandman UI
- added shell integration options to SbiePlus

### Changed
- SbieCtrl does not longer auto show the tutorian on first start
- when hooking, the to the trampoline migrated section of the original function is not longer noped out
-- it caused issues with unity games, will be investigated and re enabled later

### Fixed
- fixed color issue with vertical tabs in dark mode
- fixed wrong path separators when adding new forced folders
- fixed directroy listing bug intriduced in 5.43
- fixed issues with settings window when not being connected to driver
- fixed issue when starting sandman ui as admin
- fixed auto content delete not working with sandman ui



## [0.4.0 / 5.43] - 2020-09-05

### Added
Expand Down
4 changes: 2 additions & 2 deletions Sandboxie/apps/com/RpcSs/rpcss.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ _FX int __stdcall WinMain(
}
}

if (1) {
/*if (1) {
MSG_HEADER req;
req.length = sizeof(req);
req.msgid = MSGID_SBIE_INI_RUN_SBIE_CTRL;
SbieDll_CallServer(&req);
}
}*/

return DoLingerLeader();
}
6 changes: 3 additions & 3 deletions Sandboxie/apps/control/MyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ CMyFrame::CMyFrame(BOOL ForceVisible, BOOL ForceSync)
m_view = m_view_old = 0;
m_hidden = FALSE;

CUserSettings::GetInstance().GetBool(_ShowWelcome, m_ShowWelcome, TRUE);
//CUserSettings::GetInstance().GetBool(_ShowWelcome, m_ShowWelcome, TRUE);
CUserSettings::GetInstance().GetBool(_AlwaysOnTop, m_AlwaysOnTop, FALSE);

m_ReSyncShortcuts = ForceSync;
Expand Down Expand Up @@ -1975,7 +1975,7 @@ void CMyFrame::OnTimer(UINT_PTR nIDEvent)
// first time?
//

if (m_ShowWelcome && (! inModalState)) {
/*if (m_ShowWelcome && (! inModalState)) {
m_ShowWelcome = FALSE;
CUserSettings::GetInstance().SetBool(_ShowWelcome, FALSE);
Expand All @@ -1985,7 +1985,7 @@ void CMyFrame::OnTimer(UINT_PTR nIDEvent)
CGettingStartedWizard wizard(this);
return;
}
}*/

//
// resync shortcuts? usually Sandboxie Control does not resync
Expand Down
2 changes: 1 addition & 1 deletion Sandboxie/apps/control/MyFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CMyFrame : public CFrameWnd
CPoint m_TrayPoint;

BOOL m_hidden;
BOOL m_ShowWelcome;
//BOOL m_ShowWelcome;
BOOL m_ReSyncShortcuts;
BOOL m_AutoRunSoftCompat;
BOOL m_AlwaysOnTop;
Expand Down
6 changes: 3 additions & 3 deletions Sandboxie/common/my_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#ifndef _MY_VERSION_H
#define _MY_VERSION_H

#define MY_VERSION_BINARY 5,43
#define MY_VERSION_STRING "5.43"
#define MY_VERSION_COMPAT "5.43"
#define MY_VERSION_BINARY 5,43,5
#define MY_VERSION_STRING "5.43.5"
#define MY_VERSION_COMPAT "5.43.5"

// These #defines are used by either Resource Compiler, or by NSIC installer
#define SBIE_INSTALLER_PATH "..\\Bin\\"
Expand Down
5 changes: 3 additions & 2 deletions Sandboxie/core/dll/dllhook.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,9 @@ skip_e9_rewrite: ;
#endif

// just in case nop out the rest of the code we moved to the trampoline
for(; UsedCount < ByteCount; UsedCount++)
func[UsedCount] = 0x90; // nop
// ToDo: why does this break unity games
//for(; UsedCount < ByteCount; UsedCount++)
// func[UsedCount] = 0x90; // nop

VirtualProtect(&func[-8], 20, prot, &dummy_prot);

Expand Down
2 changes: 1 addition & 1 deletion Sandboxie/core/dll/file_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ _FX NTSTATUS File_NtQueryDirectoryFile(
// we get an error return value, and have to add the trailing backslash
//

if (status == STATUS_BAD_INITIAL_PC && TruePath) {
if (status == STATUS_BAD_INITIAL_PC && CopyPath) {

WCHAR *ptr = TruePath + wcslen(TruePath);
ptr[0] = L'\\';
Expand Down
10 changes: 7 additions & 3 deletions Sandboxie/install/kmdutil/kmdutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,15 @@ int __stdcall WinMain(
int path_len = wcslen(Driver_Path);
if (path_len > 8 && wcscmp(Driver_Path + path_len - 8, L".sys.rc4") == 0)
{
FILE* inFile = _wfopen(Driver_Path, L"rb");
PWSTR Driver_Path_tmp = Driver_Path; // strip \??\ if present
if (Driver_Path_tmp[0] == L'\\' && Driver_Path_tmp[1] == L'?' && Driver_Path_tmp[2] == L'?' && Driver_Path_tmp[3] == L'\\')
Driver_Path_tmp += 4;

FILE* inFile = _wfopen(Driver_Path_tmp, L"rb");
if (inFile)
{
Driver_Path[path_len - 4] = L'\0';
FILE* outFile = _wfopen(Driver_Path, L"wb");
Driver_Path_tmp[path_len - 4] = L'\0'; // strip .rc4
FILE* outFile = _wfopen(Driver_Path_tmp, L"wb");
if (outFile)
{
fseek(inFile, 0, SEEK_END);
Expand Down
2 changes: 2 additions & 0 deletions SandboxiePlus/QSbieAPI/Sandboxie/SandBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CSandBox::CSandBox(const QString& BoxName, class CSbieAPI* pAPI) : CSbieIni(BoxN
{
//m = new SSandBox;

m_ActiveProcessCount = 0;

// when loading a sandbox that is not initialized, initialize it
int cfglvl = GetNum("ConfigLevel");
if (cfglvl >= 7)
Expand Down
3 changes: 3 additions & 0 deletions SandboxiePlus/QSbieAPI/Sandboxie/SandBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class QSBIEAPI_EXPORT CSandBox : public CSbieIni

virtual QMap<quint64, CBoxedProcessPtr> GetProcessList() const { return m_ProcessList; }

virtual int GetActiveProcessCount() const { return m_ActiveProcessCount; }

virtual SB_STATUS RunStart(const QString& Command);
virtual SB_STATUS RunCommand(const QString& Command);
virtual SB_STATUS TerminateAll();
Expand Down Expand Up @@ -78,6 +80,7 @@ class QSBIEAPI_EXPORT CSandBox : public CSbieIni
QString m_IpcPath;

QMap<quint64, CBoxedProcessPtr> m_ProcessList;
int m_ActiveProcessCount;

//private:
// struct SSandBox* m;
Expand Down
18 changes: 17 additions & 1 deletion SandboxiePlus/QSbieAPI/SbieAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ SB_STATUS CSbieAPI::Connect()

if (status != STATUS_SUCCESS) {
m->SbieApiHandle = INVALID_HANDLE_VALUE;
return SB_ERR("Failed to connect to driver", status);
return SB_ERR(tr("Failed to connect to driver"), status);
}

UpdateDriveLetters();
Expand All @@ -196,6 +196,17 @@ SB_STATUS CSbieAPI::Connect()
m->lastMessageNum = 0;
m->lastRecordNum = 0;

#ifndef _DEBUG
QStringList CompatVersions = QStringList () << "5.43" << "5.43.5";
QString CurVersion = GetVersion();
if (!CompatVersions.contains(CurVersion))
{
NtClose(m->SbieApiHandle);
m->SbieApiHandle = INVALID_HANDLE_VALUE;
return SB_ERR(tr("Incompatible Version, found Sandboxie %1, compatible versions: %2").arg(CurVersion).arg(CompatVersions.join(", ")));
}
#endif

m_bTerminate = false;
start();

Expand Down Expand Up @@ -835,6 +846,11 @@ SB_STATUS CSbieAPI::UpdateProcesses(bool bKeep, const CSandBoxPtr& pBox)
}
}

bool WasBoxClosed = pBox->m_ActiveProcessCount > 0 && boxed_pids[0] == 0;
pBox->m_ActiveProcessCount = boxed_pids[0];
if (WasBoxClosed)
emit BoxClosed(pBox->GetName());

return SB_OK;
}

Expand Down
1 change: 1 addition & 0 deletions SandboxiePlus/QSbieAPI/SbieAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class QSBIEAPI_EXPORT CSbieAPI : public QThread
void StatusChanged();
void LogMessage(const QString& Message, bool bNotify = true);
void FileToRecover(const QString& BoxName, const QString& FilePath);
void BoxClosed(const QString& BoxName);
void NotAuthorized(bool bLoginRequired, bool &bRetry);

private slots:
Expand Down
97 changes: 94 additions & 3 deletions SandboxiePlus/QSbieAPI/SbieUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ SB_STATUS CSbieUtils::Install(EComponent Component)
void CSbieUtils::Install(EComponent Component, QStringList& Ops)
{
QString HomePath = QCoreApplication::applicationDirPath().replace("/", "\\"); // "C:\\Program Files\\Sandboxie "
if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) == 0)
Ops.append(QString::fromWCharArray(L"kmdutil.exe|install|" SBIEDRV L"|") + "\"" + HomePath + "\\" + QString::fromWCharArray(SBIEDRV_SYS) + "\"" + "|type=kernel|start=demand|altitude=86900");
if ((Component & eDriver) != 0 && GetServiceStatus(SBIEDRV) == 0) // todo: why when we are admin we need \??\ and else not and why knd util from console as admin also does not need that???
Ops.append(QString::fromWCharArray(L"kmdutil.exe|install|" SBIEDRV L"|") + "\"\\??\\" + HomePath + "\\" + QString::fromWCharArray(SBIEDRV_SYS) + "\"" + "|type=kernel|start=demand|altitude=86900");
if ((Component & eService) != 0 && GetServiceStatus(SBIESVC) == 0) {
Ops.append(QString::fromWCharArray(L"kmdutil.exe|install|" SBIESVC L"|") + "\"" + HomePath + "\\" + QString::fromWCharArray(SBIESVC_EXE) + "\"" + "|type=own|start=auto|display=\"Sandboxie Service\"|group=UIGroup");
Ops.append("reg.exe|ADD|HKLM\\SYSTEM\\ControlSet001\\Services\\SbieSvc|/v|PreferExternalManifest|/t|REG_DWORD|/d|1|/f");
Expand Down Expand Up @@ -183,4 +183,95 @@ SB_STATUS CSbieUtils::ExecOps(const QStringList& Ops)
return SB_ERR("Failed to execute: " + Args.join(" "));
}
return SB_OK;
}
}

//////////////////////////////////////////////////////////////////////////////
// Shell integration

int CSbieUtils::IsContextMenu()
{
if (!CheckRegValue(L"Software\\Classes\\*\\shell\\sandbox\\command"))
return 0;
if (!CheckRegValue(L"software\\classes\\folder\\shell\\sandbox\\command"))
return 1;
return 2;
}

bool CSbieUtils::CheckRegValue(const wchar_t* key)
{
HKEY hkey;
LONG rc = RegOpenKeyEx(HKEY_CURRENT_USER, key, 0, KEY_READ, &hkey);
if (rc != 0)
return false;

ULONG type;
WCHAR path[512];
ULONG path_len = sizeof(path) - sizeof(WCHAR) * 4;
rc = RegQueryValueEx(hkey, NULL, NULL, &type, (BYTE *)path, &path_len);
RegCloseKey(hkey);
if (rc != 0)
return false;

return true;
}

void CSbieUtils::AddContextMenu(const QString& StartPath)
{
wstring start_path = L"\"" + StartPath.toStdWString() + L"\"";

CreateShellEntry(L"*", L"Run &Sandboxed", start_path, start_path + L" /box:__ask__ \"%1\" %*");

wstring explorer_path(512, L'\0');

HKEY hkeyWinlogon;
LONG rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"software\\microsoft\\windows nt\\currentversion\\winlogon", 0, KEY_READ, &hkeyWinlogon);
if (rc == 0)
{
ULONG path_len = explorer_path.size() * sizeof(WCHAR);
ULONG type;
rc = RegQueryValueEx(hkeyWinlogon, L"Shell", NULL, &type, (BYTE *)explorer_path.c_str(), &path_len);
if (rc == 0 && (type == REG_SZ || type == REG_EXPAND_SZ))
explorer_path.resize(path_len / sizeof(WCHAR));
RegCloseKey(hkeyWinlogon);
}

// get default explorer path
if (*explorer_path.c_str() == L'\0' || _wcsicmp(explorer_path.c_str(), L"explorer.exe") == 0)
{
GetWindowsDirectory((wchar_t*)explorer_path.c_str(), MAX_PATH);
ULONG path_len = wcslen(explorer_path.c_str());
explorer_path.resize(path_len);
explorer_path.append(L"\\explorer.exe");
}

CreateShellEntry(L"Folder", L"Explore &Sandboxed", start_path, start_path + L" /box:__ask__ " + explorer_path + L" \"%1\"");
}

void CSbieUtils::CreateShellEntry(const wstring& classname, const wstring& cmdtext, const wstring& iconpath, const wstring& startcmd)
{
HKEY hkey;
LONG rc = RegCreateKeyEx(HKEY_CURRENT_USER, (L"software\\classes\\" + classname + L"\\shell\\sandbox").c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL);
if (rc != 0)
return;

RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)cmdtext.c_str(), (cmdtext.length() + 1) * sizeof(WCHAR));
RegSetValueEx(hkey, L"Icon", 0, REG_SZ, (BYTE *)iconpath.c_str(), (iconpath.length() + 1) * sizeof(WCHAR));

RegCloseKey(hkey);
if (rc != 0)
return;

rc = RegCreateKeyEx(HKEY_CURRENT_USER, (L"software\\classes\\" + classname + L"\\shell\\sandbox\\command").c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL);
if (rc != 0)
return;

RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)startcmd.c_str(), (startcmd.length() + 1) * sizeof(WCHAR));

RegCloseKey(hkey);
}

void CSbieUtils::RemoveContextMenu()
{
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\*\\shell\\sandbox");
RegDeleteTreeW(HKEY_CURRENT_USER, L"software\\classes\\folder\\shell\\sandbox");
}
7 changes: 7 additions & 0 deletions SandboxiePlus/QSbieAPI/SbieUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class QSBIEAPI_EXPORT CSbieUtils
static SB_STATUS Uninstall(EComponent Component);
static bool IsInstalled(EComponent Component);

static int IsContextMenu();
static void AddContextMenu(const QString& StartPath);
static void RemoveContextMenu();

private:
static SB_STATUS ElevateOps(const QStringList& Ops);
static SB_STATUS ExecOps(const QStringList& Ops);
Expand All @@ -35,5 +39,8 @@ class QSBIEAPI_EXPORT CSbieUtils

static void Install(EComponent Component, QStringList& Ops);
static void Uninstall(EComponent Component, QStringList& Ops);

static bool CheckRegValue(const wchar_t* key);
static void CreateShellEntry(const wstring& classname, const wstring& cmdtext, const wstring& iconpath, const wstring& startcmd);
};

Loading

0 comments on commit 90f739b

Please sign in to comment.