Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GdipGetLineColors has different call signatures for 32-bit versus 64-bit #18

Closed
GCuser99 opened this issue Apr 11, 2024 · 4 comments
Closed

Comments

@GCuser99
Copy link

I've confirmed that the 32- and 64-bit versions have different call signatures by using both in tB (and of course they are not interchangeable). The 32-bit version requires a Long array of dimension 2 (Colors(0) and Colors(1)).

#If Win64 Then
Private Declare PtrSafe Function GdipGetLineColors Lib "gdiplus" (ByVal brush As LongPtr, color1 As Long, color2 As Long) As GpStatus
#Else
Private Declare Function GdipGetLineColors Lib "gdiPlus" (ByVal brush As Long, Colors As Any) As GpStatus
#End If

Thx!

@fafalone
Copy link
Owner

fafalone commented Apr 12, 2024

I see how the current definition is wrong, but not how that would be right? gdiplusflat.h:

GpStatus WINGDIPAPI
GdipGetLineColors(GpLineGradient *brush, ARGB* colors);

//gdipluspixelformats.h
typedef DWORD ARGB;

So the definition should be the same in both, Public Declare PtrSafe Function GdipGetLineColors Lib "gdiplus" (ByVal brush As LongPtr, colors As Long) As GpStatus because a DWORD is just a 4-byte Long on both 32bit and 64bit.

@GCuser99
Copy link
Author

Oh, that's strange! You are right that:

Public Declare PtrSafe Function GdipGetLineColors Lib "gdiplus" (ByVal brush As LongPtr, colors As Long) As GpStatus

...works for both!

But the two-color argument version does "seem" to work for 64-bit and not 32-bit! Here is a snippet:

Dim Values(0 To 1) As Long
If GdipGetLineColors(BrushHandle, Values(0), Values(1)) = 0& Then

Maybe the second argument is superfluous and gets ignored?

Thanks!

@GCuser99
Copy link
Author

Yeah, that is what it is... here is a test in tB which fails in 32-bit but works in 64-bit. Not sure what the expected behavior is (don't have VB6 to test).

Private Declare PtrSafe Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" ( _ 
    ByRef Destination As Any, _
    ByRef Source As Any, ByVal Length As Long, _
    ByVal superfluous As Long) '<-- added an unsupported argument

Sub test()
    Dim a As Long, b As Long
    a = 1: b = 2
    CopyMemory a, b, 4, 99999 '<-- fails in 32-bit tB with "Bad DLL Definition"
    Debug.Print a 'prints 2 in 64-bit tB
End Sub

@fafalone
Copy link
Owner

Well as long as the new version works in both 32bit and 64bit, I'll leave why the superfluous parameter works in 64bit as a mystery for those more familiar with the calling conventions on a low level.

Fixed in v7.8.379, available now.

Sorry for the multiple GDIP bugs; thanks for helping make WinDevLib better by reporting them though 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants