News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

TYPEDEF PROTO?

Started by rags, September 30, 2005, 06:34:25 AM

Previous topic - Next topic

rags

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
God made Man, but the monkey applied the glue -DEVO

James Ladd

A typedef proto would be used to define a pointer to a function so that when used
the correct argument validation is done.

hutch--

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
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm

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







rags

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
God made Man, but the monkey applied the glue -DEVO