-
Notifications
You must be signed in to change notification settings - Fork 4
/
Xander.ThisWrap.pas
42 lines (32 loc) · 1.08 KB
/
Xander.ThisWrap.pas
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
(*=========== (C) Copyright 2019, Alexander B. All rights reserved. ===========*)
(* *)
(* Module: *)
(* Xander.ThisWrap *)
(* *)
(* Description: *)
(*=============================================================================*)
unit Xander.ThisWrap;
interface
type
TThisCall = function(PClass, PFunc: Pointer): Pointer; stdcall varargs;
const
ThisCall: TThisCall = nil;
implementation
function __ThisCall(PClass, PFunc: Pointer): Pointer; assembler;
asm
cmp dword [esp + 4], 0 // is PFunc nil?
jz @A
cmp dword [esp + 8], 0 // is PClass nil?
jz @A
pop edx // return address
pop ecx // class (this) pointer
pop eax // function for call
push edx
jmp eax
@A:
or eax, -1
ret 8
end;
initialization
ThisCall := @__ThisCall;
end.