how do you in c++ access memory that not in the current process

This is a discussion on how do you in c++ access memory that not in the current process within the C++ Programming forums, part of the General Programming Boards category; say i wanted to change some memory that i know is a int but in another program ,, Code: how ...

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

    how do you in c++ access memory that not in the current process

    say i wanted to change some memory that i know is a int but in another program ,,

    Code:
    how can get my current code to say if(memoryaddress == value)
    {dosomething;}
    
    i was thinking of doing something like 
    
    #define 00xfcblah.... for the memory addresss
     or char ad[] = "00xfcblah";
    
    anyone know?

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,077
    You can't. All modern operating systems have protection against that. Besides, there is no way of possibly knowing the memory address of a particular integer if you don't have an identfier to it.
    Sent from my iPadŽ

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,825
    It's a secret!
    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.

  4. #4
    Registered User
    Join Date
    Jan 2006
    Location
    Sweden
    Posts
    92
    I know how to, but its very complicated. To write in another process you should use writeProcessMemory() and to read you should use readProcessMemory() . But in order for this to work you got to open up the process and set a token privilege for your process which is advanced and too complicated for me to explain.

    Good luck

    Daniel

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    say i wanted to change some memory that i know is a int but in another program ,,
    Why would you want to do this?

    If you're calling functions in another one of your programs, you can instead link those functions to your program.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    25
    Perhaps he's trying to make a game hacking program to change game variables?

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Who knows? It seems to me that since [s]he knows it's an int, it might be one of their programs.

    You could use a file or something to transfer information between programs.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    yes well thats what it is

    its
    #include <iostream>
    #include <windows.h>
    using namespace std;
    Code:
    int main()
    {
    int t = 0;
    while(1){cout<<"the value of t is " << t <<endl; cout<<"the address of t is " << &t<<endl;}
    sleep(5000);
    return 0;
    }
    now i would run this and then run the other thing if i had it ,,,
    amd change t from another program
    i am just interested thats all

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,077
    But you're not answering the question of why you feel you need this. Is it just a matter of curiousity?
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 07:22 AM
  2. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 08:53 AM
  3. leaked memory not freed after process is killed?
    By nantonop in forum Linux Programming
    Replies: 16
    Last Post: 09-05-2007, 02:08 PM
  4. Problem with simple case statements
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 05-08-2006, 09:39 AM
  5. linked list recursive function spaghetti
    By ... in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2003, 03:53 PM

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