From 4eeb96d5b664624262713918ced6dde577675bf6 Mon Sep 17 00:00:00 2001 From: max Date: Tue, 8 Sep 2026 23:05:49 +0200 Subject: [PATCH] fix(overlay): declare complete 64-bit ctypes prototypes for GDI/User32 --- catser/overlay.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/catser/overlay.py b/catser/overlay.py index bba73c9..9275d5a 100644 --- a/catser/overlay.py +++ b/catser/overlay.py @@ -26,6 +26,26 @@ user32 = ctypes.windll.user32 gdi32 = ctypes.windll.gdi32 kernel32 = ctypes.windll.kernel32 +# Set proper 64-bit argtypes and restype to prevent ctypes integer overflow +user32.DefWindowProcW.argtypes = [wintypes.HWND, wintypes.UINT, wintypes.WPARAM, wintypes.LPARAM] +user32.DefWindowProcW.restype = ctypes.c_longlong +user32.GetDC.argtypes = [wintypes.HWND] +user32.GetDC.restype = wintypes.HDC +user32.ReleaseDC.argtypes = [wintypes.HWND, wintypes.HDC] +user32.ReleaseDC.restype = ctypes.c_int +user32.SetWindowPos.argtypes = [wintypes.HWND, ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int, wintypes.UINT] +user32.SetWindowPos.restype = wintypes.BOOL +gdi32.CreateCompatibleDC.argtypes = [wintypes.HDC] +gdi32.CreateCompatibleDC.restype = wintypes.HDC +gdi32.DeleteDC.argtypes = [wintypes.HDC] +gdi32.DeleteDC.restype = wintypes.BOOL +gdi32.SelectObject.argtypes = [wintypes.HDC, wintypes.HGDIOBJ] +gdi32.SelectObject.restype = wintypes.HGDIOBJ +gdi32.DeleteObject.argtypes = [wintypes.HGDIOBJ] +gdi32.DeleteObject.restype = wintypes.BOOL + + + # Window styles WS_POPUP = 0x80000000 WS_VISIBLE = 0x10000000 @@ -114,6 +134,30 @@ class WNDCLASSEXW(ctypes.Structure): ("hIconSm", wintypes.HICON), ] +gdi32.CreateDIBSection.argtypes = [ + wintypes.HDC, + ctypes.POINTER(BITMAPINFO), + wintypes.UINT, + ctypes.POINTER(ctypes.c_void_p), + wintypes.HANDLE, + wintypes.DWORD, +] +gdi32.CreateDIBSection.restype = wintypes.HBITMAP + +user32.UpdateLayeredWindow.argtypes = [ + wintypes.HWND, + wintypes.HDC, + ctypes.POINTER(POINT), + ctypes.POINTER(SIZE), + wintypes.HDC, + ctypes.POINTER(POINT), + wintypes.COLORREF, + ctypes.POINTER(BLENDFUNCTION), + wintypes.DWORD, +] +user32.UpdateLayeredWindow.restype = wintypes.BOOL + + class OverlayWindow: """