This commit is contained in:
DavidXanatos 2024-03-16 18:17:56 +01:00
parent abaca776d8
commit 0da06229ea
4 changed files with 351 additions and 412 deletions

View File

@ -28,6 +28,9 @@
#include "common/my_version.h" #include "common/my_version.h"
#include <stdio.h> #include <stdio.h>
#include "common/pool.h"
#include "common/map.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Functions // Functions
@ -117,6 +120,18 @@ typedef int (*P_EnumFontFamiliesEx)(
typedef HGDIOBJ (*P_GetStockObject)(int fnObject); typedef HGDIOBJ (*P_GetStockObject)(int fnObject);
/*typedef BOOL (*P_TransparentBlt)(
HDC hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest,
HDC hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, UINT crTransparent);
typedef BOOL (*P_StretchBlt)(
HDC hdcDest, int xDest, int yDest, int wDest, int hDest,
HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop);
typedef BOOL (*P_BitBlt)(
HDC hdc, int x, int y, int cx, int cy,
HDC hdcSrc, int x1, int y1, DWORD rop);*/
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -135,6 +150,7 @@ typedef LONG (*P_DocumentProperties)(
void *__sys_GdiDllInitialize = NULL; void *__sys_GdiDllInitialize = NULL;
P_CreateDCW __sys_CreateDCW = NULL; P_CreateDCW __sys_CreateDCW = NULL;
P_CreateDCA __sys_CreateDCA = NULL;
P_GdiAddFontResourceW __sys_GdiAddFontResourceW = NULL; P_GdiAddFontResourceW __sys_GdiAddFontResourceW = NULL;
P_RemoveFontResourceExW __sys_RemoveFontResourceExW = NULL; P_RemoveFontResourceExW __sys_RemoveFontResourceExW = NULL;
P_GetFontResourceInfoW __sys_GetFontResourceInfoW = NULL; P_GetFontResourceInfoW __sys_GetFontResourceInfoW = NULL;
@ -148,11 +164,10 @@ P_GetBitmapBits __sys_GetBitmapBits = NULL;
P_DeleteObject __sys_DeleteObject = NULL; P_DeleteObject __sys_DeleteObject = NULL;
P_DeleteEnhMetaFile __sys_DeleteEnhMetaFile = NULL; P_DeleteEnhMetaFile __sys_DeleteEnhMetaFile = NULL;
P_GetStockObject __sys_GetStockObject = NULL; P_GetStockObject __sys_GetStockObject = NULL;
P_CreateDCA __sys_CreateDCA = NULL;
P_DeleteDC __sys_DeleteDC = NULL; P_DeleteDC __sys_DeleteDC = NULL;
P_BitBlt __sys_BitBlt = NULL; //P_BitBlt __sys_BitBlt = NULL;
P_StretchBlt __sys_StretchBlt = NULL; //P_StretchBlt __sys_StretchBlt = NULL;
P_TransparentBlt __sys_TransparentBlt = NULL; //P_TransparentBlt __sys_TransparentBlt = NULL;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -274,11 +289,13 @@ _FX ULONG_PTR Gdi_GdiDllInitialize_Common(
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Gui_DeleteDC // Gdi_DeleteDC
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
_FX BOOL Gui_DeleteDC(HDC hdc) { _FX BOOL Gdi_DeleteDC(HDC hdc)
{
Gdi_OnFreeDC(hdc);
return __sys_DeleteDC(hdc); return __sys_DeleteDC(hdc);
} }
@ -288,58 +305,48 @@ _FX BOOL Gui_DeleteDC(HDC hdc) {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
_FX BOOL Gui_BitBlt( //_FX BOOL Gdi_BitBlt(
HDC hdc, // HDC hdc, int x, int y, int cx, int cy,
int x, // HDC hdcSrc, int x1, int y1, DWORD rop
int y, //) {
int cx, // int ret = __sys_BitBlt(hdc, x, y, cx, cy, hdcSrc, x1, y1, rop);
int cy, // /*if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) {
HDC hdcSrc, //
int x1, // typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
int y1, // P_GetDeviceCaps GetDeviceCaps = Ldr_GetProcAddrNew(DllName_gdi32, "GetDeviceCaps", "GetDeviceCaps"); if (!GetDeviceCaps) return ret;
DWORD rop // int iWidth = GetDeviceCaps(hdc, HORZRES), iHeight = GetDeviceCaps(hdc, VERTRES);
) { // int iWidth2 = GetDeviceCaps(__sys_GetDC(NULL), HORZRES), iHeight2 = GetDeviceCaps(__sys_GetDC(NULL), VERTRES);
int ret = __sys_BitBlt(hdc, x, y, cx, cy, hdcSrc, x1, y1, rop); // if (iWidth == iWidth2 && iHeight == iHeight2) {
/*if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { // __sys_BitBlt(__sys_GetDC(NULL), x, y, cx, cy, hdcSrc, x1, y1, rop);
// }
// }*/
// return ret;
//}
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
P_GetDeviceCaps GetDeviceCaps = Ldr_GetProcAddrNew(DllName_gdi32, "GetDeviceCaps", "GetDeviceCaps"); if (!GetDeviceCaps) return ret;
int iWidth = GetDeviceCaps(hdc, HORZRES), iHeight = GetDeviceCaps(hdc, VERTRES);
int iWidth2 = GetDeviceCaps(__sys_GetDC(NULL), HORZRES), iHeight2 = GetDeviceCaps(__sys_GetDC(NULL), VERTRES);
if (iWidth == iWidth2 && iHeight == iHeight2) {
__sys_BitBlt(__sys_GetDC(NULL), x, y, cx, cy, hdcSrc, x1, y1, rop);
}
}*/
return ret;
}
_FX BOOL Gui_StretchBlt( //---------------------------------------------------------------------------
HDC hdcDest, // Gui_BitBlt
int xDest, // --------------------------------------------------------------------------
int yDest,
int wDest,
int hDest,
HDC hdcSrc,
int xSrc,
int ySrc,
int wSrc,
int hSrc,
DWORD rop
)
{
int ret = __sys_StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
/*if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) {
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
P_GetDeviceCaps GetDeviceCaps = Ldr_GetProcAddrNew(DllName_gdi32, "GetDeviceCaps", "GetDeviceCaps"); if (!GetDeviceCaps) return ret; //_FX BOOL Gdi_StretchBlt(
int iWidth = GetDeviceCaps(hdcDest, HORZRES), iHeight = GetDeviceCaps(hdcDest, VERTRES); // HDC hdcDest, int xDest, int yDest, int wDest, int hDest,
int iWidth2 = GetDeviceCaps(__sys_GetDC(NULL), HORZRES), iHeight2 = GetDeviceCaps(__sys_GetDC(NULL), VERTRES); // HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, DWORD rop
if (iWidth == iWidth2 && iHeight == iHeight2) { //)
__sys_StretchBlt(__sys_GetDC(NULL), xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop); //{
} // int ret = __sys_StretchBlt(hdcDest, xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
}*/ // /*if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) {
return ret; //
} // typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
// P_GetDeviceCaps GetDeviceCaps = Ldr_GetProcAddrNew(DllName_gdi32, "GetDeviceCaps", "GetDeviceCaps"); if (!GetDeviceCaps) return ret;
// int iWidth = GetDeviceCaps(hdcDest, HORZRES), iHeight = GetDeviceCaps(hdcDest, VERTRES);
// int iWidth2 = GetDeviceCaps(__sys_GetDC(NULL), HORZRES), iHeight2 = GetDeviceCaps(__sys_GetDC(NULL), VERTRES);
// if (iWidth == iWidth2 && iHeight == iHeight2) {
// __sys_StretchBlt(__sys_GetDC(NULL), xDest, yDest, wDest, hDest, hdcSrc, xSrc, ySrc, wSrc, hSrc, rop);
// }
// }*/
// return ret;
//}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -433,55 +440,29 @@ _FX HDC Gdi_CreateDCW2(
#endif ! _WIN64 #endif ! _WIN64
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Gui_CreateDCA // Gdi_CreateDCA
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
HBITMAP bmp2 = NULL;
_FX HDC Gui_CreateDCA(LPCSTR pwszDriver, LPCSTR pwszDevice, LPCSTR pszPort, const void* pdm) _FX HDC Gdi_CreateDCA(LPCSTR pwszDriver, LPCSTR pwszDevice, LPCSTR pszPort, const void* pdm)
{ {
HDC ret = __sys_CreateDCA(pwszDriver, pwszDevice, pszPort, pdm); HDC ret = __sys_CreateDCA(pwszDriver, pwszDevice, pszPort, pdm);
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { if (Gui_UseBlockCapture && (pwszDevice == NULL && strcmp(pwszDriver, "DISPLAY") == 0)) {
if (pwszDevice == NULL && strcmp(pwszDriver, "DISPLAY") == 0) { return Gdi_GetDummyDC(ret);
}
typedef HDC(*P_CreateCompatibleDC)(HDC hdc);
//typedef BOOL(*P_DeleteDC)(HDC hdc);
GET_WIN_API(CreateCompatibleDC, DllName_gdi32);
typedef HBITMAP (*P_CreateCompatibleBitmap)(_In_ HDC hdc, _In_ int cx, _In_ int cy);
GET_WIN_API(CreateCompatibleBitmap, DllName_gdi32);
GET_WIN_API(DeleteDC, DllName_gdi32);
typedef HGDIOBJ(*P_SelectObject)(_In_ HDC hdc, _In_ HGDIOBJ h);
GET_WIN_API(SelectObject, DllName_gdi32);
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
GET_WIN_API(GetDeviceCaps, DllName_gdi32);
int iWidth, iHeight;
HDC ret2 = CreateCompatibleDC(ret);
iWidth = GetDeviceCaps(ret, HORZRES);
iHeight = GetDeviceCaps(ret, VERTRES);
HBITMAP hBmp;
if (bmp2 == NULL)
bmp2 = CreateCompatibleBitmap(ret2, iWidth, iHeight);
hBmp = bmp2;
SelectObject(ret2, hBmp);
DeleteDC(ret);
ret = ret2;
}
}
return ret; return ret;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Gui_CreateDCW // Gdi_CreateDCW
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
_FX HDC Gui_CreateDCW(LPCWSTR pwszDriver, LPCWSTR pwszDevice, LPCWSTR pszPort, const void* pdm) _FX HDC Gdi_CreateDCW(LPCWSTR pwszDriver, LPCWSTR pwszDevice, LPCWSTR pszPort, const void* pdm)
{ {
#ifdef _WIN64 #ifdef _WIN64
HDC ret = __sys_CreateDCW(pwszDriver, pwszDevice, pszPort, pdm); HDC ret = __sys_CreateDCW(pwszDriver, pwszDevice, pszPort, pdm);
@ -489,35 +470,11 @@ _FX HDC Gui_CreateDCW(LPCWSTR pwszDriver, LPCWSTR pwszDevice, LPCWSTR pszPort,
HDC ret = Gdi_CreateDCW2((void*)pwszDriver, (void*)pwszDevice, (void*)pszPort, (void*)pdm); HDC ret = Gdi_CreateDCW2((void*)pwszDriver, (void*)pwszDevice, (void*)pszPort, (void*)pdm);
#endif // _WIN64 #endif // _WIN64
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { if (Gui_UseBlockCapture && (pwszDevice == NULL && lstrcmp(pwszDriver, L"DISPLAY") == 0)) {
if (pwszDevice == NULL && lstrcmp(pwszDriver, L"DISPLAY") == 0) { return Gdi_GetDummyDC(ret);
}
typedef HDC(*P_CreateCompatibleDC)(HDC hdc);
//typedef BOOL(*P_DeleteDC)(HDC hdc);
GET_WIN_API(CreateCompatibleDC, DllName_gdi32);
typedef HBITMAP(*P_CreateCompatibleBitmap)(_In_ HDC hdc, _In_ int cx, _In_ int cy);
GET_WIN_API(CreateCompatibleBitmap, DllName_gdi32);
GET_WIN_API(DeleteDC, DllName_gdi32);
typedef HGDIOBJ(*P_SelectObject)(_In_ HDC hdc, _In_ HGDIOBJ h);
GET_WIN_API(SelectObject, DllName_gdi32);
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
GET_WIN_API(GetDeviceCaps, DllName_gdi32);
int iWidth, iHeight;
HDC ret2 = CreateCompatibleDC(ret);
iWidth = GetDeviceCaps(ret, HORZRES);
iHeight = GetDeviceCaps(ret, VERTRES);
HBITMAP hBmp;
if (bmp2 == NULL)
bmp2 = CreateCompatibleBitmap(ret2, iWidth, iHeight);
hBmp = bmp2;
SelectObject(ret2, hBmp);
DeleteDC(ret);
ret = ret2;
}
}
return ret; return ret;
} }
@ -948,13 +905,13 @@ _FX BOOLEAN Gdi_InitZero(HMODULE module)
_FX BOOLEAN Gdi_Full_Init_impl(HMODULE module, BOOLEAN full) _FX BOOLEAN Gdi_Full_Init_impl(HMODULE module, BOOLEAN full)
{ {
P_CreateDCW CreateDCW; P_CreateDCW CreateDCW;
P_CreateDCA CreateDCA;
P_GdiAddFontResourceW GdiAddFontResourceW; P_GdiAddFontResourceW GdiAddFontResourceW;
P_RemoveFontResourceExW RemoveFontResourceExW; P_RemoveFontResourceExW RemoveFontResourceExW;
P_GetFontResourceInfoW GetFontResourceInfoW; P_GetFontResourceInfoW GetFontResourceInfoW;
P_CreateScalableFontResourceW CreateScalableFontResourceW; P_CreateScalableFontResourceW CreateScalableFontResourceW;
P_BitBlt BitBlt; //P_BitBlt BitBlt;
P_StretchBlt StretchBlt; //P_StretchBlt StretchBlt;
P_CreateDCA CreateDCA;
P_DeleteDC DeleteDC; P_DeleteDC DeleteDC;
P_EnumFontFamiliesEx EnumFontFamiliesExA; P_EnumFontFamiliesEx EnumFontFamiliesExA;
@ -963,6 +920,10 @@ _FX BOOLEAN Gdi_Full_Init_impl(HMODULE module, BOOLEAN full)
InitializeCriticalSection(&Gdi_CritSec); InitializeCriticalSection(&Gdi_CritSec);
Gui_UseBlockCapture = SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE);
if (Gui_UseBlockCapture)
Gdi_InitDCCache();
if (!Gdi_InitZero(module)) if (!Gdi_InitZero(module))
return FALSE; return FALSE;
@ -972,6 +933,9 @@ _FX BOOLEAN Gdi_Full_Init_impl(HMODULE module, BOOLEAN full)
CreateDCW = (P_CreateDCW) CreateDCW = (P_CreateDCW)
GetProcAddress(module, "CreateDCW"); GetProcAddress(module, "CreateDCW");
CreateDCA = (P_CreateDCA)
GetProcAddress(module, "CreateDCA");
GdiAddFontResourceW = (P_GdiAddFontResourceW) GdiAddFontResourceW = (P_GdiAddFontResourceW)
GetProcAddress(module, "GdiAddFontResourceW"); GetProcAddress(module, "GdiAddFontResourceW");
@ -981,18 +945,6 @@ _FX BOOLEAN Gdi_Full_Init_impl(HMODULE module, BOOLEAN full)
GetFontResourceInfoW = (P_GetFontResourceInfoW) GetFontResourceInfoW = (P_GetFontResourceInfoW)
GetProcAddress(module, "GetFontResourceInfoW"); GetProcAddress(module, "GetFontResourceInfoW");
CreateDCA = (P_CreateDCA)
GetProcAddress(module, "CreateDCA");
BitBlt = (P_BitBlt)
GetProcAddress(module, "BitBlt");
StretchBlt = (P_StretchBlt)
GetProcAddress(module, "StretchBlt");
DeleteDC = (P_DeleteDC)
GetProcAddress(module, "DeleteDC");
if (full) { if (full) {
CreateScalableFontResourceW = (P_CreateScalableFontResourceW) CreateScalableFontResourceW = (P_CreateScalableFontResourceW)
GetProcAddress(module, "CreateScalableFontResourceWImpl"); GetProcAddress(module, "CreateScalableFontResourceWImpl");
@ -1002,25 +954,37 @@ _FX BOOLEAN Gdi_Full_Init_impl(HMODULE module, BOOLEAN full)
GetProcAddress(module, "CreateScalableFontResourceW"); GetProcAddress(module, "CreateScalableFontResourceW");
} }
/*#ifndef _WIN64 if (Gui_UseBlockCapture) {
if (Dll_OsBuild >= 8400) { //BitBlt = (P_BitBlt)
// GetProcAddress(module, "BitBlt");
//StretchBlt = (P_StretchBlt)
// GetProcAddress(module, "StretchBlt");
DeleteDC = (P_DeleteDC)
GetProcAddress(module, "DeleteDC");
SBIEDLL_HOOK(Gdi_,DeleteDC);
//SBIEDLL_HOOK(Gdi_,BitBlt);
//SBIEDLL_HOOK(Gdi_,StretchBlt);
//SBIEDLL_HOOK_GdI(TransparentBlt);
SBIEDLL_HOOK(Gdi_, CreateDCA);
SBIEDLL_HOOK(Gdi_, CreateDCW);
}
#ifndef _WIN64
else if (Dll_OsBuild >= 8400) {
SBIEDLL_HOOK(Gdi_, CreateDCW); SBIEDLL_HOOK(Gdi_, CreateDCW);
} }
#endif ! _WIN64*/ #endif ! _WIN64
SBIEDLL_HOOK(Gdi_, GdiAddFontResourceW); SBIEDLL_HOOK(Gdi_, GdiAddFontResourceW);
SBIEDLL_HOOK(Gdi_, RemoveFontResourceExW); SBIEDLL_HOOK(Gdi_, RemoveFontResourceExW);
//SBIEDLL_HOOK(Gui_,DeleteDC);
//SBIEDLL_HOOK(Gui_,BitBlt);
//SBIEDLL_HOOK(Gui_,StretchBlt);
//SBIEDLL_HOOK_GUI(TransparentBlt);
SBIEDLL_HOOK(Gui_,CreateDCA);
SBIEDLL_HOOK(Gui_,CreateDCW);
if (GetFontResourceInfoW) { if (GetFontResourceInfoW) {
SBIEDLL_HOOK(Gdi_, GetFontResourceInfoW); SBIEDLL_HOOK(Gdi_, GetFontResourceInfoW);
} }
@ -1133,3 +1097,91 @@ _FX HGDIOBJ Gdi_GetStockObject(int fnObject) {
return rc; return rc;
} }
//---------------------------------------------------------------------------
// Gdi_InitDCCache
//---------------------------------------------------------------------------
extern POOL* Dll_Pool;
static HASH_MAP Gui_DCCache;
static CRITICAL_SECTION Gui_DCCache_CritSec;
typedef struct _DUMMY_DC{
HDC dc;
HBITMAP bmp;
} DUMMY_DC;
_FX VOID Gdi_InitDCCache()
{
static BOOLEAN Gui_DCCache_InitDone;
if (Gui_DCCache_InitDone)
return;
InitializeCriticalSection(&Gui_DCCache_CritSec);
map_init(&Gui_DCCache, Dll_Pool);
Gui_DCCache_InitDone = TRUE;
}
//---------------------------------------------------------------------------
// Gdi_GetDummyDC
//---------------------------------------------------------------------------
_FX HDC Gdi_GetDummyDC(HDC dc)
{
GET_WIN_API(SelectObject, DllName_gdi32);
GET_WIN_API(GetDeviceCaps, DllName_gdi32);
GET_WIN_API(CreateCompatibleBitmap, DllName_gdi32);
GET_WIN_API(CreateCompatibleDC, DllName_gdi32);
GET_WIN_API(DeleteDC, DllName_gdi32);
HDC ret = CreateCompatibleDC(dc);
int iWidth = GetDeviceCaps(dc, HORZRES);
int iHeight = GetDeviceCaps(dc, VERTRES);
HBITMAP bmp = CreateCompatibleBitmap(ret, iWidth, iHeight);
SelectObject(ret, bmp);
DeleteDC(dc);
EnterCriticalSection(&Gui_DCCache_CritSec);
DUMMY_DC* dummy = map_get(&Gui_DCCache, dc);
if (!dummy)
dummy = map_insert(&Gui_DCCache, dc, NULL, sizeof(DUMMY_DC));
dummy->dc = dc;
dummy->bmp = bmp;
LeaveCriticalSection(&Gui_DCCache_CritSec);
return ret;
}
//---------------------------------------------------------------------------
// Gdi_GetDummyDC
//---------------------------------------------------------------------------
_FX void* Gdi_OnFreeDC(HDC dc)
{
GET_WIN_API(DeleteObject, DllName_gdi32);
EnterCriticalSection(&Gui_DCCache_CritSec);
DUMMY_DC* dummy = map_get(&Gui_DCCache, dc);
if (dummy) {
DeleteObject(dummy->bmp);
map_remove(&Gui_DCCache, dc);
}
LeaveCriticalSection(&Gui_DCCache_CritSec);
return NULL;
}

View File

@ -50,168 +50,168 @@ BOOLEAN Gui_UseProxyService = TRUE;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
P_SetThreadDesktop __sys_SetThreadDesktop = NULL; P_SetThreadDesktop __sys_SetThreadDesktop = NULL;
P_SwitchDesktop __sys_SwitchDesktop = NULL; P_SwitchDesktop __sys_SwitchDesktop = NULL;
P_UserHandleGrantAccess __sys_UserHandleGrantAccess = NULL; P_UserHandleGrantAccess __sys_UserHandleGrantAccess = NULL;
P_GetFocus __sys_GetFocus = NULL; P_GetFocus __sys_GetFocus = NULL;
P_ShowWindow __sys_ShowWindow = NULL; P_ShowWindow __sys_ShowWindow = NULL;
P_ExitWindowsEx __sys_ExitWindowsEx = NULL; P_ExitWindowsEx __sys_ExitWindowsEx = NULL;
P_EndTask __sys_EndTask = NULL; P_EndTask __sys_EndTask = NULL;
P_ConsoleControl __sys_ConsoleControl = NULL; P_ConsoleControl __sys_ConsoleControl = NULL;
P_SwapMouseButton __sys_SwapMouseButton = NULL; P_SwapMouseButton __sys_SwapMouseButton = NULL;
P_SetDoubleClickTime __sys_SetDoubleClickTime = NULL; P_SetDoubleClickTime __sys_SetDoubleClickTime = NULL;
P_AnimateWindow __sys_AnimateWindow = NULL; P_AnimateWindow __sys_AnimateWindow = NULL;
P_GetClipboardFormatName __sys_GetClipboardFormatNameA = NULL; P_GetClipboardFormatName __sys_GetClipboardFormatNameA = NULL;
P_GetClipboardFormatName __sys_GetClipboardFormatNameW = NULL; P_GetClipboardFormatName __sys_GetClipboardFormatNameW = NULL;
P_RegisterClipboardFormat __sys_RegisterClipboardFormatA = NULL; P_RegisterClipboardFormat __sys_RegisterClipboardFormatA = NULL;
P_RegisterClipboardFormat __sys_RegisterClipboardFormatW = NULL; P_RegisterClipboardFormat __sys_RegisterClipboardFormatW = NULL;
P_RealGetWindowClass __sys_RealGetWindowClassA = NULL; P_RealGetWindowClass __sys_RealGetWindowClassA = NULL;
P_RealGetWindowClass __sys_RealGetWindowClassW = NULL; P_RealGetWindowClass __sys_RealGetWindowClassW = NULL;
P_GetWindowText __sys_GetWindowTextA = NULL; P_GetWindowText __sys_GetWindowTextA = NULL;
P_GetWindowText __sys_GetWindowTextW = NULL; P_GetWindowText __sys_GetWindowTextW = NULL;
P_CallWindowProc __sys_CallWindowProcA = NULL; P_CallWindowProc __sys_CallWindowProcA = NULL;
P_CallWindowProc __sys_CallWindowProcW = NULL; P_CallWindowProc __sys_CallWindowProcW = NULL;
P_CreateWindowEx __sys_CreateWindowExA = NULL; P_CreateWindowEx __sys_CreateWindowExA = NULL;
P_CreateWindowEx __sys_CreateWindowExW = NULL; P_CreateWindowEx __sys_CreateWindowExW = NULL;
P_DefWindowProc __sys_DefWindowProcA = NULL; P_DefWindowProc __sys_DefWindowProcA = NULL;
P_DefWindowProc __sys_DefWindowProcW = NULL; P_DefWindowProc __sys_DefWindowProcW = NULL;
P_ActivateKeyboardLayout __sys_ActivateKeyboardLayout = NULL; P_ActivateKeyboardLayout __sys_ActivateKeyboardLayout = NULL;
P_MoveWindow __sys_MoveWindow = NULL; P_MoveWindow __sys_MoveWindow = NULL;
P_SetWindowPos __sys_SetWindowPos = NULL; P_SetWindowPos __sys_SetWindowPos = NULL;
P_GetWindowInfo __sys_GetWindowInfo = NULL; P_GetWindowInfo __sys_GetWindowInfo = NULL;
P_RegisterClass __sys_RegisterClassA = NULL; P_RegisterClass __sys_RegisterClassA = NULL;
P_RegisterClass __sys_RegisterClassW = NULL; P_RegisterClass __sys_RegisterClassW = NULL;
P_RegisterClass __sys_RegisterClassExA = NULL; P_RegisterClass __sys_RegisterClassExA = NULL;
P_RegisterClass __sys_RegisterClassExW = NULL; P_RegisterClass __sys_RegisterClassExW = NULL;
P_UnregisterClass __sys_UnregisterClassA = NULL; P_UnregisterClass __sys_UnregisterClassA = NULL;
P_UnregisterClass __sys_UnregisterClassW = NULL; P_UnregisterClass __sys_UnregisterClassW = NULL;
P_GetClassInfo __sys_GetClassInfoA = NULL; P_GetClassInfo __sys_GetClassInfoA = NULL;
P_GetClassInfo __sys_GetClassInfoW = NULL; P_GetClassInfo __sys_GetClassInfoW = NULL;
P_GetClassInfo __sys_GetClassInfoExA = NULL; P_GetClassInfo __sys_GetClassInfoExA = NULL;
P_GetClassInfo __sys_GetClassInfoExW = NULL; P_GetClassInfo __sys_GetClassInfoExW = NULL;
P_GetClassName __sys_GetClassNameA = NULL; P_GetClassName __sys_GetClassNameA = NULL;
P_GetClassName __sys_GetClassNameW = NULL; P_GetClassName __sys_GetClassNameW = NULL;
P_EnumWindows __sys_EnumWindows = NULL; P_EnumWindows __sys_EnumWindows = NULL;
P_EnumChildWindows __sys_EnumChildWindows = NULL; P_EnumChildWindows __sys_EnumChildWindows = NULL;
P_EnumThreadWindows __sys_EnumThreadWindows = NULL; P_EnumThreadWindows __sys_EnumThreadWindows = NULL;
P_EnumDesktopWindows __sys_EnumDesktopWindows = NULL; P_EnumDesktopWindows __sys_EnumDesktopWindows = NULL;
P_EnumDesktops __sys_EnumDesktopsA = NULL; P_EnumDesktops __sys_EnumDesktopsA = NULL;
P_EnumDesktops __sys_EnumDesktopsW = NULL; P_EnumDesktops __sys_EnumDesktopsW = NULL;
P_FindWindow __sys_FindWindowA = NULL; P_FindWindow __sys_FindWindowA = NULL;
P_FindWindow __sys_FindWindowW = NULL; P_FindWindow __sys_FindWindowW = NULL;
P_FindWindowEx __sys_FindWindowExA = NULL; P_FindWindowEx __sys_FindWindowExA = NULL;
P_FindWindowEx __sys_FindWindowExW = NULL; P_FindWindowEx __sys_FindWindowExW = NULL;
P_GetDesktopWindow __sys_GetDesktopWindow = NULL; P_GetDesktopWindow __sys_GetDesktopWindow = NULL;
P_GetShellWindow __sys_GetShellWindow = NULL; P_GetShellWindow __sys_GetShellWindow = NULL;
P_GetProp __sys_GetPropA = NULL; P_GetProp __sys_GetPropA = NULL;
P_GetProp __sys_GetPropW = NULL; P_GetProp __sys_GetPropW = NULL;
P_SetProp __sys_SetPropA = NULL; P_SetProp __sys_SetPropA = NULL;
P_SetProp __sys_SetPropW = NULL; P_SetProp __sys_SetPropW = NULL;
P_RemoveProp __sys_RemovePropA = NULL; P_RemoveProp __sys_RemovePropA = NULL;
P_RemoveProp __sys_RemovePropW = NULL; P_RemoveProp __sys_RemovePropW = NULL;
P_GetWindowLong __sys_GetWindowLongA = NULL; P_GetWindowLong __sys_GetWindowLongA = NULL;
P_GetWindowLong __sys_GetWindowLongW = NULL; P_GetWindowLong __sys_GetWindowLongW = NULL;
P_SetWindowLong __sys_SetWindowLongA = NULL; P_SetWindowLong __sys_SetWindowLongA = NULL;
P_SetWindowLong __sys_SetWindowLongW = NULL; P_SetWindowLong __sys_SetWindowLongW = NULL;
P_GetClassLong __sys_GetClassLongA = NULL; P_GetClassLong __sys_GetClassLongA = NULL;
P_GetClassLong __sys_GetClassLongW = NULL; P_GetClassLong __sys_GetClassLongW = NULL;
#ifdef _WIN64 #ifdef _WIN64
P_GetWindowLongPtr __sys_GetWindowLongPtrA = NULL; P_GetWindowLongPtr __sys_GetWindowLongPtrA = NULL;
P_GetWindowLongPtr __sys_GetWindowLongPtrW = NULL; P_GetWindowLongPtr __sys_GetWindowLongPtrW = NULL;
P_SetWindowLongPtr __sys_SetWindowLongPtrA = NULL; P_SetWindowLongPtr __sys_SetWindowLongPtrA = NULL;
P_SetWindowLongPtr __sys_SetWindowLongPtrW = NULL; P_SetWindowLongPtr __sys_SetWindowLongPtrW = NULL;
P_GetClassLongPtr __sys_GetClassLongPtrA = NULL; P_GetClassLongPtr __sys_GetClassLongPtrA = NULL;
P_GetClassLongPtr __sys_GetClassLongPtrW = NULL; P_GetClassLongPtr __sys_GetClassLongPtrW = NULL;
#endif _WIN64 #endif _WIN64
P_SetWindowsHookEx __sys_SetWindowsHookExA = NULL; P_SetWindowsHookEx __sys_SetWindowsHookExA = NULL;
P_SetWindowsHookEx __sys_SetWindowsHookExW = NULL; P_SetWindowsHookEx __sys_SetWindowsHookExW = NULL;
P_UnhookWindowsHookEx __sys_UnhookWindowsHookEx = NULL; P_UnhookWindowsHookEx __sys_UnhookWindowsHookEx = NULL;
P_CreateDialogParam __sys_CreateDialogParamA = NULL; P_CreateDialogParam __sys_CreateDialogParamA = NULL;
P_CreateDialogParam __sys_CreateDialogParamW = NULL; P_CreateDialogParam __sys_CreateDialogParamW = NULL;
P_CreateDialogIndirectParam __sys_CreateDialogIndirectParamA P_CreateDialogIndirectParam __sys_CreateDialogIndirectParamA
= NULL; = NULL;
P_CreateDialogIndirectParam __sys_CreateDialogIndirectParamW P_CreateDialogIndirectParam __sys_CreateDialogIndirectParamW
= NULL; = NULL;
P_CreateDialogIndirectParamAorW P_CreateDialogIndirectParamAorW
__sys_CreateDialogIndirectParamAorW __sys_CreateDialogIndirectParamAorW
= NULL; = NULL;
P_DialogBoxParam __sys_DialogBoxParamA = NULL; P_DialogBoxParam __sys_DialogBoxParamA = NULL;
P_DialogBoxParam __sys_DialogBoxParamW = NULL; P_DialogBoxParam __sys_DialogBoxParamW = NULL;
P_DialogBoxIndirectParam __sys_DialogBoxIndirectParamA = NULL; P_DialogBoxIndirectParam __sys_DialogBoxIndirectParamA = NULL;
P_DialogBoxIndirectParam __sys_DialogBoxIndirectParamW = NULL; P_DialogBoxIndirectParam __sys_DialogBoxIndirectParamW = NULL;
P_DialogBoxIndirectParamAorW P_DialogBoxIndirectParamAorW
__sys_DialogBoxIndirectParamAorW __sys_DialogBoxIndirectParamAorW
= NULL; = NULL;
P_LoadString __sys_LoadStringW = NULL; P_LoadString __sys_LoadStringW = NULL;
P_RegisterDeviceNotification P_RegisterDeviceNotification
__sys_RegisterDeviceNotificationA __sys_RegisterDeviceNotificationA
= NULL; = NULL;
P_RegisterDeviceNotification P_RegisterDeviceNotification
__sys_RegisterDeviceNotificationW __sys_RegisterDeviceNotificationW
= NULL; = NULL;
P_UnregisterDeviceNotification P_UnregisterDeviceNotification
__sys_UnregisterDeviceNotification __sys_UnregisterDeviceNotification
= NULL; = NULL;
P_MsgWaitForMultipleObjects __sys_MsgWaitForMultipleObjects = NULL; P_MsgWaitForMultipleObjects __sys_MsgWaitForMultipleObjects = NULL;
P_PeekMessage __sys_PeekMessageA = NULL; P_PeekMessage __sys_PeekMessageA = NULL;
P_PeekMessage __sys_PeekMessageW = NULL; P_PeekMessage __sys_PeekMessageW = NULL;
P_MessageBoxW __sys_MessageBoxW = NULL; P_MessageBoxW __sys_MessageBoxW = NULL;
P_MessageBoxExW __sys_MessageBoxExW = NULL; P_MessageBoxExW __sys_MessageBoxExW = NULL;
P_WaitForInputIdle __sys_WaitForInputIdle = NULL; P_WaitForInputIdle __sys_WaitForInputIdle = NULL;
P_AttachThreadInput __sys_AttachThreadInput = NULL; P_AttachThreadInput __sys_AttachThreadInput = NULL;
P_GetOpenFileNameW __sys_GetOpenFileNameW = NULL; P_GetOpenFileNameW __sys_GetOpenFileNameW = NULL;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -334,51 +334,9 @@ static DWORD Gui_WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds);
static BOOL Gui_AttachThreadInput(DWORD idAttach, DWORD idAttachTo, BOOL fAttach); static BOOL Gui_AttachThreadInput(DWORD idAttach, DWORD idAttachTo, BOOL fAttach);
static BOOL Gui_DeleteDC(HDC hdc); static HDC Gui_CreateDCA(LPCSTR pwszDriver, LPCSTR pwszDevice, LPCSTR pszPort, const DEVMODEA* pdm);
static BOOL Gui_BitBlt( static HDC Gui_CreateDCW(LPCWSTR pwszDriver, LPCWSTR pwszDevice, LPCWSTR pszPort, const DEVMODEW* pdm);
HDC hdc,
int x,
int y,
int cx,
int cy,
HDC hdcSrc,
int x1,
int y1,
DWORD rop
);
static BOOL Gui_StretchBlt(
HDC hdcDest,
int xDest,
int yDest,
int wDest,
int hDest,
HDC hdcSrc,
int xSrc,
int ySrc,
int wSrc,
int hSrc,
DWORD rop
);
/*static BOOL Gui_TransparentBlt(
HDC hdcDest,
int xoriginDest,
int yoriginDest,
int wDest,
int hDest,
HDC hdcSrc,
int xoriginSrc,
int yoriginSrc,
int wSrc,
int hSrc,
UINT crTransparent
);*/
static HDC Gui_CreateDCA(LPCSTR pwszDriver, LPCSTR pwszDevice, LPCSTR pszPort, const DEVMODEA* pdm);
static HDC Gui_CreateDCW(LPCWSTR pwszDriver, LPCWSTR pwszDevice, LPCWSTR pszPort, const DEVMODEW* pdm);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -414,6 +372,12 @@ _FX BOOLEAN Gui_Init(HMODULE module)
const UCHAR *ProcName; const UCHAR *ProcName;
Gui_UseProtectScreen = SbieApi_QueryConfBool(NULL, L"IsProtectScreen", FALSE);
Gui_UseBlockCapture = SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE);
if (Gui_UseBlockCapture)
Gdi_InitDCCache();
if (! Gdi_InitZero(module)) // only if Gdi_Init was not called yet if (! Gdi_InitZero(module)) // only if Gdi_Init was not called yet
return FALSE; return FALSE;
@ -432,14 +396,8 @@ _FX BOOLEAN Gui_Init(HMODULE module)
GUI_IMPORT___(GetWindowDC); GUI_IMPORT___(GetWindowDC);
GUI_IMPORT___(GetDC); GUI_IMPORT___(GetDC);
GUI_IMPORT___(GetDCEx); GUI_IMPORT___(GetDCEx);
//GUI_IMPORT___(DeleteDC);
GUI_IMPORT___(ReleaseDC); GUI_IMPORT___(ReleaseDC);
//GUI_IMPORT___(BitBlt); GUI_IMPORT___(GetWindowThreadProcessId);
//GUI_IMPORT___(StretchBlt);
//GUI_IMPORT___(TransparentBlt);
// GUI_IMPORT___(CreateDCA);
// GUI_IMPORT___(CreateDCW);
GUI_IMPORT___(GetWindowThreadProcessId);
GUI_IMPORT___(SetThreadDesktop); GUI_IMPORT___(SetThreadDesktop);
GUI_IMPORT___(SwitchDesktop); GUI_IMPORT___(SwitchDesktop);
GUI_IMPORT___(UserHandleGrantAccess); GUI_IMPORT___(UserHandleGrantAccess);

View File

@ -109,8 +109,6 @@ static BOOL Gui_PrintWindow(HWND hwnd, HDC hdcBlt, UINT nFlags);
static int Gui_ReleaseDC(HWND hWnd, HDC hDc); static int Gui_ReleaseDC(HWND hWnd, HDC hDc);
static BOOL Gui_ShutdownBlockReasonCreate(HWND hWnd, LPCWSTR pwszReason); static BOOL Gui_ShutdownBlockReasonCreate(HWND hWnd, LPCWSTR pwszReason);
static EXECUTION_STATE Gui_SetThreadExecutionState(EXECUTION_STATE esFlags); static EXECUTION_STATE Gui_SetThreadExecutionState(EXECUTION_STATE esFlags);
@ -129,9 +127,6 @@ typedef HMETAFILE (*P_SetMetaFileBitsEx)(
typedef HENHMETAFILE (*P_SetEnhMetaFileBits)( typedef HENHMETAFILE (*P_SetEnhMetaFileBits)(
UINT nSize, const BYTE *lpData); UINT nSize, const BYTE *lpData);
typedef HBITMAP (*P_CreateCompatibleBitmap)(
HDC hdc, int cx, int cy);
typedef int (*P_SetDIBits) typedef int (*P_SetDIBits)
(HDC hdc, HBITMAP hbm, UINT start, UINT cLines, CONST VOID *lpBits, CONST BITMAPINFO * lpbmi, UINT ColorUse); (HDC hdc, HBITMAP hbm, UINT start, UINT cLines, CONST VOID *lpBits, CONST BITMAPINFO * lpbmi, UINT ColorUse);
@ -193,12 +188,14 @@ _FX BOOLEAN Gui_InitMisc(HMODULE module)
} }
SBIEDLL_HOOK_GUI(SwapMouseButton); SBIEDLL_HOOK_GUI(SwapMouseButton);
SBIEDLL_HOOK_GUI(SetDoubleClickTime); SBIEDLL_HOOK_GUI(SetDoubleClickTime);
SBIEDLL_HOOK_GUI(GetWindowDC);
SBIEDLL_HOOK_GUI(GetDC);
SBIEDLL_HOOK_GUI(GetDCEx);
SBIEDLL_HOOK_GUI(PrintWindow);
SBIEDLL_HOOK_GUI(ReleaseDC);
if (Gui_UseBlockCapture) {
SBIEDLL_HOOK_GUI(GetWindowDC);
SBIEDLL_HOOK_GUI(GetDC);
SBIEDLL_HOOK_GUI(GetDCEx);
SBIEDLL_HOOK_GUI(PrintWindow);
SBIEDLL_HOOK_GUI(ReleaseDC);
}
if (Dll_OsBuild >= 6000) { if (Dll_OsBuild >= 6000) {
@ -1497,42 +1494,17 @@ _FX BOOL Gui_ImmAssociateContextEx(
// Gui_GetDC // Gui_GetDC
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
HBITMAP bmp=NULL;
_FX HDC Gui_GetDC(HWND hWnd) _FX HDC Gui_GetDC(HWND hWnd)
{ {
HDC ret = __sys_GetDC(hWnd); HDC ret = __sys_GetDC(hWnd);
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { ULONG_PTR pid = 0, tid = 0;
if (Gui_UseBlockCapture && (hWnd == NULL || hWnd == __sys_GetDesktopWindow() || !Gui_IsSameBox(hWnd, &pid, &tid))) {
ULONG_PTR pid = 0, tid = 0; return Gdi_GetDummyDC(ret);
if (hWnd == NULL || hWnd == __sys_GetDesktopWindow() ||
!Gui_IsSameBox(hWnd, &pid, &tid)) {
typedef HDC(*P_CreateCompatibleDC)(HDC hdc);
typedef HGDIOBJ (*P_SelectObject)(_In_ HDC hdc, _In_ HGDIOBJ h);
GET_WIN_API(SelectObject, DllName_gdi32);
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
GET_WIN_API(GetDeviceCaps, DllName_gdi32);
typedef HBITMAP(*P_CreateCompatibleBitmap)(_In_ HDC hdc, _In_ int cx, _In_ int cy);
GET_WIN_API(CreateCompatibleBitmap, DllName_gdi32);
GET_WIN_API(CreateCompatibleDC, DllName_gdi32);
GET_WIN_API(DeleteDC, DllName_gdi32);
//typedef BOOL(*P_DeleteDC)(HDC hdc);
int iWidth, iHeight;
HDC ret2 = CreateCompatibleDC(ret);
iWidth = GetDeviceCaps(ret, HORZRES);
iHeight = GetDeviceCaps(ret, VERTRES);
HBITMAP hBmp;
if(bmp==NULL)
bmp = CreateCompatibleBitmap(ret2, iWidth, iHeight);
hBmp = bmp;
SelectObject(ret2, hBmp);
DeleteDC(ret);
ret = ret2;
}
} }
return ret; return ret;
} }
@ -1546,38 +1518,12 @@ _FX HDC Gui_GetWindowDC(HWND hWnd)
{ {
HDC ret = __sys_GetWindowDC(hWnd); HDC ret = __sys_GetWindowDC(hWnd);
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { ULONG_PTR pid = 0, tid = 0;
if (Gui_UseBlockCapture && (hWnd == NULL || hWnd == __sys_GetDesktopWindow() || !Gui_IsSameBox(hWnd, &pid, &tid))) {
ULONG_PTR pid = 0, tid = 0; return Gdi_GetDummyDC(ret);
if (hWnd == NULL || hWnd == __sys_GetDesktopWindow() ||
!Gui_IsSameBox(hWnd, &pid, &tid)) {
typedef HDC(*P_CreateCompatibleDC)(HDC hdc);
//typedef BOOL(*P_DeleteDC)(HDC hdc);
GET_WIN_API(CreateCompatibleDC, DllName_gdi32);
GET_WIN_API(DeleteDC, DllName_gdi32);
typedef HGDIOBJ(*P_SelectObject)(_In_ HDC hdc, _In_ HGDIOBJ h);
GET_WIN_API(SelectObject, DllName_gdi32);
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
GET_WIN_API(GetDeviceCaps, DllName_gdi32);
typedef HBITMAP(*P_CreateCompatibleBitmap)(_In_ HDC hdc, _In_ int cx, _In_ int cy);
GET_WIN_API(CreateCompatibleBitmap, DllName_gdi32);
int iWidth, iHeight;
HDC ret2 = CreateCompatibleDC(ret);
iWidth = GetDeviceCaps(ret, HORZRES);
iHeight = GetDeviceCaps(ret, VERTRES);
HBITMAP hBmp;
if (bmp == NULL)
bmp = CreateCompatibleBitmap(ret2, iWidth, iHeight);
hBmp = bmp;
SelectObject(ret2, hBmp);
DeleteDC(ret);
ret = ret2;
}
} }
return ret; return ret;
} }
@ -1591,38 +1537,12 @@ _FX HDC Gui_GetDCEx(HWND hWnd, HRGN hrgnClip, DWORD flags)
{ {
HDC ret = __sys_GetDCEx(hWnd, hrgnClip, flags); HDC ret = __sys_GetDCEx(hWnd, hrgnClip, flags);
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { ULONG_PTR pid = 0, tid = 0;
if (Gui_UseBlockCapture && (hWnd == NULL || hWnd == __sys_GetDesktopWindow() || !Gui_IsSameBox(hWnd, &pid, &tid))) {
ULONG_PTR pid = 0, tid = 0; return Gdi_GetDummyDC(ret);
if (hWnd == NULL || hWnd == __sys_GetDesktopWindow() ||
!Gui_IsSameBox(hWnd, &pid, &tid)) {
typedef HDC(*P_CreateCompatibleDC)(HDC hdc);
//typedef BOOL(*P_DeleteDC)(HDC hdc);
GET_WIN_API(CreateCompatibleDC, DllName_gdi32);
GET_WIN_API(DeleteDC, DllName_gdi32);
typedef HGDIOBJ(*P_SelectObject)(_In_ HDC hdc, _In_ HGDIOBJ h);
GET_WIN_API(SelectObject, DllName_gdi32);
typedef int (*P_GetDeviceCaps)(_In_opt_ HDC hdc, _In_ int index);
GET_WIN_API(GetDeviceCaps, DllName_gdi32);
typedef HBITMAP(*P_CreateCompatibleBitmap)(_In_ HDC hdc, _In_ int cx, _In_ int cy);
GET_WIN_API(CreateCompatibleBitmap, DllName_gdi32);
int iWidth, iHeight;
HDC ret2 = CreateCompatibleDC(ret);
iWidth = GetDeviceCaps(ret, HORZRES);
iHeight = GetDeviceCaps(ret, VERTRES);
HBITMAP hBmp;
if (bmp == NULL)
bmp = CreateCompatibleBitmap(ret2, iWidth, iHeight);
hBmp = bmp;
SelectObject(ret2, hBmp);
DeleteDC(ret);
ret = ret2;
}
} }
return ret; return ret;
} }
@ -1634,7 +1554,7 @@ _FX HDC Gui_GetDCEx(HWND hWnd, HRGN hrgnClip, DWORD flags)
_FX BOOL Gui_PrintWindow(HWND hwnd, HDC hdcBlt, UINT nFlags) _FX BOOL Gui_PrintWindow(HWND hwnd, HDC hdcBlt, UINT nFlags)
{ {
if (SbieApi_QueryConfBool(NULL, L"IsBlockCapture", FALSE)) { if (Gui_UseBlockCapture) {
if (hwnd == NULL || hwnd == __sys_GetDesktopWindow()) { if (hwnd == NULL || hwnd == __sys_GetDesktopWindow()) {
@ -1651,7 +1571,16 @@ _FX BOOL Gui_PrintWindow(HWND hwnd, HDC hdcBlt, UINT nFlags)
} }
return __sys_PrintWindow(hwnd, hdcBlt, nFlags); return __sys_PrintWindow(hwnd, hdcBlt, nFlags);
} }
_FX int Gui_ReleaseDC(HWND hWnd, HDC hdc) {
//---------------------------------------------------------------------------
// Gui_ReleaseDC
//---------------------------------------------------------------------------
_FX int Gui_ReleaseDC(HWND hWnd, HDC hdc)
{
Gdi_OnFreeDC(hdc);
return __sys_ReleaseDC(hWnd, hdc); return __sys_ReleaseDC(hWnd, hdc);
} }

View File

@ -1239,23 +1239,23 @@ void COptionsWindow::SaveDebug()
DbgOption.Changed = false; DbgOption.Changed = false;
} }
} }
void COptionsWindow::OnCaptureChanged() {
void COptionsWindow::OnCaptureChanged()
{
if (ui.chkBlockCapture->checkState()) { if (ui.chkBlockCapture->checkState()) {
ui.chkProtectWindow->setChecked(FALSE); ui.chkProtectWindow->setChecked(FALSE);
ui.chkProtectWindow->setCheckable(FALSE); ui.chkProtectWindow->setCheckable(FALSE);
} } else
else {
ui.chkProtectWindow->setCheckable(TRUE); ui.chkProtectWindow->setCheckable(TRUE);
}
OnAdvancedChanged(); OnAdvancedChanged();
} }
void COptionsWindow::OnProtectChanged() {
void COptionsWindow::OnProtectChanged()
{
if (ui.chkProtectWindow->checkState()) { if (ui.chkProtectWindow->checkState()) {
ui.chkBlockCapture->setChecked(FALSE); ui.chkBlockCapture->setChecked(FALSE);
ui.chkBlockCapture->setCheckable(FALSE); ui.chkBlockCapture->setCheckable(FALSE);
} } else
else {
ui.chkBlockCapture->setCheckable(TRUE); ui.chkBlockCapture->setCheckable(TRUE);
}
OnAdvancedChanged(); OnAdvancedChanged();
} }