zhkl0228 / unidbg

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

求大佬帮忙看下,android native 静态注册函数调用出现 memory failed #147

Closed huojiaan closed 4 years ago

huojiaan commented 4 years ago

//代码如下 package com.tzrd;

import com.github.unidbg.AndroidEmulator; import com.github.unidbg.Module; import com.github.unidbg.Symbol; import com.github.unidbg.linux.android.AndroidARMEmulator; import com.github.unidbg.linux.android.AndroidResolver; import com.github.unidbg.linux.android.dvm.*; import com.github.unidbg.memory.Memory; import com.github.unidbg.memory.MemoryBlock;

import java.io.File; import java.io.IOException;

/**

huojiaan commented 4 years ago

libtre.so.zip

huojiaan commented 4 years ago

com.meilishuo_144115188276579027_10.0.0.2220_1000005.apk.zip

huojiaan commented 4 years ago

sdk=23, libc=LinuxModule{base=0x40006000, size=540672, name='libc.so'} java.lang.NullPointerException at com.tzrd.TzrdClient.(TzrdClient.java:73) at com.tzrd.TzrdClient.main(TzrdClient.java:85) [16:01:31 027] WARN [com.github.unidbg.arm.AbstractARMEmulator] (AbstractARMEmulator$1:55) - memory failed: address=0x73696b18, size=4, value=0x0, PC=RX@0x400019a8[libtre.so]0x19a8, LR=unicorn@0x62 [16:01:31 030] WARN [com.github.unidbg.AbstractEmulator] (AbstractEmulator:349) - emulate RX@0x40001981[libtre.so]0x1981 exception sp=unicorn@0xbffff608, msg=Invalid memory read (UC_ERR_READ_UNMAPPED), offset=5ms

zhkl0228 commented 4 years ago

jni方法不是这样调用,参考测试用例

huojiaan commented 4 years ago

以下是错误信息 Connected to the target VM, address: '127.0.0.1:51470', transport: 'socket' sdk=23, libc=LinuxModule{base=0x40006000, size=540672, name='libc.so'} Disconnected from the target VM, address: '127.0.0.1:51470', transport: 'socket' java.lang.IllegalArgumentException: find method failed: sign(Ljava/lang/String;)Ljava/lang/String at com.github.unidbg.linux.android.dvm.DvmClass.findNativeFunction(DvmClass.java:213) at com.github.unidbg.linux.android.dvm.DvmObject.callJniMethod(DvmObject.java:39) at com.github.unidbg.linux.android.dvm.DvmClass.callStaticJniMethod(DvmClass.java:222) at com.tzrd.TzrdClient.main(TzrdClient.java:79)

huojiaan commented 4 years ago

image

huojiaan commented 4 years ago

jni方法不是这样调用,参考测试用例

你好,作者大哥,我之前尝试 用 callStaticJniMethod 调用, 但是发现这个so 是静态注册的, 没有调用jni_onload来注册函数 ,所以调用这个函数 callStaticJniMethod 出现找不到那个我需要调用的函数,所以才尝试用 module.callFunction

huojiaan commented 4 years ago

这个是我自己写的一个apk 调用刚刚那个so 的例子 image

zhkl0228 commented 4 years ago

Native = vm.resolveClass("com/maihan/tredian/util/TreUtil");

huojiaan commented 4 years ago

Native = vm.resolveClass("com/maihan/tredian/util/TreUtil");

你好,噢噢,我搞错了,加漏了,我再试试,谢谢🙏