This is fasm
https://board.flatassembler.net/topic.p ... 500#132500
Code: Select all
format PE GUI 4.0
entry start
include '%fasminc%\win32a.inc'
section '.code' code readable executable
start:
mov [ExecOnExit],1
invoke MessageBox, 0, szHelloWorld, szHelloWorld, MB_OK
invoke ExitProcess, 0
section '.data' Data readable writeable executable
szTitle db 'Callback Msg', 0
szHelloWorld db 'Hello World',0
szCallback1 db 'This is the first tls callback function',0
szCallback2 db 'this is the second tls callback function',0
ExecOnExit dd 0
my_callback1:
;this will be executed only on application start, befor entry point.
mov eax, [ExecOnExit] ;check if this is the callback on start app, or on exit.
test eax, eax
jnz @f
invoke MessageBox, 0, szCallback1, szTitle, MB_OK
@@:
ret
my_callback2:
;this will be executed 2 times, on start and on exit the app.
invoke MessageBox, 0, szCallback2, szTitle, MB_OK
ret
section '.tls' Data readable writeable
Data 9 ;the tls directory is the 9nth directory entry.
.RawDataStartVA dd 0
.RawDataEndVA dd 0
.AddressofIndex dd adress_of_index
.AddressofCallback dd adress_of_callback
.SizeofZeroFill dd 0
.Characteristic dd 0
adress_of_index dd 0
adress_of_callback dd my_callback1, my_callback2, 0
End Data
section '.idata' Import Data readable writeable
library kernel32,'kernel32.dll',\
user32,'user32.dll',\
msvcrt,'msvcrt.dll'
include '%fasminc%\api\kernel32.inc'
include '%fasminc%\api\user32.inc'
include '%fasminc%\api\msvcrt.inc'
But inline asm returns an error: data 9 illegal instruction
Any ideas?