On Sat, Feb 11, 2012 at 2:27 PM, Maarten Lankhorst <m.b.lankho...@gmail.com>wrote:
> Are you sure? I don't see any example calls being wrapped to ITextHost > for example.. > Yup, I worked on it myself. All those ITextHost_*(...), which you can easily grep for in editor.c, are using macros in editor.h: --- snip --- #ifdef __i386__ /* Use wrappers to perform thiscall on i386 */ #define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl) #else /* __i386__ */ #define TXTHOST_VTABLE(This) (This)->lpVtbl #endif /* __i386__ */ /*** ITextHost methods ***/ #define ITextHost_TxGetDC(This) TXTHOST_VTABLE(This)->TxGetDC(This) ... --- end snip --- So for i386 it will use the itextHostStdcallVtbl, which is defined in txthost.c to pop the This pointer off the stack and into a register, then grab the pointer to the vtable, and jump to the thiscall method. --- snip --- #define STDCALL(func) __stdcall_ ## func #define DEFINE_STDCALL_WRAPPER(num,func,args) \ extern typeof(func) __stdcall_ ## func; \ __ASM_STDCALL_FUNC(__stdcall_ ## func, args, \ "popl %eax\n\t" \ "popl %ecx\n\t" \ "pushl %eax\n\t" \ "movl (%ecx), %eax\n\t" \ "jmp *(4*(" #num "))(%eax)" ) DEFINE_STDCALL_WRAPPER(3,ITextHostImpl_TxGetDC,4) ... const ITextHostVtbl itextHostStdcallVtbl = { NULL, NULL, NULL, __stdcall_ITextHostImpl_TxGetDC, ... --- end snip --- The ITextHost interface is also implemented in txthost.c for non-windowless richedit controls. That interface is implemented using thiscall wrappers which do the reverse of the standard call wrappers.