Log in

View Full Version : A question about Binding two files


Hero
July 16th, 2005, 08:35
Hi all
I have an exe file that need an special DLL for running.
I add an section to my exe file,Then insert my DLL file fully in this new section.
I want to know how I can load this DLL and use it,without mapping it to HDD?
(I think this is named "file binding",but I didn't know how I can exactly do this)

sincerely yours

disavowed
July 16th, 2005, 09:02
http://www.bitsum.com/pebundle.asp ("http://www.bitsum.com/pebundle.asp")

Alternatively, you can write stubs for each function exported by your DLL, point them to the correct code in your binary, and export them. Then you can have the program LoadLibrary itself and use GetProcAddress to get the exported stubs to be called (idea stolen from "Hacker Disassembling Uncovered", Part I, Step Four, Method 0)

Hero
July 16th, 2005, 12:45
Thanks disavowed!
I was thinking that it should be something similar to what you mentioned,but
that must important is entrypoint.
What I should to do for entrypoint?Because the entrypoint is defers for calling
as EXE or as DLL.
In addition thanks for that ebook.I immediatly download it!Thanks for anyone who shares!

sincerely yours

joe
July 16th, 2005, 15:00
I find one tutorial 'Loading a DLL from memory' (this is exactly what You search):
http://www.joachim-bauch.de/tutorials/load_dll_memory.html/en/view

Hero
July 16th, 2005, 22:12
Thanks Joe!
This fully solved problem.Thanks for great tutorial.

sincerely yours

Hero
July 23rd, 2005, 06:09
Hi all
Now I want to ask another question.
Is there any program that binds two exe files and run them concurrently?
I tried to write this program using the tutorial for DLL,but it does not work.
it is becuase of relocations,that in DLL is available and correctable,but not
avaialable in exe.I don't know that adding an .reloc(i mean relocation section)
will correct problem or not,but i'm not sure.
because in a command like this:
mov eax,[425678]
from the main file,when it maps to another part of memory,this static address
should change.Is there adding an .reloc section will solve the problem?
Is there any program to do this(PEBundle is not working well)?

sincerely yours

YesItsMe
July 23rd, 2005, 09:56
Is there any program to do this?

yup

Thinstall will do it...

joe
July 23rd, 2005, 10:05
I tried to write this program using the tutorial for DLL,but it does not work.
it is becuase of relocations,that in DLL is available and correctable,but not
avaialable in exe.I don't know that adding an .reloc(i mean relocation section)
will correct problem or not,but i'm not sure.
because in a command like this:
mov eax,[425678]
from the main file,when it maps to another part of memory,this static address
should change.Is there adding an .reloc section will solve the problem?
Is there any program to do this(PEBundle is not working well)?

I'm sorry, but I thinj, that it's not possible to create program which can do it.
Problem is in relocation. To do this You must decompile program & recompile it with switch to generate relocations. But I don't known how to right decompile program (I fail on somple calc.exe, which is simple).
Problem how to run program from memory was described in title 'execute another application from program ' on MASMforum:
http://www.masmforum.com/simple/?topic=576.0
But only when You compile it from switch.
I think that it can be done with some ramdisk (but HOW???).

Hero
July 23rd, 2005, 14:42
Is there possible to correct this with hand making an allocation table?

joe
July 23rd, 2005, 14:54
I don't known structure of allocation table, but I think that You must have disasssembled source. I can mistake, but manually You must repair all referenced addresses. Some week ago I search this & nothink usefull. Only ramdrive system seems to be universal solution.
EDIT: There is else one solution - create emulation to API CreateProcess & adjust it to load file from memory. I can do it, but early I lost view (try to debug it!).