filename of memory mapped libraries osx

我怕爱的太早我们不能终老 提交于 2019-12-12 11:27:20

问题


I need to get the filenames of all memory mapped libraries of the current application. Currently I'm going through all mapped libraries via vm_region. Sadly it doesn't provide information about the filename of the current region. Is there a way to get this information in c without doing popen on vmmap ?


回答1:


  • For regular mmap-ed files you can use proc_regionfilename()
    • Note that you must provide a MAX_PATH-sized buffer to it.
    • implemented in apple's libc - libproc.c, the underlying syscall is proc_info.
  • For libraries from dyld_shared_cache you get "/private/var/db/dyld/dyld_shared_cache_x86_64" as the path and need to find the actual library name.
    • https://code.google.com/p/psutil/issues/detail?id=260 speculates you can parse dyld_shared_cache_*.map file to get this info.
    • https://stackoverflow.com/a/15714052/1026 points to another implementation, http://newosxbook.com/src.jl?tree=listings&file=12-1-vmmap.c


来源:https://stackoverflow.com/questions/8240436/filename-of-memory-mapped-libraries-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!