📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Target Specific - General  >>  relocation without reloc table

Topic created on: December 14, 2010 10:51 CST by AMX .

Hello,

I basically want to execute a function from a Windows(TM) PE executable (.EXE) so I load it with LoadLibrary, assign the functions address to a function ptr and call it. The problem is that the .EXE gets loaded to 0x440000 instead of 0x400000 so for example "mov     eax, dword ptr ds:OFFS" contains a wrong offset. Im working under linux/wine. I want a solution.

A preferred solution is probably to force the 0x400000 image base address on loading if thats possible. I haven't found something like that. Possible? (VrtulaAlloc also fails to allocate enough memory)

My current approach is to find all instructions that contain hardcoded offsets and skip all others (via http://www.devmaster.net/codespotlight/show.php?id=25). Does code like this probably already exist? I really don't want to reinvent the steel here ;-).

I suspect the length calculator (http://www.devmaster.net/codespotlight/show.php?id=25) to give wrong results for some kind of jump like "0xff 0x24 #imm32 <-> jmp     ds:off[eax*4]" can somebody confirm this.

Regards

  cseagle     December 15, 2010 12:40.25 CST
So you have written program A that wants to load program B and invoke a function within program B.  The problem as I see it is that program A is probably already loading at 0x400000 since this is the default ImageBase for windows executables.  Why not use the Visual Studios /BASE:addr option to specify a different ImageBase for program A when you build it?  Then the space at 0x400000 should remain free for you to load program B there?

  RabidCicada     January 6, 2011 11:36.36 CST
If I remember right there is a way to get loadlibrary or some other system call to resolve the relocation table stuff.  It might be a parameter or flag.

There is a lower level system call on Pre-Vista/7 that can resolve everything like it was going to be executed but it doesn't execute it.

It's been a while since I've looked at stuff so I'm sorry, but I don't remember what the call was.

  RabidCicada     January 6, 2011 11:40.18 CST
Also...some EXE's might not have reloc tables....as EXE's aren't supposed to need them...just dynamically loaded libraries.

  palaniyappan     January 8, 2011 06:50.32 CST
you can compile your exe with /FIXED:NO option in visual studio, which will generate executable with relocation information(relocation directory).

  AMX   March 19, 2011 09:31.10 CDT
Thanks for all your replies! Actually I dont have the source, so no rebuilding.
I started doing it the hard way like finding the function in IDA, ripping it (+ human post-processing), adding the asm file to my Makefile etc.
I made soem progress but still Im not sure if what I get is the real thing.

The project is: reversing CEVA-X instruction set from the TRACE32 debugger which contains a disassmbler (you can download an update which contains the exe from lauterbach.com). Seems like the CEVA-X is a popular DSP, systems with SoC (=ARM+CEVA) are available for approx. 50 bucks featuring an LCD display and two pads for an UART link.

I dont know if this will be successful or not. If somebody wants to lend a hand he/she is very welcome.

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit