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 28,631 total registered users.


Recently Created Topics
windbg - olly/immunity
May/14
Reverse a WinRAR pac...
May/13
Add comments to resu...
May/10
can we code script ...
May/09
Type Casting Structu...
May/07
How to Reverse Engin...
May/03
Sulley on OS X (10.7)
May/01
Help me guys
May/01
IDA Resource Viewer ...
Apr/28
How do i use plugins...
Apr/27


Recent Forum Posts
windbg - olly/immunity
blowcheck
Help me guys
Olivier
Reverse a WinRAR pac...
NirIzr
windbg - olly/immunity
anonymouse
Reverse a WinRAR pac...
DriEm
Add comments to resu...
phn1x
IDA Resource Viewer ...
DriEm
Add comments to resu...
qiuhan
IDA Resource Viewer ...
waleeda...
IDA Resource Viewer ...
DriEm


Recent Blog Entries
waleedassar
Apr/20
OllyDbg NumberOfSections Crash

icegood
Apr/13
Advanced labels plugin for ...

waleedassar
Mar/31
GetModuleFileNameEx And Inf...

waleedassar
Mar/31
OllyDbg v1.10 And Wow64

waleedassar
Mar/29
OllyDbg Resource Table Pars...

More ...


Recent Blog Comments
raxen on:
Mar/27
Anti-Dumping

Dallas on:
Mar/22
ChapljaVM Code Obfuscator

Dallas on:
Mar/22
Hack stuff, get paid

Dallas on:
Mar/22
Exe Packer TAGGANT system f...

Dallas on:
Mar/22
Olly2 SystemTray Plugin

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit