Hi ,
From the NASM Manual (6.2.4)
The IMPORT directive takes two required parameters, separated by white space, which are (respectively) the name of the symbol you wish to import and the name of the library you wish to import it from. For example:
import WSAStartup wsock32.dll
A third optional parameter gives the name by which the symbol is known in the library you are importing it from, in case this is not the same as the name you wish the symbol to be known by to your code once you have imported it. For example:
import asyncsel wsock32.dll WSAAsyncSelect
Looks to be related to your query.
Regards,
Mathi.
WARNING: |
I haven't used Windows in a few years. I'm not sure how up to date this information is. |
Is it possible to have the name within NASM be different than the name of the name of the function in the imported DLL file?
DUMPBIN /EXPORTS wsock32.dll > wsock32.def
LIBRARY wsock32
EXETYPE NT
SUBSYSTEM WINDOWS
EXPORTS
WSAAsyncSelect = asyncsel
WARNING: I haven't used Windows in a few years. I'm not sure how up to date this information is. Is it possible to have the name within NASM be different than the name of the name of the function in the imported DLL file?
Yes you can! But not with NASM. ???
Okay, so that answer isn't exactly clear is it. ;D
The problem with your above question is, what you want to do isn't the responsibility of NASM and therefore NASM doesn't do it. Aliasing external functions is for your linker to handle. What VB6 was doing was creating a .DEF file and using the LIB program to generate a .LIB file which got linked into your program. The .LIB file would contain an alias that forwards one symbol to the other. For example, here (http://www.dsource.org/projects/bindings/wiki/DefFiles/Kernel32) is a .DEF file for KERNEL32.DLL. This file can be built using LIB /DEF:KERNEL32.DEF and then the resulting KERNEL32.LIB can be linked in at compile-time. In this example, the internal (decorated) names are being aliased with simpler (undecorated) names.
If you want to create a DEF file for a DLL, use the DUMPBIN utility that comes with MS VC++. With this program, you can get a list of all the function names exported by the DLL, like so:Code: [Select]DUMPBIN /EXPORTS wsock32.dll > wsock32.def
Then edit the wsock32.def to include these lines before the list of names:Code: [Select]LIBRARY wsock32
EXETYPE NT
SUBSYSTEM WINDOWS
EXPORTS
Finally, at the end of the DEF add a line to forward the symbol:Code: [Select]WSAAsyncSelect = asyncsel
And finally, you can create your .LIB from this .DEF file like we do above, LIB /DEF:wsock32.def. Then in your assembler code, you should be able to just use EXTERN asyncsel without worrying about what the other name was.
Of course, this assumes you are using a linker that supports LIB files, like Microsoft's Linker or Pelle Orinius' Linker. As far as I know, GoLINK doesn't have support for non-static .LIB files (in fact, it's a bragging right that it doesn't need them and uses the DLL's directly). So your mileage may vary.
Use %define