procedure TEventList.CallInvoke(method: TMethod; params:
array of const);
var
:
Regs :
array[plEAX..plECX]
of Cardinal;
doStack : boolean;
stack :
array[0..1023]
of Byte;
stacksize : integer;
sc : integer;
p : Pointer;
begin
Regs[plEAX] := Cardinal(Method.data);
if (doStack)
then
begin
fillchar(stack,sizeof(stack),0);
StackSize := Sizeof(TVarRec)*(Length(Params));
sc := 0;
for I := High(params)
downto Low(Params)
do
begin
move(params[i],stack[sc],sizeof(params[i]));
inc(sc,sizeof(params[i]));
end;
p := @Stack;
asm
SUB ESP,Stacksize
MOV p,ESP
end;
Regs[plEDX] := Cardinal(p);
Regs[plECX] := Cardinal(Stacksize);
end
else
begin
for I := 0
to MethSig.ParamCount - 1
do
begin
if (MethSig.parameters[i].location <> plEax)
AND (MethSig.parameters[i].ParamName <> '
Self')
then
Regs[MethSig.Parameters[i].Location] := GetValueAsCardinal(params[i-1]);
end;
end;
// Do the call
asm
MOV EAX,DWORD PTR Regs[0]
MOV EDX,DWORD PTR Regs[4]
MOV ECX,DWORD PTR Regs[8]
CALL Method.code
MOV DWORD PTR Regs[0],EAX
MOV DWORD PTR Regs[4],EDX
end;
End;