fix(overlay): declare complete 64-bit ctypes prototypes for GDI/User32

This commit is contained in:
2026-09-08 23:05:49 +02:00
parent 9bade210f5
commit 4eeb96d5b6
+44
View File
@@ -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:
"""