Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

适配android5 api22出现的问题 #9

Closed
AdenTk opened this issue May 9, 2022 · 8 comments
Closed

适配android5 api22出现的问题 #9

AdenTk opened this issue May 9, 2022 · 8 comments

Comments

@AdenTk
Copy link

AdenTk commented May 9, 2022

dpt-android5.zip

环境:
Nexus5
android5.1.1
api22

执行出错,日志上看着是CodeItem已经回填成功,但是出现了NullPointerException

dpt-android5.zip:
1、android5.patch 我适配android5 修改的代码,包括添加了LoadMethod_L函数
2、error.log错误日志。

希望大神有空帮忙看下
@luoyesiqiu
Copy link
Owner

应该是没填完,代码就执行了

@AdenTk
Copy link
Author

AdenTk commented May 11, 2022

我有试过在填充后,把begin指针对应的size大小的dex文件保存到私有目录,使用jadx打开dex,发现抽取后的方法是有被填充回去的。

@luoyesiqiu
Copy link
Owner

那把base.odex文件删掉试试

@AdenTk
Copy link
Author

AdenTk commented May 11, 2022

删除了/data/dalvik-cache/arm目录下的odex文件,确实可以正常运行,请问有什么措施可以不让他走odex呢?

@luoyesiqiu
Copy link
Owner

luoyesiqiu commented May 11, 2022

试试hook execv,看有没有hook到dex2oat的执行

@AdenTk
Copy link
Author

AdenTk commented May 11, 2022

使用以下代码进行hook execv未发现他走dex2oat的过程

static void* (*oriexecve_addr)(const char *__file, char *const *__argv, char *const *__envp);

static void* (*oriexecv_addr)(const char *__path, char *const *__argv);

void* execve_addr22(const char *__file, char *const *__argv, char *const *__envp) {
    DLOGD("process:%d,enter execve:%s", getpid(), __file);
    if (strstr(__file, "dex2oat")) {
        return NULL;
    } else {
        return oriexecve_addr(__file, __argv, __envp);
    }
}

void* execv_addr22(const char *__path, char *const *__argv) {
    DLOGD("process:%d,enter execv:%s", getpid(), __path);
    if (strstr(__path, "dex2oat")) {
        return NULL;
    } else {
        return oriexecv_addr(__path, __argv);
    }
}

void hook_exec(){
    void *execv_addr = DobbySymbolResolver(GetLibcPath(), "execv");

    DobbyHook(execv_addr, (void *) execv_addr22,
              (void **) &oriexecv_addr);

    void *execve_addr = DobbySymbolResolver(GetLibcPath(), "execve");
    
    DobbyHook(execve_addr, (void *) execve_addr22,
              (void **) &oriexecve_addr);
}

@blueb0ne
Copy link

这个问题后来有解决吗?

@luoyesiqiu
Copy link
Owner

当前方式自己解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants