delphi – 如何用接口的safecall函数方法进行RTTI调用?

我有这个测试计划 https://gist.github.com/real-mielofon/5002732
RttiValue := RttiMethod.Invoke(RttiInstance,[10]);

和简单的单位与界面:

unit Unit163;

interface

type
{$M+}
  ISafeIntf = interface
    function TestMethod(aI: integer): integer; safecall;
  end;
{$M-}
 type
   TSafeClass = class(TInterfacedobject,ISafeIntf)
   public
     function TestMethod(aI: integer): integer; safecall;
   end;

implementation

function TSafeClass.TestMethod(aI: integer): integer;
begin
  result := aI+1; // Exception !!
end;

end.

我有kaboom

result := aI+1;

如果是程序或不是safecall,那么没关系:-(

解决方法

现在自己尝试过,看了代码,我的结论是有一个bug. RTTI单元确实尝试执行安全方法重写.它只是看起来错了.我建议您将项目作为QC报告提交,并通过使用带有HRESULT返回值的stdcall来解决问题.

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...