Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

dllexport - Can a standard executable have an export table?

I have an executable written in C that has some functions in it that I would like to use from a c# application. I have written plenty of dlls before and was able to use functions in them by prepending __declspec(dllexport) to the function declaration. Can I do this from an executable? will the executable actually export the function?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes you can! Yes the executable will export the functions. This is not done very often, but it works pretty good. According the Specification (http://msdn.microsoft.com/en-us/gg463119.aspx) of the Executable, there is no difference between DLL and Executable as far as the Exports is concerned. EXE like DLL can have an Export Table directory that documents the functions that will be exported by the image. As an Example of a "normal" Executable exporting functions, have a look at Chrome.exe. See the snapshot I made using PEStudio showing Chrome exporting some functions. Some Windows built-in Executable also export functions (e.g. the Local Security Authority Subsystem - lsass.exe). The Windows Kernel (ntoskrnl.exe) image also exports more than 2000 functions (on a Windows7 system).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...