Calling Internal functions from a second program question.

03/08/2012 02:39 Algaru#1
I wanted to question how to call a function of a program with a second independent program.

First is a program that prints a int variable once every 5 seconds. It contains an uncalled function that turns the int into int++. However this function isn't called by said program.

The second program would be able call the programs uncalled function. Just wanting to know a point in the right detection.
03/08/2012 09:16 SmackJew#2
Easiest way would be to inject a .dll that calls the function from within the process. You could also pick a function that gets called very often, many Windows functions get called several times per second, write a jump to a codecave into it, call your function in the codecave, execute the overwritten Opcodes and then return to the hooked function. This can be done without injecting a .dll.
03/08/2012 21:54 Threk#3
Quote:
Originally Posted by Algaru View Post
I wanted to question how to call a function of a program with a second independent program.

First is a program that prints a int variable once every 5 seconds. It contains an uncalled function that turns the int into int++. However this function isn't called by said program.

The second program would be able call the programs uncalled function. Just wanting to know a point in the right detection.
You could use code injection.
Assemble your asm code to opcodes ( for example with fasm) and then inject it via CreateRemoteThread.

Or use Dll Injection.

If you have the source code for both programs you could also use IPC (for example a named pipe).
04/04/2012 23:07 @night@#4
If the target routine has only one argument it would be possible to call the function directly with CreateRemoteThread.
If thats not the case you will have to inject a dll/asm-code because CreateRemoteThread is not able to deliver more than one argument.
mfg @night@