News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

invoking the function when its address is received from winapi

Started by shaikkareem, October 11, 2013, 07:40:07 PM

Previous topic - Next topic

Vortex

Simple parameter checking. The macro will report now a supply of incorrect number of parameters.

include     MacroCall.inc

MessageBox  equ <pm4>

.data

user32      db 'user32.dll',0
MessageBoxA db 'MessageBoxA',0
msg         db 'Macro calling MessageBox',0
msg2        db 'Another MessageBox test',0
capt        db 'Test',0

.data?

hDLL        dd ?
pFunc       dd ?

.code

start:

    invoke  LoadLibrary,ADDR user32
    mov     hDLL,eax

    invoke  GetProcAddress,eax,ADDR MessageBoxA
    mov     pFunc,eax

;   The suffix pm is activating the number of parameters check

;   pmX : X is the number of parameters.

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

   _invoke  %MessageBox pFunc,0,ADDR msg2,ADDR capt,MB_OK

    invoke  FreeLibrary,hDLL
    invoke  ExitProcess,0

END start