zhkl0228 / unidbg

Allows you to emulate an Android native library, and an experimental iOS emulation
Apache License 2.0
3.91k stars 971 forks source link

AttachCurrentThread 不执行 #654

Open q601180252 opened 3 months ago

q601180252 commented 3 months ago

我重新Onload 时 0.97 版本AttachCurrentThread中的方法不执行

  jint res = OnLoad(getnewvm(), nullptr);
static JNIInvokeInterface libre2vm{

        .DestroyJavaVM=[](JavaVM *vm) -> jint {
            LOGAR("DestroyJavaVM(JavaVM*)");
            return 0;
        },
        .AttachCurrentThread=[](JavaVM *vm, JNIEnv **p_env, void *thr_args) {
            LOGGER("AttachCurrentThread(%p, env, %p)\n", vm, thr_args);
            *p_env = subenv;
//          return origAttachCurrentThread(vm, p_env, thr_args);
            if (!javaAttached) {
                javaAttached = true;
                while (true) {
                    LOGAR("exit");
                    syscall(SYS_exit, 0);
                }
            }
            return 0;
        },
        .DetachCurrentThread=[](JavaVM *vm) -> jint {
            LOGAR("DetachCurrentThread(JavaVM*)");
//                return origDetachCurrentThread(vm);
            return 0;
        },

        .GetEnv=libre2getenv,
        .AttachCurrentThreadAsDaemon=[](JavaVM *vm, JNIEnv **p_env, void *thr_args) {
            LOGAR("AttachCurrentThreadAsDaemon(vm, env, rest)");
//          return origAttachCurrentThreadAsDaemon(vm, p_env, thr_args);
            return 0;
        }
};

static JavaVM hiervmptr{.functions=&libre2vm};

//extern JavaVM *vmptr;
JavaVM *getnewvm() {
    LOGGER("AttachCurrentThread %d\n", 1);
    return &hiervmptr;

}