Mac ReadProcessMemory WinAPI equivalent

Discussion in 'Mac Programming' started by Jester831, Aug 16, 2008.

  1. Jester831 macrumors newbie

    Joined:
    Aug 16, 2008
    #1
    Do any of the mac programming languages have a function for reading or writing to another programs memory?
     
  2. larkost macrumors 6502a

    Joined:
    Oct 13, 2007
    #2
    What is your goal here? If you are looking to reach into someone else's code, or are you looking at doing inter-process communication?
     
  3. Jester831 thread starter macrumors newbie

    Joined:
    Aug 16, 2008
    #3
    I have a C# app that uses readprocessmemory that I'm rewriting for mac.
     
  4. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    Not directly I think. IPC is the best way to go. Remember that Mac OS X is more secure than Windows is.
     
  5. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #5
    You may also want to look in to shared memory. It may not be exactly what you need here, but it would allow you have a "buffer" shared between processes. You would need to implement some coherency checking using some sort of lock.

    Another option would be using a file that you memory map in various processes. Again, coherency checking will be needed.

    Cromulent already mentioned IPC, which would also be an option if these processes have a parent/child relationship.

    This page describes about all of these options I've mentioned:
    http://www.ecst.csuchico.edu/~beej/guide/ipc/

    As an aside, I can't believe something like that exists in the Win32 API. When I searched for it, in the first page of google results there is an MSDN blog post explaining some reasons why the use of ReadProcessMemory is a bad idea anyway.
    http://blogs.msdn.com/oldnewthing/archive/2006/01/17/513779.aspx

    -Lee
     
  6. Jester831 thread starter macrumors newbie

    Joined:
    Aug 16, 2008
    #6
    It's a buddy program for another program that I did not write... stuff like shared memory and IPC isn't really viable. Soo, is it impossible then?
     
  7. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    Well in that case you can either use an Input Manager to hack your way into their code or look at mach-inject to get your code into that process...
     
  8. fluxforge macrumors member

    Joined:
    Apr 16, 2010
    Location:
    europe
    #8
  9. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #9
    In case that article disappears here's the $0.05 summary.
    Code:
    ReadProcessMemory() -> vm_read_overwrite()
    WriteProcessMemory() -> vm_write()
    It references the book "Mac OS X Internals: A Systems Approach" by Amit Singh.

    B
     

Share This Page