flat assembler
Message board for the users of flat assembler.

Index > Main > How to implement tls.callbacks and question?

Author
Thread Post new topic Reply to topic
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
How can I implement tls.callbacks in fasm??


I get this error when trying to include this aplib.inc

C:\Documents and Settings\Owner\Desktop\crap\fasmexp\aplib.inc [7]:

aP_pack PROTO
c :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
error: illegal instruction.
Post 17 Oct 2005, 21:39
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
tls.callback? I have no idea what is this, but such definition 'name PROTO :DWORD, :DWORD' is masm-specific. Convert the code to fasm first. And use 'Search', this topic was mentioned about three times afair
Post 18 Oct 2005, 12:11
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Reverend wrote:
tls.callback? I have no idea what is this, but such definition 'name PROTO :DWORD, :DWORD' is masm-specific. Convert the code to fasm first. And use 'Search', this topic was mentioned about three times afair


tls? threadlocalstorage?

fs:[18] is a pointer to fs, aka teb, and from there you can check for the tlspointer

_________________
redghost.ca
Post 18 Oct 2005, 16:37
View user's profile Send private message AIM Address MSN Messenger Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
I know TLS stands for Thread Local Storage, but what does it have to do with
Quote:
C:\Documents and Settings\Owner\Desktop\crap\fasmexp\aplib.inc [7]:

aP_pack PROTO
c :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
error: illegal instruction.
??
Post 18 Oct 2005, 17:41
View user's profile Send private message Visit poster's website Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
It doesn't have anything to do with the proto... It was just a seprate question.

THREAD LOCAL STORAGE CALLBACKS ... How can I implement these in fasm?
Post 18 Oct 2005, 19:15
View user's profile Send private message Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One
tls callback is only used in NT Windows. in 9x it does not have any effects. u need to write the tls directory manually in fasm..
Code:
data 9
;here goes the tls directory.
end data
    


here's one example
Code:
include 'win32ax.inc'

.code
start :
      ret

proc tls_callback DllHandle, Reason, Reserved
     .if [Reason] = 1
      invoke MessageBox, 0, "Process_Attach", "tls_callback", 0
     .elseif {Reason] = 0
      invoke MessageBox, 0, "Process_Detach", "tls_callback", 0
     .endif
endp

.end start

.data

data 9
dd 0                    ;Raw Data Start VA
dd 0                    ;Raw Data End VA
dd tls_index            ;Address of Index
dd tls_callbacks        ;Address of Callbacks
dd 0                    ;Size of Zero Fill
dd 0                    ;Reserved

tls_index dd 0
tls_callbacks dd tls_callback, 0
end data

    


the tls_callbacks is virtual address that points to array of tls callbacks function and terminated by 0 and are called one by one by Windows. tls_callback procedure itself have the same arguments as DLL entrypoint. Please note that all addresses in tls directory are NOT rva. I hope Privalov may include tls macro set in the future in the std win32 include.
Post 19 Oct 2005, 02:51
View user's profile Send private message MSN Messenger Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
Thank you ancient.... That example is what I was looking for thank you so much Smile.... !!!!!

My friend used this as an anti-debug .. but I had no idea how to do it in fasm sigh.... THANKS!
Post 19 Oct 2005, 03:49
View user's profile Send private message Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One
u can also download PE/coff specification from M$ site.. the info are there.
Post 20 Oct 2005, 01:32
View user's profile Send private message MSN Messenger Reply with quote
Cthulhu



Joined: 12 May 2005
Posts: 29
Cthulhu
What type of data is "data 9" ?
Post 07 Nov 2005, 13:19
View user's profile Send private message Reply with quote
shism2



Joined: 14 Sep 2005
Posts: 248
shism2
data 9
dd 0 ;Raw Data Start VA
dd 0 ;Raw Data End VA
dd tls_index ;Address of Index
dd tls_callbacks ;Address of Callbacks
dd 0 ;Size of Zero Fill
dd 0 ;Reserved

tls_index dd 0
tls_callbacks dd tls_callback, 0
end data

I think it's probably just a structure
Post 08 Nov 2005, 01:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.