haskell / win32

Haskell support for the Win32 API
http://hackage.haskell.org/package/Win32
Other
97 stars 62 forks source link

c_SetWindowLongPtr uses the wrong pointer type and crashes #180

Closed BestYeen closed 3 years ago

BestYeen commented 3 years ago

c_GetWindowLongPtr has a result of type LONG_PTR (64 bit). This is in accordance with the MS Docs at https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptrw

c_SetWindowLongPtr uses a parameter and returns a result of type Ptr LONG (32 bit), which is wrong. Docs: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptrw

When using the function to alter a window style on a button on my window, it works by chance. When using the function to alter a window style on my main window itself, it always freezes up. A fresh FFI import of that function from winuser.h with the right pointer type works as intended. A code proof would be a little fiddly right now, but the discrepancy becomes very clear when looking at both functions' signatures and the docs.

Your Environment

GHCi, version 8.10.4 on Windows 10, 64 bit.

Best regards!

Mistuke commented 3 years ago

Sorry for the delay. I'll fix this tonight.