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
|
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
TITLE xptcinvoke_asm_x86_msvc.asm
.686P
.model flat
PUBLIC _NS_InvokeByIndex
EXTRN @invoke_copy_to_stack@12:PROC
;
; extern "C" nsresult __cdecl
; NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
; uint32_t paramCount, nsXPTCVariant* params)
;
_TEXT SEGMENT
_NS_InvokeByIndex PROC
; Build frame
push ebp
mov ebp, esp
; Save paramCount for later
mov edx, dword ptr [ebp+16]
; Do we have any parameters?
test edx, edx
jz noparams
; Build call for copy_to_stack, which is __fastcall
; Allocate space for parameters. 8 is the biggest size
; any parameter can be, so assume that all our parameters
; are that large.
mov eax, edx
shl eax, 3
sub esp, eax
mov ecx, esp
push dword ptr [ebp+20]
call @invoke_copy_to_stack@12
noparams:
; Push the `this' parameter for the call.
mov ecx, dword ptr [ebp+8]
push ecx
; Load the vtable.
mov edx, dword ptr [ecx]
; Call the vtable index at `methodIndex'.
mov eax, dword ptr [ebp+12]
call dword ptr [edx+eax*4]
; Reset and return.
mov esp, ebp
pop ebp
ret
_NS_InvokeByIndex ENDP
_TEXT ENDS
END
|