Hello,

I'm using a declaration like this

TYPE TRSMControl = FUNCTION (AData: PtrInt): PtrInt; CDECL; VARARGS;
VAR RSMControl: TRSMControl;

to make calls to a DLL function which expects a variable number of arguments. 
For example:

RSMControl (PtrInt(1), PtrInt(2), PtrInt(3))

On win32, this works fine. On win64, I get only the first argument correctly, 
the rest is garbage. Within the DLL, I subsequently access all parameters by 
taking the address of the first parameter and incrementing it in steps of 4 
bytes (or 8 bytes on win64).

I wonder whether I'm doing something wrong on the caller or callee side. The 
code worked reliably on win32, but I'm now trying to target win64 and am facing 
the problem that I cannot access the data that were passed. The CDECL calling 
convention should pass all arguments on the stack, and I expect subsequent 
arguments to be at subsequent memory addresses.

Does anyone have a clue for me?

Kind regards,
Thomas

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to