-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuReflection.pas
More file actions
65 lines (56 loc) · 1.12 KB
/
uReflection.pas
File metadata and controls
65 lines (56 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
unit uReflection;
interface
uses Sysutils;
type TStringArray = array of string;
type
TSmartMethod = class
private
FsMethodName : String;
public
constructor Create(psMethodName : String);
function Execute(poObject: TObject; paParams : TStringArray) : variant;
end;
implementation
{ TReflection }
constructor TSmartMethod.Create(psMethodName : String);
begin
FsMethodName := psMethodName;
end;
function TSmartMethod.Execute(poObject: TObject;
paParams: TStringArray) : variant;
var
oMethod : Pointer;
i : integer;
nSize : Integer;
oResult : string;
valueAdress : Pointer;
begin
oMethod := poObject.MethodAddress(FsMethodName);
nSize := length(paParams);
if nSize > 2 then
begin
for i := 2 to nSize-1 do
begin
valueAdress := Pointer(paParams[i]);
asm
push valueAdress
end;
end;
end;
asm
lea eax, oResult
push eax
end;
valueAdress := Pointer(paParams[1]);
asm
mov ecx, valueAdress;
end;
valueAdress := Pointer(paParams[0]);
asm
mov edx, valueAdress;
mov eax, ebx
call oMethod;
end;
result := oResult;
end;
end.