The MASM Forum

64 bit assembler => UASM Assembler Development => Topic started by: Vortex on September 14, 2016, 04:58:45 AM

Title: Alternative invoke macro
Post by: Vortex on September 14, 2016, 04:58:45 AM
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
Title: Re: Alternative invoke macro
Post by: Vortex on September 14, 2016, 08:07:51 PM
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
Title: Re: Alternative invoke macro
Post by: hutch-- on September 14, 2016, 10:16:09 PM
 :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