Page 1 of 1
InterfaceCpp to support thiscall win x86
Posted: Tue May 07, 2013 11:37 pm
by idle
Would be nice to have Thiscall support for Interfaces with c++ libs
It's essentially the same as a standard call with the exception that the object is passed in ecx
instead of being pushed on the stack
for windows x86
Code: Select all
InterfaceCpp myInterface
somefunc(v1,v2,v3)
EndInterface
;*interface\somefunc(v1,v2,v3)
push v3
push v2
push v1
mov eax, [P_interface]
mov ecx, eax
mov eax, [eax]
call dword [eax+?]
Re: InterfaceCpp to support thiscall win x86
Posted: Tue Apr 15, 2014 2:30 pm
by User_Russian
Agreed.
In PB no OOP and Fred is not going to add!
Necessary, to invent ways of calling thiscall interface methods using assembler.
But to write a procedure to calling thiscall., Is impossible, because in the procedure the contents of register ecx, replaced by another when copying arguments.
Because of this, I was constantly disappointed in PureBasic due to the inability to implement elementary things!
OOP is implemented in almost all programming languages​​, an example of C + +. And in PureBasic can not afford to work with it (for example, calling the method object from a DLL written in C++).
Re: InterfaceCpp to support thiscall win x86
Posted: Wed Apr 16, 2025 3:11 pm
by breeze4me
+1
https://www.purebasic.fr/english/viewtopic.php?t=86741
As I showed in the example in the post above, it seems to be natively supported in GCC as well. Maybe Clang has something similar.
Code: Select all
! int __attribute__ ((thiscall)) (*func)(int, int, int) = v_func;
! v_result = func(v_txtsrv, 2048, 0);
Or simply:
Code: Select all
! int __thiscall (*func)(int, int, int) = v_func;
......
Re: InterfaceCpp to support thiscall win x86
Posted: Wed Apr 16, 2025 3:33 pm
by Quin
+1