Skip to content

c_SetWindowLongPtr uses the wrong pointer type and crashes #180

Closed
@BestYeen

Description

@BestYeen

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions