I'm don't understand how to do the more complicated macros...Is there some tutorial on macros, or
info text?
This is my current problem,
I like calling MessageBox in below way in my code, and would like to have a macro for it:
push MB_OK
call @f
db "title",0
@@: call @f
db "goodbye cruel world",0
@@: push NULL ; ( or hWnd )
call MessageBox
Thanks in advance. :tongue:
info text?
This is my current problem,
I like calling MessageBox in below way in my code, and would like to have a macro for it:
push MB_OK
call @f
db "title",0
@@: call @f
db "goodbye cruel world",0
@@: push NULL ; ( or hWnd )
call MessageBox
Thanks in advance. :tongue:
MsgBox MACRO titl:REQ, txt:REQ, button:=<MB_OK>, hnd:=<NULL>
LOCAL _1,_2
push button
call _1
db titl,0
_1: call _2
db txt,0
_2: push hnd ; ( or hWnd )
call MessageBoxA
ENDM
use like:
MsgBox "Dude:", "Where is my car?"
Thanks!! :) Just what I wanted!!
Can you explain these:
Does the 'REQ' mean the variable is a string?
Does the < >-brackets mean the contents inside the brackets is a define?
Can you explain these:
Does the 'REQ' mean the variable is a string?
Does the < >-brackets mean the contents inside the brackets is a define?
:REQ means value is required.
:=<{?}> means default value.
All arguments to macros are strings - there is no exception. MASM may evaluate the argument before passing it to the macro, but the macro always gets a string. MASM may evaluate the argument inside the macro when it is used, but the macro argument is always a string. :)
:=<{?}> means default value.
All arguments to macros are strings - there is no exception. MASM may evaluate the argument before passing it to the macro, but the macro always gets a string. MASM may evaluate the argument inside the macro when it is used, but the macro argument is always a string. :)
Great! I see things more clearly now! Soon I'll be the master of macros!!
Is there more handy 'evaluation-specifiers' (what to call it?)
like the
:REQ and :=<{?}>
:grin:
Is there more handy 'evaluation-specifiers' (what to call it?)
like the
:REQ and :=<{?}>
:grin:
:VARARG means grab all remaining arguments into one string (comma separated). Read chapter 9 of the MASM manual. Also, look at the example on the board and you will understand more.
I use MB macro at debug stage of multiprocess project.
It let me see in which process it appears.
It let me see in which process it appears.
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
$T MACRO sText
local szDummy
.data
IF @SizeStr(<sText>)
szDummy db sText, 0
ELSE
szDummy db 0
ENDIF
.code
EXITM <offset szDummy>
ENDM
MB MACRO mes
sub esp, 128
mov eax, esp
invoke GetModuleFileName, NULL, eax, 128
mov eax, esp
push MB_OK
push eax
push $T(<mes>)
invoke GetActiveWindow
push eax
call MessageBox
add esp, 128
ENDM
.code
start:
MB "qwerty"
ret
end start
Cool! Thanks, this helps me!