This commit is contained in:
DavidXanatos 2024-07-21 14:33:05 +02:00
parent b41d18079a
commit 98ea5bf6c4
3 changed files with 175 additions and 95 deletions

View File

@ -221,28 +221,36 @@ _FX NTSTATUS SysInfo_NtQuerySystemInformation(
typedef LSTATUS(*ROK)(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
typedef LSTATUS(*RQVEW)(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
typedef LSTATUS(*RCK)(HKEY hKey);
ROK RegOpenKeyExW = (ROK)GetProcAddress(GetModuleHandle(DllName_advapi32), "RegOpenKeyExW");
RQVEW RegQueryValueExW = (RQVEW)GetProcAddress(GetModuleHandle(DllName_advapi32), "RegQueryValueExW");
RCK RegCloseKey = (RCK)GetProcAddress(GetModuleHandle(DllName_advapi32), "RegCloseKey");
ROK RegOpenKeyExW = (ROK)GetProcAddress(LoadLibraryW(DllName_advapi32), "RegOpenKeyExW");
RQVEW RegQueryValueExW = (RQVEW)GetProcAddress(LoadLibraryW(DllName_advapi32), "RegQueryValueExW");
RCK RegCloseKey = (RCK)GetProcAddress(LoadLibraryW(DllName_advapi32), "RegCloseKey");
HKEY hKey = NULL;
PVOID lpData = NULL;
DWORD dwLen = 0;
DWORD dwLen = 0x10000;
PVOID lpData = Dll_AllocTemp(dwLen);
DWORD type;
if (!lpData)
return STATUS_UNSUCCESSFUL;
// if not set we return no information, 0 length
if (RegOpenKeyExW && RegOpenKeyExW(HKEY_CURRENT_USER, L"System\\SbieCustom\\", 0, KEY_READ, &hKey)) {
if (RegOpenKeyExW && RegOpenKeyExW(HKEY_CURRENT_USER, L"System\\SbieCustom", 0, KEY_READ, &hKey) == 0) {
RegQueryValueExW(hKey, L"SMBiosTable", 0, &type, lpData, &dwLen);
RegCloseKey(hKey);
}
*ReturnLength = dwLen;
if (dwLen > 0) {
if (dwLen > BufferLength)
if (dwLen + sizeof(PSYSTEM_FIRMWARE_TABLE_INFORMATION) > BufferLength)
return STATUS_BUFFER_TOO_SMALL;
memcpy(Buffer, lpData, dwLen);
firmwareTableInfo->TableBufferLength = dwLen;
memcpy(firmwareTableInfo->TableBuffer, lpData, dwLen);
}
Dll_Free(lpData);
return STATUS_SUCCESS;
}
}

View File

@ -4687,16 +4687,6 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
<string>Privacy</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_29">
<item row="2" column="2">
<widget class="QComboBox" name="cmbLangID"/>
</item>
<item row="10" column="4">
<widget class="QCheckBox" name="chkShowHiddenProcTmpl">
<property name="text">
<string>Show Templates</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QCheckBox" name="chkHideFirmware">
<property name="toolTip">
@ -4707,50 +4697,13 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QPushButton" name="btnAddProcess">
<item row="7" column="0" colspan="4">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Add Process</string>
<string>Hide host processes from processes running in the sandbox.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblProcessHiding">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Process Hiding</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_72">
<property name="text">
<string>Use a custom Locale/LangID</string>
</property>
</widget>
</item>
<item row="9" column="4">
<spacer name="verticalSpacer_16">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1" colspan="3">
<widget class="QCheckBox" name="chkHideNonSystemProcesses">
<property name="text">
<string>Don't allow sandboxed processes to see processes running outside any boxes</string>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
@ -4767,40 +4720,20 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</property>
</spacer>
</item>
<item row="11" column="4">
<widget class="QPushButton" name="btnDelProcess">
<item row="12" column="0" colspan="5">
<widget class="QCheckBox" name="chkBlockWMI">
<property name="toolTip">
<string>Some programs read system deatils through WMI(A Windows built-in database) instead of normal ways. For example,&quot;tasklist.exe&quot; could get full processes list even if &quot;HideOtherBoxes&quot; is opened through accessing WMI. Enable this option to stop these heavior.</string>
</property>
<property name="text">
<string>Remove</string>
<string>Prevent sandboxed processes from accessing system deatils through WMI (see tooltip for more Info)</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="QLabel" name="label_24">
<item row="5" column="1" colspan="3">
<widget class="QCheckBox" name="chkHideNonSystemProcesses">
<property name="text">
<string>Hide host processes from processes running in the sandbox.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QCheckBox" name="chkHideOtherBoxes">
<property name="text">
<string>Don't allow sandboxed processes to see processes running in other boxes</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblPrivacyProtection">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Data Protection</string>
<string>Don't allow sandboxed processes to see processes running outside any boxes</string>
</property>
</widget>
</item>
@ -4821,13 +4754,90 @@ This is done to prevent rogue processes inside the sandbox from creating a renam
</column>
</widget>
</item>
<item row="12" column="0" colspan="5">
<widget class="QCheckBox" name="chkBlockWMI">
<property name="toolTip">
<string>Some programs read system deatils through WMI(A Windows built-in database) instead of normal ways. For example,&quot;tasklist.exe&quot; could get full processes list even if &quot;HideOtherBoxes&quot; is opened through accessing WMI. Enable this option to stop these heavior.</string>
<item row="3" column="0">
<widget class="QLabel" name="lblProcessHiding">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Prevent sandboxed processes from accessing system deatils through WMI (see tooltip for more Info)</string>
<string>Process Hiding</string>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QPushButton" name="btnAddProcess">
<property name="text">
<string>Add Process</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_72">
<property name="text">
<string>Use a custom Locale/LangID</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QPushButton" name="btnDelProcess">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblPrivacyProtection">
<property name="font">
<font>
<bold>true</bold>
<kerning>true</kerning>
</font>
</property>
<property name="text">
<string>Data Protection</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="cmbLangID"/>
</item>
<item row="10" column="4">
<widget class="QCheckBox" name="chkShowHiddenProcTmpl">
<property name="text">
<string>Show Templates</string>
</property>
</widget>
</item>
<item row="9" column="4">
<spacer name="verticalSpacer_16">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1" colspan="3">
<widget class="QCheckBox" name="chkHideOtherBoxes">
<property name="text">
<string>Don't allow sandboxed processes to see processes running in other boxes</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="btnDumpFW">
<property name="toolTip">
<string>Dump the current Firmare Tables to HKCU\System\SbieCustom</string>
</property>
<property name="text">
<string>Dump FW Tables</string>
</property>
</widget>
</item>

View File

@ -100,6 +100,7 @@ void COptionsWindow::CreateAdvanced()
connect(ui.chkHideFirmware, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged()));
connect(ui.cmbLangID, SIGNAL(currentIndexChanged(int)), this, SLOT(OnAdvancedChanged()));
connect(ui.btnDumpFW, SIGNAL(clicked(bool)), this, SLOT(OnDumpFW()));
connect(ui.chkHideOtherBoxes, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged()));
connect(ui.chkHideNonSystemProcesses, SIGNAL(clicked(bool)), this, SLOT(OnAdvancedChanged()));
@ -266,7 +267,7 @@ void COptionsWindow::LoadAdvanced()
ShowTriggersTmpl();
//
ui.chkHideFirmware->setChecked(m_pBox->GetBool("HideFirmwareInfo", true));
ui.chkHideFirmware->setChecked(m_pBox->GetBool("HideFirmwareInfo", false));
ui.cmbLangID->setCurrentIndex(ui.cmbLangID->findData(m_pBox->GetNum("CustomLCID", 0)));
@ -1341,6 +1342,67 @@ void COptionsWindow::SaveDebug()
}
}
#define WIN32_NO_STATUS
typedef long NTSTATUS;
#include "..\..\Sandboxie\common\win32_ntddk.h"
typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
ULONG ProviderSignature;
ULONG Action;
ULONG TableID;
ULONG TableBufferLength;
UCHAR TableBuffer[ANYSIZE_ARRAY];
} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
#define FIRMWARE_TABLE_PROVIDER_ACPI 'ACPI'
#define FIRMWARE_TABLE_PROVIDER_SMBIOS 'RSMB'
typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION {
SystemFirmwareTable_Enumerate,
SystemFirmwareTable_Get
} SYSTEM_FIRMWARE_TABLE_ACTION;
void COptionsWindow::OnDumpFW()
{
ULONG returnLength = 0;
NTSTATUS status;
SYSTEM_FIRMWARE_TABLE_INFORMATION* firmwareTableInfo;
ULONG firmwareTableSize = sizeof(SYSTEM_FIRMWARE_TABLE_INFORMATION) + 0x10000; // Initial size
retry:
firmwareTableInfo = (SYSTEM_FIRMWARE_TABLE_INFORMATION*)malloc(firmwareTableSize);
firmwareTableInfo->ProviderSignature = FIRMWARE_TABLE_PROVIDER_SMBIOS;
firmwareTableInfo->Action = SystemFirmwareTable_Get;
firmwareTableInfo->TableID = 0;
firmwareTableInfo->TableBufferLength = firmwareTableSize - sizeof(SYSTEM_FIRMWARE_TABLE_INFORMATION);
status = NtQuerySystemInformation(SystemFirmwareTableInformation, firmwareTableInfo, firmwareTableSize, &returnLength);
if (status == 0xC0000023L/*STATUS_BUFFER_TOO_SMALL*/) {
free(firmwareTableInfo);
firmwareTableSize += 0x10000;
goto retry;
}
if (!NT_SUCCESS(status))
CSandMan::ShowMessageBox(this, QMessageBox::Critical, tr("Failed to retrieve firmware table information."));
else if(firmwareTableInfo->TableBufferLength)
{
HKEY hKey;
DWORD disposition;
if(RegCreateKeyExW(HKEY_CURRENT_USER, L"System\\SbieCustom", 0, 0, 0, KEY_WRITE, NULL, &hKey, &disposition) == 0)
{
if(RegSetValueExW(hKey, L"SMBiosTable", 0, REG_BINARY, firmwareTableInfo->TableBuffer, firmwareTableInfo->TableBufferLength) == 0)
CSandMan::ShowMessageBox(this, QMessageBox::Information, tr("Firmware table saved successfully to host registry: HKEY_CURRENT_USER\\System\\SbieCustom<br />you can copy it to the sandboxed registry to have a different value for each box."));
RegCloseKey(hKey);
}
}
free(firmwareTableInfo);
}
void COptionsWindow::InitLangID()
{
// Note: list by ChatGPT