The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Vermi on October 02, 2006, 06:19:21 PM

Title: reloc .exe without .reloc section ?
Post by: Vermi on October 02, 2006, 06:19:21 PM
You will surely found I've a strange idea, but I'm wondering if it's possible to relocate an executable that as no .reloc section.
I explain a little more :
I load the exe in the memoryspace of my current process, and then I want to call functions in that executable ( it's like a dll, but for now it's an exe, and I can't change It ) using LoadLibrary. I've made code to find the functions and it work fine, but when I jump, the function atempt to write the datas at the wrong place (exe has not been relocate :/ ). I have found an API ( ReBaseImage ), but I don't it's helpfull.

note : The ImportTable of the .exe is not filled, by LoadLibrary, but it's not a problem yet.

If anyone have an idea.... ^^

@+
Vermi
Title: Re: reloc .exe without .reloc section ?
Post by: trodon on October 02, 2006, 07:32:21 PM
hi Vermi this is seems like good idea, you can make .exe like dll, when you finish the code try to compile like this

\masm32\bin\ml /c /coff project.asm

\masm32\bin\Link /SUBSYSTEM:WINDOWS  /DEF: project.def  project.obj

so your dll will be created like exe file, when you do this open your exe file in some PE editor and change in charecteristic uncheck DLL
after this save your file and you can call this from another exe.
btw if someone have some bether solution please post how?

Title: Re: reloc .exe without .reloc section ?
Post by: Vermi on October 02, 2006, 09:31:30 PM
The problem is : the .exe I try to load into the memory is not from me, I don't have the source Ôo
For now, i'm thinking about writing a PE Loader internal to my program, but the problem of relocation is unsoluble without some API.
The best would be to map the exe at the right memory place ( 00400000 for most of exes, if I remember well ).
I'm still searching, if it's impossible, I will find another way ^^

@+
Vermi
Title: Re: reloc .exe without .reloc section ?
Post by: PBrennick on October 03, 2006, 12:36:53 AM
Please explain why you want to treat someone else's exe like a dll.  This sounds strange to me.  What are your goals?

Paul
Title: Re: reloc .exe without .reloc section ?
Post by: hutch-- on October 03, 2006, 12:43:37 AM
hmmmm,

Quote
I don't have the source

What you have in mind is not allowed under the forum rules so I have no alternative than to close this topic.