Thread: Newbie question: pointers, other program's memory

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    1

    Newbie question: pointers, other program's memory

    A C++ tutorial says this:
    For instance, the operating system will probably prevent you from accessing memory that it knows your program doesn't own: this will cause your program to crash. If it let you use the memory, you could mess with the memory of any running program--for instance, if you had a document opened in Word, you could change the text! Fortunately, Windows and other modern operating systems will stop you from accessing that memory and cause your program to crash. To avoid crashing your program, you should always initialize pointers before you use them.
    Yet there are programs that do change other program's memory while they're running (I'm thinking mainly of game cheaters). Is there an easy way to get the OS to allow you to get the address of a certain piece of data that's in another program's memory, and possibly change it?

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Yep. It's called hacking and there's plenty of info about that on the web.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    903
    We will not help you in any way to do this, but basically you need to open the executable file into an Hex Editor.

  4. #4
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Desolation
    We will not help you in any way to do this, but basically you need to open the executable file into an Hex Editor.
    Didn't you just contradict yourself there?

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Yep. It's called hacking and there's plenty of info about that on the web.
    Perhaps you mean "cracking"? . . .
    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
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    It's not worth the risk. You could trash the CPU memory or do somthing worse. Pointers are powerful things, do not under any circumstances fool around with them. Listen to mario and dwks, they know what they are talking about.

    When you get to learn more advanced C++, you will come to understand the usefulness of pointers as memory allocation. IE: new and delete operators.
    Double Helix STL

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I wrote a program that lets you examine (read: read memory). Even then, you can only access about 640KB of memory and Windows protection errors are common . . . if you tried writing to memory, no telling what you would do.
    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
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    > Perhaps you mean "cracking"? . . .

    I gave up on that one, dwks

    Last time I got into an heated debate over it, it finished with me being told language evolves and I'd better evolve with it. Of course my attempts at explaining that it was the dumb media who don't know an oreo from axe that started calling it hacking in the first place, didn't produce the desired effect of convincing him.

    Everywhere I turn i see it called hacking these days. I gave up.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    What happens if language evolves and all short ways to express a meaning are suddenly lost? I believes that's one evolution that is worth fighting against.

    If we can't use hacker as it was intended anymore, what do we call hackers?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Apparently the trend is to call them crackers. As you are probably aware.
    I seem to recall a few months ago an interesting thread in these forums about an university that was training hackers for IT security jobs. The university website did the correct choice of words... the news article on the web didn't. Some people on that thread didn't either.

    I couldn't agree more with you. But it seems the meaning is getting lost.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #11
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by Mario F.
    Apparently the trend is to call them crackers.
    Wait a moment.
    The trend (media-inspired) is to misuse the word hacker for what actually are crackers. Are you telling me that real hackers, in turn, are called crackers now? That would be quite an insult.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #12
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Yup. My bad. The trend is to call all hackers.

    I think those in position to do something about it, aren't doing much.... the hackers.

    However, companies are increasingly more aware of the need to employ security specialists that know the tools. It's possible that with the public awareness that may spur from their profession, either the term "hacker" departs from cracker again, or a new term is devised.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  13. #13
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    In general your program will never be able to see beyond its own memory; every program has its own virtual memory and you can't directly read data beyond the process boundary (except that DLL data may map to multiple processes). That is, the contents of address 0x12345678 in your program is unrelated to 0x12345678 in another program or 0x12345678 in physical RAM.

    There are ways to break this, though. Antivirus programs, debuggers, etc. routinely do.

    But your average pointer only makes sense within the confines of your own process. It's not possible for you to craft a pointer within your process that points to memory of another process, at least not since Windows 95. To try to do so would be like asking which page in Moby Dick is page 342 in War and Peace. You won't ever find any page of War and Peace however hard you scour Moby Dick. Likewise you won't find another process' memory by looking at addresses in your own.

    In general Windows isn't protection faulting because you're trying to access memory that is reserved for another application (as the tutorial seems to say), it's protection faulting because the memory you're trying to access doesn't exist -- that is, the virtual memory address you are trying to access does not correspond to any physical memory address in the system's memory.

    The virtual address space of your program is (at least) 4 GB, but only some portion of that actually maps to physical memory.
    Last edited by Cat; 11-24-2006 at 07:07 PM.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  14. #14
    Registered User
    Join Date
    May 2006
    Posts
    903
    Quote Originally Posted by Neo1
    Didn't you just contradict yourself there?
    Somewhat, it depends on how you see it. "Using an Hex Editor to open an executable file" is pretty vague, eh ? That did put him in the right direction but he still doesn't know how to crack it.

  15. #15
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Yeah well, don't feel too clever dropping hints, 'cause yr wrong

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mutex and Shared Memory Segment Questions.
    By MadDog in forum Linux Programming
    Replies: 14
    Last Post: 06-20-2010, 04:04 AM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  3. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  4. simple pointers question
    By euphie in forum C Programming
    Replies: 4
    Last Post: 05-25-2006, 01:51 AM
  5. memory question (pointer related)
    By cjschw in forum C++ Programming
    Replies: 2
    Last Post: 04-30-2004, 01:09 PM