Capstone 反汇编程序 Java 绑定:"Invalid memory access"
Capstone Disassembler Java Bindings: "Invalid memory access"
我正在使用 Capstone
反汇编程序的 Java bindings。当我运行代码示例
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.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.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.run(ParentRunner.java:314)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:312)
at org.junit.runners.ParentRunner.access0(ParentRunner.java:66)
at org.junit.runners.ParentRunner.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
可用,但它仍然不起作用。够奇怪的,它在 they didn't make an update since July 2018.
之前有效
没关系,it seems to be an issue with a newer JDK。我最近切换到 JDK 11
。解决方法是等到 Capstone
支持 Java 9
和更高版本或使用 Java 8
所以确实是一个 Capstone
错误。
编辑:
此问题现已修复。
我正在使用 Capstone
反汇编程序的 Java bindings。当我运行代码示例
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.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.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.run(ParentRunner.java:314)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:312)
at org.junit.runners.ParentRunner.access0(ParentRunner.java:66)
at org.junit.runners.ParentRunner.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
可用,但它仍然不起作用。够奇怪的,它在 they didn't make an update since July 2018.
没关系,it seems to be an issue with a newer JDK。我最近切换到 JDK 11
。解决方法是等到 Capstone
支持 Java 9
和更高版本或使用 Java 8
所以确实是一个 Capstone
错误。
编辑:
此问题现已修复。