support for __thiscall calling convention
Posted: Tue Apr 24, 2012 12:20 pm
Many libraries these days don't push the hidden *this parameter onto the stack, so to call interface methods you have to do asm hacks.
Support for __thiscall is needed on interfaces, to work with many external libraries these days.
__thiscall description:
http://msdn.microsoft.com/en-us/library ... 80%29.aspx
InterfaceThis MyObject
ProcedureThis myProc()
heres the asm hack example:
Support for __thiscall is needed on interfaces, to work with many external libraries these days.
__thiscall description:
http://msdn.microsoft.com/en-us/library ... 80%29.aspx
would be nice to have something like this:The __thiscall calling convention is used on member functions and is the default calling convention used by C++ member functions that do not use variable arguments. Under __thiscall, the callee cleans the stack, which is impossible for vararg functions. Arguments are pushed on the stack from right to left, with the this pointer being passed via register ECX, and not on the stack, on the x86 architecture.
InterfaceThis MyObject
ProcedureThis myProc()
heres the asm hack example:
Code: Select all
DisableDebugger
EnableASM
Interface MyObject
DoThis(param1.l)
DoThat(param1.s)
EndInterface
Global m.MyObject
; __thiscall asm hack........
Procedure This(param1.l)
Protected *this
MOV *this, ECX
MessageRequester("Info", "This Proc"+#CRLF$+"*this (ECX): "+Hex(*This)+#CRLF$+"param1: "+Str(param1))
EndProcedure
; __stdcall + *this
Procedure That(*This, param1.s)
MessageRequester("Info", "That Proc"+#CRLF$+"*this (ECX): "+Hex(*This)+#CRLF$+"param1: "+param1)
EndProcedure
m = ?VTable
MOV ECX, m
m\DoThis(3)
m\DoThat("test")
DataSection
VTable:
Data.i ?Procedures
Procedures:
Data.i @This(), @That()
EndDataSection