Hi.
I am using a pointer to a function (procedure), and this is what I have:
func1 PROTO arg1:BYTE, arg2:BYTE
func2 PROTO arg1:BYTE, arg2:BYTE
FUNCPROTO TYPEDEF PROTO arg1:BYTE, arg2:BYTE
FUNCPTR TYPEDEF PTR FUNCPROTO
...
Main proc
push esi
mov ebx, OFFSET pfunc
;Put 0 into esi to call the first proc.
;Put 4 into esi for the second proc.
mov esi, 4
invoke FUNCPTR PTR , 65, 66
pop esi
ret
Main endp
This works fine. I'm just wondering if there is a better or more efficient way of using pointers to procs?
ThanxTry :
.code
;function
Func1 PROC
;func1 code
Func1 ENDP
Func2 PROC
;func2 code
Func2 ENDP
.data
; array of function pointers
pfunc DWORD Func1, Func2
; define function offset
FUNC1 = 0
FUNC2 = 4
.code
call pfunc
; or if the function is selected at runtime :
; ebx = function index
call pfunc[4*ebx]
This message was edited by karim, on 6/23/2001 1:05:56 PMThanx for your help.
Looks simpler than what I had. :-)
Ya'all may also want to check out the COM tuts, this is very similar to object virtual function tables. That code may be adaptable to your needs.
http://here.is/cominasm