pascaldragon at googlemail.com
Wed Nov 25 19:53:11 CET 2015
On 25.11.2015 19:47, Michael Van Canneyt wrote:
> On Wed, 25 Nov 2015, Sven Barth wrote:
>>>> Virtual method interceptors are not implemented, but they are planned
>>>> like every other Delphi compatible part of the RTTI. They require a
>>>> bit of
>>>> platform dependent support though as they'll need to deal with calling
>>>> conventions (even if it might only be one as AFAIK we only allow the
>>>> default calling convention for virtual methods...).
>>> Sounds like the same code as for interface method RTTI can be reused.
>> But that will only provide half of it, because a Virtual Method
>> Interceptor (VMI) also needs to provide the callee while for the
>> interface method RTTI (or later on Invoke()) you only need to provide
>> the necessary means to call the function (which a VMI needs to be able
>> to do as well, which is what I mean "half").
> Hmh. Why does it need to provide the callee ? I thought it just meant
> inserting a stub in the VMT and make sure all arguments are passed
> correctly ?
> No doubt you know better :)
The method stub needs to call the OnBefore and OnAfter handlers before
and after calling the virtual method that had been intercepted (and here
it needs to know which method had been intercepted as well, because
*all* virtual methods are hooked), thus it needs to preserve the
original arguments across the calls to OnBefore and OnAfter (this would
not be required if passed on the stack, but e.g. on i386 the register
calling convention is used which stores stuff in registers). In addition
it needs to pass on the parameters to the handlers and return the
result. So it indeed needs to provide a full callee.
More information about the fpc-devel