Added DLL code to prevent full-screen screenshots of processes in the sandbox.

This commit is contained in:
love-code-yeyixiao 2024-03-03 08:57:32 +08:00
parent 15c10f2963
commit 0c5446a8e4
3 changed files with 68 additions and 1 deletions

View File

@ -380,6 +380,9 @@ _FX BOOLEAN Gui_Init(HMODULE module)
Gui_UseProxyService = !Dll_CompartmentMode && !SbieApi_QueryConfBool(NULL, L"NoSandboxieDesktop", FALSE);
// NoSbieDesk END
GUI_IMPORT___(GetWindowDC)
GUI_IMPORT___(GetDC)
GUI_IMPORT___(GetDCEx)
GUI_IMPORT___(GetWindowThreadProcessId);
GUI_IMPORT___(SetThreadDesktop);
GUI_IMPORT___(SwitchDesktop);

View File

@ -412,6 +412,12 @@ typedef int (*P_LoadString)(
typedef BOOL (*P_SetProcessWindowStation)(HWINSTA hWinSta);
typedef BOOL(*P_GetWindowDC)(HWND hWnd);
typedef BOOL(*P_GetDC)(HWND hWnd);
typedef BOOL(*P_GetDCEx)(HWND hWnd,HRGN hrgnClip,DWORD flags);
typedef BOOL (*P_SetThreadDesktop)(HDESK hDesktop);
typedef BOOL (*P_SwitchDesktop)(HDESK hDesktop);
@ -534,6 +540,9 @@ extern ATOM Gui_WindowProcOldA_Atom;
#endif
#define GUI_SYS_VAR_2(nm) GUI_SYS_VAR_AW(nm,A); GUI_SYS_VAR_AW(nm,W);
GUI_SYS_VAR(GetDC)
GUI_SYS_VAR(GetDCEx)
GUI_SYS_VAR(GetWindowDC)
GUI_SYS_VAR(ClipCursor)
GUI_SYS_VAR(GetClipCursor)

View File

@ -176,7 +176,9 @@ _FX BOOLEAN Gui_InitMisc(HMODULE module)
}
SBIEDLL_HOOK_GUI(SwapMouseButton);
SBIEDLL_HOOK_GUI(SetDoubleClickTime);
SBIEDLL_HOOK_GUI(GetWindowDC)
SBIEDLL_HOOK_GUI(GetDC)
SBIEDLL_HOOK_GUI(GetDCEx)
if (Dll_OsBuild >= 6000) {
//
@ -1458,3 +1460,56 @@ _FX BOOL Gui_ImmAssociateContextEx(
return ok;
}
//---------------------------------------------------------------------------
// Gui_GetDC
//---------------------------------------------------------------------------
_FX HDC Gui_GetDC(HWND hWnd)
{
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) {
if (hWnd == NULL || hWnd == GetDesktopWindow()) {
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
ULONG_PTR pid, tid;
if (!Gui_IsSameBox(hWnd, pid, tid)) {
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
}
return __sys_GetDC(hWnd);
}
_FX HDC Gui_GetWindowDC(HWND hWnd)
{
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) {
if (hWnd == NULL || hWnd == GetDesktopWindow()) {
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
ULONG_PTR pid, tid;
if (!Gui_IsSameBox(hWnd, pid, tid)) {
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
}
return __sys_GetWindowDC(hWnd);
}
_FX HDC Gui_GetDCEx(HWND hWnd,HRGN hrgnClip,DWORD flags)
{
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) {
if (hWnd == NULL || hWnd == GetDesktopWindow()) {
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
ULONG_PTR pid, tid;
if (!Gui_IsSameBox(hWnd, pid, tid)) {
SetLastError(ERROR_ACCESS_DENIED);
return NULL;
}
}
return __sys_GetWindowDC(hWnd);
}