为了更好地解释我要完成的工作,我将从可行的东西开始。
假设我们有一个过程可以调用另一个过程并传递一个字符串参数给它:
procedure CallSaySomething(AProc: Pointer; const AValue: string);
var
LAddr: Integer;
begin
LAddr := Integer(PChar(AValue));
asm
MOV EAX, LAddr
CALL AProc;
end;
end;
这是我们将调用的过程:
procedure SaySomething(const AValue: string);
begin
ShowMessage( AValue );
end;
现在我可以像这样调用SaySomething(经过测试并且有效(: ):
CallSaySomething(@SaySomething, 'Morning people!');
我的问题是,我怎样才能实现类似的功能,但这次SaySomething应该是一个方法:
type
TMyObj = class
public
procedure SaySomething(const AValue: string); // calls show message by passing AValue
end;
所以,如果你还和我在一起......,我的目标是完成一个类似于:
procedure CallMyObj(AObjInstance, AObjMethod: Pointer; const AValue: string);
begin
asm
// here is where I need help...
end;
end;
我已经给了它很多镜头,但我的组装知识是有限的。