0

我正在使用反汇编程序的Java 绑定。Capstone当我运行代码示例时

import capstone.Capstone;
import org.junit.Test;

public class DisassemblerTest
{
    private static byte[] CODE = {0x55, 0x48, (byte) 0x8b, 0x05, (byte) 0xb8,
            0x13, 0x00, 0x00};

    @Test
    public void testDisassembler()
    {
        Capstone cs = new Capstone(Capstone.CS_ARCH_X86, Capstone.CS_MODE_64);
        Capstone.CsInsn[] allInsn = cs.disasm(CODE, 0x1000);
        for (Capstone.CsInsn anAllInsn : allInsn)
        {
            System.out.printf("0x%x:\t%s\t%s\n", anAllInsn.address,
                    anAllInsn.mnemonic, anAllInsn.opStr);
        }
    }
}

我得到一个Error

java.lang.Error: Invalid memory access

    at com.sun.jna.Native.invokeInt(Native Method)
    at com.sun.jna.Function.invoke(Function.java:425)
    at com.sun.jna.Function.invoke(Function.java:360)
    at com.sun.jna.Library$Handler.invoke(Library.java:244)
    at capstone.$Proxy7.cs_disasm(Unknown Source)
    at capstone.Capstone.disasm(Capstone.java:457)
    at capstone.Capstone.disasm(Capstone.java:442)
    at DisassemblerTest.testDisassembler(DisassemblerTest.java:13)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:349)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:314)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:312)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:292)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:396)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

我的maven依赖是:

<dependency>
    <groupId>com.github.transcurity</groupId>
    <artifactId>capstone</artifactId>
    <version>LATEST</version> <!-- 3.0.5-rc2 -->
</dependency>

请注意,我capstone.dll在项目的根目录中提供了它并找到了它。否则会收到一个UnsatisfiedLinkError. 我确保它是最新DLL可用的,但它仍然不起作用。奇怪的是,它之前有效,自 2018 年 7 月以来他们没有进行更新

4

1 回答 1

0

没关系,这似乎是较新的 JDK 的问题。我最近切换到JDK 11. 解决方法是等到Capstone支持Java 9和更高版本或使用Java 8它确实是一个Capstone错误。

编辑:
此问题现已修复。

于 2018-11-28T15:53:49.180 回答