Author Topic: invoking the function when its address is received from winapi  (Read 7015 times)

Vortex

  • Member
  • *****
  • Posts: 2106
Re: invoking the function when its address is received from winapi
« Reply #15 on: October 13, 2013, 05:56:13 AM »
Here is another version.

Vortex

  • Member
  • *****
  • Posts: 2106
Re: invoking the function when its address is received from winapi
« Reply #16 on: October 14, 2013, 01:38:57 AM »
Simple parameter checking. The macro will report now a supply of incorrect number of parameters.

Code: [Select]
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