News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Alternative invoke macro

Started by Vortex, September 14, 2016, 04:58:45 AM

Previous topic - Next topic

Vortex

An alternative macro for 32-bit programming. It does not require functions prototypes and registers can be specified instead of function names. The same macro works with HJWasm and Masm.

A quick example :

include     ..\MessageBox.inc

.data

msg         db '_invoke macro test',0
capt        db 'Test',0
MsgBox      db 'MessageBoxA',0
user32      db 'user32.dll',0

.data?

hLib        dd ?

.code

start:

    _invoke  LoadLibrary,ADDR user32
    mov     hLib,eax

    _invoke GetProcAddress,eax,ADDR MsgBox

    _invoke eax,0,ADDR msg,ADDR capt,MB_OK

; without the _invoke macro :

;   invoke pr4 PTR eax,0,ADDR msg,ADDR capt,MB_OK

    _invoke FreeLibrary,hLib

    _invoke ExitProcess,0

END start

Vortex

A trick for the auto-declaration of external functions and creating import libraries from system DLLs.

Modifying invoke.inc :

IFNDEF funcname

    EXTERN funcname:PROC

ENDIF


Building the import libraries :

\PellesC\bin\polib /OUT:kernel32.lib /MACHINE:X86 %windir%\system32\kernel32.dll

\PellesC\bin\polib /OUT:user32.lib /MACHINE:X86 %windir%\system32\user32.dll

hutch--

 :biggrin:

Erol,

This looks like a piece of genius. I will have to give this a try. Gratsie.  :t

IFNDEF funcname
    EXTERN funcname:PROC
ENDIF