Jump to content
Tuts 4 You

Exe to DLL


Loveless

Recommended Posts

Hey guys,

I'm looking to transform an EXE into a DLL. Nothing complex, just want the app to run when LoadLibrary executes DLL main. I don't know if it's possible to do this, and I don't know if it's been done. A quick review revealed nothing. However, any insights into this would be much appreciated.

-Loveless

Link to comment

Right off hand, either you could rip whe whole thing and compile to a dll... or write a dll to extract the program to a temp dir or wherever and run it.. Like I said just first thing that comes to my mind.

Doc

Link to comment

Thanks Dr. However temp dir doesn't work as I want it to be loaded in memory as a DLL. I doubt I can rip the entire thing either, program in question is 8 megs compiled (did someone say BLOAT ****ING TED?) (no offence teddy)

Edited by Loveless
Link to comment

Well, I got the damn thing to load, except it wouldn't load at 00400000 so I had to change imagebase to 10000000. Sadly there are no relocs for the exe so this completely ****ed up the code sections interaction with .data (everything pointing to 00Bxxxxx, should be 10Exxxxx or whatever). I tried to use reloc rebuilder by PE Tools and DLL rebaser by Dr Golova but PETools said there are too many relocs and Golova's tool only works with the import table. Sooooo..... any suggestions? I might code something to go through the damn thing with Hackman dissassembler DLL and rebase all Imm32 to +new_imagebase. But I'm lazy, and I'd rather use existing tools.

-Loveless

Edited by Loveless
Link to comment
Well, I got the damn thing to load

Yeah I played around with a couple exe's have same problem.... 8 megs :banana: anyway out of pure intrest ill keep on ****ing around with it. Good luck man.

Doc

Edited by DrPepUr
Fucking bannana supposed to be a horse taking a dump :-\
Link to comment
Well, I got the damn thing to load, except it wouldn't load at 00400000 so I had to change imagebase to 10000000. Sadly there are no relocs for the exe so this completely ****ed up the code sections interaction with .data (everything pointing to 00Bxxxxx, should be 10Exxxxx or whatever). I tried to use reloc rebuilder by PE Tools and DLL rebaser by Dr Golova but PETools said there are too many relocs and Golova's tool only works with the import table. Sooooo..... any suggestions? I might code something to go through the damn thing with Hackman dissassembler DLL and rebase all Imm32 to +new_imagebase. But I'm lazy, and I'd rather use existing tools.

-Loveless

Is there a reason you don't just leave it at 0x400000 and have the base of the loader at a different location?

Link to comment
CodeExplorer

Regarding changing from EXE to DLL:

The difference between and EXE and a DLL comes under Characteristics flag

- is Dll flag selected or not.

Also a exe don't have Export Table - I don't know any tools which can add Export Table and not even a tools which can rebuild Export Table :cry:

Anyway I think you don't need Export Table, just change some things at Entry Point.

Cheers,

CodeRipper

Link to comment

Hello hello,

What I've done so far:

Changed in PE header characteristics to DLL. Relocs still stripped.

DLL refuses to load because its address space is taken up by windows and there are no relocs so it cant rebase. So, now I break in olly on System Entrypoint, and I unmap the memory windows had taken up, and then load the Library. However, dep gets angry at me. So I turned of DEP. Now am testing. Will post what happened later :)

@Killboy: reloz isn't what I'm looking for, sorry :( Something like PE Tools reloc rebuilder plugin would be nice.

Edited by Loveless
Link to comment
Also a exe don't have Export Table - I don't know any tools which can add Export Table and not even a tools which can rebuild Export Table :cry:
Sorry mate, I don't agree... I have found hundreds of exe files with export table, even I have developed several using it.

No tools performing that task? I have lot of code that performs that. Maybe it could be added to a tool... ;)

Anyway, if you don't build a relocations section, the dll won't be loaded. The system needs that information to load it.

Try this tool to rebuild a relocations section:

http://www.tuts4you.com/download.php?view.419

Good luck

Nacho_dj

Link to comment

Thanks Nacho, but ReloX only works if the Exe can load itself into 2 different places and then have me dump it. But how could it load itself in 2 different imagebases if it doesnt have relocs in the first place, eh? :D

-Loveless

Link to comment
CodeExplorer

"Sorry mate, I don't agree... I have found hundreds of exe files with export table, even I have developed several using it."

I know that some exes have Export Table - I saw such exes (I've forgot to mention this);

while all Dlls always have Export Table.

Cheers

CodeRipper

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...