format PE64 console
entry start
include 'win64a.inc'
section '.text' code readable executable
start:
lea rax,[testmsg]
call onLog
xor rax,rax
call [ExitProcess]
int3
onLog:
; fix me
mov rsi,rax ; src str
lea rdi,[msgbuf] ; dst buff
mov rdx, 511 ; max chars
call strncpy ; copt string from [rax] to [msgbuf]
retn
int3
strncpy:
push rbp
mov rbp, rsp
xor rcx, rcx
jloop:
cmp BYTE [rsi + rcx], 0
je jend
cmp rcx, rdx
je jend
mov al, [rsi + rcx]
mov [rdi + rcx], al
inc rcx
jmp jloop
jend:
mov BYTE [rdi + rcx], 0
mov rax, rdi
mov rsp, rbp
pop rbp
ret
section '.data' data readable writeable
testmsg db "This is a test message!",0
msgbuf rb 512
section '.idata' import readable writeable
library kernel32,'KERNEL32.DLL'
include 'api/kernel32.inc'Code: ASM
fasm