From 48058e1a687c15976b49f01f843eb09c2fc31fd2 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Mon, 22 Jul 2024 08:42:00 +0200 Subject: [PATCH] 1.14.5 --- CHANGELOG.md | 1 + Sandboxie/core/dll/sbieapi.c | 30 ++++++++++++++++++++++++++++++ Sandboxie/core/dll/sbieapi.h | 6 ++++++ Sandboxie/core/svc/GuiServer.cpp | 4 ++-- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 023980d0..19b32046 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - added UI options - fixed schannel error SEC_E_SECPKG_NOT_FOUND in encrypted sandboxes [#4081](https://github.com/sandboxie-plus/Sandboxie/issues/4081) - fixed The name of the sandbox is too long, causing an error in sbie2327 [#4064](https://github.com/sandboxie-plus/Sandboxie/issues/4064) +- fixed Job objects cannot be assigned memory limits greater than 4 GB [#4096](https://github.com/sandboxie-plus/Sandboxie/issues/4096) ### Changed - the certificate format can now take an explicit validity days specification, needed for gapless certificate renewal diff --git a/Sandboxie/core/dll/sbieapi.c b/Sandboxie/core/dll/sbieapi.c index 0fd0304a..66b52bc2 100644 --- a/Sandboxie/core/dll/sbieapi.c +++ b/Sandboxie/core/dll/sbieapi.c @@ -1506,6 +1506,36 @@ _FX ULONG SbieApi_QueryConfNumber( } +//--------------------------------------------------------------------------- +// SbieApi_QueryConfBool +//--------------------------------------------------------------------------- + + +_FX ULONG64 SbieApi_QueryConfNumber64( + const WCHAR *section_name, // WCHAR [66] + const WCHAR *setting_name, // WCHAR [66] + ULONG64 def) +{ + WCHAR value[64]; + *value = L'\0'; + if (!NT_SUCCESS(SbieApi_QueryConfAsIs( + section_name, setting_name, 0, value, sizeof(value))) + || *value == L'\0') // empty string + return def; + ULONG64 num = _wtoi64(value); + if (num == 0) { + WCHAR* ptr = value; + //if(*ptr == L'-') + // ptr++; + while (*ptr == L'0') + ptr++; + if(*ptr == L'\0') + return def; + } + return num; +} + + //--------------------------------------------------------------------------- // SbieApi_EnumBoxes //--------------------------------------------------------------------------- diff --git a/Sandboxie/core/dll/sbieapi.h b/Sandboxie/core/dll/sbieapi.h index 96345aed..9cf379ae 100644 --- a/Sandboxie/core/dll/sbieapi.h +++ b/Sandboxie/core/dll/sbieapi.h @@ -368,6 +368,12 @@ ULONG SbieApi_QueryConfNumber( const WCHAR *setting_name, // WCHAR [66] ULONG def); +SBIEAPI_EXPORT +ULONG64 SbieApi_QueryConfNumber64( + const WCHAR *section_name, // WCHAR [66] + const WCHAR *setting_name, // WCHAR [66] + ULONG64 def); + SBIEAPI_EXPORT LONG SbieApi_EnumBoxes( LONG index, // initialize to -1 diff --git a/Sandboxie/core/svc/GuiServer.cpp b/Sandboxie/core/svc/GuiServer.cpp index f9f7cd1e..2dbc787c 100644 --- a/Sandboxie/core/svc/GuiServer.cpp +++ b/Sandboxie/core/svc/GuiServer.cpp @@ -1096,9 +1096,9 @@ HANDLE GuiServer::GetJobObjectForAssign(const WCHAR *boxname) JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobELInfo = {0}; jobELInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_BREAKAWAY_OK | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK; - ULONG TotalMemoryLimit = SbieApi_QueryConfNumber(boxname, L"TotalMemoryLimit", 0); + SIZE_T TotalMemoryLimit = (SIZE_T)SbieApi_QueryConfNumber64(boxname, L"TotalMemoryLimit", 0); ULONG ProcessNumberLimit = SbieApi_QueryConfNumber(boxname, L"ProcessNumberLimit", 0); - ULONG ProcessMemoryLimit = SbieApi_QueryConfNumber(boxname, L"ProcessMemoryLimit", 0); + SIZE_T ProcessMemoryLimit = (SIZE_T)SbieApi_QueryConfNumber64(boxname, L"ProcessMemoryLimit", 0); if (TotalMemoryLimit != 0) { jobELInfo.JobMemoryLimit = TotalMemoryLimit; jobELInfo.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_JOB_MEMORY;