Here is a macro to copy strings to the stack :
StrToStack This string is passed to the stack
esp points to the address of the string in the stack.
The StrToStack macro splits a string to DWORD values and pushes them to the stack :
kc
ats
eht
ot d
essa
p si
gni
rts
sihT
push 27491
push 1635021600
push 1701344288
push 1869881444
push 1702064993
push 1881174889
push 543649385
push 1920234272
push 1936287828
Examples :
include Test.inc
include StrToStackMacro.inc
; DEBUG_STR_TO_STACK=1
.code
start:
invoke StdOut,\
@StrToStack(Line copied to the stack)
add esp,stackcount
invoke ExitProcess,0
END start
include Test.inc
include StrToStackMacro.inc
; DEBUG_STR_TO_STACK=1
.data
frmt db 13,10,13,10,'%s',13,10,'%s'
db 13,10,13,10
db 'Length of string1 = %d',13,10
db 'Length of string2 = %d',13,10
db 0
.data?
str1 dd ?
str2 dd ?
len1 dd ?
len2 dd ?
stack dd ?
buffer db 128 dup(?)
.code
start:
StdOutX <Macro test>
StrToStack This string is passed to the stack
mov str1,esp
mov stack,stackcount
mov len1,stringlen
mov str2,\
@StrToStack(The second long line copied to the stack)
add stack,stackcount
mov len2,stringlen
invoke wsprintf,ADDR buffer,\
ADDR frmt,str1,str2,len1,len2
invoke StdOut,ADDR buffer
add esp,stack
invoke ExitProcess,0
END start
stackcount : defined by the macro, number of bytes to balance the stack to remove the string
stringlen : defined by the macro, the length of the string in the stack