Page 1 of 1
tls directory
Posted: Mon Aug 07, 2017 12:55 pm
by yofu
How to create tls directory?
This code causes an error illegal instruction
Code: Select all
!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
!End Data
Re: tls directory
Posted: Tue Aug 08, 2017 4:33 am
by citystate
what language is that? I don't think it's using pb commands (which may explain why you're getting illegal instruction errors)
Re: tls directory
Posted: Tue Aug 08, 2017 9:40 am
by yofu
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?
Re: tls directory
Posted: Tue Aug 08, 2017 11:05 am
by IdeasVacuum
What is wrong with using PB's function?
CreateDirectory(sDirectoryName.s)
Re: tls directory
Posted: Tue Aug 08, 2017 12:39 pm
by yofu
Lol, this is not a folder.
TLS -
Thread Local Storage
Re: tls directory
Posted: Tue Aug 08, 2017 1:55 pm
by Fred
try in lowercase 'data'
Re: tls directory
Posted: Tue Aug 08, 2017 5:26 pm
by yofu
Fred wrote:try in lowercase 'data'
The same error

Re: tls directory
Posted: Tue Aug 08, 2017 5:47 pm
by firace
Edit: (just a wild guess)
I think the reason is the "format PE GUI 4.0" directive which is required.
I guess that's why it won't work in PB, which only uses the MS COFF format IIRC.
Re: tls directory
Posted: Tue Aug 08, 2017 7:59 pm
by yofu
firace wrote:I guess that's why it won't work in PB, which only uses the MS COFF format IIRC.
Yes, when using the format MS COFF, also throws the same error
