Sign in to follow this  
Ang88

[java] Getting a Process Handle and Modifying memory address values?

Recommended Posts

Ang88    122
I am fairly new to java, and i am learning it in school. I am trying to learn how to get a process handle, then modify the value of certain memory addresses within that process. The process is an outside process. So far i have found this site (http://www.jniwrapper.com/docs/javadoc/winpack/com/jniwrapper/win32/process/Process.html ) that seems to help, but im not sure how to go about doing it. If anyone knows how to do this in java that would be great

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I read that title and thought 'wft, did I accidentally click on the C forum, circa gamedev 1995?'.....

Share this post


Link to post
Share on other sites
Ang88    122
Quote:
Original post by Anonymous Poster
I read that title and thought 'wft, did I accidentally click on the C forum, circa gamedev 1995?'.....


hmm ok, but it would be nice if someone could get me started in the right direction

my aim is aporto88

Share this post


Link to post
Share on other sites
Palidine    1315
i don't know if you can do any of this in java. i suppose you could with some embedded C code or something or perhaps there's a nice lib out there somewhere. anyway here's how to enumerate the currently active processes on your machine:

http://www.codeproject.com/threads/enumprocnt5.asp?df=100&forumid=4071&exp=0&select=658622

getting into the process memory should be pretty tough on a win2000/XP machine as they are supposed to be protected memory environments (clicky). however, one of the fields of the structs in there is a heap ID so perhaps you could get in that way. dunno, this is fairly far above my head ATM. my feeling however, is that the design of the windows system is such that this shouldn't be possible so you'd probably have to exploit some bug in the windows code to get what you want. and that's bad. DON'T DO IT!

-me

p.s. that java function you found creates new processes, it does not create a handle to existing processes.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by Ang88
I am fairly new to java, and i am learning it in school. I am trying to learn how to get a process handle, then modify the value of certain memory addresses within that process. The process is an outside process.


The real answer to this is to use NIO buffers and share memory between your java process and your "other" process. This way, it's all actually very easy (just look for Sun's docs on using "NIO" with "JNI"?; it's the basis for most of the OpenGL stuff, so should be easy to find articles on).

This, of course, requires that you are using legitimate hooks into the "other" process.

If not, give up. It is sufficiently hard to do cracking of other processes in java that it's not generally worth the effort. Note also that Sun has a policy of making it hard(er). For instance, Sun has a policy (or maybe they just use it as an excuse not to code?) that they will not grant raw access to network interfaces, which makes it impossible to write a packet sniffer in pure java. You can sort of do it, but you need to write a packet sniffer in C and then script it from java, which is normally enough to make people not bother.

Your cracking may be legitimate (for instance trying to overlay / modify code to which the source has been lost, in order to fix bugs) but java has been designed not to support this kind of thing.

redmilamber

Share this post


Link to post
Share on other sites
TheBluMage    372
I agree with the above posts. Java just wasn't designed with a whole lot of "under the hood" stuff in mind. The JNI is an option, but a majority of your programming won't be in Java, it will be spent writing the native library. You'll probably want to be looking into a language/runtime that gets a little more low-level.

If you don't want to struggle a whole lot with a new language's syntax and the lack of a garbage collector, you could try C#, which is pretty similar to Java as far as the language goes, but it has a few nice things tossed in, like easy-to-use interop and optional pointers. I know the .NET Framework has support for getting the handle of a process, but I'm not sure about modifying another process's memory, so you might need to use interop for that part. Of course, you'll have a new dependancy, the .NET Framework.

Otherwise, C++ is probably your best bet to accomplish what you want to do.

Share this post


Link to post
Share on other sites
Ang88    122
alright, well, thanks for the info, it sounds a little more advanced then i thought, so once i get around to that level, i will probably try it using some of the things suggested

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this