flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > [little IDEA] Name decoration.

Author
Thread Post new topic Reply to topic
max



Joined: 20 May 2009
Posts: 1
max
Hi, All.
Sorry for my english Smile

FASM have "public" directive for COFF.

we can write

public MyProc as 'xxxMyProc'

and link it to our C code as xxxMyProc function

int xxxMyProc(int arg1);

but
if function is __cdecl we must have _MyProc name
if function is __stdcall we must have _MyProc@8 name (if proc with 2 DWORD args)
if function is __fastcall we must have @MyProc@8 name (if proc with 2 DWORD args)

and FASM can do it.

something like this.

for
public MyProc as __cdecl

generate equivalent

public MyProc as '_MyProc'


for
public MyProc as __stdcall(2) ; 2 - 2 args

generate equivalent

public MyProc as '_MyProc@8' ; 8 - 2*4 bytes (for x86-32)

for
public MyProc as __fastcall(2) ; 2 - 2 args

generate equivalent

public MyProc as '@MyProc@8' ; 8 - 2*4 bytes (for x86-32)



Name decoration rules:
http://msdn.microsoft.com/en-us/library/deaxefa7.aspx

Thanks.
Max
Post 20 May 2009, 09:44
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you can easily extend public to very similar functionality with macro
Post 20 May 2009, 11:26
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17715
Location: In your JS exploiting you and your system
revolution
Or you can override the proc macro to auto-generate the public name. But building strings with the pre-processor is tricky. You will need to learn match quite well.
Post 20 May 2009, 11:52
View user's profile Send private message Visit poster's website Reply with quote
guignol



Joined: 06 Dec 2008
Posts: 727
guignol
yeah Smile
a perfect match is, gently speaking, tricky Cool
Post 03 Jun 2009, 15:11
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.