I tried to use
mov rdx, 4
push rdx
mov rsi, temp_str
push rsi
mov rdi, temp_str1
push rdi
call memmove
and
sub rsp, 24
mov [rsp + 16], rdx
mov [rsp + 8], rsi
mov [rsp], rdi
call memmove
add rsp, 24
and other kinds of magic, but nothing works. Which spell do the job?
(temp_str and temp_str1 defined as
temp_str db "abc", 0
temp_str1 db "def", 0
, memmove is from msvcrt)
EDIT:
sub rsp, 32
mov rcx, temp_str1
mov rdx, temp_str
mov r8, 4
call memmove
also crashes.
EDIT 2: Full code:
format PE64 console
entry prog
include "win64ax.inc"
section '.idata' import data readable writeable
library kernel32, 'kernel32.dll', msvcrt, 'msvcrt.dll'
import kernel32, ExitProcess,'ExitProcess'
import msvcrt, memmove, 'memmove'
section '.text' code readable executable
prog:
;;mov rdx, 4
;;push rdx
;;mov rsi, temp_str
;;push rsi
;;mov rdi, temp_str1
;;push rdi
;;call memmove
;;sub rsp, 24
;;mov [rsp + 16], rdx
;;mov [rsp + 8], rsi
;;mov [rsp], rdi
;;call memmove
;;add rsp, 24
;;push rbp
;;mov rbp, rsp
;;push rdx
;;push rsi
;;push rdi
;;call memmove
;;mov rsp, rbp
;;pop rbp
sub rsp, 32
mov rcx, temp_str1
mov rdx, temp_str
mov r8, 3
call memmove ; crash
add rsp, 32
end_prog:
invoke ExitProcess, 0
section '.data' data readable writeable
temp_str db "abc", 0
temp_str1 db "def", 0