Closed huojiaan closed 4 years ago
sdk=23, libc=LinuxModule{base=0x40006000, size=540672, name='libc.so'}
java.lang.NullPointerException
at com.tzrd.TzrdClient.
jni方法不是这样调用,参考测试用例
以下是错误信息 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)
jni方法不是这样调用,参考测试用例
你好,作者大哥,我之前尝试 用 callStaticJniMethod 调用, 但是发现这个so 是静态注册的, 没有调用jni_onload来注册函数 ,所以调用这个函数 callStaticJniMethod 出现找不到那个我需要调用的函数,所以才尝试用 module.callFunction
这个是我自己写的一个apk 调用刚刚那个so 的例子
Native = vm.resolveClass("com/maihan/tredian/util/TreUtil");
Native = vm.resolveClass("com/maihan/tredian/util/TreUtil");
你好,噢噢,我搞错了,加漏了,我再试试,谢谢🙏
//代码如下 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;
/**
@date 2020/6/8 下午3:43 */ public class TzrdClient extends AbstractJni { private static final String APP_PACKAGE_NAME = "com.maihan.tredian";
//创建安卓的模拟器 private final AndroidEmulator emulator;
//创建虚拟机 private final VM vm;
//创建运行模块 private final Module module;
//android native 类 private final DvmClass Native;
//创建对应的报名安卓模拟器 private static AndroidEmulator createARMEmulator() { return new AndroidARMEmulator(APP_PACKAGE_NAME); }
private TzrdClient() throws Exception { emulator = createARMEmulator();
}
private void destroy() throws IOException { emulator.close(); }
public static void main(String args[]) { try { TzrdClient tzrdClient = new TzrdClient(); tzrdClient.destroy();
} }