From 7e13550360a70876b8a0b5aef423c4da85d5c2e4 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Fri, 5 Apr 2024 20:35:04 +0200 Subject: [PATCH] added #3276 --- CHANGELOG.md | 5 +++++ Sandboxie/core/dll/dllmain.c | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dafcd10f..4684c045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [1.13.5 / 5.68.5] - 2024-03-?? +### Added +- added Setting all processes per box to a certain core [#3276](https://github.com/sandboxie-plus/Sandboxie/issues/3276) + - set "CpuAffinityMask=0x00000001" in the ini where 0x00000001 is a bit mask indicating which cores are to be used + - only supports cores 0-31 fore 32+ will be alwayd disabled when this option is used + ### Changed - on systems in test signing mode sandboxie will by default try outdated offsets - changed Qt5 version to Qt5.15.13 with latest security patches [#3694](https://github.com/sandboxie-plus/Sandboxie/pull/3694) (thanks LumitoLuma) diff --git a/Sandboxie/core/dll/dllmain.c b/Sandboxie/core/dll/dllmain.c index 51f1471e..a1aff870 100644 --- a/Sandboxie/core/dll/dllmain.c +++ b/Sandboxie/core/dll/dllmain.c @@ -516,6 +516,19 @@ _FX void Dll_InitInjected(void) ExitProcess(-1); } + // + // Setup soft resource restrictions + // + + WCHAR str[32]; + if (NT_SUCCESS(SbieApi_QueryConfAsIs(NULL, L"CpuAffinityMask", 0, str, sizeof(str) - sizeof(WCHAR))) && str[0] == L'0' && (str[1] == L'x' || str[1] == L'X')){ + + WCHAR* endptr; + KAFFINITY AffinityMask = wcstoul(str + 2, &endptr, 16); // note we only support core 0-31 as wcstoull is not exported by ntdll + if (AffinityMask) + NtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &AffinityMask, sizeof(KAFFINITY)); + } + Dll_InitComplete = TRUE; if (! Dll_RestrictedToken)