Skip to content

Commit 938e0a8

Browse files
committed
1.11.0b
1 parent d870afd commit 938e0a8

File tree

5 files changed

+106
-40
lines changed

5 files changed

+106
-40
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [1.11.1 / 5.66.1] - 2023-08-??
88

9+
### Added
10+
- added 'RamDiskLetter=R:\' option allowing to mount the ramdisk root to a drive letter
11+
912
### Changed
1013
- changed the new optin layout to now be the default for non vintage views (can be changed back in the settings)
1114

Sandboxie/core/svc/MountManager.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ std::shared_ptr<BOX_MOUNT> MountManager::FindImDisk(const std::wstring& ImageFil
729729
//---------------------------------------------------------------------------
730730

731731

732-
std::shared_ptr<BOX_MOUNT> MountManager::MountImDisk(const std::wstring& ImageFile, const wchar_t* pPassword, ULONG64 sizeKb, ULONG session_id)
732+
std::shared_ptr<BOX_MOUNT> MountManager::MountImDisk(const std::wstring& ImageFile, const wchar_t* pPassword, ULONG64 sizeKb, ULONG session_id, const wchar_t* drvLetter)
733733
{
734734
bool ok = false;
735735

@@ -744,8 +744,17 @@ std::shared_ptr<BOX_MOUNT> MountManager::MountImDisk(const std::wstring& ImageFi
744744

745745
// todo allow mounting without mount
746746

747-
WCHAR Drive[4] = L" :";
748-
Drive[0] = ImDiskFindFreeDriveLetter();
747+
WCHAR Drive[4] = L"\0:";
748+
if (drvLetter) {
749+
WCHAR letter = towupper(drvLetter[0]);
750+
if (letter >= L'A' && letter <= L'Z' && drvLetter[1] == L':') {
751+
DWORD logical_drives = GetLogicalDrives();
752+
if((logical_drives & (1 << (letter - L'A'))) == 0)
753+
Drive[0] = letter;
754+
}
755+
}
756+
else
757+
Drive[0] = ImDiskFindFreeDriveLetter();
749758
if (Drive[0] == 0) {
750759
SbieApi_LogEx(session_id, 2234, L"");
751760
return NULL;
@@ -842,8 +851,10 @@ std::shared_ptr<BOX_MOUNT> MountManager::MountImDisk(const std::wstring& ImageFi
842851

843852
ok = true;
844853

845-
if (!DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE | DDD_RAW_TARGET_PATH, Drive, pMount->NtPath.c_str())) {
846-
SbieApi_LogEx(session_id, 2235, L"%S", Drive);
854+
if (!drvLetter) {
855+
if (!DefineDosDevice(DDD_REMOVE_DEFINITION | DDD_EXACT_MATCH_ON_REMOVE | DDD_RAW_TARGET_PATH, Drive, pMount->NtPath.c_str())) {
856+
SbieApi_LogEx(session_id, 2235, L"%S", Drive);
857+
}
847858
}
848859
}
849860
}
@@ -998,8 +1009,11 @@ bool MountManager::AcquireBoxRoot(const WCHAR* boxname, const WCHAR* reg_root, c
9981009
ULONG sizeKb = SbieApi_QueryConfNumber(NULL, L"RamDiskSizeKb", 0);
9991010
if (sizeKb < 100*1024) // we want at lesat 100MB
10001011
SbieApi_LogEx(session_id, 2238, L"");
1001-
else
1002-
m_RamDisk = MountImDisk(L"", NULL, sizeKb, session_id);
1012+
else {
1013+
WCHAR drvLetter[32] = { 0 };
1014+
SbieApi_QueryConf(NULL, L"RamDiskLetter", 0, drvLetter, ARRAYSIZE(drvLetter));
1015+
m_RamDisk = MountImDisk(L"", NULL, sizeKb, session_id, *drvLetter ? drvLetter : NULL);
1016+
}
10031017
}
10041018
pRoot->Mount = m_RamDisk;
10051019
}

Sandboxie/core/svc/MountManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class MountManager
8080
bool RemoveJunction(const std::wstring& FileRootPath, ULONG session_id);
8181

8282
std::shared_ptr<BOX_MOUNT> FindImDisk(const std::wstring& ImageFile, ULONG session_id);
83-
std::shared_ptr<BOX_MOUNT> MountImDisk(const std::wstring& ImageFile, const wchar_t* pPassword, ULONG64 sizeKb, ULONG session_id);
83+
std::shared_ptr<BOX_MOUNT> MountImDisk(const std::wstring& ImageFile, const wchar_t* pPassword, ULONG64 sizeKb, ULONG session_id, const wchar_t* drvLetter = NULL);
8484
static bool TryUnmountImDisk(const std::wstring& Device, HANDLE hProcess, int iMode = 0);
8585
static bool UnmountImDisk(const std::wstring& Device, HANDLE hProcess);
8686
bool UnmountImDiskLocked(const std::shared_ptr<BOX_MOUNT>& pToUnMount, ULONG session_id);

SandboxiePlus/SandMan/Forms/SettingsWindow.ui

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@
11761176
<item row="0" column="0">
11771177
<widget class="QTabWidget" name="tabsAddons">
11781178
<property name="currentIndex">
1179-
<number>0</number>
1179+
<number>1</number>
11801180
</property>
11811181
<widget class="QWidget" name="tabAddonList">
11821182
<attribute name="title">
@@ -1267,44 +1267,38 @@
12671267
<layout class="QGridLayout" name="gridLayout_40">
12681268
<item row="0" column="0">
12691269
<layout class="QGridLayout" name="gridLayout_39">
1270-
<item row="2" column="4">
1271-
<widget class="QLineEdit" name="txtRamLimit">
1272-
<property name="maximumSize">
1273-
<size>
1274-
<width>100</width>
1275-
<height>16777215</height>
1276-
</size>
1277-
</property>
1278-
</widget>
1279-
</item>
12801270
<item row="2" column="1" colspan="2">
12811271
<widget class="QCheckBox" name="chkRamDisk">
12821272
<property name="text">
12831273
<string>Enable Ram Disk creation</string>
12841274
</property>
12851275
</widget>
12861276
</item>
1287-
<item row="2" column="5">
1277+
<item row="2" column="6">
12881278
<widget class="QLabel" name="lblRamLimit">
12891279
<property name="text">
12901280
<string>kilobytes</string>
12911281
</property>
12921282
</widget>
12931283
</item>
1294-
<item row="0" column="0">
1295-
<widget class="QLabel" name="lblDiskImage">
1296-
<property name="font">
1297-
<font>
1298-
<bold>true</bold>
1299-
<kerning>true</kerning>
1300-
</font>
1284+
<item row="3" column="3">
1285+
<widget class="QComboBox" name="cmbRamLetter">
1286+
<property name="sizePolicy">
1287+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
1288+
<horstretch>0</horstretch>
1289+
<verstretch>0</verstretch>
1290+
</sizepolicy>
13011291
</property>
1292+
</widget>
1293+
</item>
1294+
<item row="3" column="1" colspan="2">
1295+
<widget class="QCheckBox" name="chkRamLetter">
13021296
<property name="text">
1303-
<string>Disk Image Support</string>
1297+
<string>Assign drive letter to Ram Disk</string>
13041298
</property>
13051299
</widget>
13061300
</item>
1307-
<item row="3" column="1">
1301+
<item row="4" column="1">
13081302
<spacer name="verticalSpacer_13">
13091303
<property name="orientation">
13101304
<enum>Qt::Vertical</enum>
@@ -1317,7 +1311,40 @@
13171311
</property>
13181312
</spacer>
13191313
</item>
1320-
<item row="2" column="3">
1314+
<item row="1" column="1" colspan="6">
1315+
<widget class="QLabel" name="lblImDisk">
1316+
<property name="text">
1317+
<string>&lt;a href=&quot;addon://ImDisk&quot;&gt;Install ImDisk&lt;/a&gt; driver to enable Ram Disk and Disk Image support.</string>
1318+
</property>
1319+
<property name="openExternalLinks">
1320+
<bool>false</bool>
1321+
</property>
1322+
</widget>
1323+
</item>
1324+
<item row="0" column="0">
1325+
<widget class="QLabel" name="lblDiskImage">
1326+
<property name="font">
1327+
<font>
1328+
<bold>true</bold>
1329+
<kerning>true</kerning>
1330+
</font>
1331+
</property>
1332+
<property name="text">
1333+
<string>Disk Image Support</string>
1334+
</property>
1335+
</widget>
1336+
</item>
1337+
<item row="2" column="5">
1338+
<widget class="QLineEdit" name="txtRamLimit">
1339+
<property name="maximumSize">
1340+
<size>
1341+
<width>100</width>
1342+
<height>16777215</height>
1343+
</size>
1344+
</property>
1345+
</widget>
1346+
</item>
1347+
<item row="2" column="3" colspan="2">
13211348
<widget class="QLabel" name="lblRamDisk">
13221349
<property name="text">
13231350
<string>RAM Limit</string>
@@ -1327,7 +1354,7 @@
13271354
</property>
13281355
</widget>
13291356
</item>
1330-
<item row="3" column="2" colspan="4">
1357+
<item row="4" column="6">
13311358
<spacer name="horizontalSpacer_10">
13321359
<property name="orientation">
13331360
<enum>Qt::Horizontal</enum>
@@ -1340,13 +1367,13 @@
13401367
</property>
13411368
</spacer>
13421369
</item>
1343-
<item row="1" column="1" colspan="5">
1344-
<widget class="QLabel" name="lblImDisk">
1345-
<property name="text">
1346-
<string>&lt;a href=&quot;addon://ImDisk&quot;&gt;Install ImDisk&lt;/a&gt; driver to enable Ram Disk and Disk Image support.</string>
1370+
<item row="3" column="4" colspan="3">
1371+
<widget class="QLabel" name="lblRamLetter">
1372+
<property name="toolTip">
1373+
<string>When a Ram Disk is already mounted you need to unmount it for this option to take effect.</string>
13471374
</property>
1348-
<property name="openExternalLinks">
1349-
<bool>false</bool>
1375+
<property name="text">
1376+
<string>* takes effect on disk creation</string>
13501377
</property>
13511378
</widget>
13521379
</item>

SandboxiePlus/SandMan/Windows/SettingsWindow.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
376376
}
377377
});
378378
connect(ui.txtRamLimit, SIGNAL(textChanged(const QString&)), this, SLOT(OnRamDiskChange()));
379+
connect(ui.chkRamLetter, SIGNAL(stateChanged(int)), this, SLOT(OnRamDiskChange()));
380+
connect(ui.cmbRamLetter, SIGNAL(currentIndexChanged(int)), this, SLOT(OnGeneralChanged()));
381+
DWORD logical_drives = GetLogicalDrives();
382+
for (CHAR search = 'D'; search <= 'Z'; search++) {
383+
if ((logical_drives & (1 << (search - 'A'))) == 0)
384+
ui.cmbRamLetter->addItem(QString("%1:\\").arg(QChar(search)));
385+
}
379386
//
380387

381388
// Advanced Config
@@ -521,9 +528,11 @@ CSettingsWindow::CSettingsWindow(QWidget* parent)
521528
connect(ui.buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked(bool)), this, SLOT(apply()));
522529
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
523530

524-
//COptionsWindow__AddCertIcon(ui.chkUpdateTemplates);
525-
COptionsWindow__AddCertIcon(ui.chkUpdateIssues);
526-
COptionsWindow__AddCertIcon(ui.chkRamDisk);
531+
if (!CERT_IS_LEVEL(g_CertInfo, eCertStandard)) {
532+
//COptionsWindow__AddCertIcon(ui.chkUpdateTemplates);
533+
COptionsWindow__AddCertIcon(ui.chkUpdateIssues);
534+
COptionsWindow__AddCertIcon(ui.chkRamDisk);
535+
}
527536

528537
this->installEventFilter(this); // prevent enter from closing the dialog
529538

@@ -932,6 +941,9 @@ void CSettingsWindow::LoadSettings()
932941
quint32 uDiskLimit = theAPI->GetGlobalSettings()->GetNum64("RamDiskSizeKb");
933942
ui.chkRamDisk->setChecked(uDiskLimit > 0);
934943
if(uDiskLimit > 0) ui.txtRamLimit->setText(QString::number(uDiskLimit));
944+
QString RamLetter = theAPI->GetGlobalSettings()->GetText("RamDiskLetter");
945+
ui.chkRamLetter->setChecked(!RamLetter.isEmpty());
946+
ui.cmbRamLetter->setCurrentText(RamLetter);
935947
m_HoldChange = true;
936948
OnRamDiskChange();
937949
m_HoldChange = false;
@@ -1047,6 +1059,11 @@ void CSettingsWindow::LoadSettings()
10471059

10481060
void CSettingsWindow::OnRamDiskChange()
10491061
{
1062+
if (sender() == ui.chkRamDisk) {
1063+
if (ui.chkRamDisk->isChecked())
1064+
theGUI->CheckCertificate(this);
1065+
}
1066+
10501067
if (ui.chkRamDisk->isChecked() && ui.txtRamLimit->text().isEmpty())
10511068
ui.txtRamLimit->setText(QString::number(2 * 1024 * 1024));
10521069

@@ -1056,6 +1073,10 @@ void CSettingsWindow::OnRamDiskChange()
10561073
ui.lblRamLimit->setEnabled(bEnabled);
10571074
ui.lblRamLimit->setText(tr("kilobytes (%1)").arg(FormatSize(ui.txtRamLimit->text().toULongLong() * 1024)));
10581075

1076+
ui.chkRamLetter->setEnabled(bEnabled);
1077+
ui.cmbRamLetter->setEnabled(bEnabled && ui.chkRamLetter->isChecked());
1078+
ui.lblRamLetter->setEnabled(bEnabled && ui.chkRamLetter->isChecked());
1079+
10591080
OnGeneralChanged();
10601081
}
10611082

@@ -1437,6 +1458,7 @@ void CSettingsWindow::SaveSettings()
14371458
WriteText("IpcRootPath", ui.ipcRoot->text()); //ui.ipcRoot->setText("\\Sandbox\\%USER%\\%SANDBOX%\\Session_%SESSION%");
14381459

14391460
WriteText("RamDiskSizeKb", ui.chkRamDisk->isChecked() ? ui.txtRamLimit->text() : "");
1461+
WriteText("RamDiskLetter", ui.chkRamLetter->isChecked() ? ui.cmbRamLetter->currentText() : "");
14401462

14411463
WriteAdvancedCheck(ui.chkWFP, "NetworkEnableWFP", "y", "");
14421464
WriteAdvancedCheck(ui.chkObjCb, "EnableObjectFiltering", "", "n");

0 commit comments

Comments
 (0)