This question is about understanding something about strings. I know I could use macros to do this better than it is possible with my humble assembly knowledge, but I want to learn. I would be glad about answers.
So when I try to invoke a correctly imported function like MessageBox (through macros, though
), I'd like to push the arguments at my own without invoke. I tried:
push MB_OK
push _string2
jmp @f
_string2 db "Caption",0
@@:
push _string1
jmp @f
_string1 db "My Text ",0
@@:
push dword 0
call [MessageBox]
This code works. But if I try to reserve bytes and define the strings before I push them, it doesn't work anymore. I personally wonder, why? The Box shows up but Caption and Text seem to be empty. I thought the reason could be, that I didn't declare a binary 0 at the end of the string. But the WIN API Helpfile says, that wsprintf adds a binary 0 automatically.
push MB_OK
cinvoke wsprintf,_string2,'%s',"Caption"
push _string2
jmp @f
_string2 rb 20
@@:
(... same for string 1...)
push dword 0
call [MessageBox]