Hello,

a few misc question about imports and exports ....

Using a debugger sometimes I have seen the same function listed twice in import tables at different addresses. This is something that I have always wondered about. How can it be and why???

Also, I have seen dlls export variables. How can you do it? I mean how do you compile/link a dll or exe to have it export variables?

One final question: how can you export functions (how do you compile/link?) in a exe and why? I mean why have an exe and not a dll export functions?
Thx to all.

H.
Posted on 2003-02-20 05:16:15 by yaa

One final question: how can you export functions (how do you compile/link?) in a exe and why? I mean why have an exe and not a dll export functions?


yaa,

You can check the thread:

http://www.asmcommunity.net/board/index.php?topic=8726&highlight=export+function
Posted on 2003-02-20 05:28:31 by Vortex
Vortex, my questions where stimulated by that thread ... yet they are not unaswered in said thread, reason why I decided to post them.

H.
Posted on 2003-02-20 06:28:09 by yaa
Are my questions really that complex that no one is answering?

yaa
Posted on 2003-02-22 12:20:34 by yaa
Using a debugger sometimes I have seen the same function listed twice in import tables at different addresses. This is something that I have always wondered about. How can it be and why???

Why wouldn't it be possible :) ?
You probably won't find it in 'normal' programs. Sometimes packers import one function out of each dll to eliminate the need for a loadlibrary call, and in addition add some import information for the loader, so some functions might appear twice.

Also, I have seen dlls export variables. How can you do it? I mean how do you compile/link a dll or exe to have it export variables?

Just make the variable public (PUBLIC var in masm) and add it to the exports section in the .def file.

One final question: how can you export functions (how do you compile/link?) in a exe and why? I mean why have an exe and not a dll export functions? Thx to all.

Use a .def file when linking the exe. I don't know why you'd need it but on the other hand there's no reason not to allow it since dlls and exes share the same format (PE).

Thomas
Posted on 2003-02-22 13:15:43 by Thomas
Hello Thomas,

first of all thank you for your answers.

I saw the same function imported twice in a non packed application although I just can't find it anymore, anyhow it did surprise me. Can I think about it as a "missed" optimization by the compiler???
From your answer I take that linkers will most of the time create a IAT with a single entry for each function.

A public variable in MASM seems to me to correspond to a global non static variable in C.

The only exported function in exe I have always known about is the ___CPPdebugHook function which is left by Borland's compilers (Delphi and C++) in executables for debugging purposes.

Regards,
yaa
Posted on 2003-02-23 17:51:46 by yaa