add flat assembler toolchain
This commit is contained in:
27
toolchain/fasmw17332/EXAMPLES/WIN64/DLL/MSGDEMO.ASM
Normal file
27
toolchain/fasmw17332/EXAMPLES/WIN64/DLL/MSGDEMO.ASM
Normal file
@ -0,0 +1,27 @@
|
||||
format PE64 console
|
||||
entry start
|
||||
|
||||
include 'win64a.inc'
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
start:
|
||||
sub rsp,8
|
||||
|
||||
invoke WriteMessage,message
|
||||
|
||||
invoke ExitProcess,0
|
||||
|
||||
section '.data' data readable
|
||||
|
||||
message db "Hi! I'm the example program!",0
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel32,'KERNEL32.DLL',\
|
||||
writemsg,'WRITEMSG.DLL'
|
||||
|
||||
include 'api/kernel32.inc'
|
||||
|
||||
import writemsg,\
|
||||
WriteMessage,'WriteMessage'
|
47
toolchain/fasmw17332/EXAMPLES/WIN64/DLL/WRITEMSG.ASM
Normal file
47
toolchain/fasmw17332/EXAMPLES/WIN64/DLL/WRITEMSG.ASM
Normal file
@ -0,0 +1,47 @@
|
||||
format PE64 console DLL
|
||||
entry DllEntryPoint
|
||||
|
||||
include 'win64a.inc'
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
|
||||
mov eax,TRUE
|
||||
ret
|
||||
endp
|
||||
|
||||
proc WriteMessage uses rbx rsi rdi, message
|
||||
mov rdi,rcx ; first parameter passed in RCX
|
||||
invoke GetStdHandle,STD_OUTPUT_HANDLE
|
||||
mov rbx,rax
|
||||
xor al,al
|
||||
or rcx,-1
|
||||
repne scasb
|
||||
dec rdi
|
||||
mov r8,-2
|
||||
sub r8,rcx
|
||||
sub rdi,r8
|
||||
invoke WriteFile,rbx,rdi,r8,bytes_count,0
|
||||
ret
|
||||
endp
|
||||
|
||||
section '.bss' data readable writeable
|
||||
|
||||
bytes_count dd ?
|
||||
|
||||
section '.edata' export data readable
|
||||
|
||||
export 'WRITEMSG.DLL',\
|
||||
WriteMessage,'WriteMessage'
|
||||
|
||||
section '.reloc' fixups data readable discardable
|
||||
|
||||
if $=$$
|
||||
dd 0,8 ; if there are no fixups, generate dummy entry
|
||||
end if
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel32,'KERNEL32.DLL'
|
||||
|
||||
include 'api/kernel32.inc'
|
Reference in New Issue
Block a user