Skip to content

Commit 4a1b0c0

Browse files
RootHideRootHide
authored andcommitted
fix dl* for dyld_shared_cache
1 parent b45e2ab commit 4a1b0c0

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

vroot.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,21 +702,36 @@ VROOT_LOG("@%s\n",__FUNCTION__);
702702
return ret;
703703
}
704704

705+
#include <mach-o/dyld.h>
706+
void* VROOT_API_NAME(dlopen)(const char * __path, int __mode)
707+
{
708+
VROOT_LOG("@%s\n",__FUNCTION__);
709+
710+
if(_dyld_shared_cache_contains_path(__path)) {
711+
return dlopen(__path, __mode);
712+
}
713+
714+
const char* newpath = jbroot_alloc(__path);
715+
void* ret = dlopen(newpath, __mode);
716+
if(newpath) free((void*)newpath);
717+
return ret;
718+
}
705719
int VROOT_API_NAME(dladdr)(const void * addr, Dl_info * info)
706720
{
707721
VROOT_LOG("@%s\n",__FUNCTION__);
708722

709723
int ret = dladdr(addr, info);
710-
if(ret != 0)
724+
if(ret != 0 && !_dyld_shared_cache_contains_path(info->dli_fname))
711725
{
712726
//need use cache
713-
const char* newfname = rootfs_alloc(info->dli_fname);
727+
const char* newfname = rootfs(info->dli_fname);
714728
if(strcmp(info->dli_fname, newfname) != 0)
715729
{
716730
info->dli_fname = newfname;
717731
}
718-
//fakechroot do this, do we need?
719-
// const char* newsname = jbroot_revert(info->dli_sname);
732+
733+
//sname??? fakechroot do this, do we need?
734+
// const char* newsname = jbroot(info->dli_sname);
720735
// if(strcmp(info->dli_sname, newsname) != 0)
721736
// {
722737
// info->dli_sname = newsname;

vroot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ MACRO_define VROOT_H
2828

2929
//what about tweaks? VROOT_API_DEF(void*, dlsym, (void * __handle, const char * __symbol))
3030

31-
VROOT_API_WRAP(void*, dlopen, (const char * __path, int __mode), (newpath,__mode), __path)
31+
VROOT_API_DEF(void*, dlopen, (const char * __path, int __mode))
3232

3333
VROOT_API_DEF(int, dladdr, (const void * addr, Dl_info * info) )
3434

0 commit comments

Comments
 (0)