From 688889d68124798c27cad634caedc1929987d826 Mon Sep 17 00:00:00 2001 From: DavidXanatos <3890945+DavidXanatos@users.noreply.github.com> Date: Sun, 3 Mar 2024 12:06:46 +0100 Subject: [PATCH] 1.13.2 --- CHANGELOG.md | 3 ++- Sandboxie/core/dll/guimisc.c | 45 ++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 118e9748..38ae31f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - added menu entry to restart Sandman as admin [#3581](https://github.com/sandboxie-plus/Sandboxie/issues/3581) (thx Yeyixiao) -- Added the option to prevent sandboxed programs from accessing the images of the window outside the sandbox [#624](https://github.com/sandboxie-plus/Sandboxie/issues/624) [#1985](https://github.com/sandboxie-plus/Sandboxie/issues/1985) (thx Yeyixiao) +- Added the option to prevent sandboxed programs from accessing the images of the window outside the sandbox [#1985](https://github.com/sandboxie-plus/Sandboxie/issues/1985) (thx Yeyixiao) +- added option to block taking screen capture/screenshot of sandboxed processes [#624](https://github.com/sandboxie-plus/Sandboxie/issues/624) (thx Yeyixiao) - Sandman, suspend all processes [#3582](https://github.com/sandboxie-plus/Sandboxie/issues/3582) ### Fixed diff --git a/Sandboxie/core/dll/guimisc.c b/Sandboxie/core/dll/guimisc.c index b9a93a5f..ec6da314 100644 --- a/Sandboxie/core/dll/guimisc.c +++ b/Sandboxie/core/dll/guimisc.c @@ -100,9 +100,14 @@ static LONG Gui_GetRawInputDeviceInfoW( _Inout_ LPVOID pData, _Inout_ PUINT pcbSize); static HDC Gui_GetDC(HWND hWnd); + static HDC Gui_GetWindowDC(HWND hWnd); + static HDC Gui_GetDCEx(HWND hWnd, HRGN hrgnClip, DWORD flags); + static BOOL Gui_PrintWindow(HWND hwnd,HDC hdcBlt,UINT nFlags); + + //--------------------------------------------------------------------------- @@ -1466,6 +1471,7 @@ _FX BOOL Gui_ImmAssociateContextEx( return ok; } + //--------------------------------------------------------------------------- // Gui_GetDC //--------------------------------------------------------------------------- @@ -1474,12 +1480,16 @@ _FX BOOL Gui_ImmAssociateContextEx( _FX HDC Gui_GetDC(HWND hWnd) { if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { + if (hWnd == NULL || hWnd == __sys_GetDesktopWindow()) { + SetLastError(ERROR_ACCESS_DENIED); return NULL; } ULONG_PTR pid=0, tid=0; + if (!Gui_IsSameBox(hWnd, &pid, &tid)) { + SetLastError(ERROR_ACCESS_DENIED); return NULL; } @@ -1487,15 +1497,24 @@ _FX HDC Gui_GetDC(HWND hWnd) return __sys_GetDC(hWnd); } + +//--------------------------------------------------------------------------- +// Gui_GetWindowDC +//--------------------------------------------------------------------------- + + _FX HDC Gui_GetWindowDC(HWND hWnd) { if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { if (hWnd == NULL || hWnd == __sys_GetDesktopWindow()) { + SetLastError(ERROR_ACCESS_DENIED); return NULL; } ULONG_PTR pid = 0, tid = 0; + if (!Gui_IsSameBox(hWnd, &pid, &tid)) { + SetLastError(ERROR_ACCESS_DENIED); return NULL; } @@ -1503,35 +1522,51 @@ _FX HDC Gui_GetWindowDC(HWND hWnd) return __sys_GetWindowDC(hWnd); } + +//--------------------------------------------------------------------------- +// Gui_GetDCEx +//--------------------------------------------------------------------------- + + _FX HDC Gui_GetDCEx(HWND hWnd,HRGN hrgnClip,DWORD flags) { if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { + if (hWnd == NULL || hWnd == __sys_GetDesktopWindow()) { + SetLastError(ERROR_ACCESS_DENIED); return NULL; } ULONG_PTR pid = 0, tid = 0; if (!Gui_IsSameBox(hWnd, &pid, &tid)) { + SetLastError(ERROR_ACCESS_DENIED); return NULL; } } return __sys_GetWindowDC(hWnd); } -_FX BOOL Gui_PrintWindow( - HWND hwnd, - HDC hdcBlt, - UINT nFlags -) { + + +//--------------------------------------------------------------------------- +// Gui_PrintWindow +//--------------------------------------------------------------------------- + + +_FX BOOL Gui_PrintWindow(HWND hwnd, HDC hdcBlt, UINT nFlags) +{ if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { + if (hwnd == NULL || hwnd == __sys_GetDesktopWindow()) { + SetLastError(ERROR_ACCESS_DENIED); return 0; } ULONG_PTR pid = 0, tid = 0; if (!Gui_IsSameBox(hwnd, &pid, &tid)) { + SetLastError(ERROR_ACCESS_DENIED); return 0; }