Can someone explain what would be the purpose of TYPEDEF PROTO, why would it be used?
The masm manual doesn't give an example of its use.
thanks
rags
A typedef proto would be used to define a pointer to a function so that when used
the correct argument validation is done.
rags,
See if this pair of macros has the TYPDEF data you are after.
; --------------------------------------------
; the following two macros are for prototyping
; direct addresses with a known argument list.
; --------------------------------------------
SPROTO MACRO func_addr:REQ,arglist:VARARG ;; STDCALL version
LOCAL lp,var
.data?
func_addr dd ?
.const
var typedef PROTO STDCALL arglist
lp TYPEDEF PTR var
EXITM <equ <(TYPE lp) PTR func_addr>>
ENDM
CPROTO MACRO func_addr:REQ,arglist:VARARG ;; C calling version
LOCAL lp,var
.data?
func_addr dd ?
.const
var typedef PROTO C arglist
lp TYPEDEF PTR var
EXITM <equ <(TYPE lp) PTR func_addr>>
ENDM
Hello,
At what he can be used ?
Here is a sample for dynamic call of dll function
;declare
PExitProcess TYPEDEF PROTO :DWORD
FExitProcess TYPEDEF PTR PExitProcess
ExitProcess TEXTEQU <FExitProcess ptr AExitProcess>
;data
AExitProcess dd 0
;code
;-- we have got HdllKernel by loadlibrary
invoke GetProcAddress,HdllKernel,SADR("ExitProcess")
mov AExitProcess,eax
;and now we can call the function in the same manners if there is
;the user32.inc and user32.lib included,but there are not loaded
invoke ExitProcess,0
;---------------------------------------------------------------------------------------------------------------------------------------
It can be used also for com in the same manners
ToutEnMasm
Thank you for the explanations and examples of how TYPEDEF PROTO is used.
Looking at the help file included with the masm32 package I was unable to make heads
or tails of it.
Thanks,
Rags