flat assembler
Message board for the users of flat assembler.
Index
> Windows > Name decorators when declaring EXTERNALS |
Author |
|
majidkamali1370 28 Dec 2011, 21:54
I don't know your answer but, about underline, it is for stdcall declaration.
As MSDN: Quote: An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12 http://msdn.microsoft.com/en-us/library/zxk0tw93%28v=vs.71%29.aspx |
|||
28 Dec 2011, 21:54 |
|
AsmGuru62 28 Dec 2011, 22:19
@wyvern: so are you asking for MASM coding or FASM coding?
Because, I have never had to use the underscores or these EXTRN things in FASM. |
|||
28 Dec 2011, 22:19 |
|
wyvern 28 Dec 2011, 22:38
@AsmGuru62 If you use FORMAT PE in FASM im pretty sure you will never use decorators. Even if you work with some linkers like GOLINK or ALINK you can ignore decorators. I think im not asking for a particular assembler coding, but mi most used assembler is FASM. For example look the FASM example at C:\FASM\EXAMPLES\MSCOFF\MSCOFF.ASM, it is using decoratos, like if it was good practice, good habit or whatever
From what i understand, name mangling is a C++ thing for linkers and is used by some vendors like Micrsooft or Borland, if im not wrong it was originally designed for "function overloading", so the linker can recognize diferent functions with the same name. Im in doubt if this is important or not for ASM development on Windows. FASM doesnt add the "_" prefix to functions (like MASM/TASM or GOASM with /ms), i should add this myself for some propposit?, or i can foget about this if mi linker of choice doesnt care?. And the "'__imp__ExitProcess@4'" thing is alien for me, its equivalent to "_ExitProcess@4" ? |
|||
28 Dec 2011, 22:38 |
|
AsmGuru62 29 Dec 2011, 00:18
I see... I write my whole programs in FASM only, so I am not using any linkers at all. But, I think, yes, you need decorations to interface FASM with other components, written not in FASM, but with some other type of language.
If I am not mistaken "_imp__xxxx" is some kind of a JMP to a real function. I have seen this often - in HLL when code calls an API -- the CALL itself come to a some kind of JMP table and from there it goes to a real API function imported from Windows DLLs. FASM, however, calls API straight by an address inside import table -- no additional jumps. Very cool! |
|||
29 Dec 2011, 00:18 |
|
revolution 29 Dec 2011, 00:42
Name decoration is not a fasm thing, or a Windows thing. It is a C/C++ thing. If you are linking to the C/C++ library then you have to match the names that C/C++ used when it made the library.
Also note that some C/C++ compilers have even worse looking name mangling that what you show above. |
|||
29 Dec 2011, 00:42 |
|
wyvern 29 Dec 2011, 01:08
So, calling a entry point like this "_start:" or even adding the "_" to var labels is unnecessary or absurd. I wonder why a lot of asm code out there is writenn like that.
|
|||
29 Dec 2011, 01:08 |
|
revolution 29 Dec 2011, 02:15
wyvern wrote: So, calling a entry point like this "_start:" or even adding the "_" to var labels is unnecessary or absurd. If you are using "extrn" directive then you will have to match the function name to whatever the other compiler has named the function. If you are using just the Windows API and your own asm code then you can name things in any way you please. |
|||
29 Dec 2011, 02:15 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.