diff --git a/Sandboxie/core/dll/gui.c b/Sandboxie/core/dll/gui.c index 90bb5b8d..adc525cf 100644 --- a/Sandboxie/core/dll/gui.c +++ b/Sandboxie/core/dll/gui.c @@ -1374,9 +1374,13 @@ _FX HWND Gui_CreateWindowExW( else hWndParent = NULL; } - if (SbieApi_QueryConfBool(NULL, "BlockInterferenceControl", FALSE)) + + if (Gui_BlockInterferenceControl){ + if (dwExStyle & WS_EX_TOPMOST) dwExStyle = dwExStyle & ~WS_EX_TOPMOST; + } + // // create window // @@ -1480,9 +1484,11 @@ _FX HWND Gui_CreateWindowExA( else clsnm = Gui_CreateClassNameA(lpClassName); - if (SbieApi_QueryConfBool(NULL, "BlockInterferenceControl", FALSE)) + if (Gui_BlockInterferenceControl){ + if (dwExStyle & WS_EX_TOPMOST) dwExStyle = dwExStyle & ~WS_EX_TOPMOST; + } if (hWndParent && (hWndParent != HWND_MESSAGE) && (! __sys_IsWindow(hWndParent))) { @@ -1938,21 +1944,27 @@ _FX BOOL Gui_MoveWindow( SetLastError(ERROR_INVALID_WINDOW_HANDLE); return FALSE; } - if (SbieApi_QueryConfBool(NULL, L"BlockInterferenceControl", FALSE)) { - RECT rt; - typedef (*P_SystemParametersInfoA)(UINT uiAction, - UINT uiParam, - PVOID pvParam, - UINT fWinIni); - typedef (*P_GetSystemMetrics)(int nIndex); - P_SystemParametersInfoA SystemParametersInfoA = Ldr_GetProcAddrNew("user32.dll", "SystemParametersInfoA", "SystemParametersInfoA"); if (!SystemParametersInfoA) goto then; - P_GetSystemMetrics GetSystemMetrics = Ldr_GetProcAddrNew("user32.dll", "GetSystemMetrics", "GetSystemMetrics"); if (!GetSystemMetrics) goto then; - SystemParametersInfoA(SPI_GETWORKAREA, 0, &rt, 0); - int y1 = GetSystemMetrics(SM_CYSCREEN) - rt.bottom; - if (y + h > y1) - h = y1 - y-2; - } - then: + + if (Gui_BlockInterferenceControl) { + + typedef BOOL (*P_SystemParametersInfoA)(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni); + static P_SystemParametersInfoA SystemParametersInfoA = NULL; + if (!SystemParametersInfoA) SystemParametersInfoA = Ldr_GetProcAddrNew("user32.dll", "SystemParametersInfoA", "SystemParametersInfoA"); + + typedef int (*P_GetSystemMetrics)(int nIndex); + static P_GetSystemMetrics GetSystemMetrics = NULL; + if (!GetSystemMetrics) GetSystemMetrics = Ldr_GetProcAddrNew("user32.dll", "GetSystemMetrics", "GetSystemMetrics"); + + if (SystemParametersInfoA && GetSystemMetrics) { + + RECT rt; + SystemParametersInfoA(SPI_GETWORKAREA, 0, &rt, 0); + int y1 = GetSystemMetrics(SM_CYSCREEN) - rt.bottom; + if (y + h > y1) + h = y1 - y - 2; + } + } + return __sys_MoveWindow(hWnd, x, y, w, h, bRepaint); } @@ -1975,23 +1987,30 @@ _FX BOOL Gui_SetWindowPos( // // use SbieSvc GUI Proxy if hWnd is accessible but outside the sandbox // - if (SbieApi_QueryConfBool(NULL, L"BlockInterferenceControl", FALSE)) { - if (hWndInsertAfter == HWND_TOPMOST || hWndInsertAfter == HWND_TOP) - hWndInsertAfter = HWND_DESKTOP; - RECT rt; - typedef (*P_SystemParametersInfoA)(UINT uiAction, - UINT uiParam, - PVOID pvParam, - UINT fWinIni); - typedef (*P_GetSystemMetrics)(int nIndex); - P_SystemParametersInfoA SystemParametersInfoA = Ldr_GetProcAddrNew("user32.dll", "SystemParametersInfoA", "SystemParametersInfoA"); if (!SystemParametersInfoA) goto then; - P_GetSystemMetrics GetSystemMetrics = Ldr_GetProcAddrNew("user32.dll", "GetSystemMetrics", "GetSystemMetrics"); if (!GetSystemMetrics) goto then; - SystemParametersInfoA(SPI_GETWORKAREA, 0, &rt, 0); - int y1 = GetSystemMetrics(SM_CYSCREEN) - rt.bottom; - if (y+h > y1) - h = y1-y - 2; - } - then: + + if (Gui_BlockInterferenceControl) { + + if (hWndInsertAfter == HWND_TOPMOST || hWndInsertAfter == HWND_TOP) + hWndInsertAfter = HWND_DESKTOP; + + typedef BOOL (*P_SystemParametersInfoA)(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni); + static P_SystemParametersInfoA SystemParametersInfoA = NULL; + if (!SystemParametersInfoA) SystemParametersInfoA = Ldr_GetProcAddrNew("user32.dll", "SystemParametersInfoA", "SystemParametersInfoA"); + + typedef int (*P_GetSystemMetrics)(int nIndex); + static P_GetSystemMetrics GetSystemMetrics = NULL; + if (!GetSystemMetrics) GetSystemMetrics = Ldr_GetProcAddrNew("user32.dll", "GetSystemMetrics", "GetSystemMetrics"); + + if (SystemParametersInfoA && GetSystemMetrics) { + + RECT rt; + SystemParametersInfoA(SPI_GETWORKAREA, 0, &rt, 0); + int y1 = GetSystemMetrics(SM_CYSCREEN) - rt.bottom; + if (y + h > y1) + h = y1 - y - 2; + } + } + if (Gui_UseProxyService && !Gui_IsSameBox(hWnd, NULL, NULL)) { GUI_SET_WINDOW_POS_REQ req; diff --git a/Sandboxie/core/dll/gui_p.h b/Sandboxie/core/dll/gui_p.h index 2d3fcf56..03afd243 100644 --- a/Sandboxie/core/dll/gui_p.h +++ b/Sandboxie/core/dll/gui_p.h @@ -502,6 +502,8 @@ extern BOOLEAN Gui_OpenAllWinClasses; // not running in a restricted job extern BOOLEAN Gui_UseProtectScreen; extern BOOLEAN Gui_UseBlockCapture; +extern BOOLEAN Gui_BlockInterferenceControl; + extern BOOLEAN Gui_UseProxyService; extern BOOLEAN Gui_DisableTitle; diff --git a/Sandboxie/core/dll/guimisc.c b/Sandboxie/core/dll/guimisc.c index 3058d1c2..8ab172f8 100644 --- a/Sandboxie/core/dll/guimisc.c +++ b/Sandboxie/core/dll/guimisc.c @@ -171,7 +171,7 @@ static ULONG Gui_OpenClipboard_seq = -1; static HANDLE Gui_DummyInputDesktopHandle = NULL; -static BOOLEAN Gui_BlockInterferenceControl = FALSE; + BOOLEAN Gui_BlockInterferenceControl = FALSE; //--------------------------------------------------------------------------- @@ -201,10 +201,10 @@ _FX BOOLEAN Gui_InitMisc(HMODULE module) SBIEDLL_HOOK_GUI(ClipCursor); SBIEDLL_HOOK_GUI(SwapMouseButton); SBIEDLL_HOOK_GUI(SetDoubleClickTime); - SBIEDLL_HOOK_GUI(ShowCursor); - SBIEDLL_HOOK_GUI(BringWindowToTop); - SBIEDLL_HOOK_GUI(SwitchToThisWindow); - SBIEDLL_HOOK_GUI(SetActiveWindow); + SBIEDLL_HOOK_GUI(ShowCursor); + SBIEDLL_HOOK_GUI(BringWindowToTop); + SBIEDLL_HOOK_GUI(SwitchToThisWindow); + SBIEDLL_HOOK_GUI(SetActiveWindow); if (Gui_UseBlockCapture) { SBIEDLL_HOOK_GUI(GetWindowDC); @@ -1648,25 +1648,53 @@ _FX EXECUTION_STATE Gui_SetThreadExecutionState(EXECUTION_STATE esFlags) //return __sys_SetThreadExecutionState(esFlags); } -_FX int Gui_ShowCursor(BOOL bShow) { + +//--------------------------------------------------------------------------- +// Gui_ShowCursor +//--------------------------------------------------------------------------- + + +_FX int Gui_ShowCursor(BOOL bShow) +{ if (Gui_BlockInterferenceControl && !bShow) return 0; return __sys_ShowCursor(bShow); } -_FX HWND Gui_SetActiveWindow(HWND hWnd) { + +//--------------------------------------------------------------------------- +// Gui_SetActiveWindow +//--------------------------------------------------------------------------- + + +_FX HWND Gui_SetActiveWindow(HWND hWnd) +{ if (Gui_BlockInterferenceControl) return NULL; return __sys_SetActiveWindow(hWnd); } -_FX BOOL Gui_BringWindowToTop(HWND hWnd) { + +//--------------------------------------------------------------------------- +// Gui_BringWindowToTop +//--------------------------------------------------------------------------- + + +_FX BOOL Gui_BringWindowToTop(HWND hWnd) +{ if (Gui_BlockInterferenceControl) return FALSE; return __sys_BringWindowToTop(hWnd); } -_FX void Gui_SwitchToThisWindow(HWND hWnd, BOOL fAlt) { + +//--------------------------------------------------------------------------- +// Gui_SwitchToThisWindow +//--------------------------------------------------------------------------- + + +_FX void Gui_SwitchToThisWindow(HWND hWnd, BOOL fAlt) +{ if (Gui_BlockInterferenceControl) return; __sys_SwitchToThisWindow(hWnd, fAlt);