5

I'm creating a memory modifying program for my own learning purposes. A friend of mine pointed out a function in another program that I want to trigger.

The function is at 0x004B459C in the other program. I know how to read and write memory, but how can I trigger this function from my program. I do not have the source to this other program.

My question is do I need to inject the function if I know this hex code, or do I just write something to memory to trigger this?

5
  • What have you tried? Why would you want to communicate with another process through altering specific sections of memory in C#? Commented Apr 2, 2013 at 15:05
  • I'm learning about the memory modification process, and now I'm curious as to how people trigger a function remotely. Commented Apr 2, 2013 at 15:07
  • I think you should add tags WinApi and C , cause your question is related to using low-level OS capabilities, rather then C# Commented Apr 2, 2013 at 15:10
  • 2
    Windows is going to protect the memory of the other process, so you will not be able to access the function unless it is exposed in some standard way, such as a DLL entry point, COM object, etc... Commented Apr 2, 2013 at 15:14
  • See this for game hacking, and useful libraries : google.hu/search?q="Memory+Hacking+Library+List" Commented Jun 19, 2014 at 13:42

2 Answers 2

3

Think a bit about what you really want. You want the other process to execute this function. Processes don't execute code, it's threads that execute code. If you want the other process to call this function as a part of it's normal operations, you will have to figure out inputs etc. which will make one of the other process's threads call it. Generally speaking, any other way you will be running the risk of corrupting the other process. It is possible to inject a thread into another process and have it call the function you're interested in (see CreateRemoteThread). If this function is intended to be called on the message pump thread, you could inject a message hook into the other process, send it a special message and call it from your hook. There are a few more ways (APC) but these are still more complicated for little gain.

Sign up to request clarification or add additional context in comments.

3 Comments

This code 0x004B459C means that I have the functions position right? So I just have to make my own DLL with a function of my own and inject it so another program can execute this, right?
Basically yes, although it's called address not position. And this sort of thing is best done in native code (C/C++), not C#. You cannot inject a C# assembly without a native bootstrap dll anyway.
Well after hours and hours of research I finally made a DLL that I injected and called this function. However, I went with C++ instead. That's ok since it's a separate solution and file. pastebin.com/GwKxRQwx
3

you are missing some basic architecture fundamentals :-) you cannot simply call a function knowing its address from another process! think of it, this means that your program can get the memory of any program and execute code! this will be a mess and a complete insecure environment. first some basics: 1) windows guarantees that you only see the memory of your own process, one of the most important principles of an OS (even Windows) is to isolate processes including their memory of course. 2) did think about permissions, usually any code that runs must run under a user account, another process might mean another process account.

the answer is simple, if your program is .NET/C# then check what the .NET framework provides you for inter process communication, this is the thing you must search for, every platform, Java, windows native, .NET provides an offical way how process communicate with each other, it is called interprocess communication, check it in .NET framework

1 Comment

Thats not right, windows even offers methods to read and write memory to other processes, even without being elevated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.