From 41e43940a06375c24e9c82071775dd1c98660c60 Mon Sep 17 00:00:00 2001 From: Dragon-Git <42856316+Dragon-Git@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:04:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20svuvm.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pysvuvm/svuvm.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pysvuvm/svuvm.cpp b/src/pysvuvm/svuvm.cpp index 3a67c5f..3aa17a9 100644 --- a/src/pysvuvm/svuvm.cpp +++ b/src/pysvuvm/svuvm.cpp @@ -1,5 +1,8 @@ #include #include +#ifdef __APPLE__ +#include +#endif #include #include #include "svdpi.h" @@ -58,10 +61,19 @@ void py_func(const char* mod_name, const char* func_name, const char* mod_paths) } } #elif defined(__APPLE__) + uint32_t image_count = _dyld_image_count(); Dl_info dl_info; - if (dladdr((void*)py_func, &dl_info)) { - dir_path = dirname(const_cast(dl_info.dli_fname)); - path.attr("append")(dir_path); + + for(uint32_t i=0; i= (intptr_t)header && (intptr_t)py_func < (intptr_t)header + _dyld_get_image_vmaddr_slide(i)) { + dir_path = dirname(const_cast(image_name)); + path.attr("append")(dir_path); + } + } } #else #error Platform not supported.