Forum > DirectX

Problem with DLL and Win64

(1/1)

SonnyBoyXXl:
Hi folks,
I have a problem with a Win64 Application - the same code works well in Win32, so I think it's an compiler issue. I work with CT 6.4
Calling the function GetSize from ID2D1Bitmap makes the problem
the function is declared as


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ID2D1Bitmap = interface(ID2D1Image)        ['{a2296057-ea42-4099-983b-539fb6505426}']        function GetSize: TD2D1_SIZE_F; stdcall;          

Calling the function the compiler makes the code:

--- Quote ---# [56] lBitmapSize := lBitmap.GetSize();
   movq   -48(%rbp),%rcx
   movq   -48(%rbp),%rax
   movq   (%rax),%rax
   call   *32(%rax)
   movq   %rax,-128(%rbp)
--- End quote ---

the function crashes on the line as you see in the attached picture.

The image itself is valid, could be drawn etc. but calling the get function fails. Also other functions like GetPixelSize fails.

Could be the problem that the rcx register is assigned, and Windows request the rdx register ?
How to solve this?

best regards





ASBzone:
Are you calling the same DLL in the 32-bit application as in the 64-bit one?

SonnyBoyXXl:
Hi folks,
I have now the answer. Finding this article https://forum.dlang.org/post/krxvtovytmjhnocyupah@forum.dlang.org and
working a small example in VisualStudio it seems that M$ is not following the calling convention  for some COM routines >:D

So the working assembler routine is this one. The RDX register needs the adress of the return value too.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$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} 
I'm not sure if this is a "always working" way. Some gurus should look at this topic. I will place a bug issue in the bug tracker.

Best regards.

marcov:
Please file a bug, and quote that URL. Thank you.

Navigation

[0] Message Index

Go to full version