Determining programmatically what modules are loaded in another process? (OS X)

后端 未结 4 851
名媛妹妹
名媛妹妹 2020-12-30 12:34

What I\'m trying to do I feel is pretty straightforward, I\'m just not sure exactly how to do it.

Specifically I just want to get a list of modules (shared/dynamic l

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 12:59

    There's some existing BSD-licensed code you can take from the Breakpad project that does exactly this:

    • http://code.google.com/p/google-breakpad/source/browse/trunk/src/client/mac/handler/dynamic_images.h
    • http://code.google.com/p/google-breakpad/source/browse/trunk/src/client/mac/handler/dynamic_images.cc

    dyld provides some hooks for GDB, notably a well-known function symbol that gdb can use to get access to a struct that contains this info. See http://www.opensource.apple.com/source/dyld/dyld-132.13/include/mach-o/dyld_images.h You can see how GDB does it here: http://www.opensource.apple.com/source/gdb/gdb-1344/src/gdb/macosx/macosx-nat-dyld.c (look for "macosx_init_addresses"). The internals of lookup_minimal_symbol are too horrible to talk about, but Breakpad's implementation is fairly straightforward.

提交回复
热议问题