JJ,
> Most Windows API (flat) function names (such as ExitProcess) in
> the DLL are not mangled.
Correct. (I, wrongly, assumed you where talking about C{something}
libraries)
> And since I use the INVOKE directive to call the imported function,
> that directive uses function names appended with argument size -
> as defined by the PROTO directive.
And that is what the .H (or .INC) files are for: they describe *how* the
functions have to be called (and what kind of result you can expect).
> I could use the primitive CALL instruction to call the function so
> that I don't have to use mangled function names in the DEF/LIB
> file, but I'll have to PUSH the function arguments manually.
I wanted to go for a plain "no", but I guess it depends on the used
compiler/assembler itself.
For instance, I can call functions (inside my own program or DLLs) without a
PROTO (or in my case, a PROCDESC) in sight anywhere (and have done so for
many years). Though having them means that a compile/assemble time check
on the number and type of arguments can be performed.
But you could always create a .H file yourself for the DLL/LIB in question.
The only problem will than be where you get that "how many arguments does
this function take, what types are they" info from (welcome to my world by
the way. Its what I need to do for every DLL I want to use ...).
Luckily the MSDN has got a wealth of of information in that regard.
> I was just hoping that INVOKE is a better way to call a function,
> but things suggest that I was wrong.
No, you're right, it is (see above). It just needs a bit more work to be
able to keep using them.
> What compiler are using? Cause IIRC, IMPLIB is available only for
> Borland compiler.
I'm not. I'm using Borlands TASM32 v5 assembler, which was long ago used as
the backend for their C compiler. I bought it as a stand-alone package
though (which includes both IMPLIB and IMPDEF as well as a resource compiler
and other tools - it even included a few books. You know, real paper. :-) )
> Perhaps it would be easier to create a "builder" script that tries to
> compiles a project to retrieve "unsatisfied external symbol" errors
> and use that information to create the DEF file and make the LIB file.
I don't think that that will be possible. Although you will probably be
able to filter the "huh? I don't recognise this function name" entries from
the error listing, it won't include information to which DLL it expects the
name to be in. And you really need that for the DEF file.
Personally I would, for a "plain" DLL, opt to just generate the LIB file
from the DLL, and than either define the way the function needs to be called
(PROTO / PROCDESC) in the sourcefile itself, or in a (new) .H / .INC file.
But please do remember that the DEF vs LIB is an "or" thing. You can use
both at the same time, but you only *need* one of them (at least, with
Tasm32. YMMV).
> Too late. I've gone to the dark side before I see the bright side -
> almost 3 decades ago. >8D
Shucks. Thats what happened to me too (4 decades ago). :-)
>> IIRC I can force my linker to import everything by ordinal.
>
> Please do tell. Maybe it's time I stop trying to use what most people
> use, and use anything to achieve what I need.
I'm sorry. I just went back and checked. And although the TLINK32 "o" flag
is defined as "Import by ordinals" I could still see, when doing a hexdump,
the DLL function names in all their glory. I must have misunderstood (or
simply forgotten) something there. :-\
> How would you do if you want to mix both by name and by ordinal
> function importing?
I don't think its something you can control - from within the sourcecode I
mean. AFAIK its gouverned by the LIB and/or DEF file: if the function name
symbol is linked to a "by ordinal" import that will be used, if its linked
to a "by name" import, than it will be used.
Hmmm ... That makes me wonder: is the above "o" switch maybe ment for a LIB
entry where both a symbol as well as an ordinal entry are available. I'll
have to check that out some day.
> I know that it's possible, because I've seen some applications linking
> to (mostly) WSOCK32.DLL functions by both name and ordinal.
True. But thats than caused by the LIB file for WS2_32 than containing
both "by name" and "by ordinal" entries (and your function symbols
referencing them).
Do you have something like TDUMP - to "dump" the contents of a LIB (or DLL)
file with ? You can than see the different entries yourself.
Though I must say that WS2_32.DLL on my machine (XPsp3) does not seem to
contain any "by ordinal only" entries. But that does not mean the LIB could
not be constructed with both though.
Regards,
Rudy Wieser