Results 1 to 5 of 5
  1. #1
    Joshe343's Avatar
    Join Date
    Feb 2015
    Gender
    male
    Posts
    18
    Reputation
    10
    Thanks
    1

    ReadProcessMemory

    Not sure why but all of a sudden ReadProcessMemory isn't reading the amount of bytes I'm asking it to.
    Code:
    byte[] ReadBytes(uint address, int len) // (0x0D000000, 0x08000000) is what I pass through this
    {
        int buffer = 0;
        byte[] output = new byte[len];
        ReadProcessMemory(HO_Process, (IntPtr)address, output, len, out buffer); // this makes buffers value 0x0031E000
        return output;
    }
    EDIT: Just so you know, ReadProcessMemory is returning false and GetLastError returns 0.
    Last edited by Joshe343; 03-31-2015 at 12:13 AM.

  2. #2
    Chaoscode's Avatar
    Join Date
    Mar 2015
    Gender
    male
    Posts
    9
    Reputation
    10
    Thanks
    0
    make sure the code is running at the same level or higher for access. I ran into this also.

  3. #3
    Joshe343's Avatar
    Join Date
    Feb 2015
    Gender
    male
    Posts
    18
    Reputation
    10
    Thanks
    1
    Quote Originally Posted by Chaoscode View Post
    make sure the code is running at the same level or higher for access. I ran into this also.
    I don't know what was causing the issue but I restarted my PC and it started working again lol.

  4. #4
    Eddington's Avatar
    Join Date
    Apr 2015
    Gender
    male
    Posts
    57
    Reputation
    10
    Thanks
    5
    My Mood
    Fine
    You should implement some sort of error checking. ReadProcessMemory returns 0 if it fails. Combine it with GetLastError() to get an error code you can look up on google. I had trouble with a remote thread, got the error code, was able to find it and see that I didn't have sufficient permissions.

    Code:
    if (ReadProcessMemory(HO_Process, (IntPtr)address, output, len, out buffer) ==0)
    {
    MessageBox.Show(NULL, "Error Reading Memory" +GetLastError(), "Error", MB_OK);
    }

  5. #5
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Return value

    If the function succeeds, the return value is nonzero.
    If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.

    The function fails if the requested read operation crosses into an area of the process that is inaccessible.
    You're reading from 0x0 to 0x08000000, and it's extremely unlikely that the target process actually has all of that allocated...you're trying to read an address (many) that hasn't been allocated yet.

    Use VirtualQueryEx() if you want to find all allocated memory regions.

    edit: nvm, apparently it works. ? Not sure how, but ok.
    Last edited by abuckau907; 04-14-2015 at 11:16 AM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Similar Threads

  1. [Tutorial] ReadProcessMemory
    By aanthonyz in forum C++/C Programming
    Replies: 27
    Last Post: 07-30-2016, 06:05 AM
  2. [Source Code] C# WriteProcessMemory/ReadProcessMemory
    By Kantanomo in forum C# Programming
    Replies: 10
    Last Post: 09-03-2012, 04:21 PM
  3. [Help] ReadProcessMemory - Read 8 byte [solved]
    By pyton789 in forum Visual Basic Programming
    Replies: 7
    Last Post: 09-18-2011, 07:49 AM
  4. ReadProcessMemory
    By Void in forum C++/C Programming
    Replies: 17
    Last Post: 04-03-2010, 07:12 AM
  5. Write/ReadProcessMemory errors
    By Dragonion in forum General Game Hacking
    Replies: 0
    Last Post: 09-23-2008, 08:11 AM