Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 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 Reply

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...