readProcessMemory() in JNA menu

User Tag List

Results 1 to 12 of 12
  1. #1
    Slikey's Avatar Active Member
    Reputation
    15
    Join Date
    Jun 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    readProcessMemory() in JNA

    Hello Guys,

    I just started my job at a big IT Company in Germany and finally got the Java support of employees which can actually help me with some crazy shit. I just started to write a WoW Bot in Java.
    YES, I choose Java, because of the.. aw. the real programmers of you know why. I hope you can help me with something that I don't know how the C# handles things.

    I am running the JNA / JNI on my Framework. I already found some tutorials on the internet, but they are only for C# / C++ / AutoIt. The point is that you have access in Kernel32 and User32 Libs of WIndows with the JNA. Now my Problem. I ported the most things by myself to Java already. Success here

    In the MSDN Docs are the functions WriteProcessMemory() and ReadProcessMemory().
    Code:
    BOOL WINAPI ReadProcessMemory(
      _In_   HANDLE hProcess,
      _In_   LPCVOID lpBaseAddress,
      _Out_  LPVOID lpBuffer,
      _In_   SIZE_T nSize,
      _Out_  SIZE_T *lpNumberOfBytesRead
    );
    In Java it works that I declare the same function, but what does the lpBuffer return? Is it an array or just an integer? What do I have to put in for nSize?
    Let's make a example.

    I want this to read the following adress.
    Code:
    0x008FC38A FLOAT 2312.30920
    How would you setup that readProcessMemory for that special case? I hope you can help me. When I got a nice base for the bot I will make it OpenSource so that it may support the community.

    Thank you!

    readProcessMemory() in JNA
  2. #2
    asdcxy's Avatar Corporal
    Reputation
    6
    Join Date
    Oct 2012
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lpBuffer has to be a pointer to a variable where the content at this memory adress will be stored
    nSize how many bytes you want to read
    but this would better fit in the general programming section

    but no idea why anybody would write a bot in java, this is just a pain in the ass

  3. #3
    Slikey's Avatar Active Member
    Reputation
    15
    Join Date
    Jun 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay so you mean that

    Code:
    int hProcess = SomeShitToGetProcessID();
    int nSize = 8;
    int lpBuffer = "";
    int lpBaseAddress = 0x034685FC;
    ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, null);
    Code:
    0x034685FC STRING "Hello botting world!"
    Would write his into the lpBuffer or does this function only read in HEX values?
    Code:
    "Hello bo"

    EDIT: Rep'd you for your help

  4. #4
    xalcon's Avatar Contributor ふたなり
    Authenticator enabled
    Reputation
    198
    Join Date
    Oct 2008
    Posts
    291
    Thanks G/R
    20/58
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well, ReadProcessMemory does not read "HEX" values, it just copies the bytes at the given position (lpBaseAddress) to the position lpBuffer points by reading nSize bytes.
    But I doubt your code will work since ReadProcessMemory wants a pointer where it can write to, not just an int with value zero. (or in your case an empty string, which ofc wasn't your intention, right?)
    I think the code should look more like this, but I've no idea if this will work in java:

    Code:
    int hProcess = SomeShitToGetProcessID();
    int nSize = 8;
    byte[] lpBuffer = new byte[nSize];
    int lpBaseAddress = 0x034685FC;
    ReadProcessMemory(hProcess, lpBaseAddress, lpBuffer, nSize, null);
    YES, I choose Java, because of the.. aw. the real programmers of you know why.
    Well, then I'm not a real programmer, I guess o_o" Anyway, good luck!
    "Threads should always commit suicide - they should never be murdered" - DirectX SDK

  5. #5
    DrakeFish's Avatar Lazy Leecher

    Reputation
    634
    Join Date
    Nov 2008
    Posts
    569
    Thanks G/R
    0/14
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found this post that seems to contain the solution to your problem: java - FOR JNI experts, How Would I use JNI to call ReadProcessMemory? (Read memory from windows applications) - Stack Overflow

    The code snippet from the last post on stackoverflow seems to be an example of how to use ReadProcessMemory in java. You will apparently have to use the Memory class (see outputBuffer in the snippet) to get your values.

    Here's your JNA Memory class : https://github.com/twall/jna/blob/ma...na/Memory.java
    It offers various getX methods depending on what kind of data you'll need. I think getString() is what you needed here.

    I have no idea how you can claim that Java is a good language to code a bot in, C# offers you a lot more functionalities to work with memory. (heck, it even supports using pointers)
    Last edited by DrakeFish; 10-15-2012 at 10:05 AM.

  6. #6
    Slikey's Avatar Active Member
    Reputation
    15
    Join Date
    Jun 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep'd you both too. I didn't look that close into this Memory class. Thank you. The Pointerfunction is brought by the JNA, too.

    So thank you very much for helping me. I hope I can release the first project files this week. (Nothing to do on the company so I use this time to program a bot and everythings looks like normal

  7. #7
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Switch to a native programming language. When your project involves memory management it's the best option.

    Originally Posted by Slikey View Post
    YES, I choose Java, because of the.. aw. the real programmers of you know why.
    "Real programmers"? I don't think you're in a position to judge.

  8. #8
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Real programmers would know how to read API documentation.

  9. #9
    asdcxy's Avatar Corporal
    Reputation
    6
    Join Date
    Oct 2012
    Posts
    29
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Jadd View Post
    Switch to a native programming language.
    shitstorm from all the c# users incomming :P

  10. #10
    Pandu91's Avatar Member
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    41
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by asdcxy View Post
    shitstorm from all the c# users incomming :P
    If you know C# it is easy to learn Java Or if you know Java it is easy to learn C# so I don't think that there will be any shitstorm. Btw you quoted wrong too, because Jadd didn't meant C# because C# isn't a native language too

  11. #11
    Slikey's Avatar Active Member
    Reputation
    15
    Join Date
    Jun 2009
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Too much trolling. Please close this thread^^

  12. #12
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    troll

    There is no reason to use Java anymore... If you insist on coding for the JVM (for whatever reason), use Scala (beautiful). You could even mix code in packages... If you insist on the syntax, use C# ffs. There's almost nothing in Java you can't do in C#. A big plus for me is custom value types, especially regarding bot development and efficient algorithms. There are even native languages like Home - D Programming Language which beat the crap out of Java (disregarding the lack for runtime reflection...). Java is antiquated and has a too high legacy payload. In addition, there aren't frequent updates and wtf language/runtime features like Linq or the DLR. It's only some of the people who didn't yet accept the facts.

    /troll

Similar Threads

  1. ReadProcessMemory w/o BlackMagic
    By cloud_wizard in forum WoW Memory Editing
    Replies: 20
    Last Post: 01-03-2009, 03:26 AM
  2. C++ ReadProcessMemory problem
    By 0_00_0 in forum WoW Memory Editing
    Replies: 12
    Last Post: 12-26-2008, 05:39 AM
  3. Problem with ReadProcessMemory : access denied
    By Fayat in forum Programming
    Replies: 2
    Last Post: 10-22-2008, 06:29 PM
  4. Attempting to make Glider restarter with ReadProcessMemory
    By airlinedev in forum WoW Memory Editing
    Replies: 3
    Last Post: 05-24-2008, 03:04 PM
All times are GMT -5. The time now is 12:14 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search