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.
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 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:
DUMPBIN /EXPORTS wsock32.dll > wsock32.def
Then edit the wsock32.def to include these lines before the list of names:
LIBRARY wsock32
EXETYPE NT
SUBSYSTEM WINDOWS
EXPORTS
Finally, at the end of the DEF add a line to forward the symbol:
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.