flat assembler
Message board for the users of flat assembler.

Index > Windows > Something wrong with my macros:(

Author
Thread Post new topic Reply to topic
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13
I try to write a MessageBox macros in order to call MessageBox only with one operand...

for example

Code:
WriteMessage "MessageBox macros"    


instead of

Code:
push 0
push 0
push message
push 0
    



It's a source, but it's smth wrong with it:

Code:
format PE GUI 4.0
entry start
include '%fasminc%\win32a.inc'
section '.data' data readable writeable
Caption db ' ',0
section '.code' code readable writeable executable
start:
jmp next
macro WriteMessage mess
{
local behind
push MB_OK
push Caption
call behind
db mess,0
behind:
push 0
call [MessageBox]
}
next:
WriteMessage 'test string!'
invoke ExitProcess,0
section '.idata' readable writeable
library user32,'user32.dll',
kernel32,'kernel32.dll'
import user32,
MessageBox,'MessageBoxA'
import kernel32,
ExitProcess,'ExitProcess'
    



P.S. Sorry, for my awful English...

_________________
FASM Rulezzzzzz!
Post 18 Oct 2007, 18:24
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
format PE GUI 4.0
entry start 
include '%fasminc%\win32a.inc' 

section '.data' data readable writeable
  Caption db ' ',0

section '.code' code readable writeable executable

start:
; jmp next ; No need at all since macros are in the output file only at the places you call them
macro WriteMessage mess 
{ 
local behind

  push MB_OK
  push Caption
  call behind

  db   mess,0

behind:
  push 0
  call [MessageBox]
} 
;next:

WriteMessage 'test string!'
invoke ExitProcess,0

section '.idata' readable writeable import ; You forgot to add "import"
library user32,'user32.dll',\
kernel32,'kernel32.dll' 
import user32,\
MessageBox,'MessageBoxA' 
import kernel32,\
ExitProcess,'ExitProcess'      


It only was a simple mistake. I also commented the first jump because it is not needed (check comments).
Post 18 Oct 2007, 18:36
View user's profile Send private message Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13
Oh... Thanks alot!Smile
You always help me;)
Post 18 Oct 2007, 18:45
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.