In borland Delphi, if you put the keyword (export) after the function declaration, the function would be exported whether or not the file is a DLL. i want to know if it's possible to use a function exported in an EXE file, because every time i tried, i ended up with access violation errors. can anybody help?
Posted on 2006-05-01 21:59:42 by XCHG

Sure, just create a DEF file like you would to declare the exports of a DLL.
You may also need to declare the exported procs as PUBLIC, I can't remember.
Posted on 2006-05-02 00:55:01 by Homer
Just keep in mind that win9x doesn't support importing from exe files, even if the exe has relocations. There may be some special-cases where a DLL could use GetModuleHandle to obtain the exe handle and get at it's imports, but I haven't played with that.
Posted on 2006-05-02 02:35:45 by f0dder
Warcraft III's EXE exports many functions and works properly on win9x. So there has to be a way to make it work.
Posted on 2006-05-02 14:25:00 by ti_mo_n

Warcraft III's EXE exports many functions and works properly on win9x. So there has to be a way to make it work.


What does it export to, though? Other programs, or DLL files that warcraft3.exe uses?
Posted on 2006-05-02 14:30:40 by f0dder
Other warcraft's DLLs, like Game.DLL
Posted on 2006-05-02 14:44:33 by ti_mo_n

Other warcraft's DLLs, like Game.DLL


Allow me to quote myself, then: There may be some special-cases where a DLL could use GetModuleHandle to obtain the exe handle and get at it's imports, but I haven't played with that.

- the issue with exports from EXEs is when other EXEs try to do LoadLibrary on them.
Posted on 2006-05-02 14:51:24 by f0dder
Oh, OK. Didn't know that :shock: Thank you for the informaion :)
Posted on 2006-05-02 15:01:36 by ti_mo_n
Yeah i got it to work, but it's too bad that we can't invoke the exported function of another exe file through another exe file.

btw thanks everyone
Posted on 2006-05-04 22:44:35 by XCHG

Yeah i got it to work, but it's too bad that we can't invoke the exported function of another exe file through another exe file.

btw thanks everyone


That would be pretty much impossible as they are running in different address spaces, any pointers returned would be jibberish and useless.
Posted on 2006-05-05 16:09:45 by donkey
Well, both EXEs and DLLs are just Portable Executables - an EXE with a relocation section (or a different imagebase than 0x400000) should be mappable just fine in another process. 9x doesn't handle this, though. Can't remember the exact results on NT - it was possible to load the EXE and get at resources, but I can't remember whether relocations where applied.
Posted on 2006-05-05 16:17:47 by f0dder

Well, both EXEs and DLLs are just Portable Executables - an EXE with a relocation section (or a different imagebase than 0x400000) should be mappable just fine in another process. 9x doesn't handle this, though. Can't remember the exact results on NT - it was possible to load the EXE and get at resources, but I can't remember whether relocations where applied.


I would think that you would have to load with LOAD_LIBRARY_AS_DATAFILE and so nothing is mapped. I will have to try it some day.
Posted on 2006-05-10 00:09:32 by donkey