Calling Direct2D functions under Win64 have unvalid results (win64 ABI structured return types)
Original Reporter info from Mantis: SonnyBoy
-
Reporter name: Norbert Sonnleitner
Original Reporter info from Mantis: SonnyBoy
- Reporter name: Norbert Sonnleitner
Description:
Trying to use ID2D1Bitmap.GetSize results in Win64 to an unvalid result. Also other functions. Same routines working well in Win32.
Additional information:
According to https://forum.dlang.org/post/krxvtovytmjhnocyupah@forum.dlang.org MS is not following the calling convention in COM routines.
the FPC compiler produces this ASM code
# [56] lBitmapSize := lBitmap.GetSize();
movq -48(%rbp),%rcx
movq -48(%rbp),%rax
movq (%rax),%rax
call *32(%rax)
movq %rax,-128(%rbp)
where -48(%rbp) is lBitmap and -128(%rbp) is lBitmapSize
but the correct (and working) ASM code is
{$asmmode intel}
asm
mov rax , QWORD PTR [lBitmap]
mov rax , QWORD PTR [rax]
lea rdx , [lBitmapSize]
mov rcx , QWORD PTR [lBitmap]
call QWORD PTR [rax+32] // GetSize is first function
mov rax , qword ptr [rax]
mov qword ptr [lBitmapSize],rax
end;
{$ENDIF}
seems the functions need the adresse of the result in RDX register.
Mantis conversion info:
- Mantis ID: 34078
- OS: Win64
- OS Build: 10
- Build: CT 6.4
- Platform: x64
- Version: 3.1.1