Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TASM5 : Creating a DLL whith a function exported by Ordinal.

30 views
Skip to first unread message

R.Wieser

unread,
Mar 10, 2013, 11:59:04 AM3/10/13
to
Hello all,

My language of choice is Borlands Tasm 5.0 (32-bit), in which I can create
native DLLs and export functions by their names (using the "EXPORTDLL"
directive).

My question is, does anyone remember/know how to export a function by
Ordinal only (read: unnamed). If its at all possible that is.

Related question: Can I specify, for a named export, at which ordinal its
going to be in the export-list, and if so how.

Regards,
Rudy Wieser

P.s.
The documentation I got with the assembler does specify the directive, but
nothing in relation to the above.



Jeroen Mostert

unread,
Mar 10, 2013, 2:35:28 PM3/10/13
to
On 2013-03-10 16:59, R.Wieser wrote:
> My language of choice is Borlands Tasm 5.0 (32-bit), in which I can create
> native DLLs and export functions by their names (using the "EXPORTDLL"
> directive).
>
> My question is, does anyone remember/know how to export a function by
> Ordinal only (read: unnamed). If its at all possible that is.
>
I have no idea how EXPORTDLL works, but with the Microsoft tools (and I suspect
this works with the Borland tools as well) you have to use an explicit .DEF file
passed to the linker, and then the syntax is

EXPORTS
function @ordinal NONAME

> Related question: Can I specify, for a named export, at which ordinal its
> going to be in the export-list, and if so how.
>
That's the same as above, leaving off NONAME.

--
J.

R.Wieser

unread,
Mar 11, 2013, 6:17:44 AM3/11/13
to
Hello Jeroen,

> the syntax is
>
> EXPORTS
> function @ordinal NONAME

The function now shows up at the specified ordinal. Thank you.

Alas, the "NONOAME" directive seems to be ignored, its still named ... (the
fact that its ignored and does not throw an error is interresting in itself
though)

Related, new question: I see that the ordinal offset is always One (I
expected it to automatically adjust to the lowest ordinal used, but it
doesn't). Do you know if there is a directive (that I can try) to change
this offset ?

Regards,
Rudy Wieser


-- Origional message:
Jeroen Mostert <jmos...@xs4all.nl> schreef in berichtnieuws
513cd270$0$6951$e4fe...@news2.news.xs4all.nl...

Jeroen Mostert

unread,
Mar 11, 2013, 7:13:50 AM3/11/13
to
On 2013-03-11 11:17, R.Wieser wrote:
>> the syntax is
>>
>> EXPORTS
>> function @ordinal NONAME
>
> The function now shows up at the specified ordinal. Thank you.
>
> Alas, the "NONOAME" directive seems to be ignored, its still named ... (the
> fact that its ignored and does not throw an error is interresting in itself
> though)
>
Since .DEF files are an MS invention, it's likely the Borland linker just
ignores directives it doesn't know to increase compatibility. Try using NODUCKS
as a directive. If that gives an error, then it means NONAME is recognized but
not implemented, otherwise it means the linker just doesn't care about
directives it doesn't know.

> Related, new question: I see that the ordinal offset is always One (I
> expected it to automatically adjust to the lowest ordinal used, but it
> doesn't). Do you know if there is a directive (that I can try) to change
> this offset ?
>
Pretty sure there isn't, since it's redundant with explicitly specifying
ordinals. The case of "I want some functions to appear at these ordinals, but
please automatically do something sensible for the rest" probably wasn't
considered by the toolsmiths.

The linker *ought* to be clever enough not to reuse ordinals (i.e. if you've
specified one explicitly for a function the auto-assigned ordinals will just
skip that one, and not give an error) but I haven't tried.

Worst case you'll have to write a tool yourself to generate the .DEF file with
ordinals like you want them.

--
J.

R.Wieser

unread,
Mar 11, 2013, 8:48:45 AM3/11/13
to
Hello Jeroen,

> Since .DEF files are an MS invention, it's likely the Borland
> linker just ignores directives it doesn't know to increase
> compatibility.

Something I thought of as well. But than again, what good is
"compatibility" when the results are not the same. :-\

> Pretty sure there isn't, since it's redundant with explicitly
> specifying ordinals.

Quite so. On the other hand, 1) starting named exports at a certain offset
(without explicitily defining ordinals for all of them) than becomes a
possibility 2) as the linker does not do it automatically I assumed that its
needed to be done explicitily.

> The case of "I want some functions to appear at these
> ordinals, but please automatically do something sensible
>for the rest" probably wasn't considered by the toolsmiths.

That it actually does: The ordinal export went where I wanted it, the named
export was put at ordinal 1 (the first free one).

The situation I asked the question about was a single ordinal export at (for
instance) 10. A dump of the DLL showed me 10 exported adresses, 1 used.
Thats, in the DLL, wasting 9 entries in two tables.

> Worst case you'll have to write a tool yourself to generate the
> .DEF file with ordinals like you want them.

:-) Yes, that won't be a problem. Its just that I see non-optimal
behaviour and like to know if I can alter it.

The problem how to let the linker generate an ordinal-only export in the DLL
remains though. Oh well, if push comes to shove I can always write
something which will patch the generated DLL (using either the DEF file or
some added info in the sourcefile), removing the names from the apropriate
tables.

Thanks for the answers.
Rudy Wieser


-- Origional message
Jeroen Mostert <jmos...@xs4all.nl> schreef in berichtnieuws
513dbc6e$0$6909$e4fe...@news2.news.xs4all.nl...
0 new messages