i dont understand why i keep getting the same wrong answer(see comment) regardless of what number i pass in.
About x64:
When the callback returns it puts your number in the integer return register, rax. But dllcall will return, to you, what ever happens to be in the float return register, xmm0. For example, if you comment out the first two msgboxes, you might get another result. Likewise, when the callback is called, it will read, for the first four parameters, whatever is in the integer parameter registers, which are rcx, rdx, r8, r9, but when you pass a float / double, these are put in xmm0-3 registers. The twist is, that dllcall always (unconventionally) passes params in both the integer and float registers, that is why the
Receiving parameters by address example in the callbackcreate docs work on x64. The reason it passes the params in all registers, is to support calling variadic functions. So don't be fooled by the (poor) example in the docs, that will only work when the caller is dllcall. The example was probably written with the 32 bit calling conventions in mind, for those, it works more generally.
Here is a non-sensical example which currently (at least for me) happens to
work, you should be able to figure out what happens with the above information,
Code: Select all
; do not use this code
timesTwo := CallbackCreate(n => (n := numget(&n, 'double')*2, numget(&n, 'double')) )
MsgBox DllCall(timesTwo, "Double", 2.5, "Double")
Cheers.