Merge pull request #14 from sandboxie-plus/master

Update fork
This commit is contained in:
Sebastian G 2021-01-31 17:52:21 +01:00 committed by GitHub
commit 4284d541af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
164 changed files with 13591 additions and 8610 deletions

View File

@ -1,6 +1,8 @@
name: CI
on:
# workflow_dispatch:
# branches: [ master ]
push:
branches: [ master ]
pull_request:
@ -8,9 +10,16 @@ on:
jobs:
build:
strategy:
matrix:
platform: [Win32, x64]
#strategy:
# matrix:
# #platform: [Win32, x64]
# #qt-target: [win32_msvc2019, win64_msvc2019_64]
# include:
# - platform: Win32
# qt-target: win32_msvc2019
# - platform: x64
# qt-target: win64_msvc2019_64
runs-on: windows-2019
steps:
- name: Checkout code
@ -19,36 +28,72 @@ jobs:
- name: Setup msbuild
uses: microsoft/setup-msbuild@v1
- name: Build Sandboxie
run: msbuild /t:build Sandboxie\Sandbox.sln /p:Configuration="SbieRelease" /p:Platform=${{ matrix.platform }}
# - name: Build Sandboxie
# run: msbuild /t:build Sandboxie\Sandbox.sln /p:Configuration="SbieRelease" /p:Platform=${{ matrix.platform }}
- name: Build Sandboxie 32 bit
run: msbuild /t:build Sandboxie\Sandbox.sln /p:Configuration="SbieRelease" /p:Platform=Win32 -maxcpucount:8
- name: Build Sandboxie 64 bit
run: msbuild /t:build Sandboxie\Sandbox.sln /p:Configuration="SbieRelease" /p:Platform=x64 -maxcpucount:8
- name: Cache Qt
id: cache-qt
uses: actions/cache@v1
with:
path: ../Qt
key: ${{ runner.os }}-QtCache
key: Qt-5.15.1-QtCache
- name: Install Qt
- name: Install Qt 64 bit
uses: jurplel/install-qt-action@v2
with:
version: '5.15.1'
dir: ..
# arch: ${{ matrix.qt-target }}
arch: 'win64_msvc2019_64'
# tools: 'tools_qtcreator,4.14.0-0-202012170949,qt.tools.qtcreator'
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Build Sandboxie-Plus
run: msbuild /t:build SandboxiePlus\SandboxiePlus.sln /p:Configuration="Release" /p:Platform=${{ matrix.platform }}
- name: Install Qt 32 bit
uses: jurplel/install-qt-action@v2
with:
version: '5.15.1'
dir: ..
# arch: ${{ matrix.qt-target }}
arch: 'win32_msvc2019'
# tools: 'tools_qtcreator,4.14.0-0-202012170949,qt.tools.qtcreator'
cached: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Upload Sandboxie
- name: Installing Jom
if: steps.cache.outputs.cache-hit != 'true'
run: SandboxiePlus\install_jom.cmd
- name: Build Sandboxie-Plus 64 bit
run: SandboxiePlus\qmake_plus.cmd x64
- name: Build Sandboxie-Plus 32 bit
run: SandboxiePlus\qmake_plus.cmd Win32
- name: Merging Builds
run: Installer\merge_builds.cmd
- name: Upload Sandboxie 32
uses: actions/upload-artifact@v2
with:
name: Sandboxie (${{ matrix.platform }})
name: Sandboxie_x86
path: |
Sandboxie/Bin/${{ matrix.platform }}/SbieRelease
!**/*.pdb
!**/*.ipdb
!**/*.exp
!**/*.ilk
!**/*.iobj
!**/*.lib
!**/*.cer
Sandboxie/Bin/${{ matrix.platform }}/SbieRelease/SbieDrv.pdb
Installer/SbiePlus32/*
- name: Upload Sandboxie 64
uses: actions/upload-artifact@v2
with:
name: Sandboxie_x64
path: |
Installer/SbiePlus64/*

View File

@ -7,25 +7,58 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [0.6.5 / 5.47.0] - 2021-01-31
### Added
- added detection for waterfox.exe, Palemoon.exe, basilisk.exe and brave.exe firefox forks
- added bluetooth API support, IPC port can be opened with "OpenBluetooth=y"
-- this should resolve issues with many unity games hanging on startup for a long time
- added enhanced RPC/IPC interface tracing
- when DefaultBox is not found by the SandMan UI, it will be recreated
- "Disable Forced Programs" time is now saved and reloaded
### Changed
- reduced sandman cpu usage
- sandboxie.ini and templates.ini can now be UTF8 encoded
-- this feature is experimental, files without a UTF-8 Signature should be recognized also
-- "ByteOrderMark=yes" is obsolete, sandboxie.ini is now always saved with a BOM/Signature
- legacy language files can now be UTF8 encoded
- reworked file migration behaviour, removed hardcoded lists in favour of templates
-- you can now use "CopyAlways=", "DontCopy=" and "CopyEmpty=" that support the same syntax as "OpenFilePath="
-- "CopyBlockDenyWrite=program.exe,y" makes a write open call to a file that won't be copied fail instead of turning it read only
- removed hardcoded SkipHook list in favour of templates
### Fixed
- fixed old memory pool leak in the sbie driver
- fixed issue with item selection in the access restrictions ui
- fixed updater crash in sbiectrl.exe
- fixed issues wih RPC calls introduced in sbie 5.33.1
- fixed recently broken terminate all command
- fixed a couple minor UI issues with Sandman UI
- fixed IPC issue with windows 7 and 8 resulting in process termination
- fixed "recover to" functionality
## [0.6.0 / 5.46.5] - 2021-01-25
### Added
- added comfirmation prompts to terminate all commands
- added confirmation prompts to terminate all commands
- added window title to boxed process info
- added winspy based sandboxed window finder
- added option to view disabled boxes and double click on box to enable it
### Changed
- reset columns now resized them to fit the content, also "Reset Columns" can now be localized
- "Reset Columns" now resizes them to fit the content, and it can now be localized
- modal windows are now centered to the parent
- improved new box window
### Fixed
- fixed issues with window modality
- fixed issues when main window was set to be always on top
- fixed an driver issue with windows 10 insider build 21286
- fixed a driver issue with windows 10 insider build 21286
- fixed issues with snapshot dialog
- fixed an issue when writing to a path that aready exist in the napshot but not outside
- fixed an issue when writing to a path that already exist in the snapshot but not outside

109
Installer/copy_build.cmd Normal file
View File

@ -0,0 +1,109 @@
REM @ECHO OFF
set archPath=%1
set sysPath=%windir%\System32
set qtPath=%~dp0..\..\Qt\5.15.1\msvc2019_64
set instPath=%~dp0\SbiePlus64
IF %archPath% == x86 (
set archPath=Win32
set instPath=%~dp0\SbiePlus32
set sysPath=%windir%\SysWOW64
set qtPath=%~dp0..\..\Qt\5.15.1\msvc2019
)
set srcPath=%~dp0..\SandboxiePlus\Bin\%archPath%\Release
set sbiePath=%~dp0..\Sandboxie\Bin\%archPath%\SbieRelease
echo inst: %instPath%
echo arch: %archPath%
echo sys: %sysPath%
echo source: %srcPath%
echo source: %sbiePath%
mkdir %instPath%
ECHO Copying VC Runtime
copy %sysPath%\msvcp140.dll %instPath%\
copy %sysPath%\vcruntime140.dll %instPath%\
copy %sysPath%\msvcp140_1.dll %instPath%\
copy %sysPath%\vcruntime140_1.dll %instPath%\
ECHO Copying Qt Librarys
copy %qtPath%\bin\Qt5Core.dll %instPath%\
copy %qtPath%\bin\Qt5Gui.dll %instPath%\
copy %qtPath%\bin\Qt5Network.dll %instPath%\
copy %qtPath%\bin\Qt5Widgets.dll %instPath%\
copy %qtPath%\bin\Qt5WinExtras.dll %instPath%\
mkdir %instPath%\platforms
copy %qtPath%\plugins\platforms\qdirect2d.dll %instPath%\platforms\
copy %qtPath%\plugins\platforms\qminimal.dll %instPath%\platforms\
copy %qtPath%\plugins\platforms\qoffscreen.dll %instPath%\platforms\
copy %qtPath%\plugins\platforms\qwindows.dll %instPath%\platforms\
mkdir %instPath%\styles
copy %qtPath%\plugins\styles\qwindowsvistastyle.dll %instPath%\styles\
ECHO Copying OpenSSL libs
rem copy /y %~dp0OpenSSL\%archPath%\libeay32.dll %instPath%\
rem copy /y %~dp0OpenSSL\%archPath%\ssleay32.dll %instPath%\
IF %archPath% == Win32 (
copy /y %~dp0OpenSSL\Win32\libssl-1_1.dll %instPath%\
copy /y %~dp0OpenSSL\Win32\libcrypto-1_1.dll %instPath%\
)
IF %archPath% == x64 (
copy /y %~dp0OpenSSL\x64\libssl-1_1-x64.dll %instPath%\
copy /y %~dp0OpenSSL\x64\libcrypto-1_1-x64.dll %instPath%\
)
rem for openssl
copy %sysPath%\msvcr100.dll %instPath%\
ECHO Copying Project and Librarys
copy %srcPath%\MiscHelpers.dll %instPath%\
copy %srcPath%\QSbieAPI.dll %instPath%\
copy %srcPath%\QtSingleApp.dll %instPath%\
copy %srcPath%\SandMan.exe %instPath%\
ECHO Copying SandMan translations
mkdir %instPath%\translations\
rem copy /y %~dp0..\SandboxiePlus\SandMan\sandman_*.qm %instPath%\translations\
copy /y %~dp0..\SandboxiePlus\Build_SandMan_%archPath%\release\sandman_*.qm %instPath%\translations\
ECHO Copying Sandboxie
copy /y %sbiePath%\SbieSvc.exe %instPath%\
copy /y %sbiePath%\SbieDll.dll %instPath%\
copy /y %sbiePath%\SbieDrv.sys %instPath%\
copy /y %sbiePath%\SbieDrv.pdb %instPath%\
copy /y %sbiePath%\SbieCtrl.exe %instPath%\
copy /y %sbiePath%\Start.exe %instPath%\
copy /y %sbiePath%\kmdutil.exe %instPath%\
copy /y %sbiePath%\SbieIni.exe %instPath%\
copy /y %sbiePath%\SbieMsg.dll %instPath%\
copy /y %sbiePath%\SboxHostDll.dll %instPath%\
copy /y %sbiePath%\SandboxieBITS.exe %instPath%\
copy /y %sbiePath%\SandboxieCrypto.exe %instPath%\
copy /y %sbiePath%\SandboxieDcomLaunch.exe %instPath%\
copy /y %sbiePath%\SandboxieRpcSs.exe %instPath%\
copy /y %sbiePath%\SandboxieWUAU.exe %instPath%\
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..\Sandboxie\install\Templates.ini %instPath%\
copy /y %~dp0..\Sandboxie\install\Manifest0.txt %instPath%\
copy /y %~dp0..\Sandboxie\install\Manifest1.txt %instPath%\
copy /y %~dp0..\Sandboxie\install\Manifest2.txt %instPath%\

View File

@ -0,0 +1,8 @@
mkdir %~dp0\OpenSSL
curl --ssl-no-revoke -L http://wiki.overbyte.eu/arch/openssl-1.1.1i-win64.zip -o %~dp0\OpenSSL\openssl-1.1.1i-win64.zip
"C:\Program Files\7-Zip\7z.exe" x -o%~dp0\OpenSSL\x64\ %~dp0\OpenSSL\openssl-1.1.1i-win64.zip
curl --ssl-no-revoke -L http://wiki.overbyte.eu/arch/openssl-1.1.1i-win32.zip -o %~dp0\OpenSSL\openssl-1.1.1i-win32.zip
"C:\Program Files\7-Zip\7z.exe" x -o%~dp0\OpenSSL\Win32\ %~dp0\OpenSSL\openssl-1.1.1i-win32.zip

View File

@ -0,0 +1,15 @@
REM @ECHO OFF
call %~dp0get_openssl.cmd
call %~dp0copy_build.cmd x64
call %~dp0copy_build.cmd x86
REM mkdir %rootPath%\SbiePlus64\LogAPI
REM copy /y %~dp0..\LogApiDll\output\amd64\VerboseDebug\logapi64.dll %rootPath%\SbiePlus64\LogAPI\logapi64.dll
REM copy /y %~dp0..\LogApiDll\output\i386\VerboseDebug\logapi32.dll %rootPath%\SbiePlus64\LogAPI\logapi32.dll
REM mkdir %rootPath%\SbiePlus32\LogAPI
REM copy /y %~dp0..\LogApiDll\output\i386\VerboseDebug\logapi32.dll %rootPath%\SbiePlus32\LogAPI\logapi32.dll

View File

@ -26,12 +26,14 @@ Open Source release
- mpheath - help with inno setup
### Translators
- yuhao2348732 - ZH
- nkh0472 - CN
- bastik-1001 - DE
- JNylson - PT
- lufog - RU
- xorcan -RT
- yuhao2348732 - Chinese Simplified
- nkh0472 - Chinese Simplified
- bastik-1001 - German
- JNylson - Portuguese
- lufog - Russian
- xorcan - Turkish
- TragicLifeHu - Chinese Traditional
More volunteers welcome ;)

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1022
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SboxDrv", "core\drv\SboxDrv.vcxproj", "{4019C5EB-8D1E-40E4-B7D1-5601B4B27288}"
ProjectSection(ProjectDependencies) = postProject

View File

@ -80,6 +80,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -92,6 +93,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -105,6 +107,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@ -120,6 +123,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>

View File

@ -75,6 +75,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib;ole32.lib;wtsapi32.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -83,6 +84,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib;ole32.lib;wtsapi32.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -93,12 +95,18 @@
<Link>
<AdditionalDependencies>advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib;ole32.lib;wtsapi32.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">
<ClCompile />
<Link>
<AdditionalDependencies>advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib;ole32.lib;wtsapi32.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="bits.c" />

View File

@ -79,6 +79,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;secur32.lib;advapi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -87,6 +88,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;secur32.lib;advapi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -97,12 +99,18 @@
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;secur32.lib;advapi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">
<ClCompile />
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;secur32.lib;advapi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="crypto.c" />

View File

@ -78,6 +78,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;kernel32.lib;secur32.lib;Advapi32.lib;Ntdll.lib;User32.lib</AdditionalDependencies>
@ -87,6 +88,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;kernel32.lib;secur32.lib;Advapi32.lib;Ntdll.lib;User32.lib</AdditionalDependencies>
@ -95,6 +97,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">
<ClCompile>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;kernel32.lib;secur32.lib;Advapi32.lib;Ntdll.lib;User32.lib</AdditionalDependencies>
@ -103,6 +106,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">
<ClCompile>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;kernel32.lib;secur32.lib;Advapi32.lib;Ntdll.lib;User32.lib</AdditionalDependencies>

View File

@ -79,6 +79,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ws2_32.lib;advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib</AdditionalDependencies>
@ -88,6 +89,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ws2_32.lib;advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib</AdditionalDependencies>
@ -96,6 +98,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">
<ClCompile>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ws2_32.lib;advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib</AdditionalDependencies>
@ -104,6 +107,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">
<ClCompile>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ws2_32.lib;advapi32.lib;kernel32.lib;ntdll.lib;gdi32.lib;user32.lib;secur32.lib;psapi.lib</AdditionalDependencies>

View File

@ -83,6 +83,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;secur32.lib;ntdll.lib;psapi.lib;AdvApi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -92,6 +93,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;secur32.lib;ntdll.lib;psapi.lib;AdvApi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -102,6 +104,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;secur32.lib;ntdll.lib;psapi.lib;AdvApi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -112,6 +115,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;secur32.lib;ntdll.lib;psapi.lib;AdvApi32.lib;user32.lib;%(AdditionalDependencies)</AdditionalDependencies>

View File

@ -67,6 +67,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
@ -75,6 +76,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
@ -83,6 +85,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
@ -91,6 +94,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Lib>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -123,7 +123,7 @@ void CRunBrowser::OnYes()
void CRunBrowser::OnNo()
{
ShellExecute(
m_pParentWnd->m_hWnd, NULL, m_url, NULL, NULL, SW_SHOWNORMAL);
m_pParentWnd ? m_pParentWnd->m_hWnd : NULL , NULL, m_url, NULL, NULL, SW_SHOWNORMAL);
EndDialog(0);
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,13 +47,14 @@ enum {
#define MODIF_IEXPLORE 0x0001
#define MODIF_FIREFOX 0x0002
#define MODIF_CHROME 0x0004
#define MODIF_EDGE 0x0008
#define MODIF_OTHERWB 0x0080
#define MODIF_NONLOCAL 0x2000
#define MODIF_ADDONS 0x4000
#define MODIF_BROWSER \
(MODIF_IEXPLORE | MODIF_FIREFOX | MODIF_CHROME | MODIF_OTHERWB)
(MODIF_IEXPLORE | MODIF_EDGE | MODIF_FIREFOX | MODIF_CHROME | MODIF_OTHERWB)
//---------------------------------------------------------------------------
@ -145,6 +147,8 @@ CAppPage::CAppPage(TMPL_INFO *info, const CString &BoxName)
if (m_tmpl_info.ClassModifier & MODIF_IEXPLORE)
m_titleForPage = L"Internet Explorer";
if (m_tmpl_info.ClassModifier & MODIF_EDGE)
m_titleForPage = "Microsoft Edge";
if (m_tmpl_info.ClassModifier & MODIF_FIREFOX)
m_titleForPage = L"Firefox";
if (m_tmpl_info.ClassModifier & MODIF_CHROME)
@ -244,8 +248,7 @@ void CAppPage::Access_OnInitDialog(CBox &box)
void CAppPage::Access_OnOK(CBox &box)
{
BOOL global = CBoxes::GetInstance().GetBox(0).
IsTemplateEnabled(Template_ScreenReader);
BOOL global = CBoxes::GetInstance().GetBox(0).IsTemplateEnabled(Template_ScreenReader);
BOOL wasEnabled = box.IsTemplateEnabled(Template_ScreenReader);
if (! wasEnabled)
@ -538,24 +541,32 @@ void CAppPage::Template_Filter()
POSITION old_pos = pos;
CString name = m_tmpl_sections.GetNext(pos);
BOOL ie = (name.Find(L"IExplore_") != -1);
BOOL edge = (name.Find(L"Edge_") != -1);
BOOL ff = (name.Find(L"Firefox_") != -1)
|| (name.Find(L"Waterfox_") != -1)
|| (name.Find(L"PaleMoon_") != -1);
BOOL ch = (name.Find(L"Chrome_") != -1)
|| (name.Find(L"Iron_") != -1)
|| (name.Find(L"Dragon_") != -1)
|| (name.Find(L"Vivaldi_") != -1)
|| (name.Find(L"Neon_") != -1);
|| (name.Find(L"PaleMoon_") != -1)
|| (name.Find(L"SeaMonkey_") != -1);
BOOL ch = (name.Find(L"Chrome_") != -1);
BOOL other = (name.Find(L"Dragon_") != -1)
|| (name.Find(L"Iron_") != -1)
|| (name.Find(L"Ungoogled_") != -1)
|| (name.Find(L"Vivaldi_") != -1)
|| (name.Find(L"Brave_") != -1)
|| (name.Find(L"Maxthon_6_") != -1)
|| (name.Find(L"Opera_") != -1)
|| (name.Find(L"Yandex_") != -1);
BOOL keep = FALSE;
if ((modif & MODIF_IEXPLORE) && ie)
keep = TRUE;
else if ((modif & MODIF_EDGE) && edge)
keep = TRUE;
else if ((modif & MODIF_FIREFOX) && ff)
keep = TRUE;
else if ((modif & MODIF_CHROME) && ch)
keep = TRUE;
else if ((modif & MODIF_OTHERWB) && (! ie) && (! ff) && (! ch))
else if ((modif & MODIF_OTHERWB) && other)
keep = TRUE;
if (modif & MODIF_NONLOCAL) {
@ -989,6 +1000,8 @@ void CAppPage::AddPages(CPropertySheet &sheet, const CString &BoxName)
info.WithCreate = FALSE;
info.ClassModifier = MODIF_IEXPLORE; // IExplore
m_app_pages.AddTail(new CAppPage(&info, BoxName));
info.ClassModifier = MODIF_EDGE; // Microsoft Edge
m_app_pages.AddTail(new CAppPage(&info, BoxName));
info.ClassModifier = MODIF_FIREFOX; // Firefox
m_app_pages.AddTail(new CAppPage(&info, BoxName));
info.WithLink = TRUE;
@ -1162,19 +1175,19 @@ void CAppPage::UpdateWebTemplates(CBox &box)
// replace with: Template=SeaMonkey_Bookmarks_DirectAccess
//
const CString &SeaMonkeyTemplate(L"SeaMonkey_Bookmarks_DirectAccess");
const CString &SeaMonkeyPath1(
L"%AppData%\\Mozilla\\Profiles\\*\\bookmark*");
const CString &SeaMonkeyPath2(
L"%AppData%\\Mozilla\\Profiles\\*\\places*");
//const CString &SeaMonkeyTemplate(L"SeaMonkey_Bookmarks_DirectAccess");
//const CString &SeaMonkeyPath1(
// L"%AppData%\\Mozilla\\Profiles\\*\\bookmark*");
//const CString &SeaMonkeyPath2(
// L"%AppData%\\Mozilla\\Profiles\\*\\places*");
UpdateTemplates2(
box, L"seamonkey.exe", SeaMonkeyTemplate,
SeaMonkeyPath1, SeaMonkeyPath2);
//UpdateTemplates2(
// box, L"seamonkey.exe", SeaMonkeyTemplate,
// SeaMonkeyPath1, SeaMonkeyPath2);
UpdateTemplates2(
box, L"seamon~1.exe", SeaMonkeyTemplate,
SeaMonkeyPath1, SeaMonkeyPath2);
//UpdateTemplates2(
// box, L"seamon~1.exe", SeaMonkeyTemplate,
// SeaMonkeyPath1, SeaMonkeyPath2);
//
// find and remove:
@ -1184,10 +1197,10 @@ void CAppPage::UpdateWebTemplates(CBox &box)
// replace with: Template=SeaMonkey_Bookmarks_DirectAccess
//
UpdateTemplates2(
box, L"opera.exe", L"Opera_Bookmarks_DirectAccess",
L"%AppData%\\Opera\\Opera\\Profile\\opera6.adr",
L"%AppData%\\Opera\\Opera\\Profile\\notes.adr");
//UpdateTemplates2(
// box, L"opera.exe", L"Opera_Bookmarks_DirectAccess",
// L"%AppData%\\Opera\\Opera\\Profile\\opera6.adr",
// L"%AppData%\\Opera\\Opera\\Profile\\notes.adr");
}
@ -1220,28 +1233,28 @@ void CAppPage::UpdateEmailTemplates(CBox &box)
// Outlook Express
//
CStringList _OutlookExpressFiles;
CStringList _OutlookExpressKeys;
//CStringList _OutlookExpressFiles;
//CStringList _OutlookExpressKeys;
_OutlookExpressFiles.AddTail(L"%AppData%\\Identities");
_OutlookExpressFiles.AddTail(L"%Local AppData%\\Identities");
_OutlookExpressFiles.AddTail(L"%AppData%\\Microsoft\\Address Book");
_OutlookExpressFiles.AddTail(L"*.eml");
//_OutlookExpressFiles.AddTail(L"%AppData%\\Identities");
//_OutlookExpressFiles.AddTail(L"%Local AppData%\\Identities");
//_OutlookExpressFiles.AddTail(L"%AppData%\\Microsoft\\Address Book");
//_OutlookExpressFiles.AddTail(L"*.eml");
_OutlookExpressKeys.AddTail(L"HKEY_CURRENT_USER\\Identities");
_OutlookExpressKeys.AddTail(
L"HKEY_CURRENT_USER\\Software\\Microsoft\\Outlook Express");
_OutlookExpressKeys.AddTail(
L"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Account Manager");
_OutlookExpressKeys.AddTail(
L"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Outlook Express");
_OutlookExpressKeys.AddTail(
L"HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\"
L"Microsoft\\Outlook Express");
//_OutlookExpressKeys.AddTail(L"HKEY_CURRENT_USER\\Identities");
//_OutlookExpressKeys.AddTail(
// L"HKEY_CURRENT_USER\\Software\\Microsoft\\Outlook Express");
//_OutlookExpressKeys.AddTail(
// L"HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Account Manager");
//_OutlookExpressKeys.AddTail(
// L"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Outlook Express");
//_OutlookExpressKeys.AddTail(
// L"HKEY_LOCAL_MACHINE\\Software\\Wow6432Node\\"
// L"Microsoft\\Outlook Express");
UpdateTemplates3(
box, L"msimn.exe", L"Outlook_Express",
_OutlookExpressFiles, _OutlookExpressKeys);
//UpdateTemplates3(
// box, L"msimn.exe", L"Outlook_Express",
// _OutlookExpressFiles, _OutlookExpressKeys);
//
// find and remove:
@ -1370,9 +1383,9 @@ void CAppPage::UpdateEmailTemplates(CBox &box)
box, L"thunderbird.exe", _Thunderbird,
_ThunderbirdFiles, _ThunderbirdKeys);
UpdateTemplates3(
box, L"thunde~1.exe", _Thunderbird,
_ThunderbirdFiles, _ThunderbirdKeys);
//UpdateTemplates3(
// box, L"thunde~1.exe", _Thunderbird,
// _ThunderbirdFiles, _ThunderbirdKeys);
//
// find and remove:
@ -1410,9 +1423,9 @@ void CAppPage::UpdateEmailTemplates(CBox &box)
box, L"seamonkey.exe", _SeaMonkey,
_SeaMonkeyFiles, _SeaMonkeyKeys);
UpdateTemplates3(
box, L"seamon~1.exe", _SeaMonkey,
_SeaMonkeyFiles, _SeaMonkeyKeys);
//UpdateTemplates3(
// box, L"seamon~1.exe", _SeaMonkey,
// _SeaMonkeyFiles, _SeaMonkeyKeys);
//
// find and remove:
@ -1557,5 +1570,18 @@ void CAppPage::SetDefaultTemplates6(CBox &box)
void CAppPage::SetDefaultTemplates7(CBox &box)
{
box.EnableTemplate(L"BlockPorts", TRUE);
//box.EnableTemplate(L"WindowsFontCache", TRUE); // since 5.46.3 open by driver
box.EnableTemplate(L"qWave", TRUE);
SetDefaultTemplates8(box);
}
//---------------------------------------------------------------------------
// SetDefaultTemplates8
//---------------------------------------------------------------------------
void CAppPage::SetDefaultTemplates8(CBox& box)
{
box.EnableTemplate(L"FileCppy", TRUE);
box.EnableTemplate(L"SkipHook", TRUE);
}

View File

@ -126,6 +126,7 @@ public:
static void SetDefaultTemplates6(CBox &box);
static void SetDefaultTemplates7(CBox &box);
static void SetDefaultTemplates8(CBox& box);
};

View File

@ -226,18 +226,23 @@ void CBox::SetDefaultSettings()
int cfglvl;
ini.GetNum(m_name, _ConfigLevel, cfglvl);
if (cfglvl >= 7)
if (cfglvl >= 8)
return;
BOOL ok = TRUE;
if (cfglvl >= 1) {
ok = ini.SetNum(m_name, _ConfigLevel, 7);
ok = ini.SetNum(m_name, _ConfigLevel, 8);
if (ok) {
if (cfglvl == 6) {
if (cfglvl == 7) {
CAppPage::SetDefaultTemplates8(*this);
}
else if (cfglvl == 6) {
CAppPage::SetDefaultTemplates7(*this);
@ -250,7 +255,7 @@ void CBox::SetDefaultSettings()
goto done;
}
ok = ini.SetNum(m_name, _ConfigLevel, 7);
ok = ini.SetNum(m_name, _ConfigLevel, 8);
if (ok)
{

View File

@ -106,6 +106,7 @@
<IntrinsicFunctions>false</IntrinsicFunctions>
<MinimalRebuild />
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>uafxcw.lib;common.lib;SbieDll.lib;ntdll.lib;psapi.lib;wininet.lib;winhttp.lib</AdditionalDependencies>
@ -124,6 +125,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<MinimalRebuild />
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>uafxcw.lib;common.lib;SbieDll.lib;ntdll.lib;psapi.lib;wininet.lib;winhttp.lib</AdditionalDependencies>
@ -141,6 +143,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<MinimalRebuild />
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>uafxcw.lib;common.lib;SbieDll.lib;ntdll.lib;psapi.lib;wininet.lib;winhttp.lib</AdditionalDependencies>
@ -156,6 +159,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<MinimalRebuild />
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>uafxcw.lib;common.lib;SbieDll.lib;ntdll.lib;psapi.lib;wininet.lib;winhttp.lib</AdditionalDependencies>

View File

@ -82,6 +82,7 @@
<Filter>common\json</Filter>
</ClCompile>
<ClCompile Include="UpdateDialog.cpp" />
<ClCompile Include="Updater.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AboutDialog.h" />
@ -164,6 +165,7 @@
<Filter>common\json</Filter>
</ClInclude>
<ClInclude Include="UpdateDialog.h" />
<ClInclude Include="Updater.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SbieControl.rc" />

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -402,8 +402,19 @@ ULONG CUpdater::UpdaterServiceThread(void *lpParameter)
}
if (!pContext->version.IsEmpty() && pContext->version.Compare(_T(MY_VERSION_STRING)) != 0)
if (!pContext->version.IsEmpty()) // && pContext->version.Compare(_T(MY_VERSION_STRING)) != 0)
{
UCHAR myVersion[4] = { MY_VERSION_BINARY, 0 };
ULONG MyVersion = ntohl(*(ULONG*)&myVersion);
ULONG Version = 0;
for (int Position = 0, Bits = 24; Position < pContext->version.GetLength() && Bits >= 0; Bits -= 8) {
CString Num = pContext->version.Tokenize(L".", Position);
Version |= (_wtoi(Num) & 0xFF) << Bits;
}
if (Version > MyVersion)
if (pContext->Manual || IgnoredUpdates.Find(pContext->version) == NULL)
{
bNothing = false;

View File

@ -101,6 +101,7 @@
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -113,6 +114,7 @@
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -126,6 +128,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -139,6 +142,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -98,6 +98,7 @@
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -111,6 +112,7 @@
</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -125,6 +127,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -139,6 +142,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<MinimalRebuild />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -79,6 +79,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>libvcruntime.lib;libucrt.lib;ntdll.lib;User32.lib;Shell32.lib;Shlwapi.lib;Kernel32.lib;Gdi32.lib;SbieDll.lib;Ole32.lib;Common.lib;Advapi32.lib;Comctl32.lib;Comdlg32.lib;uuid.lib</AdditionalDependencies>
@ -93,6 +94,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>libvcruntime.lib;libucrt.lib;ntdll.lib;User32.lib;Shell32.lib;Shlwapi.lib;Kernel32.lib;Gdi32.lib;SbieDll.lib;Ole32.lib;Common.lib;Advapi32.lib;Comctl32.lib;Comdlg32.lib;uuid.lib</AdditionalDependencies>
@ -117,6 +119,7 @@
</Manifest>
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">
@ -133,6 +136,7 @@
</Manifest>
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -90,6 +91,7 @@ typedef enum {
WPAD_PORT,
GAME_CONFIG_STORE_PORT,
SMART_CARD_PORT,
BT_PORT,
NUM_DYNAMIC_PORTS
} ENUM_DYNAMIC_PORT_TYPE;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,8 +21,8 @@
#ifndef _MY_VERSION_H
#define _MY_VERSION_H
#define MY_VERSION_BINARY 5,46,5
#define MY_VERSION_STRING "5.46.5"
#define MY_VERSION_BINARY 5,47,0
#define MY_VERSION_STRING "5.47.0"
#define MY_VERSION_COMPAT "5.46.0" // this refers to the driver ABI compatibility
// These #defines are used by either Resource Compiler, or by NSIC installer

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,6 +36,7 @@ struct STREAM {
HANDLE handle;
UCHAR *data_ptr;
ULONG data_len;
ULONG encoding;
__declspec(align(8)) UCHAR data[0];
};
@ -71,6 +73,7 @@ __declspec(align(16)) NTSTATUS Stream_Open(
stream->data_len = 0;
stream->data_ptr = &stream->data[0];
stream->encoding = 0;
*out_stream = stream;
return STATUS_SUCCESS;
@ -145,6 +148,7 @@ __declspec(align(16)) NTSTATUS Stream_Open(
stream->data_len = 0;
stream->data_ptr = &stream->data[0];
stream->encoding = 0;
*out_stream = stream;
return status;
@ -351,3 +355,203 @@ NTSTATUS Stream_Write_Long(
STREAM_PUT_BYTE(b[3]);
return STATUS_SUCCESS;
}
//---------------------------------------------------------------------------
// Stream_Read_BOM
//---------------------------------------------------------------------------
NTSTATUS Stream_Read_BOM(
IN STREAM* stream,
ULONG* encoding)
{
if (stream->data_len == 0)
{
NTSTATUS status = Stream_Read_More(stream);
if (!NT_SUCCESS(status))
return status;
}
if (stream->data_len >= 3 && stream->data[0] == 0xEF && stream->data[1] == 0xBB && stream->data[2] == 0xBF)
{
stream->data_ptr += 3;
stream->data_len -= 3;
stream->encoding = 1;
//DbgPrint("sbie read ini, found UTF-8 Signature\n");
}
else if (stream->data_len >= 2 && stream->data[0] == 0xFF && stream->data[1] == 0xFE)
{
stream->data_ptr += 2;
stream->data_len -= 2;
stream->encoding = 0;
//DbgPrint("sbie read ini, found Unicode (UTF-16 LE) BOM\n");
}
else if (stream->data_len >= 2 && stream->data[0] == 0xFE && stream->data[1] == 0xFF)
{
stream->data_ptr += 2;
stream->data_len -= 2;
stream->encoding = 2;
//DbgPrint("sbie read ini, found Unicode (UTF-16 BE) BOM\n");
}
else
{
// If there is no BOM/Signature try to detect the file type
// Unicode Litle Endian (windows wchar_t) will have the n*2+1 bytes 0 as long, as no higher unicode chrakters are used
BOOLEAN LooksUnicodeLE = TRUE;
// similrly Unicode Big Endian (byte swaped) will have the n*2 bytes 0 as long
BOOLEAN LooksUnicodeBE = TRUE;
// UTF-8 shouldn't have null bytes
for (ULONG pos = 0; (pos + 1) < min(stream->data_len, 16); pos += 2) // check first 8 char16's
{
if (stream->data[pos] != 0)
LooksUnicodeBE = FALSE;
if (stream->data[pos + 1] != 0)
LooksUnicodeLE = FALSE;
}
if (!LooksUnicodeLE && !LooksUnicodeBE)
{
stream->encoding = 1;
//DbgPrint("sbie read ini, looks UTF-8 encoded\n");
}
else if (!LooksUnicodeLE && LooksUnicodeBE)
{
stream->encoding = 2;
//DbgPrint("sbie read ini, looks Unicode (UTF-16 BE) encoded\n");
}
else
{
stream->encoding = 0;
//if (LooksUnicodeLE && !LooksUnicodeBE)
// DbgPrint("sbie read ini, looks Unicode (UTF-16 LE) encoded\n");
//else
// DbgPrint("sbie read ini, encoding looks broken, assuming (UTF-16 LE)\n");
}
}
if (encoding) *encoding = stream->encoding;
return STATUS_SUCCESS;
}
//---------------------------------------------------------------------------
// Stream_Read_Wchar
//---------------------------------------------------------------------------
NTSTATUS Stream_Read_Wchar(
IN STREAM* stream,
OUT USHORT* v)
{
if (stream->encoding == 0) // Unicode Litle Endian
{
UCHAR* b = (UCHAR*)v;
STREAM_GET_BYTE(b[0]);
STREAM_GET_BYTE(b[1]);
}
else if (stream->encoding == 2) // Unicode Big Endian
{
UCHAR* b = (UCHAR*)v;
STREAM_GET_BYTE(b[1]);
STREAM_GET_BYTE(b[0]);
}
else if (stream->encoding == 1) // utf 8
{
UCHAR cur_byte;
read_next:
STREAM_GET_BYTE(cur_byte);
//Figure out the current code unit to determine the range. It is split into 6 main groups, each of which handles the data
//differently from one another.
if (cur_byte < 0x80) {
//0..127, the ASCII range.
//We directly plug in the values to the UTF-16 code unit.
*v = (wchar_t)(cur_byte);
}
else if (cur_byte < 0xC0) {
//0x80..0xBF, we ignore. These are reserved for UTF-8 encoding.
goto read_next;
}
else if (cur_byte < 0xE0) {
//128..2047, the extended ASCII range, and into the Basic Multilingual Plane.
//Work on the first code unit.
wchar_t highShort = (wchar_t)(cur_byte & 0x1F);
//Increment the current code unit pointer to the next code unit
STREAM_GET_BYTE(cur_byte);
//Work on the second code unit.
wchar_t lowShort = (wchar_t)(cur_byte & 0x3F);
//Create the UTF-16 code unit, then increment the iterator
int unicode = (highShort << 8) | lowShort;
//Check to make sure the "unicode" is in the range [0..D7FF] and [E000..FFFF].
if ((0 <= unicode && unicode <= 0xD7FF) || (0xE000 <= unicode && unicode <= 0xFFFF)) {
//Directly set the value to the UTF-16 code unit.
*v = (wchar_t)unicode;
}
}
else if (cur_byte < 0xF0) {
//2048..65535, the remaining Basic Multilingual Plane.
//Work on the UTF-8 code units one by one.
//If drawn out, it would be 1110aaaa 10bbbbcc 10ccdddd
//Where a is 4th byte, b is 3rd byte, c is 2nd byte, and d is 1st byte.
wchar_t fourthChar = (wchar_t)(cur_byte & 0xF);
STREAM_GET_BYTE(cur_byte);
wchar_t thirdChar = (wchar_t)(cur_byte & 0x3C) >> 2;
wchar_t secondCharHigh = (wchar_t)(cur_byte & 0x3);
STREAM_GET_BYTE(cur_byte);
wchar_t secondCharLow = (wchar_t)(cur_byte & 0x30) >> 4;
wchar_t firstChar = (wchar_t)(cur_byte & 0xF);
//Create the resulting UTF-16 code unit, then increment the iterator.
int unicode = (fourthChar << 12) | (thirdChar << 8) | (secondCharHigh << 6) | (secondCharLow << 4) | firstChar;
//Check to make sure the "unicode" is in the range [0..D7FF] and [E000..FFFF].
//According to math, UTF-8 encoded "unicode" should always fall within these two ranges.
if ((0 <= unicode && unicode <= 0xD7FF) || (0xE000 <= unicode && unicode <= 0xFFFF)) {
//Directly set the value to the UTF-16 code unit.
*v = (wchar_t)unicode;
}
}
else if (cur_byte < 0xF8) {
//65536..10FFFF, the Unicode UTF range
//Work on the UTF-8 code units one by one.
//If drawn out, it would be 11110abb 10bbcccc 10ddddee 10eeffff
//Where a is 6th byte, b is 5th byte, c is 4th byte, and so on.
wchar_t sixthChar = (wchar_t)(cur_byte & 0x4) >> 2;
wchar_t fifthCharHigh = (wchar_t)(cur_byte & 0x3);
STREAM_GET_BYTE(cur_byte);
wchar_t fifthCharLow = (wchar_t)(cur_byte & 0x30) >> 4;
wchar_t fourthChar = (wchar_t)(cur_byte & 0xF);
STREAM_GET_BYTE(cur_byte);
wchar_t thirdChar = (wchar_t)(cur_byte & 0x3C) >> 2;
wchar_t secondCharHigh = (wchar_t)(cur_byte & 0x3);
STREAM_GET_BYTE(cur_byte);
wchar_t secondCharLow = (wchar_t)(cur_byte & 0x30) >> 4;
wchar_t firstChar = (wchar_t)(cur_byte & 0xF);
int unicode = (sixthChar << 4) | (fifthCharHigh << 2) | fifthCharLow | (fourthChar << 12) | (thirdChar << 8) | (secondCharHigh << 6) | (secondCharLow << 4) | firstChar;
wchar_t highSurrogate = (unicode - 0x10000) / 0x400 + 0xD800;
wchar_t lowSurrogate = (unicode - 0x10000) % 0x400 + 0xDC00;
//Set the UTF-16 code units
//*v1 = lowSurrogate;
//*v2 = highSurrogate;
*v = L'_';
}
else {
goto read_next;
}
}
else
return STATUS_INVALID_PARAMETER;
return STATUS_SUCCESS;
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -83,6 +84,14 @@ NTSTATUS Stream_Write_Long(
IN STREAM *stream,
IN ULONG v);
NTSTATUS Stream_Read_BOM(
IN STREAM* stream,
ULONG* encoding);
NTSTATUS Stream_Read_Wchar(
IN STREAM* stream,
OUT USHORT* v);
//---------------------------------------------------------------------------
#endif // _MY_STREAM_H

View File

@ -94,6 +94,7 @@
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<CompileAs>Default</CompileAs>
<OmitFramePointers />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>ntdll.lib;uuid.lib;kernel32.lib</AdditionalDependencies>
@ -113,6 +114,7 @@
<Optimization>Disabled</Optimization>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>ntdll.lib;uuid.lib;kernel32.lib</AdditionalDependencies>
@ -133,6 +135,7 @@
<CompileAs>Default</CompileAs>
<OmitFramePointers />
<Optimization>MaxSpeed</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>ntdll.lib;uuid.lib;kernel32.lib</AdditionalDependencies>
@ -151,6 +154,7 @@
<ClCompile>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>ntdll.lib;uuid.lib;kernel32.lib</AdditionalDependencies>
@ -182,6 +186,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\common\stream.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="acscmonitor.c" />
<ClCompile Include="advapi.c">
<ShowIncludes Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">false</ShowIncludes>
@ -191,6 +201,7 @@
</ClCompile>
<ClCompile Include="callsvc.c" />
<ClCompile Include="com.c" />
<ClCompile Include="config.c" />
<ClCompile Include="cred.c" />
<ClCompile Include="crypt.c" />
<ClCompile Include="custom.c" />
@ -225,6 +236,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="file_copy.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="file_pipe.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
@ -350,7 +367,9 @@
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\common\pattern.h" />
<ClInclude Include="..\..\common\pool.h" />
<ClInclude Include="..\..\common\stream.h" />
<ClInclude Include="advapi.h" />
<ClInclude Include="debug.h" />
<ClInclude Include="dll.h" />

View File

@ -173,6 +173,13 @@
<ClCompile Include="rpcrt.c">
<Filter>ipc</Filter>
</ClCompile>
<ClCompile Include="..\..\common\stream.c">
<Filter>common</Filter>
</ClCompile>
<ClCompile Include="config.c" />
<ClCompile Include="file_copy.c">
<Filter>file</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="advapi.h" />
@ -215,6 +222,12 @@
<Filter>com</Filter>
</ClInclude>
<ClInclude Include="trace.h" />
<ClInclude Include="..\..\common\stream.h">
<Filter>common</Filter>
</ClInclude>
<ClInclude Include="..\..\common\pattern.h">
<Filter>common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc" />

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

331
Sandboxie/core/dll/config.c Normal file
View File

@ -0,0 +1,331 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
// Config
//---------------------------------------------------------------------------
#define NOGDI
#include "dll.h"
#include "common/pool.h"
#include "common\pattern.h"
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Variables
//---------------------------------------------------------------------------
extern POOL* Dll_Pool;
extern POOL* Dll_PoolTemp;
static BOOLEAN Config_MatchImageGroup(
const WCHAR* group, ULONG group_len, const WCHAR* test_str,
ULONG depth);
static BOOLEAN Config_MatchImage(
const WCHAR* pat_str, ULONG pat_len, const WCHAR* test_str,
ULONG depth);
//---------------------------------------------------------------------------
// Config_MatchImage
//---------------------------------------------------------------------------
_FX BOOLEAN Config_MatchImage(
const WCHAR* pat_str, ULONG pat_len, const WCHAR* test_str,
ULONG depth)
{
PATTERN* pat;
WCHAR* tmp;
ULONG tmp_len;
BOOLEAN ok;
//
// if pat_len was specified, we should create the match pattern
// using only the first pat_len characters of pat_str
//
if (pat_len) {
tmp_len = (pat_len + 1) * sizeof(WCHAR);
tmp = Dll_AllocTemp(tmp_len);
if (!tmp)
return FALSE;
wcsncpy(tmp, pat_str, pat_len);
tmp[pat_len] = L'\0';
pat = Pattern_Create(Dll_PoolTemp, tmp, TRUE);
Dll_Free(tmp);
}
else {
pat = Pattern_Create(Dll_PoolTemp, pat_str, TRUE);
}
if (!pat)
return FALSE;
//
//
//
if (*pat_str == L'<') {
ok = Config_MatchImageGroup(
Pattern_Source(pat), 0, test_str, depth + 1);
Pattern_Free(pat);
return ok;
}
//
// create a lower-case copy of test_str
//
ok = FALSE;
tmp_len = (wcslen(test_str) + 1) * sizeof(WCHAR);
tmp = Dll_AllocTemp(tmp_len);
if (tmp) {
memcpy(tmp, test_str, tmp_len);
_wcslwr(tmp);
ok = Pattern_Match(pat, tmp, wcslen(tmp));
Dll_Free(tmp);
}
Pattern_Free(pat);
return ok;
}
//---------------------------------------------------------------------------
// Config_MatchImageGroup
//---------------------------------------------------------------------------
_FX BOOLEAN Config_MatchImageGroup(
const WCHAR* group, ULONG group_len, const WCHAR* test_str,
ULONG depth)
{
ULONG index;
BOOLEAN match = FALSE;
WCHAR conf_buf[2048];
if (!group_len)
group_len = wcslen(group);
for (index = 0; (!match); ++index) {
//
// get next process group setting, compare to passed group name.
// if the setting is <passed_group_name>= then we accept it.
//
NTSTATUS status = SbieApi_QueryConf(
NULL, L"ProcessGroup", index, conf_buf, sizeof(conf_buf) - 16 * sizeof(WCHAR));
if (!NT_SUCCESS(status))
break;
ULONG value_len;
const WCHAR* value = conf_buf;
value_len = wcslen(value);
if (value_len <= group_len + 1)
continue;
if (_wcsnicmp(value, group, group_len) != 0)
continue;
value += group_len;
if (*value != L',')
continue;
++value;
//
// value now points at the comma-separated
// list of processes in this process group
//
while (*value) {
WCHAR* ptr = wcschr(value, L',');
if (ptr)
value_len = (ULONG)(ULONG_PTR)(ptr - value);
else
value_len = wcslen(value);
if (value_len) {
if (*value != L'<') {
match = Config_MatchImage(
value, value_len, test_str, depth + 1);
}
else if (depth < 6) {
match = Config_MatchImageGroup(
value, value_len, test_str, depth + 1);
}
if (match)
break;
}
value += value_len;
while (*value == L',')
++value;
}
}
return match;
}
//---------------------------------------------------------------------------
// Config_MatchImageAndGetValue
//---------------------------------------------------------------------------
_FX WCHAR* Config_MatchImageAndGetValue(WCHAR* value)
{
ULONG image_len = (wcslen(Dll_ImageName) + 1) * sizeof(WCHAR);
WCHAR* image_lwr = Dll_AllocTemp(image_len);
if (!image_lwr) {
SbieApi_Log(2305, NULL);
return NULL;
}
memcpy(image_lwr, Dll_ImageName, image_len);
_wcslwr(image_lwr);
//image_len = wcslen(image_lwr);
//
// if the setting indicates an image name followed by a comma,
// then match the image name against the executing process.
//
WCHAR* tmp = wcschr(value, L',');
if (tmp) {
BOOLEAN inv, match;
//
// exclamation marks negates the matching
//
if (*value == L'!') {
inv = TRUE;
++value;
}
else
inv = FALSE;
ULONG len = (ULONG)(tmp - value);
if (len) {
match = Config_MatchImage(value, len, image_lwr, 1);
if (inv)
match = !match;
if (!match)
tmp = NULL;
}
value = tmp ? tmp + 1 : NULL;
}
Dll_Free(image_lwr);
return value;
}
//---------------------------------------------------------------------------
// Config_InitPatternList
//---------------------------------------------------------------------------
_FX BOOLEAN Config_InitPatternList(const WCHAR* setting, LIST* list)
{
WCHAR conf_buf[2048];
PATTERN* pat;
ULONG index = 0;
while (1) {
NTSTATUS status = SbieApi_QueryConf(
NULL, setting, index, conf_buf, sizeof(conf_buf) - 16 * sizeof(WCHAR));
if (!NT_SUCCESS(status))
break;
++index;
WCHAR* value = Config_MatchImageAndGetValue(conf_buf);
if (value)
{
pat = Pattern_Create(Dll_Pool, value, TRUE);
List_Insert_After(list, NULL, pat);
}
}
return TRUE;
}
//---------------------------------------------------------------------------
// Config_GetSettingsForImageName
//---------------------------------------------------------------------------
_FX NTSTATUS Config_GetSettingsForImageName(
const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext)
{
WCHAR conf_buf[2048];
WCHAR* found_value = NULL;
ULONG index = 0;
while (1) {
NTSTATUS status = SbieApi_QueryConf(
NULL, setting, index, conf_buf, sizeof(conf_buf) - 16 * sizeof(WCHAR));
if (!NT_SUCCESS(status))
break;
++index;
WCHAR* value = Config_MatchImageAndGetValue(conf_buf);
if (!value)
continue;
if (found_value) {
SbieApi_Log(2302, L"%S - %S [%S]", setting, Dll_ImageName, Dll_BoxName);
break;
}
found_value = value;
}
if (found_value) wcscpy_s(value, value_size / sizeof(WCHAR), found_value);
else if (deftext) wcscpy_s(value, value_size / sizeof(WCHAR), deftext);
else value[0] = L'\0';
return STATUS_SUCCESS;
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -371,6 +371,8 @@ NTSTATUS Dll_GetCurrentSidString(UNICODE_STRING *SidString);
// Functions (dllhook)
//---------------------------------------------------------------------------
NTSTATUS Dll_GetSettingsForImageName(
const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext);
BOOLEAN Dll_SkipHook(const WCHAR *HookName);
@ -733,6 +735,20 @@ BOOLEAN DigitalGuardian_Init(HMODULE);
BOOLEAN ComDlg32_Init(HMODULE);
//---------------------------------------------------------------------------
// Functions (Config)
//---------------------------------------------------------------------------
WCHAR* Config_MatchImageAndGetValue(WCHAR* value);
BOOLEAN Config_InitPatternList(const WCHAR* setting, LIST* list);
NTSTATUS Config_GetSettingsForImageName(
const WCHAR* setting, WCHAR* value, ULONG value_size, const WCHAR* deftext);
//---------------------------------------------------------------------------

View File

@ -37,9 +37,6 @@
static void *SbieDll_Hook_CheckChromeHook(void *SourceFunc);
static WCHAR *Dll_GetSettingsForImageName(
const WCHAR *setting, const WCHAR *deftext);
ULONG_PTR DLL_FindWow64Target(ULONG_PTR address);
//---------------------------------------------------------------------------
@ -585,13 +582,14 @@ _FX void *SbieDll_Hook_CheckChromeHook(void *SourceFunc)
//---------------------------------------------------------------------------
_FX WCHAR *Dll_GetSettingsForImageName(
const WCHAR *setting, const WCHAR *deftext)
_FX NTSTATUS Dll_GetSettingsForImageName(
const WCHAR *setting, WCHAR* value, ULONG value_size, const WCHAR *deftext)
{
POOL *pool;
WCHAR *text, *image_lwr, *buf;
ULONG text_len, image_len;
ULONG index;
BOOLEAN match = FALSE;
//
//
@ -648,8 +646,10 @@ _FX WCHAR *Dll_GetSettingsForImageName(
++index;
ptr = wcschr(buf, L',');
if (! ptr)
continue;
if (!ptr) {
ptr = buf;
goto skip_match; // if there is no L',' it means any image
}
*ptr = L'\0';
if (buf[0] == L'/' && buf[1] == L'/' &&
@ -663,42 +663,51 @@ _FX WCHAR *Dll_GetSettingsForImageName(
image_pat = Pattern_Create(pool, buf_ptr, TRUE);
if (Pattern_Match(image_pat, image_lwr, image_len)) {
match = TRUE;
}
Pattern_Free(image_pat);
if (!match)
continue;
if (text_len)
*ptr = L','; // restore comma if text is not empty
else
++ptr; // or skip comma if text is empty
skip_match:
{
ULONG ptr_len;
WCHAR *new_text;
if (text_len)
*ptr = L','; // restore comma if text is not empty
else
++ptr; // or skip comma if text is empty
WCHAR* new_text;
ptr_len = wcslen(ptr);
new_text = Pool_Alloc(pool,
(text_len + ptr_len + 1) * sizeof(WCHAR));
if (! new_text)
(text_len + ptr_len + 1) * sizeof(WCHAR));
if (!new_text)
goto outofmem;
wmemcpy(new_text, text, text_len);
wmemcpy(new_text + text_len, ptr, ptr_len + 1);
text = new_text;
text_len = text_len + ptr_len;
}
Pattern_Free(image_pat);
break;
}
//
// finish
//
buf = Dll_Alloc((text_len + 1) * sizeof(WCHAR));
wmemcpy(buf, text, text_len + 1);
wcscpy_s(value, value_size / sizeof(WCHAR), text);
Pool_Delete(pool);
return buf;
return STATUS_SUCCESS;
outofmem:
SbieApi_Log(2305, NULL);
ExitProcess(-1);
return NULL;
return STATUS_INSUFFICIENT_RESOURCES;
}
@ -709,37 +718,26 @@ outofmem:
_FX BOOLEAN Dll_SkipHook(const WCHAR *HookName)
{
static WCHAR *HookText = NULL;
static WCHAR HookText[256];
static BOOLEAN HookTextInit = TRUE;
BOOLEAN found = FALSE;
//
// initialize hook text based on image name
//
if (! HookName) {
if (HookTextInit) {
const WCHAR *deftext = NULL;
HookTextInit = FALSE;
if (_wcsicmp(Dll_ImageName, L"DragonSaga.exe") == 0)
deftext = L"ntqsi,enumwin,findwin";
if (_wcsicmp(Dll_ImageName, L"BatmanAC.exe") == 0)
deftext = L"enumwin,findwin";
if (_wcsicmp(Dll_ImageName, L"PotPlayer64.exe") == 0 ||
_wcsicmp(Dll_ImageName, L"PotPlayerMini64.exe") == 0 ||
_wcsicmp(Dll_ImageName, L"mpc-hc64.exe") == 0) {
deftext = L"cocreate";
}
HookText = Dll_GetSettingsForImageName(L"SkipHook", deftext);
Dll_GetSettingsForImageName(L"SkipHook", HookText, sizeof(HookText), NULL);
}
//
// query for a specific hook
//
} else if (HookText) {
if (HookName && *HookText) {
ULONG len = wcslen(HookName);
WCHAR *ptr = HookText;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -554,7 +554,12 @@ _FX void Dll_SelectImageType(void)
L"dllhost.exe", (WCHAR *)DLL_IMAGE_DLLHOST,
L"iexplore.exe", (WCHAR *)DLL_IMAGE_INTERNET_EXPLORER,
L"firefox.exe", (WCHAR *)DLL_IMAGE_MOZILLA_FIREFOX,
L"waterfox.exe", (WCHAR *)DLL_IMAGE_MOZILLA_FIREFOX,
L"palemoon.exe", (WCHAR *)DLL_IMAGE_MOZILLA_FIREFOX,
L"basilisk.exe", (WCHAR *)DLL_IMAGE_MOZILLA_FIREFOX,
L"brave.exe", (WCHAR *)DLL_IMAGE_MOZILLA_FIREFOX,
L"wmplayer.exe", (WCHAR *)DLL_IMAGE_WINDOWS_MEDIA_PLAYER,
L"winamp.exe", (WCHAR *)DLL_IMAGE_NULLSOFT_WINAMP,

View File

@ -47,9 +47,9 @@ static void *Dll_AllocFromPool(POOL *pool, ULONG size);
//---------------------------------------------------------------------------
static POOL *Dll_Pool = NULL;
static POOL *Dll_PoolTemp = NULL;
static POOL *Dll_PoolCode = NULL;
POOL *Dll_Pool = NULL;
POOL *Dll_PoolTemp = NULL;
POOL *Dll_PoolCode = NULL;
static ULONG Dll_TlsIndex = TLS_OUT_OF_INDEXES;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,7 +20,7 @@
// File
//---------------------------------------------------------------------------
#define NOGDI
#include "dll.h"
#include "obj.h"
#include <stdio.h>
@ -201,9 +201,8 @@ static NTSTATUS File_MigrateFile(
const WCHAR *TruePath, const WCHAR *CopyPath,
BOOLEAN IsWritePath, BOOLEAN WithContents);
static const BOOLEAN File_MigrateFile_ManualBypass(const WCHAR *TruePath, ULONGLONG file_size);
static const WCHAR *File_MigrateFile_ShouldBypass(const WCHAR *TruePath);
static const BOOLEAN File_MigrateFile_ManualBypass(
const WCHAR *TruePath, ULONGLONG file_size);
static NTSTATUS File_CopyShortName(
const WCHAR *TruePath, const WCHAR *CopyPath);
@ -352,9 +351,6 @@ static ULONG File_PublicUserLen = 0;
static WCHAR *File_HomeNtPath = NULL;
static ULONG File_HomeNtPathLen = 0;
static ULONG File_CopyLimitKb = (80 * 1024); // 80 MB
static BOOLEAN File_CopyLimitSilent = FALSE;
static BOOLEAN File_Windows2000 = FALSE;
static WCHAR *File_AltBoxPath = NULL;
@ -375,6 +371,7 @@ static ULONG File_Snapshot_Count = 0;
#include "file_pipe.c"
#include "file_dir.c"
#include "file_misc.c"
#include "file_copy.c"
#include "file_init.c"
@ -2864,39 +2861,6 @@ ReparseLoop:
status = STATUS_SUCCESS;
}
//
// Internet Shortcuts (.url files) are consistently overwritten
// as part of their usage. If the shortcut exists only as a
// TruePath, then we pretend it's a read-only file
//
// apply similar handling to media files
//
if (FileType & TYPE_FILE) {
WCHAR *dot = wcsrchr(TruePath, L'.');
if (dot) {
static const WCHAR *_ReadOnlyFileTypes =
L".url.avi.wma.wmv.mpg.mp3.mp4";
const WCHAR *ptr = _ReadOnlyFileTypes;
WCHAR dot1 = towlower(dot[1]);
WCHAR dot2 = towlower(dot[2]);
WCHAR dot3 = towlower(dot[3]);
while (*ptr) {
if (dot1 == ptr[1] && dot2 == ptr[2] && dot3 == ptr[3]) {
FileType |= TYPE_READ_ONLY | TYPE_SYSTEM;
break;
}
ptr += 4;
}
}
}
//
// we don't have CopyPath, but if we did find TruePath, and this
// is a read-only operation, then let the system handle it
@ -3158,34 +3122,6 @@ ReparseLoop:
}
}
if (WithContents) {
//
// don't copy contents of Windows Explorer thumbcache
// (note that name was chaged to iconcache on Windows 8)
//
WCHAR *dot = wcsrchr(TruePath, L'.');
if (dot && _wcsicmp(dot + 1, L"db") == 0) {
WCHAR *ptr;
ULONG len = wcslen(TruePath) + 1;
WCHAR *TempPath = Dll_AllocTemp(len * sizeof(WCHAR));
wmemcpy(TempPath, TruePath, len);
_wcslwr(TempPath);
ptr = wcsstr(TempPath,
L"\\microsoft\\windows\\explorer\\");
if (ptr && ( wcsncmp(ptr + 28, L"thumbcache_", 11) == 0
|| wcsncmp(ptr + 28, L"iconcache_", 10) == 0)) {
WithContents = FALSE;
}
Dll_Free(TempPath);
}
}
} else {
WithContents = FALSE;
@ -3990,296 +3926,6 @@ _FX NTSTATUS File_CreatePath(WCHAR *TruePath, WCHAR *CopyPath)
}
//---------------------------------------------------------------------------
// File_MigrateFile
//---------------------------------------------------------------------------
_FX NTSTATUS File_MigrateFile(
const WCHAR *TruePath, const WCHAR *CopyPath,
BOOLEAN IsWritePath, BOOLEAN WithContents)
{
NTSTATUS status;
HANDLE TrueHandle, CopyHandle;
OBJECT_ATTRIBUTES objattrs;
UNICODE_STRING objname;
IO_STATUS_BLOCK IoStatusBlock;
FILE_NETWORK_OPEN_INFORMATION open_info;
ULONGLONG file_size;
ACCESS_MASK DesiredAccess;
ULONG CreateOptions;
InitializeObjectAttributes(
&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, Secure_NormalSD);
//
// open TruePath. if we get a sharing violation trying to open it,
// try to get the driver to open it bypassing share access. if even
// this fails, then we can't copy the data, but can still create an
// empty file
//
RtlInitUnicodeString(&objname, TruePath);
status = __sys_NtCreateFile(
&TrueHandle, FILE_GENERIC_READ, &objattrs, &IoStatusBlock,
NULL, 0, FILE_SHARE_VALID_FLAGS,
FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
if (IsWritePath && status == STATUS_ACCESS_DENIED)
status = STATUS_SHARING_VIOLATION;
if (status == STATUS_SHARING_VIOLATION) {
status = SbieApi_OpenFile(&TrueHandle, TruePath);
if (! NT_SUCCESS(status)) {
WithContents = FALSE;
status = __sys_NtCreateFile(
&TrueHandle, FILE_READ_ATTRIBUTES | SYNCHRONIZE,
&objattrs, &IoStatusBlock, NULL, 0, FILE_SHARE_VALID_FLAGS,
FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
}
}
if (! NT_SUCCESS(status))
return status;
//
// query attributes and size of the TruePath file
//
status = __sys_NtQueryInformationFile(
TrueHandle, &IoStatusBlock, &open_info,
sizeof(FILE_NETWORK_OPEN_INFORMATION), FileNetworkOpenInformation);
if (! NT_SUCCESS(status)) {
NtClose(TrueHandle);
return status;
}
if (WithContents) {
static BOOLEAN _ReinitCopyLimit = FALSE;
if (_ReinitCopyLimit) {
_ReinitCopyLimit = FALSE;
File_InitCopyLimit();
}
file_size = open_info.EndOfFile.QuadPart;
if (File_CopyLimitKb != -1 && file_size > (File_CopyLimitKb * 1024)) {
const WCHAR *TruePathName =
File_MigrateFile_ShouldBypass(TruePath);
if (TruePathName && !File_MigrateFile_ManualBypass(TruePath, file_size)) {
NtClose(TrueHandle);
if (! File_CopyLimitSilent) {
ULONG TruePathNameLen = wcslen(TruePathName);
WCHAR *text = Dll_AllocTemp(
(TruePathNameLen + 64) * sizeof(WCHAR));
Sbie_snwprintf(text, (TruePathNameLen + 64), L"%s [%s / %I64u]",
TruePathName, Dll_BoxName, file_size);
SbieApi_Log(2102, text);
Dll_Free(text);
_ReinitCopyLimit = TRUE;
}
return STATUS_BAD_INITIAL_PC;
}
}
} else
file_size = 0;
//
// create the CopyPath file
//
RtlInitUnicodeString(&objname, CopyPath);
if (open_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
DesiredAccess = FILE_GENERIC_READ;
CreateOptions = FILE_DIRECTORY_FILE;
} else {
DesiredAccess = FILE_GENERIC_WRITE;
CreateOptions = FILE_NON_DIRECTORY_FILE;
}
status = __sys_NtCreateFile(
&CopyHandle, DesiredAccess, &objattrs, &IoStatusBlock,
NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_VALID_FLAGS,
FILE_CREATE, FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions,
NULL, 0);
if (! NT_SUCCESS(status)) {
NtClose(TrueHandle);
return status;
}
//
// copy the file, if so desired
//
if (file_size) {
ULONG Next_Status = GetTickCount() + 3000; // wait 3 seconds
void *buffer = Dll_AllocTemp(PAGE_SIZE);
if (! buffer) {
status = STATUS_INSUFFICIENT_RESOURCES;
file_size = 0;
}
while (file_size > 0) {
ULONG buffer_size =
(file_size > PAGE_SIZE) ? PAGE_SIZE : (ULONG)file_size;
status = NtReadFile(
TrueHandle, NULL, NULL, NULL, &IoStatusBlock,
buffer, buffer_size, NULL, NULL);
if (NT_SUCCESS(status)) {
buffer_size = (ULONG)IoStatusBlock.Information;
file_size -= (ULONGLONG)buffer_size;
status = NtWriteFile(
CopyHandle, NULL, NULL, NULL, &IoStatusBlock,
buffer, buffer_size, NULL, NULL);
}
if (! NT_SUCCESS(status))
break;
ULONG Cur_Ticks = GetTickCount();
if (Next_Status < Cur_Ticks) {
Next_Status = Cur_Ticks + 1000; // update prgress every second
WCHAR size_str[32];
Sbie_snwprintf(size_str, 32, L"%I64u", file_size);
const WCHAR* strings[] = { Dll_BoxName, TruePath, size_str, NULL };
SbieApi_LogMsgExt(2198, strings);
}
}
if (buffer)
Dll_Free(buffer);
}
//
// set the short name on the file. we must do this before we copy
// its attributes, as this may make the file read-only
//
if (NT_SUCCESS(status)) {
status = File_CopyShortName(TruePath, CopyPath);
if (IsWritePath && status == STATUS_ACCESS_DENIED)
status = STATUS_SUCCESS;
}
//
// set information on the CopyPath file
//
if (NT_SUCCESS(status)) {
FILE_BASIC_INFORMATION info;
info.CreationTime.QuadPart = open_info.CreationTime.QuadPart;
info.LastAccessTime.QuadPart = open_info.LastAccessTime.QuadPart;
info.LastWriteTime.QuadPart = open_info.LastWriteTime.QuadPart;
info.ChangeTime.QuadPart = open_info.ChangeTime.QuadPart;
info.FileAttributes = open_info.FileAttributes;
status = File_SetAttributes(CopyHandle, CopyPath, &info);
}
NtClose(TrueHandle);
NtClose(CopyHandle);
return status;
}
//---------------------------------------------------------------------------
// File_MigrateFile_ManualBypass
//---------------------------------------------------------------------------
_FX const BOOLEAN File_MigrateFile_ManualBypass(const WCHAR *TruePath, ULONGLONG file_size)
{
MAN_FILE_MIGRATION_REQ req;
MAN_FILE_MIGRATION_RPL *rpl = NULL;
BOOLEAN ok = FALSE;
req.msgid = MAN_FILE_MIGRATION;
req.file_size = file_size;
wcscpy(req.file_path, TruePath);
rpl = SbieDll_CallServerQueue(INTERACTIVE_QUEUE_NAME, &req, sizeof(req), sizeof(*rpl));
if (rpl)
{
ok = rpl->retval != 0;
Dll_Free(rpl);
}
return ok;
}
//---------------------------------------------------------------------------
// File_MigrateFile_ShouldBypass
//---------------------------------------------------------------------------
_FX const WCHAR *File_MigrateFile_ShouldBypass(const WCHAR *TruePath)
{
// todo: load this list from file
static const WCHAR *_names[] = {
// firefox
L"places.sqlite", L"xul.mfl",
// windows installer etc
L"qmgr0.dat", L"qmgr1.dat", L"infcache.1", L"cbs.log",
// explorer
L"thumbcache_32.db", L"thumbcache_96.db", L"thumbcache_256.db",
L"thumbcache_1024.db", L"thumbcache_idx.db", L"thumbcache_sr.db",
// internet explorer 10 web cache
L"webcachev01.dat", L"webcachev01.tmp",
L"webcachev24.dat", L"webcachev24.tmp",
// end of list
NULL
};
const WCHAR **nameptr;
const WCHAR *name = wcsrchr(TruePath, L'\\');
if (name)
++name;
else
name = TruePath;
for (nameptr = _names; *nameptr; ++nameptr)
if (_wcsicmp(name, *nameptr) == 0)
return NULL;
return name;
}
//---------------------------------------------------------------------------
// File_CopyShortName
//---------------------------------------------------------------------------

View File

@ -0,0 +1,442 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
// File (Copy)
//---------------------------------------------------------------------------
#include "common\pattern.h"
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
static void File_InitCopyLimit(void);
static BOOLEAN File_InitFileMigration(void);
//---------------------------------------------------------------------------
// Variables
//---------------------------------------------------------------------------
extern POOL* Dll_Pool;
extern POOL* Dll_PoolTemp;
typedef enum { // Note: thisorder defines the config priority
FILE_DONT_COPY,
FILE_COPY_CONTENT,
FILE_COPY_EMPTY,
NUM_COPY_MODES
} ENUM_COPY_MODES;
static LIST File_MigrationOptions[NUM_COPY_MODES];
static BOOLEAN File_MigrationDenyWrite = FALSE;
static ULONG File_CopyLimitKb = (80 * 1024); // 80 MB
static BOOLEAN File_CopyLimitSilent = FALSE;
//---------------------------------------------------------------------------
// File_InitFileMigration
//---------------------------------------------------------------------------
_FX BOOLEAN File_InitFileMigration(void)
{
//File_PathPool = Pool_Create();
//if (!File_PathPool) {
// SbieApi_Log(2305, NULL);
// return FALSE;
//}
for(ULONG i=0; i < NUM_COPY_MODES; i++)
List_Init(&File_MigrationOptions[i]);
Config_InitPatternList(L"CopyEmpty", &File_MigrationOptions[FILE_COPY_EMPTY]);
Config_InitPatternList(L"CopyAlways", &File_MigrationOptions[FILE_COPY_CONTENT]);
Config_InitPatternList(L"DontCopy", &File_MigrationOptions[FILE_DONT_COPY]);
WCHAR conf[16];
Config_GetSettingsForImageName(L"CopyBlockDenyWrite", conf, sizeof(conf), NULL);
if (*conf == L'y' || *conf == L'Y')
File_MigrationDenyWrite = TRUE;
File_InitCopyLimit();
return TRUE;
}
//---------------------------------------------------------------------------
// File_MigrateFile_GetMode
//---------------------------------------------------------------------------
_FX ULONG File_MigrateFile_GetMode(const WCHAR* TruePath, ULONGLONG file_size)
{
ULONG mode = NUM_COPY_MODES;
ULONG path_len = (wcslen(TruePath) + 1) * sizeof(WCHAR);
WCHAR* path_lwr = Dll_AllocTemp(path_len);
if (!path_lwr) {
SbieApi_Log(2305, NULL);
return FILE_DONT_COPY;
}
memcpy(path_lwr, TruePath, path_len);
_wcslwr(path_lwr);
path_len = wcslen(path_lwr);
//
// Check what preset applyes to this file type/path
//
for (ULONG i = 0; i < NUM_COPY_MODES; i++)
{
PATTERN* pat = List_Head(&File_MigrationOptions[i]);
while (pat)
{
if (Pattern_Match(pat, path_lwr, path_len))
{
mode = i;
goto found_match;
}
pat = List_Next(pat);
}
}
found_match:
Dll_Free(path_lwr);
if (mode != NUM_COPY_MODES)
return mode;
//
// if tere is no configuration for this file type/path decide based on the file size
//
if (File_CopyLimitKb == -1 || file_size < (File_CopyLimitKb * 1024))
return FILE_COPY_CONTENT;
//
// ask the user to decide if the large file should be coped into the sandbox
//
MAN_FILE_MIGRATION_REQ req;
MAN_FILE_MIGRATION_RPL* rpl = NULL;
BOOLEAN ok = FALSE;
req.msgid = MAN_FILE_MIGRATION;
req.file_size = file_size;
wcscpy(req.file_path, TruePath);
rpl = SbieDll_CallServerQueue(INTERACTIVE_QUEUE_NAME, &req, sizeof(req), sizeof(*rpl));
if (rpl)
{
ok = rpl->retval != 0;
Dll_Free(rpl);
if(ok)
return FILE_COPY_CONTENT;
}
//
// issue apropriate message if so configured, and user wasn't asked
//
else if (!File_CopyLimitSilent)
{
const WCHAR* name = wcsrchr(TruePath, L'\\');
if (name)
++name;
else
name = TruePath;
ULONG TruePathNameLen = wcslen(name);
WCHAR* text = Dll_AllocTemp(
(TruePathNameLen + 64) * sizeof(WCHAR));
Sbie_snwprintf(text, (TruePathNameLen + 64), L"%s [%s / %I64u]",
name, Dll_BoxName, file_size);
SbieApi_Log(2102, text);
Dll_Free(text);
}
return FILE_DONT_COPY;
}
//---------------------------------------------------------------------------
// File_InitCopyLimit
//---------------------------------------------------------------------------
_FX void File_InitCopyLimit(void)
{
static const WCHAR* _CopyLimitKb = L"CopyLimitKb";
static const WCHAR* _CopyLimitSilent = L"CopyLimitSilent";
NTSTATUS status;
WCHAR str[32];
//
// if this is one of SandboxieCrypto, SandboxieWUAU or WUAUCLT,
// or TrustedInstaller, then we don't impose a CopyLimit
//
BOOLEAN SetMaxCopyLimit = FALSE;
if (Dll_ImageType == DLL_IMAGE_SANDBOXIE_CRYPTO ||
Dll_ImageType == DLL_IMAGE_SANDBOXIE_WUAU ||
Dll_ImageType == DLL_IMAGE_WUAUCLT ||
Dll_ImageType == DLL_IMAGE_TRUSTED_INSTALLER) {
SetMaxCopyLimit = TRUE;
}
if (SetMaxCopyLimit) {
File_CopyLimitKb = -1;
File_CopyLimitSilent = FALSE;
return;
}
//
// get configuration settings for CopyLimitKb and CopyLimitSilent
//
status = SbieApi_QueryConfAsIs(
NULL, _CopyLimitKb, 0, str, sizeof(str) - sizeof(WCHAR));
if (NT_SUCCESS(status)) {
ULONGLONG num = _wtoi64(str);
if (num)
File_CopyLimitKb = (num > 0x000000007fffffff) ? -1 : (ULONG)num;
else
SbieApi_Log(2207, _CopyLimitKb);
}
File_CopyLimitSilent =
SbieApi_QueryConfBool(NULL, _CopyLimitSilent, FALSE);
}
//---------------------------------------------------------------------------
// File_MigrateFile
//---------------------------------------------------------------------------
_FX NTSTATUS File_MigrateFile(
const WCHAR* TruePath, const WCHAR* CopyPath,
BOOLEAN IsWritePath, BOOLEAN WithContents)
{
NTSTATUS status;
HANDLE TrueHandle, CopyHandle;
OBJECT_ATTRIBUTES objattrs;
UNICODE_STRING objname;
IO_STATUS_BLOCK IoStatusBlock;
FILE_NETWORK_OPEN_INFORMATION open_info;
ULONGLONG file_size;
ACCESS_MASK DesiredAccess;
ULONG CreateOptions;
InitializeObjectAttributes(
&objattrs, &objname, OBJ_CASE_INSENSITIVE, NULL, Secure_NormalSD);
//
// open TruePath. if we get a sharing violation trying to open it,
// try to get the driver to open it bypassing share access. if even
// this fails, then we can't copy the data, but can still create an
// empty file
//
RtlInitUnicodeString(&objname, TruePath);
status = __sys_NtCreateFile(
&TrueHandle, FILE_GENERIC_READ, &objattrs, &IoStatusBlock,
NULL, 0, FILE_SHARE_VALID_FLAGS,
FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
if (IsWritePath && status == STATUS_ACCESS_DENIED)
status = STATUS_SHARING_VIOLATION;
if (status == STATUS_SHARING_VIOLATION) {
status = SbieApi_OpenFile(&TrueHandle, TruePath);
if (!NT_SUCCESS(status)) {
WithContents = FALSE;
status = __sys_NtCreateFile(
&TrueHandle, FILE_READ_ATTRIBUTES | SYNCHRONIZE,
&objattrs, &IoStatusBlock, NULL, 0, FILE_SHARE_VALID_FLAGS,
FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
}
}
if (!NT_SUCCESS(status))
return status;
//
// query attributes and size of the TruePath file
//
status = __sys_NtQueryInformationFile(
TrueHandle, &IoStatusBlock, &open_info,
sizeof(FILE_NETWORK_OPEN_INFORMATION), FileNetworkOpenInformation);
if (!NT_SUCCESS(status)) {
NtClose(TrueHandle);
return status;
}
if (WithContents) {
file_size = open_info.EndOfFile.QuadPart;
ULONG mode = File_MigrateFile_GetMode(TruePath, file_size);
if (mode == FILE_COPY_EMPTY)
file_size = 0;
else if (mode == FILE_DONT_COPY)
{
NtClose(TrueHandle);
if (File_MigrationDenyWrite)
return STATUS_ACCESS_DENIED;
else
return STATUS_BAD_INITIAL_PC;
}
}
else
file_size = 0;
//
// create the CopyPath file
//
RtlInitUnicodeString(&objname, CopyPath);
if (open_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
DesiredAccess = FILE_GENERIC_READ;
CreateOptions = FILE_DIRECTORY_FILE;
}
else {
DesiredAccess = FILE_GENERIC_WRITE;
CreateOptions = FILE_NON_DIRECTORY_FILE;
}
status = __sys_NtCreateFile(
&CopyHandle, DesiredAccess, &objattrs, &IoStatusBlock,
NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_VALID_FLAGS,
FILE_CREATE, FILE_SYNCHRONOUS_IO_NONALERT | CreateOptions,
NULL, 0);
if (!NT_SUCCESS(status)) {
NtClose(TrueHandle);
return status;
}
//
// copy the file, if so desired
//
if (file_size) {
ULONG Next_Status = GetTickCount() + 3000; // wait 3 seconds
void* buffer = Dll_AllocTemp(PAGE_SIZE);
if (!buffer) {
status = STATUS_INSUFFICIENT_RESOURCES;
file_size = 0;
}
while (file_size > 0) {
ULONG buffer_size =
(file_size > PAGE_SIZE) ? PAGE_SIZE : (ULONG)file_size;
status = NtReadFile(
TrueHandle, NULL, NULL, NULL, &IoStatusBlock,
buffer, buffer_size, NULL, NULL);
if (NT_SUCCESS(status)) {
buffer_size = (ULONG)IoStatusBlock.Information;
file_size -= (ULONGLONG)buffer_size;
status = NtWriteFile(
CopyHandle, NULL, NULL, NULL, &IoStatusBlock,
buffer, buffer_size, NULL, NULL);
}
if (!NT_SUCCESS(status))
break;
ULONG Cur_Ticks = GetTickCount();
if (Next_Status < Cur_Ticks) {
Next_Status = Cur_Ticks + 1000; // update prgress every second
WCHAR size_str[32];
Sbie_snwprintf(size_str, 32, L"%I64u", file_size);
const WCHAR* strings[] = { Dll_BoxName, TruePath, size_str, NULL };
SbieApi_LogMsgExt(2198, strings);
}
}
if (buffer)
Dll_Free(buffer);
}
//
// set the short name on the file. we must do this before we copy
// its attributes, as this may make the file read-only
//
if (NT_SUCCESS(status)) {
status = File_CopyShortName(TruePath, CopyPath);
if (IsWritePath && status == STATUS_ACCESS_DENIED)
status = STATUS_SUCCESS;
}
//
// set information on the CopyPath file
//
if (NT_SUCCESS(status)) {
FILE_BASIC_INFORMATION info;
info.CreationTime.QuadPart = open_info.CreationTime.QuadPart;
info.LastAccessTime.QuadPart = open_info.LastAccessTime.QuadPart;
info.LastWriteTime.QuadPart = open_info.LastWriteTime.QuadPart;
info.ChangeTime.QuadPart = open_info.ChangeTime.QuadPart;
info.FileAttributes = open_info.FileAttributes;
status = File_SetAttributes(CopyHandle, CopyPath, &info);
}
NtClose(TrueHandle);
NtClose(CopyHandle);
return status;
}

View File

@ -106,8 +106,6 @@ static WCHAR *File_AllocAndInitEnvironment_2(
static void File_AdjustDrives(
ULONG path_drive_index, BOOLEAN subst, const WCHAR *path);
static void File_InitCopyLimit(void);
static void File_InitSnapshots(void);
@ -156,7 +154,7 @@ _FX BOOLEAN File_Init(void)
File_InitRecoverFolders();
File_InitCopyLimit();
File_InitFileMigration();
//
// intercept NTDLL entry points
@ -1489,59 +1487,6 @@ _FX WCHAR *File_AllocAndInitEnvironment_2(
}
//---------------------------------------------------------------------------
// File_InitCopyLimit
//---------------------------------------------------------------------------
_FX void File_InitCopyLimit(void)
{
static const WCHAR *_CopyLimitKb = L"CopyLimitKb";
static const WCHAR *_CopyLimitSilent = L"CopyLimitSilent";
NTSTATUS status;
WCHAR str[32];
//
// if this is one of SandboxieCrypto, SandboxieWUAU or WUAUCLT,
// or TrustedInstaller, then we don't impose a CopyLimit
//
BOOLEAN SetMaxCopyLimit = FALSE;
if (Dll_ImageType == DLL_IMAGE_SANDBOXIE_CRYPTO ||
Dll_ImageType == DLL_IMAGE_SANDBOXIE_WUAU ||
Dll_ImageType == DLL_IMAGE_WUAUCLT ||
Dll_ImageType == DLL_IMAGE_TRUSTED_INSTALLER) {
SetMaxCopyLimit = TRUE;
}
if (SetMaxCopyLimit) {
File_CopyLimitKb = -1;
File_CopyLimitSilent = FALSE;
return;
}
//
// get configuration settings for CopyLimitKb and CopyLimitSilent
//
status = SbieApi_QueryConfAsIs(
NULL, _CopyLimitKb, 0, str, sizeof(str) - sizeof(WCHAR));
if (NT_SUCCESS(status)) {
ULONGLONG num = _wtoi64(str);
if (num)
File_CopyLimitKb = (num > 0x000000007fffffff) ? -1 : (ULONG)num;
else
SbieApi_Log(2207, _CopyLimitKb);
}
File_CopyLimitSilent =
SbieApi_QueryConfBool(NULL, _CopyLimitSilent, FALSE);
}
//---------------------------------------------------------------------------
// File_TranslateDosToNtPath
//---------------------------------------------------------------------------
@ -1750,11 +1695,10 @@ _FX void File_GetSetDeviceMap(WCHAR *DeviceMap96)
//---------------------------------------------------------------------------
// File_InitCopyLimit
// File_InitSnapshots
//---------------------------------------------------------------------------
/* CRC */
// CRC
#define CRC_WITH_ADLERTZUK64
#include "common/crc.c"

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -370,11 +370,12 @@ _FX BOOLEAN Ipc_Init(void)
Ipc_CreateObjects();
if (Dll_OsBuild >= 9600)
g_Ipc_DynamicPortNames[SPOOLER_PORT] = Dll_Alloc(DYNAMIC_PORT_NAME_CHARS * sizeof(WCHAR));
g_Ipc_DynamicPortNames[SPOOLER_PORT] = Dll_Alloc(DYNAMIC_PORT_NAME_CHARS * sizeof(WCHAR));
g_Ipc_DynamicPortNames[WPAD_PORT] = Dll_Alloc(DYNAMIC_PORT_NAME_CHARS * sizeof(WCHAR));
g_Ipc_DynamicPortNames[SMART_CARD_PORT] = Dll_Alloc(DYNAMIC_PORT_NAME_CHARS * sizeof(WCHAR));
g_Ipc_DynamicPortNames[BT_PORT] = Dll_Alloc(DYNAMIC_PORT_NAME_CHARS * sizeof(WCHAR));
g_Ipc_DynamicPortNames[GAME_CONFIG_STORE_PORT] = Dll_Alloc(DYNAMIC_PORT_NAME_CHARS * sizeof(WCHAR));
return TRUE;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -280,8 +281,9 @@ IEnumPStoreTypesImpl::~IEnumPStoreTypesImpl(void)
// IEnumPStoreTypesImpl::StringFromGUID
//---------------------------------------------------------------------------
void IEnumPStoreTypesImpl::StringFromGUID(const GUID *guid, WCHAR *str)
extern "C"
{
void Sbie_StringFromGUID(const GUID* guid, WCHAR* str)
{
struct _s {
ULONG a;
@ -301,7 +303,7 @@ void IEnumPStoreTypesImpl::StringFromGUID(const GUID *guid, WCHAR *str)
s->x1, s->x2,
s->y1, s->y2, s->y3, s->y4, s->y5, s->y6);
}
}
//---------------------------------------------------------------------------
// IEnumPStoreTypesImpl::InsertSorted
@ -312,11 +314,11 @@ void IEnumPStoreTypesImpl::InsertSorted(GUID *guid)
{
WCHAR guidL[48], guidR[48];
StringFromGUID(guid, guidR);
Sbie_StringFromGUID(guid, guidR);
IEnumPStoreListElem *elem =
(IEnumPStoreListElem *)List_Head(&m_list->list);
while (elem) {
StringFromGUID(&elem->v.guid, guidL);
Sbie_StringFromGUID(&elem->v.guid, guidL);
int c = wcscmp(guidL, guidR);
if (c == 0)
return;

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -80,8 +81,6 @@ protected:
IEnumPStoreTypesImpl(const IEnumPStoreTypesImpl *model);
~IEnumPStoreTypesImpl();
void StringFromGUID(const GUID *guid, WCHAR *str);
void InsertSorted(GUID *guid);
// IUnknown
@ -158,3 +157,4 @@ protected:
IEnumPStoreItems **ppenum);
};

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -56,6 +57,24 @@ void *Scm_QueryServiceByName(
ULONG with_service_status, ULONG with_service_config);
int Scm_Start_Sppsvc();
#ifdef _WIN64
extern ULONG_PTR __cdecl RpcRt_NdrClientCall3(
MIDL_STUBLESS_PROXY_INFO* pProxyInfo, ULONG nProcNum, void* pReturnValue, ...);
#else
//extern ULONG_PTR __cdecl RpcRt_NdrClientCall3(
// MIDL_STUBLESS_PROXY_INFO* pProxyInfo, ULONG nProcNum, void* pReturnValue, ULONG_PTR* Args);
extern ULONG_PTR __cdecl RpcRt_NdrClientCall2(
PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ULONG_PTR* Args);
#endif _WIN64
//---------------------------------------------------------------------------
@ -91,6 +110,17 @@ typedef RPC_STATUS(RPC_ENTRY *P_RpcStringFreeW)(RPC_WSTR *String);
typedef RPC_STATUS (*P_RpcMgmtSetComTimeout)(RPC_BINDING_HANDLE Binding, unsigned int __RPC_FAR Timeout);
typedef BOOL(WINAPI* P_GetModuleInformation)(_In_ HANDLE hProcess, _In_ HMODULE hModule, _Out_ LPMODULEINFO lpmodinfo, _In_ DWORD cb);
typedef ULONG_PTR(__cdecl* P_NdrClientCall3)(
MIDL_STUBLESS_PROXY_INFO* pProxyInfo, ULONG nProcNum, void* pReturnValue, ...);
typedef ULONG_PTR(__cdecl* P_NdrClientCall2)(
PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...);
//---------------------------------------------------------------------------
P_RpcStringBindingComposeW __sys_RpcStringBindingComposeW = NULL;
P_RpcBindingInqAuthClientEx __sys_RpcBindingInqAuthClientEx = NULL;
@ -108,12 +138,17 @@ P_UuidToStringW __sys_UuidToStringW = NULL;
P_RpcStringFreeW __sys_RpcStringFreeW = NULL;
extern WCHAR *g_Ipc_DynamicPortNames[NUM_DYNAMIC_PORTS];
typedef BOOL (WINAPI *P_GetModuleInformation)(_In_ HANDLE hProcess, _In_ HMODULE hModule, _Out_ LPMODULEINFO lpmodinfo, _In_ DWORD cb);
P_GetModuleInformation __sys_GetModuleInformation = NULL;
#ifdef _WIN64
P_NdrClientCall3 __sys_NdrClientCall3 = NULL;
#else
P_NdrClientCall2 __sys_NdrClientCall2 = NULL;
#endif
extern WCHAR* g_Ipc_DynamicPortNames[NUM_DYNAMIC_PORTS];
//---------------------------------------------------------------------------
// RpcRt_Init
//---------------------------------------------------------------------------
@ -156,6 +191,24 @@ _FX BOOLEAN RpcRt_Init(HMODULE module)
__sys_RpcMgmtSetComTimeout = (P_RpcMgmtSetComTimeout)Ldr_GetProcAddrNew(DllName_rpcrt4, L"RpcMgmtSetComTimeout", "RpcMgmtSetComTimeout");
}
WCHAR wsTraceOptions[4];
if (SbieApi_QueryConf(NULL, L"IpcTrace", 0, wsTraceOptions, sizeof(wsTraceOptions)) == STATUS_SUCCESS && wsTraceOptions[0] != L'\0')
{
#ifdef _WIN64
P_NdrClientCall3 NdrClientCall3;
NdrClientCall3 = (P_NdrClientCall3)Ldr_GetProcAddrNew(DllName_rpcrt4, L"NdrClientCall3", "NdrClientCall3");
SBIEDLL_HOOK(RpcRt_, NdrClientCall3);
#else
P_NdrClientCall2 NdrClientCall2;
NdrClientCall2 = (P_NdrClientCall2)Ldr_GetProcAddrNew(DllName_rpcrt4, L"NdrClientCall2", "NdrClientCall2");
SBIEDLL_HOOK(RpcRt_, NdrClientCall2);
#endif
}
return Secure_Init_Elevation(module);
}
@ -352,35 +405,47 @@ _FX ULONG RpcRt_RpcBindingFromStringBindingW(
WCHAR* pwszTempPortName = GetDynamicLpcPortName(SPOOLER_PORT);
if (pwszTempPortName) {
if (pwszTempPortName == NULL)
return RPC_S_ACCESS_DENIED;
wcscpy(wstrPortName, L"ncalrpc:[");
wcscpy(wstrPortName + 9, pwszTempPortName);
wcscat(wstrPortName, _old + 9);
}
wcscpy(wstrPortName, L"ncalrpc:[");
wcscpy(wstrPortName + 9, pwszTempPortName);
wcscat(wstrPortName, _old + 9);
}
}
// WPAD (Windows Proxy Auto Discovery) uses dynamic RPC endpoints starting in Win 10 Anniv.
else if (_wcsicmp(StringBinding, L"ncalrpc:") == 0) {
WCHAR pwszEmpty[] = L"";
WCHAR* pwszTempPortName = pwszEmpty;
ULONG_PTR hWinHttp = (ULONG_PTR)GetModuleHandle(L"WinHttp.dll");
ULONG_PTR hBtApi = (ULONG_PTR)GetModuleHandle(L"BluetoothApis.dll");
ULONG_PTR pRetAddr = (ULONG_PTR)_ReturnAddress();
if (RpcRt_TestCallingModule(pRetAddr, hWinHttp)) {
if (RpcRt_TestCallingModule(pRetAddr, hWinHttp))
{
// WPAD (Windows Proxy Auto Discovery) uses dynamic RPC endpoints starting in Win 10 Anniv.
pwszTempPortName = GetDynamicLpcPortName(WPAD_PORT);
}
else if (RpcRt_TestCallingModule(pRetAddr, hBtApi))
{
// Bluetooth support service
pwszTempPortName = GetDynamicLpcPortName(BT_PORT);
}
WCHAR* pwszTempPortName = GetDynamicLpcPortName(WPAD_PORT);
if (pwszTempPortName != pwszEmpty) {
if (pwszTempPortName) {
if (pwszTempPortName == NULL)
return RPC_S_ACCESS_DENIED;
wcscpy(wstrPortName, L"ncalrpc:[");
wcscpy(wstrPortName + 9, pwszTempPortName);
wcscat(wstrPortName, L"]");
}
wcscpy(wstrPortName, L"ncalrpc:[");
wcscpy(wstrPortName + 9, pwszTempPortName);
wcscat(wstrPortName, L"]");
}
}
RPC_STATUS status;
status = __sys_RpcBindingFromStringBindingW(*wstrPortName ? wstrPortName : StringBinding, OutBinding);
// If there are any IpcTrace options set, then output this debug string
@ -396,7 +461,7 @@ _FX ULONG RpcRt_RpcBindingFromStringBindingW(
//OutputDebugString(msg);
SbieApi_MonitorPut2(MONITOR_IPC | MONITOR_TRACE, msg, FALSE);
}
__sys_RpcMgmtSetComTimeout(*OutBinding, RPC_C_BINDING_TIMEOUT);
//__sys_RpcMgmtSetComTimeout(*OutBinding, RPC_C_BINDING_TIMEOUT); // this breaks things
return status;
}
@ -460,7 +525,7 @@ _FX RPC_STATUS RpcRt_RpcBindingCreateW(
//OutputDebugString(msg);
SbieApi_MonitorPut2(MONITOR_IPC | MONITOR_TRACE, msg, FALSE);
}
__sys_RpcMgmtSetComTimeout(*Binding, RPC_C_BINDING_TIMEOUT);
//__sys_RpcMgmtSetComTimeout(*Binding, RPC_C_BINDING_TIMEOUT); // this breaks things
return status;
}
@ -483,3 +548,62 @@ RPC_STATUS RPC_ENTRY RpcRt_RpcStringBindingComposeW(TCHAR *ObjUuid,TCHAR *ProtSe
}
return __sys_RpcStringBindingComposeW(ObjUuid,ProtSeq,NetworkAddr,EndPoint,Options,StringBinding);
}
void Sbie_StringFromGUID(const GUID* guid, WCHAR* str);
#ifdef _WIN64
ULONG_PTR RpcRt_NdrClientCall3_x64(
MIDL_STUBLESS_PROXY_INFO* pProxyInfo, ULONG nProcNum, void* pReturnValue, va_list vl
)
{
void* ReturnAddress = (void*)*(__int64*)(vl - (4 * 8));
__try
{
PRPC_CLIENT_INTERFACE rpcInterface = (PRPC_CLIENT_INTERFACE)pProxyInfo->pStubDesc->RpcInterfaceInformation;
WCHAR interfaceID[48];
Sbie_StringFromGUID(&rpcInterface->InterfaceId.SyntaxGUID, interfaceID);
WCHAR text[130];
Sbie_snwprintf(text, 130, L"Calling NdrClientCall3 for interface %s}, %d.%d", interfaceID,
rpcInterface->InterfaceId.SyntaxVersion.MajorVersion, rpcInterface->InterfaceId.SyntaxVersion.MinorVersion);
SbieApi_MonitorPut2(MONITOR_IPC | MONITOR_TRACE, text, FALSE);
}
__except (EXCEPTION_EXECUTE_HANDLER) {}
return FALSE; // return TRUE to not call the trampoline upon return
}
#else
ULONG_PTR __cdecl RpcRt_NdrClientCall2_x86(
void* ReturnAddress,
PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...)
{
//va_list vl;
//va_start(vl, pFormat);
__try
{
PRPC_CLIENT_INTERFACE rpcInterface = (PRPC_CLIENT_INTERFACE)pStubDescriptor->RpcInterfaceInformation;
WCHAR interfaceID[48];
Sbie_StringFromGUID(&rpcInterface->InterfaceId.SyntaxGUID, interfaceID);
WCHAR text[130];
Sbie_snwprintf(text, 130, L"Calling NdrClientCall2 for interface %s}, %d.%d", interfaceID,
rpcInterface->InterfaceId.SyntaxVersion.MajorVersion, rpcInterface->InterfaceId.SyntaxVersion.MinorVersion);
SbieApi_MonitorPut2(MONITOR_IPC | MONITOR_TRACE, text, FALSE);
}
__except (EXCEPTION_EXECUTE_HANDLER) {}
//va_end(vl);
return FALSE; // return TRUE to not call the trampoline upon return
}
#endif _WIN64

View File

@ -1285,9 +1285,9 @@ _FX BOOLEAN SbieApi_QueryConfBool(
*value = L'\0';
SbieApi_QueryConfAsIs(
section_name, setting_name, 0, value, sizeof(value));
if (*value == 'y' || *value == 'Y')
if (*value == L'y' || *value == L'Y')
return TRUE;
if (*value == 'n' || *value == 'N')
if (*value == L'n' || *value == L'N')
return FALSE;
return def;
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -222,3 +222,31 @@ l04: dec esp
Gui_MsgWaitForMultipleObjects@20 ENDP
PUBLIC C Gui_MsgWaitForMultipleObjects@20
;----------------------------------------------------------------------------
; RpcRt_NdrClientCall2
;----------------------------------------------------------------------------
EXTERN C RpcRt_NdrClientCall2_x86 : PROC
;EXTERN C RpcRt_NdrClientCall2_... : PROC
EXTERN C __sys_NdrClientCall2 : DWORD
RpcRt_NdrClientCall2 PROC C PUBLIC
call RpcRt_NdrClientCall2_x86
test al,al
jnz CancelCall
jmp dword ptr [__sys_NdrClientCall2]
CancelCall:
; jmp RpcRt_NdrClientCall2_...
ret
RpcRt_NdrClientCall2 ENDP
PUBLIC C RpcRt_NdrClientCall2

View File

@ -189,3 +189,55 @@ l01: mov eax,dword ptr [rdx]
l02: ret
Gui_FixupCallbackPointers ENDP
;----------------------------------------------------------------------------
; RpcRt_NdrClientCall3
;----------------------------------------------------------------------------
EXTERN RpcRt_NdrClientCall3_x64 : PROC
;EXTERN RpcRt_NdrClientCall3_... : PROC
EXTERN __sys_NdrClientCall3 : QWORD
RpcRt_NdrClientCall3 PROC
mov rax,rsp
mov [rax+1*8],rcx ; spill pProxyInfo
mov [rax+2*8],rdx ; spill nProcNum
mov [rax+3*8],r8 ; spill pReturnValue
mov [rax+4*8],r9 ; spill first variadic parameter
sub rsp,8+(4*8)
;; xor rcx,rcx ; clear pProxyInfo
;; xor rdx,rdx ; clear nProcNum
;; xor r8,r8 ; clear pReturnValue
; mov r8,[rsp + 8+(4*8)] ; return poitner
lea r9,[rsp + 8+(4*8) + 4*8] ; Args
call RpcRt_NdrClientCall3_x64
test al,al
jnz CancelCall
lea rax,[rsp+8+(4*8)]
mov rcx,[rax+1*8] ; restore pProxyInfo
mov rdx,[rax+2*8] ; restore nProcNum
mov r8,[rax+3*8] ; restore pReturnValue
mov r9,[rax+4*8] ; restore first variadic parameter
add rsp,8+(4*8)
jmp [__sys_NdrClientCall3]
CancelCall:
;;; xor rcx,rcx ; clear pProxyInfo
;;; xor rdx,rdx ; clear nProcNum
;;; xor r8,r8 ; clear pReturnValue
;; mov r8,[rsp + 8+(4*8)] ; return poitner
; lea r9,[rsp + 8+(4*8) + 4*8] ; Args
; call RpcRt_NdrClientCall3_...
add rsp,8+(4*8)
ret
RpcRt_NdrClientCall3 ENDP

View File

@ -109,6 +109,7 @@
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<PreprocessorDefinitions>POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Native</SubSystem>
@ -140,6 +141,7 @@
</DisableSpecificWarnings>
<AdditionalOptions>/Wv:18 %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Native</SubSystem>
@ -179,6 +181,7 @@
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<PreprocessorDefinitions>POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Native</SubSystem>
@ -208,6 +211,7 @@
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<PreprocessorDefinitions>POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Native</SubSystem>
@ -255,6 +259,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\common\stream.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\dll\hook_inst.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>
@ -419,6 +429,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\..\common\stream.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\dll\hook.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieRelease|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='SbieDebug|Win32'">true</ExcludedFromBuild>

View File

@ -115,6 +115,9 @@
<ClCompile Include="syscall_open.c">
<Filter>syscall</Filter>
</ClCompile>
<ClCompile Include="..\..\common\stream.c">
<Filter>common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="api.h" />
@ -172,6 +175,9 @@
<ClInclude Include="syscall.h">
<Filter>syscall</Filter>
</ClInclude>
<ClInclude Include="..\..\common\stream.h">
<Filter>common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="aulldvrm.asm" />

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -51,6 +51,7 @@ typedef struct _CONF_DATA {
POOL *pool;
LIST sections; // CONF_SECTION
BOOLEAN home; // TRUE if configuration read from Driver_Home_Path
ULONG encoding; // 0 - unicode, 1 - utf8, 2 - unicode (byte swaped)
volatile ULONG use_count;
} CONF_DATA;
@ -140,6 +141,9 @@ static const WCHAR *Conf_Template = L"Template";
static const WCHAR *Conf_H = L"H";
static const WCHAR *Conf_W = L"W";
static const WCHAR* Conf_Unicode = L"U";
static const WCHAR* Conf_UTF8 = L"8";
//---------------------------------------------------------------------------
// Conf_AdjustUseCount
@ -249,6 +253,8 @@ _FX NTSTATUS Conf_Read(ULONG session_id)
data.home = path_home;
data.use_count = 0;
status = Stream_Read_BOM(stream, &data.encoding);
linenum = 1;
while (NT_SUCCESS(status))
status = Conf_Read_Sections(stream, &data, &linenum);
@ -277,6 +283,8 @@ _FX NTSTATUS Conf_Read(ULONG session_id)
} else {
status = Stream_Read_BOM(stream, NULL);
linenum = 1 + CONF_TMPL_LINE_BASE;
while (NT_SUCCESS(status))
@ -581,7 +589,7 @@ _FX NTSTATUS Conf_Read_Line(STREAM *stream, WCHAR *line, int *linenum)
// skip leading control and whitespace characters
while (1) {
status = Stream_Read_Short(stream, &ch);
status = Stream_Read_Wchar(stream, &ch);
if ((! NT_SUCCESS(status)) || (ch > 32 && ch < 0xFE00))
break;
if (ch == L'\r')
@ -609,7 +617,7 @@ _FX NTSTATUS Conf_Read_Line(STREAM *stream, WCHAR *line, int *linenum)
if (ptr - line == CONF_LINE_LEN)
status = STATUS_BUFFER_OVERFLOW;
else
status = Stream_Read_Short(stream, &ch);
status = Stream_Read_Wchar(stream, &ch);
if ((! NT_SUCCESS(status)) || ch == L'\n' || ch == L'\r')
break;
}
@ -1060,11 +1068,20 @@ _FX const WCHAR *Conf_Get(
_wcsicmp(setting, L"IniLocation") == 0) {
// return "H" if configuration file was found in the Sandboxie
// home directory, or "S" if it was found in Windows directory
// home directory, or "W" if it was found in Windows directory
value = (Conf_Data.home) ? Conf_H : Conf_W;
} else if (have_setting) {
} else if ((!have_section) && have_setting &&
_wcsicmp(setting, L"IniEncoding") == 0) {
// return "U" if configuration file was Unicode encoded,
// or "8" if it was UTF-8 encoded
value = (Conf_Data.encoding == 1) ? Conf_UTF8 : Conf_Unicode;
}
else if (have_setting) {
check_global = ((index & CONF_GET_NO_GLOBAL) == 0);
index &= 0xFFFF;
@ -1232,6 +1249,7 @@ _FX NTSTATUS Conf_Api_Reload(PROCESS *proc, ULONG64 *parms)
Conf_Data.pool = NULL;
List_Init(&Conf_Data.sections);
Conf_Data.home = FALSE;
Conf_Data.encoding = 0;
ExReleaseResourceLite(Conf_Lock);
KeLowerIrql(irql);
@ -1373,6 +1391,7 @@ _FX BOOLEAN Conf_Init(void)
Conf_Data.pool = NULL;
List_Init(&Conf_Data.sections);
Conf_Data.home = FALSE;
Conf_Data.encoding = 0;
if (! Mem_GetLockResource(&Conf_Lock, TRUE))
return FALSE;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -204,19 +204,15 @@ _FX BOOLEAN Ipc_Init(void)
Api_SetFunction(API_GET_DYNAMIC_PORT_FROM_PID, Ipc_Api_GetDynamicPortFromPid);
Api_SetFunction(API_OPEN_DYNAMIC_PORT, Ipc_Api_OpenDynamicPort);
if (Driver_OsVersion >= DRIVER_WINDOWS_81) {
if (!Mem_GetLockResource(&Ipc_Dynamic_Ports[SPOOLER_PORT].pPortLock, TRUE))
return FALSE;
}
if (Driver_OsVersion >= DRIVER_WINDOWS_10) {
if(!Mem_GetLockResource(&Ipc_Dynamic_Ports[WPAD_PORT].pPortLock, TRUE)
|| !Mem_GetLockResource(&Ipc_Dynamic_Ports[GAME_CONFIG_STORE_PORT].pPortLock, TRUE)
|| !Mem_GetLockResource(&Ipc_Dynamic_Ports[SMART_CARD_PORT].pPortLock, TRUE)
) return FALSE;
}
// prepare dynamic ports
if (!Mem_GetLockResource(&Ipc_Dynamic_Ports[WPAD_PORT].pPortLock, TRUE)
|| !Mem_GetLockResource(&Ipc_Dynamic_Ports[SMART_CARD_PORT].pPortLock, TRUE)
|| !Mem_GetLockResource(&Ipc_Dynamic_Ports[BT_PORT].pPortLock, TRUE)
// since Windows 8
|| !Mem_GetLockResource(&Ipc_Dynamic_Ports[SPOOLER_PORT].pPortLock, TRUE)
// since Windows 10
|| !Mem_GetLockResource(&Ipc_Dynamic_Ports[GAME_CONFIG_STORE_PORT].pPortLock, TRUE)
) return FALSE;
//
// finish

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -231,34 +231,13 @@ BOOLEAN UnicodeStringEndsWith(PCUNICODE_STRING pString1, PWCHAR pString2, BOOLEA
return (RtlCompareUnicodeString(&usStr, &usSearch, boolCaseInSensitive) == 0);
}
BOOLEAN DoesRegValueExist(ULONG RelativeTo, WCHAR *Path, WCHAR *ValueName)
{
NTSTATUS status;
RTL_QUERY_REGISTRY_TABLE qrt[2];
UNICODE_STRING uni;
// we don't care about the value, but we have to give it a NULL object
uni.Length = 0;
uni.MaximumLength = 0;
uni.Buffer = NULL;
memzero(qrt, sizeof(qrt));
qrt[0].Flags = RTL_QUERY_REGISTRY_REQUIRED |
RTL_QUERY_REGISTRY_DIRECT |
RTL_QUERY_REGISTRY_NOVALUE |
RTL_QUERY_REGISTRY_NOEXPAND;
qrt[0].Name = ValueName;
qrt[0].EntryContext = &uni;
qrt[0].DefaultType = REG_NONE;
status = RtlQueryRegistryValues(
RelativeTo, Path, qrt, NULL, NULL);
return (status == STATUS_SUCCESS);
WCHAR DummyBuffer[1] = {0}; // if we provide a NULL buffer this wil cause a memory pool leak someware in the kernel
UNICODE_STRING Dummy = { 0, sizeof(DummyBuffer), DummyBuffer };
return GetRegString(RelativeTo, Path, ValueName, &Dummy);
}
BOOLEAN GetRegString(ULONG RelativeTo, WCHAR *Path, WCHAR *ValueName, UNICODE_STRING* pData)
{
NTSTATUS status;

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -72,8 +73,10 @@ MSG_HEADER *EpMapperServer::EpmapperGetPortNameHandler(MSG_HEADER *msg)
const WCHAR* wstrSpooler = L"Spooler";
const WCHAR* wstrWPAD = L"WinHttpAutoProxySvc";
//const WCHAR* wstrBT = L"bthserv";
RPC_IF_ID ifidGCS = { {0x88abcbc3, 0x34EA, 0x76AE, { 0x82, 0x15, 0x76, 0x75, 0x20, 0x65, 0x5A, 0x23 }}, 0, 0 };
RPC_IF_ID ifidSmartCard = { {0xC6B5235A, 0xE413, 0x481D, { 0x9A, 0xC8, 0x31, 0x68, 0x1B, 0x1F, 0xAA, 0xF5 }}, 1, 1 };
RPC_IF_ID ifidBluetooth = { {0x2ACB9D68, 0xB434, 0x4B3E, { 0xB9, 0x66, 0xE0, 0x6B, 0x4B, 0x3A, 0x84, 0xCB }}, 1, 0 };
RPC_IF_ID ifidRequest;
const WCHAR* pwszServiceName = NULL;
@ -81,10 +84,18 @@ MSG_HEADER *EpMapperServer::EpmapperGetPortNameHandler(MSG_HEADER *msg)
{
case SPOOLER_PORT: if (SbieApi_QueryConfBool(boxname, L"ClosePrintSpooler", FALSE)) return SHORT_REPLY(E_ACCESSDENIED);
pwszServiceName = wstrSpooler; break;
case WPAD_PORT: pwszServiceName = wstrWPAD; break;
case BT_PORT: if (!SbieApi_QueryConfBool(boxname, L"OpenBluetooth", FALSE)) return SHORT_REPLY(E_ACCESSDENIED);
//pwszServiceName = wstrBT; break;
memcpy(&ifidRequest, &ifidBluetooth, sizeof(RPC_IF_ID)); break;
case GAME_CONFIG_STORE_PORT: memcpy(&ifidRequest, &ifidGCS, sizeof(RPC_IF_ID)); break;
case SMART_CARD_PORT: if (!SbieApi_QueryConfBool(boxname, L"OpenSmartCard", TRUE)) return SHORT_REPLY(E_ACCESSDENIED);
memcpy(&ifidRequest, &ifidSmartCard, sizeof(RPC_IF_ID)); break;
default: return SHORT_REPLY(E_INVALIDARG);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -97,6 +97,7 @@
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;user32.lib;Advapi32.lib;psapi.lib;Ole32.lib;crypt32.lib;Secur32.lib;Userenv.lib;Gdi32.lib;Netapi32.lib;wtsapi32.lib;rpcrt4.lib</AdditionalDependencies>
@ -112,6 +113,7 @@
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;user32.lib;Advapi32.lib;psapi.lib;Ole32.lib;crypt32.lib;Secur32.lib;Userenv.lib;Gdi32.lib;Netapi32.lib;wtsapi32.lib;rpcrt4.lib</AdditionalDependencies>
@ -126,6 +128,7 @@
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;user32.lib;Advapi32.lib;psapi.lib;Ole32.lib;crypt32.lib;Secur32.lib;Userenv.lib;Gdi32.lib;Netapi32.lib;wtsapi32.lib;rpcrt4.lib</AdditionalDependencies>
@ -140,6 +143,7 @@
<ClCompile>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>Use</PrecompiledHeader>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>SbieDll.lib;ntdll.lib;kernel32.lib;user32.lib;Advapi32.lib;psapi.lib;Ole32.lib;crypt32.lib;Secur32.lib;Userenv.lib;Gdi32.lib;Netapi32.lib;wtsapi32.lib;rpcrt4.lib</AdditionalDependencies>

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -66,7 +66,7 @@ MSG_HEADER *SbieIniServer::Handler(void *_this, MSG_HEADER *msg)
pThis->m_text = NULL;
pThis->m_text_base = NULL;
pThis->m_text_max_len = 0;
pThis->m_insertbom = FALSE;
//pThis->m_insertbom = FALSE;
MSG_HEADER *rpl = pThis->Handler2(msg);
@ -1278,8 +1278,8 @@ ULONG SbieIniServer::CallSetSetting(WCHAR *text, MSG_HEADER *msg)
bool SbieIniServer::AddText(const WCHAR *line)
{
static const WCHAR *_ByteOrderMark = L"ByteOrderMark=";
static ULONG _ByteOrderMarkLen = 0;
//static const WCHAR *_ByteOrderMark = L"ByteOrderMark=";
//static ULONG _ByteOrderMarkLen = 0;
ULONG line_len = wcslen(line);
@ -1309,13 +1309,13 @@ bool SbieIniServer::AddText(const WCHAR *line)
m_text[2] = L'\0';
m_text += 2;
if (! _ByteOrderMarkLen)
_ByteOrderMarkLen = wcslen(_ByteOrderMark);
if (_wcsnicmp(line, _ByteOrderMark, _ByteOrderMarkLen) == 0) {
const WCHAR ch = line[_ByteOrderMarkLen];
if (ch == L'y' || ch == L'Y')
m_insertbom = TRUE;
}
//if (! _ByteOrderMarkLen)
// _ByteOrderMarkLen = wcslen(_ByteOrderMark);
//if (_wcsnicmp(line, _ByteOrderMark, _ByteOrderMarkLen) == 0) {
// const WCHAR ch = line[_ByteOrderMarkLen];
// if (ch == L'y' || ch == L'Y')
// m_insertbom = TRUE;
//}
return true;
}
@ -1366,7 +1366,8 @@ bool SbieIniServer::AddCallerText(WCHAR *setting, WCHAR *value)
ULONG SbieIniServer::RefreshConf()
{
WCHAR *IniPath, *TmpPath;
if (! GetIniPath(&IniPath, &TmpPath))
BOOLEAN IsUTF8 = FALSE;
if (! GetIniPath(&IniPath, &TmpPath, NULL, &IsUTF8))
return STATUS_INSUFFICIENT_RESOURCES;
HANDLE hFile = INVALID_HANDLE_VALUE;
@ -1440,7 +1441,16 @@ ULONG SbieIniServer::RefreshConf()
goto finish;
}
if (m_insertbom) {
if (IsUTF8)
{
// UTF-8 Signature
static const UCHAR bom[3] = { 0xEF, 0xBB, 0xBF };
ULONG lenDummy;
WriteFile(hFile, bom, sizeof(bom), &lenDummy, NULL);
}
else
//if (m_insertbom)
{
// UNICODE Byte Order Mark (little endian)
static const UCHAR bom[2] = { 0xFF, 0xFE };
ULONG lenDummy;
@ -1448,9 +1458,21 @@ ULONG SbieIniServer::RefreshConf()
}
ULONG lenToWrite = wcslen(m_text_base) * sizeof(WCHAR);
char* text_utf8 = NULL;
if (IsUTF8)
{
text_utf8 = (char*)HeapAlloc(GetProcessHeap(), 0, lenToWrite + 16);
lenToWrite = WideCharToMultiByte(CP_UTF8, 0, m_text_base, lenToWrite / sizeof(WCHAR), text_utf8, lenToWrite + 16, NULL, NULL);
}
ULONG lenWritten = 0;
if (! WriteFile(hFile, m_text_base, lenToWrite, &lenWritten, NULL))
if (! WriteFile(hFile, text_utf8 ? (void*)text_utf8 : (void*)m_text_base, lenToWrite, &lenWritten, NULL))
lenWritten = -1;
if(text_utf8)
HeapFree(GetProcessHeap(), 0, text_utf8);
if (lenWritten != lenToWrite)
SbieApi_LogEx(m_session_id, 2322, L"[16 / %d]", GetLastError());
else {
@ -1500,7 +1522,7 @@ finish:
bool SbieIniServer::GetIniPath(WCHAR **IniPath, WCHAR **TmpPath,
BOOLEAN *IsHomePath)
BOOLEAN *IsHomePath, BOOLEAN* IsUTF8)
{
static const WCHAR *_ini = SANDBOXIE_INI;
WCHAR *path = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, 2048);
@ -1516,6 +1538,12 @@ bool SbieIniServer::GetIniPath(WCHAR **IniPath, WCHAR **TmpPath,
// program home directory or from the Windows directory, and
// we use that information to select the output path
if (IsUTF8 != NULL) {
LONG rc = SbieApi_QueryConfAsIs(NULL, L"IniEncoding", 0, path, 8);
if (rc == 0 && *path == L'8')
*IsUTF8 = TRUE;
}
LONG rc = SbieApi_QueryConfAsIs(NULL, L"IniLocation", 0, path, 8);
if (rc == 0 && *path == L'H') {

View File

@ -1,5 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -75,7 +76,7 @@ protected:
ULONG RefreshConf();
bool GetIniPath(WCHAR **IniPath, WCHAR **TmpPath,
BOOLEAN *IsHomePath = NULL);
BOOLEAN *IsHomePath = NULL, BOOLEAN* IsUTF8 = NULL);
bool TokenIsAdmin(HANDLE hToken);
@ -97,7 +98,7 @@ protected:
WCHAR *m_text, *m_text_base;
ULONG m_text_max_len;
WCHAR m_line[1500];
BOOLEAN m_insertbom;
//BOOLEAN m_insertbom;
BOOLEAN m_admin;
HANDLE m_hLockFile;
ULONG m_session_id;

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
/*
* Copyright 2004-2020 Sandboxie Holdings, LLC
* Copyright 2020 David Xanatos, xanasoft.com
* Copyright 2020-2021 David Xanatos, xanasoft.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

Binary file not shown.

View File

@ -77,6 +77,7 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>libucrt.lib;libvcruntime.lib;ntdll.lib;psapi.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -88,6 +89,7 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>libucrt.lib;libvcruntime.lib;ntdll.lib;psapi.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -101,6 +103,7 @@
<FunctionLevelLinking>
</FunctionLevelLinking>
<OmitFramePointers />
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>libucrt.lib;libvcruntime.lib;ntdll.lib;psapi.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>
@ -114,6 +117,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>
</FunctionLevelLinking>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>libucrt.lib;libvcruntime.lib;ntdll.lib;psapi.lib;SbieDll.lib;%(AdditionalDependencies)</AdditionalDependencies>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More