News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Loading and running EXEs and DLLs from memory

Started by Vortex, November 06, 2005, 02:44:26 PM

Previous topic - Next topic

Antariy

Quote from: Vortex on March 11, 2011, 06:36:16 PM
Hi ragdog,

Be sure that your EXE or DLL does not to have a resource section. It may be the case that my PE loader cannot handle properly your DLL. I am not a Delphi coder and it's not easy to make a comment without a detailed testing of your case.

Hi, Vortex!

I haven't saw this thread before :U

ATM I'm assume, your code parse executable, and make it to "look" like if it was loaded by Windows loader.
But this module will never be instance of executable module for Windows itself. So, any functions which require to explicit/implicit getting of handle of module - will fail.
Delphi itself uses very deep RTLing for almost each action in the program. This RTL might use anything from a bunch of a functions, which require to work with system-type module, not manual loaded. So, it seem that this is reason why Delphi's modules are not work. Just anything HLL with complex RTL will not work with probability 99%.
This is my guess.

Vortex

#16
Hi Antariy,

Many thanks for the info. Much appreciated. My guess was that there might be a specific case with Delphi. Your reply explains well the situation. My PE loader is a simple one but it can handle normal executables created with asm and C \ C++  I don't know if there is a chance to tweak Delphi executables to work with my library. That would be interesting.


Vortex

#18
Here is version 2.1

- The linear search function in the GetProcAddr module is now replaced by a binary search algo delivering higher performance.
- The DLLmem example is improved with a DLL exporting more functions.

Vortex

The idea of EXE \ DLL from memory can be useful to create executables exporting functions. Attached zip file is illustrating this case.

ExeExportFunc.exe is a console application exporting functions. ImportFuncFromEXE.exe imports functions from that executable.

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Vortex

Hi Onan,

You are welcome. Another method to build an EXE exporting function is to change the base address :

\MASM32\BIN\link /base:0x47290000 /MAP /MAPINFO:FIXUPS /SUBSYSTEM:WINDOWS exportexe.obj

The link parameters are not mine. I think I got them from another forum topic.