Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Is memory editing is possible using JAVA?

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Is memory editing is possible using JAVA?

    Hi i m a c++ programmer no shifting to JAVA.

    is it possible to perform operations like following in java?
    WriteProcessMemory
    GetThreadContext
    SetThreadContext
    VirtualAllocEx
    CreateProcess
    ResumeThread
    or is there anything else i can do? like it would be good if i can add c++ code in java??

    or anything else possible to perform these functions??


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Is memory editing is possible using JAVA?

    I know it's possible to create a new process in Java, see: ProcessBuilder

    It's possible to suspend/resume threads in Java (provided you're able to get a reference to them), but these features are technically deprecated. See: Java Thread Primitive Deprecation.

    It's possible to call C code from Java using JNI (Java Native Interface) or JNA (Java Native Access). There are various tutorials online, including a few on this site.

    Links:
    Java Native Access/ Eclipse Indigo Swing GUI Editor
    An Introduction to the Java Native Interface
    Last edited by helloworld922; May 25th, 2012 at 09:58 AM.

  3. #3
    Forum VIP
    Join Date
    Oct 2010
    Posts
    275
    My Mood
    Cool
    Thanks
    32
    Thanked 54 Times in 47 Posts
    Blog Entries
    2

    Default Re: Is memory editing is possible using JAVA?

    Why would you need to use primitive Thread operations? I think any time where that crosses your mind, you need to rethink your logic a bit.

    Secondly, you can do some specific memory management using java.nio, for example:

    ByteBuffer.allocate
    ByteBuffer.allocateDirect

  4. #4
    Junior Member
    Join Date
    May 2012
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Is memory editing is possible using JAVA?

    basically i want this to inject any program in to a running memory....

  5. #5
    Member
    Join Date
    Apr 2012
    Location
    Superior, CO, USA
    Posts
    80
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default Re: Is memory editing is possible using JAVA?

    Quote Originally Posted by fredsilvester93 View Post
    basically i want this to inject any program in to a running memory....
    No, it's harder to write a virus in Java (which is, good or bad, what it sounds like you're trying to do).

    Java maintains a virtual machine in a single operating system process. This VM is somewhat like a true O/S virtual machine in that it takes care of memory allocation, running processes (threads), and security. One part of that security is that you can't just write to anywhere in the Java VM nor can you write to just anywhere in the O/S memory. The Java process runs as a particular O/S user - it would be a very poorly done system for Java to run as a root or administrative user.

    Remember also that Java is meant to be O/S independent. WriteProcessMemory is a Windows specific call and would not port well to Unix based O/S's nor to MVS on a mainframe. What you're trying to do is very O/S dependent and Java is not likely to be the best tool.
    Need Java help? Check out the HotJoe Java Help forums!

  6. #6
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Is memory editing is possible using JAVA?

    Quote Originally Posted by fredsilvester93 View Post
    basically i want this to inject any program in to a running memory....
    Now that sounds malicious...I wouldn't expect much help in the matter unless you prove otherwise.

  7. #7
    Junior Member
    Join Date
    May 2012
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Is memory editing is possible using JAVA?

    No basically it is not malicious. I was trying to make an antivirus program, that searches in the middle of the thread and in the specified regions for viruses. because crypters inject it inside a rundll32,kernel32 process etc which antivirus thinks it is unharmful kernel process

    My intentions are good otherwise i should have posted this in some hacking etc forum....

    Hope u will help me now

  8. #8
    Junior Member
    Join Date
    Nov 2010
    Posts
    18
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Is memory editing is possible using JAVA?

    Quote Originally Posted by fredsilvester93 View Post
    No basically it is not malicious. I was trying to make an antivirus program, that searches in the middle of the thread and in the specified regions for viruses. because crypters inject it inside a rundll32,kernel32 process etc which antivirus thinks it is unharmful kernel process

    My intentions are good otherwise i should have posted this in some hacking etc forum....

    Hope u will help me now
    Well, I don't think Java is the best language for that, but as I see the problem there is one option. Call C++ by Java.

    Java Tip 17: Integrating Java with C++ - JavaWorld

Similar Threads

  1. How to allow Java to use more memory on Linux.
    By Aucun in forum Java Theory & Questions
    Replies: 14
    Last Post: May 24th, 2012, 04:38 AM
  2. HELP ME PLEASE MEMORY MANAGEMENT PROGRAM USING JAVA
    By lockwater in forum Java Theory & Questions
    Replies: 1
    Last Post: December 2nd, 2010, 08:30 AM
  3. Memory Handling -de allocate memory in Java
    By 19world in forum Java Theory & Questions
    Replies: 4
    Last Post: June 15th, 2010, 04:05 AM
  4. Out of memory work around for a java application (please help!)
    By javameanslife in forum Java Theory & Questions
    Replies: 5
    Last Post: January 22nd, 2010, 04:27 AM
  5. Java memory management
    By trueacumen in forum Java Theory & Questions
    Replies: 5
    Last Post: August 12th, 2009, 02:40 AM