Thread: finding a program in memory

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    465

    finding a program in memory

    there wasnt a good board to post this on, since its not quite C or C++, nor is it not programming related, but its a fairly simple question and i figure somebody here has got to know it...

    i just want to know how i can find where a program is in memory... be it with DEBUG or C++ or whatever. I just want to be able to know where a program is running so that i can access its memory. I have some knowlege of assembly but its limited.
    I came up with a cool phrase to put down here, but i forgot it...

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I don't know really any assembly (never got around to learning lol) but it sounds like an OS dependent problem...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    In order to find out where a program is in memory you will need its PSP or Program Segment Prefix. In DOS this was done by an INT21h function and C even had a function that would retrieve the PSP.

    Now in protected mode the PSP might be a bit different - I'm not sure. Since all PM addresses are accessed via descriptors it might be a chore to write code that finds the PSP or equiv in protected mode.

    DOS would also report to you what programs were in memory and where. I'm sure that Windows has a similar set of functions for this. Probably an enumeration function with a callback, similar to the enumeration of fonts on the system.

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I don't think it's possible to just access a memory location in protected mode. You could however use ReadProcessMemory() and WriteProcessMemory() after finding the process ID. What specifically are you trying to achieve here?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    quenching of curiosity, mainly.
    I came up with a cool phrase to put down here, but i forgot it...

  6. #6
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Well, if you do think of something to do with this knowledge, post it, and we'll see what we can do.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  7. #7
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    well what i was thinking about at the time was helper programs for games. they seem to be everywhere and i want to know how to make them for myself.
    I came up with a cool phrase to put down here, but i forgot it...

  8. #8
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    I'm guessing that's possible with ReadProcessMemory() and WriteProcessMemory(), but I'd have no idea which memory addresses to look at.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. Program crashes and memory leaks
    By ulillillia in forum Tech Board
    Replies: 1
    Last Post: 05-15-2007, 10:54 PM
  3. Program uses a lot of memory and doesnt exit properly
    By TJJ in forum Windows Programming
    Replies: 13
    Last Post: 04-28-2004, 03:13 AM
  4. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 01:41 PM