ReadProcessMemory() help

This is a discussion on ReadProcessMemory() help within the C++ Programming forums, part of the General Programming Boards category; i am trying to use ReadProcessMemory to find a string in the running processs.. now the second param states it ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    ReadProcessMemory() help

    i am trying to use ReadProcessMemory to find a string in the running processs..
    now the second param states it needs the address in which to read
    what if i want to read all the addresss's . from 0 to the end of the code
    is it possible ,

    Code:
    #include <iostream>
    #include <windows.h>
    using namespace std;
    char buffer[500];
    
    int main()
    {
    	
        HANDLE T = OpenProcess(PROCESS_ALL_ACCESS , true , 3128);
    	ReadProcessMemory(T,0000000, buffer , sizeof(buffer) , NULL);
    	cout<<buffer<<endl;
    	return 0;
    }

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Um, I don't know, but don't really care because it's a really stupid idea.

  3. #3
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    read all the addresss's
    The address space of a process is 4GB. (Not all of which may be available.) Good luck going byte by byte through it. Allocated space could be anywhere in those 4GB, but probably constrained to the high or lower 2GB. (Which isn't much help.)

    What exactly are you wanting to do? (There might be a lot easier way to solve your problem.)

    While I've never dreamed of trying such a thing, you should be able to scan through a process's memory using VirtualQueryEx() - set lpAddress to 0 or 4KB to start, and it'll return info on that range. If the range is allocated, scan it for your data, if not, skip it, and call VirtualQueryEx() with lpAddress incremented by the size of the range. That's what I'd try, at least.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    > what if i want to read all the addresss's
    Same way as you read files which might be larger than your own memory - a smaller buffer and a for loop.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    any examples guys? really stuck

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Really helpless more like - if you can't do this without help, my impression is you're one typo away from hosing your machine.

    for ( i = 0 ; i <= 0xffffffff ; i+= 0x10000 ) if ( readprocessmem(i,buff,bufsiz) == success )......
    yada yada yada
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    thought you said use VirtualQueryEx()

  8. #8
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with ReadProcessMemory function
    By MattZimmerer in forum C Programming
    Replies: 16
    Last Post: 10-30-2008, 10:21 PM
  2. ReadProcessMemory Error
    By Scarvenger in forum Windows Programming
    Replies: 10
    Last Post: 05-28-2008, 05:47 PM
  3. ReadProcessMemory
    By brietje698 in forum C++ Programming
    Replies: 2
    Last Post: 10-14-2007, 08:37 AM
  4. ReadProcessMemory();
    By kennny2004 in forum C++ Programming
    Replies: 12
    Last Post: 07-10-2006, 11:09 PM
  5. ReadProcessMemory()
    By Josh Kasten in forum Windows Programming
    Replies: 2
    Last Post: 06-19-2003, 01:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21