Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


HELP need to call function from another exe

Posted on 2004-10-26
Medium Priority
Last Modified: 2010-05-18
i need to call a function from another .exe file .. which i dont have the source for

i disassembled the .exe and found the function i need so much .. tried to export disassembled output to an .asm file .. and with some effort compiled it into a new .exe .. but by old ida happened to have bugs .. disassembling wrong opcodes
whatever this doesnt make sense to me neither ..

i have a .exe file .. and want to write a program that .. calls a function within that .exe file and gets the output .. all i know is the offset to the function

the function i need to call .. uses 1 stack and 3 register parameters
i believe the program was built under delphi


thanks in advance
Question by:skumria
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 12

Expert Comment

ID: 12419580
Hi skumria,
Be aware that disassembling existing programs to re-engineer their functions is illegal in many countries. We can't help you there.



Author Comment

ID: 12419742
:) luckily in my country (bulgaria) its still legal

ok another scenario .. i write an exe file with function and try to call it from another .exe ?
LVL 12

Expert Comment

ID: 12422379

This is tricky. The PE loader has to load the other exe, then you can mount its memory by ReadProcessMemory()
(see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/readprocessmemory.asp) - BUT: As all process base addresses are in the same area and the code of the function won't be position-independent, you probably won't be able to map it at its original address. Also, mounting it won't give you write access to the other process. And the other process may not allow you to read its memory at all (it's a security problem to allow this).
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LVL 16

Expert Comment

ID: 12464416
>>which i dont have the source for
Do you have any .lib or .obj files that make up the .EXE?

A second option:

In your program, malloc enough memory to fit the other EXE.
Read the EXE into your memory.
typedef a function pointer of the correct type and point it at the correct offset in the EXE.
Call it.

LVL 16

Assisted Solution

PaulCaswell earned 252 total points
ID: 12464506
Note: If you use my method, any linker fixups will not be performed.
This method will only work if the function you call only calls functions with relative addresses and does not require access to any data.

LVL 12

Accepted Solution

stefan73 earned 248 total points
ID: 12470656
Yes, that's the problem. The linker fixups are necessary, but by default, you'll get overlapping address spaces for your own and the other exe.

Perhaps it's worthwile to think about looking at the PE link format? It might be possible to merge the other exe to yours, so both are loaded properly and non-overlapping when you start your program.

It'll be quite some work, though.

Author Comment

ID: 12571924
>Perhaps it's worthwile to think about looking at the PE link format? It might be possible >o merge the other exe to yours, so both are loaded properly and non-overlapping >when you start your program.

have to try that .. as soon as i have the time

to Paul .. the program needed to set its memory space which involved some decoding

anyway .. the easiest way i found on the net is the CreateRemoteThread/LoadLibrary technique .. backed with some read/writeprocessmemory calls it turned not to be that hard

5.am here falling asleep sowwy about english

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question