The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Germain on March 13, 2010, 06:54:39 AM

Title: How could I push literal text to a function?
Post by: Germain on March 13, 2010, 06:54:39 AM
Hi to all :)

I would like to know how could I push literal text to a function...

for example, if I use a messagebox, the normal way is this:

invoke MessageBox, NULL, addr Message, addr Title, MB_OK

right?

but all I want to do is this:

invoke MessageBox, NULL, "lalalalal =D", "my title :D", MB_OK

I've tested a macro made by myself but it doesn't work :/

   T MACRO TEXT
   .data
      Text_ byte MAX_PATH dup (?)
   .code
   
   mov eax, sizeof TEXT
   xor edi, edi
   
      .repeat
         mov bl, byte ptr TEXT
         mov byte ptr [Text_+edi], bl
         inc edi
      .until edi == eax
      
      push offset Text_
   ENDM


I was using it like this:
T <"ABC">

But I got an error xD

Anyone can help me?

I would appreciate your help :)

Thanks in advance ;)
Title: Re: How could I push literal text to a function?
Post by: hutch-- on March 13, 2010, 08:04:07 AM
Germain,

Have a look at the available macros for simplifies text handling.


fn MessageBox,hWnd."Text Message","Title",MB_OK

; or

mov var, rv(MessageBox,hWnd."Text Message","Title",MB_YESNO)


You must have the macros.asm file included to use them.

God I hate these new keyboards. !!!!
Title: Re: How could I push literal text to a function?
Post by: BlackVortex on March 13, 2010, 08:15:47 AM
In GoAsm you can do this :
invoke MessageBox, NULL,"Test1","Title",MB_OK

Also, I've made a macro :
MBox(%lpText,%lpTitle) MACRO
INVOKE MessageBox,0,addr %lpText,addr %lpTitle,MB_OK
ENDM


So I can quickly do :
MBox("Text1",addr sz_title)
or
MBox("Text1","MyTitle")
Title: Re: How could I push literal text to a function?
Post by: Slugsnack on March 13, 2010, 09:46:34 AM
invoke MessageBox, NULL, chr$("lalalalal =D"), chr$("my title :D"), MB_OK
Title: Re: How could I push literal text to a function?
Post by: Germain on March 13, 2010, 04:36:38 PM
Quote from: BlackVortex on March 13, 2010, 08:15:47 AM
In GoAsm you can do this :
invoke MessageBox, NULL,"Test1","Title",MB_OK

Also, I've made a macro :
MBox(%lpText,%lpTitle) MACRO
INVOKE MessageBox,0,addr %lpText,addr %lpTitle,MB_OK
ENDM


So I can quickly do :
MBox("Text1",addr sz_title)
or
MBox("Text1","MyTitle")


Thanks to all :P

I liked your macro :dance: