I don't have a good answer to any of this. A long time ago, I did a small amount of programming for Win (Win98!). I mostly used "-f obj" and Alink. As you observe, if we use "extern" and "import", we do:
call [ExitProcess]
As I recall, there's another way to do it, still using "-f obj" and Alink, and using "extern" but not "import" which involves linking against a .lib (with Alink?) and we use the more usual:
call ExitProcess
Unless I'm mistaken there's another variable called "__inp_ExitProcess" (possibly decorated). I suspect that Alink is swapping names around for us (to us?).
call [__imp_ExitProcess]
; equ
call ExitProcess
A guess, mind you!
As I recall, the only success I had with "-f win32" and using the MicroSoft linker (not quite the same version, I'm sure) was by downloading Hutch's MASM32 package and using kernel32.lib (etc.) from there. If all else fails, you might try that (beware the EULA!).
I've been told that we can "make our own import libraries" by putting just the "extern"/"import" stuff into a file, assembling it with "-f obj", and linking that .obj against our "main" .obj, assembled with "-f win32". The linker will complain about converting OMF to COFF, but it'll do it. So I'm told - haven't actually tried it, so I can't provide any details.
Another option would be to download the NASMX package. It uses Jeremy Gordon's "GoLink" linker, so isn't an answer to your question. I suspect GoLink does some "name swapping" for us, too. It may be a painless way to get a Windows .exe running, if you aren't too committed to using the linker you want to use. There aren't any .lib files in it AFAIK.
I'm sure MicroSoft has got all this stuff documented if you know where to look for it. I don't. Wish I had a better answer for ya!
Best,
Frank
Thank you for your answer!
It is weird that depending on if we use import or not in the code, the calling syntax is different. However I think I want to figure this out, I don't want to just use some tools and not understand the basis. I suppose it has something to do with the linking process, and I happened to get a book all about this!
For the "__imp_ExitProcess" thing, I have also tried, but it did not work. As I observed, the "__imp_" prefix may only apply to those GUI related functions like "__imp_MessageBoxA" (I read some article online and got this thing).
And about the OMF and the COFF, I have read in MSDN that the MS linker will convert OMF to COFF, but not all structures in OMF can be converted. So I don't like this, which is not a exact one to one mapping. And I also read that, OMF is very old, and nowadays it seems that only Borland is still using it (as I recall it correctly). That's why I want to use the win32 format.
I heard about GoLink, but since I have already VS2010, hence also the MS linker, I may want to try it first, but not downloading many new tools and finally I don't know which one will work with which one.
About the documentation, I always go for MSDN, and now MS has a new documentation helping program, once you get VS, you will have it installed. But of course if you are talking about those technical detail documentation, I also don't know, well of course, MS will not reveal so much technical detail about their products, right?
Alright, it seems like we are just chatting, but OK, this is how we grow up :-) Wish you all the best!