diff --git a/unidbg-android/src/main/java/com/github/unidbg/linux/ARM32SyscallHandler.java b/unidbg-android/src/main/java/com/github/unidbg/linux/ARM32SyscallHandler.java index fedda5df2..c8c1dc882 100644 --- a/unidbg-android/src/main/java/com/github/unidbg/linux/ARM32SyscallHandler.java +++ b/unidbg-android/src/main/java/com/github/unidbg/linux/ARM32SyscallHandler.java @@ -1667,7 +1667,7 @@ private int prctl(Backend backend, Emulator emulator) { private final long nanoTime = System.nanoTime(); - private int clock_gettime(Backend backend, Emulator emulator) { + protected int clock_gettime(Backend backend, Emulator emulator) { int clk_id = backend.reg_read(ArmConst.UC_ARM_REG_R0).intValue(); Pointer tp = UnidbgPointer.register(emulator, ArmConst.UC_ARM_REG_R1); long offset = clk_id == CLOCK_REALTIME ? System.currentTimeMillis() * 1000000L : System.nanoTime() - nanoTime; diff --git a/unidbg-android/src/main/java/com/github/unidbg/linux/ARM64SyscallHandler.java b/unidbg-android/src/main/java/com/github/unidbg/linux/ARM64SyscallHandler.java index 37cd7b954..f1cacbdc4 100644 --- a/unidbg-android/src/main/java/com/github/unidbg/linux/ARM64SyscallHandler.java +++ b/unidbg-android/src/main/java/com/github/unidbg/linux/ARM64SyscallHandler.java @@ -987,7 +987,7 @@ private int prctl(Backend backend, Emulator emulator) { private final long nanoTime = System.nanoTime(); - private int clock_gettime(Emulator emulator) { + protected int clock_gettime(Emulator emulator) { RegisterContext context = emulator.getContext(); int clk_id = context.getIntArg(0); Pointer tp = context.getPointerArg(1); diff --git a/unidbg-api/src/main/java/com/github/unidbg/arm/backend/UnicornBackend.java b/unidbg-api/src/main/java/com/github/unidbg/arm/backend/UnicornBackend.java index 79b2a331b..d3db0ba88 100644 --- a/unidbg-api/src/main/java/com/github/unidbg/arm/backend/UnicornBackend.java +++ b/unidbg-api/src/main/java/com/github/unidbg/arm/backend/UnicornBackend.java @@ -295,7 +295,7 @@ public void emu_start(long begin, long until, long timeout, long count) throws B try { unicorn.emu_start(begin, until, timeout, count); } catch (UnicornException e) { - throw new BackendException(); + throw new BackendException(e); } } diff --git a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContext.java b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContext.java index 7e165bc28..4c50cc00a 100644 --- a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContext.java +++ b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContext.java @@ -1,7 +1,7 @@ package com.github.unidbg.hook.hookzz; -import com.github.unidbg.arm.context.Arm32RegisterContext; +import com.github.unidbg.arm.context.EditableArm32RegisterContext; import com.github.unidbg.hook.InvocationContext; -public interface HookZzArm32RegisterContext extends Arm32RegisterContext, InvocationContext { +public interface HookZzArm32RegisterContext extends EditableArm32RegisterContext, InvocationContext { } diff --git a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContextImpl.java b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContextImpl.java index 5bcada3c1..0b6ba0801 100644 --- a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContextImpl.java +++ b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm32RegisterContextImpl.java @@ -37,7 +37,52 @@ public UnidbgPointer getPointerArg(int index) { } UnidbgPointer sp = getStackPointer(); - return sp.getPointer((index - 4) * emulator.getPointerSize()); + return sp.getPointer((long) (index - 4) * emulator.getPointerSize()); + } + + @Override + public void setR0(int r0) { + reg_ctx.setInt(0, r0); + } + + @Override + public void setR1(int r1) { + reg_ctx.setInt(4, r1); + } + + @Override + public void setR2(int r2) { + reg_ctx.setInt(8, r2); + } + + @Override + public void setR3(int r3) { + reg_ctx.setInt(12, r3); + } + + @Override + public void setR4(int r4) { + reg_ctx.setInt(16, r4); + } + + @Override + public void setR5(int r5) { + reg_ctx.setInt(20, r5); + } + + @Override + public void setR6(int r6) { + reg_ctx.setInt(24, r6); + } + + @Override + public void setR7(int r7) { + reg_ctx.setInt(28, r7); + } + + @Override + public void setStackPointer(Pointer sp) { + throw new UnsupportedOperationException(); } @Override diff --git a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContext.java b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContext.java index d2b7f67f3..be016ac0f 100644 --- a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContext.java +++ b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContext.java @@ -1,7 +1,7 @@ package com.github.unidbg.hook.hookzz; -import com.github.unidbg.arm.context.Arm64RegisterContext; +import com.github.unidbg.arm.context.EditableArm64RegisterContext; import com.github.unidbg.hook.InvocationContext; -public interface HookZzArm64RegisterContext extends Arm64RegisterContext, InvocationContext { +public interface HookZzArm64RegisterContext extends EditableArm64RegisterContext, InvocationContext { } diff --git a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContextImpl.java b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContextImpl.java index 938a687f1..0a99b6f0f 100644 --- a/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContextImpl.java +++ b/unidbg-api/src/main/java/com/github/unidbg/hook/hookzz/HookZzArm64RegisterContextImpl.java @@ -25,7 +25,7 @@ public UnidbgPointer getPointerArg(int index) { } UnidbgPointer sp = getStackPointer(); - return sp.getPointer((index - 8) * emulator.getPointerSize()); + return sp.getPointer((long) (index - 8) * emulator.getPointerSize()); } @Override @@ -51,6 +51,20 @@ public long getFp() { return reg_ctx.getLong(29 * 8); } + @Override + public void setXLong(int index, long value) { + if (index >= 0 && index <= 28) { + reg_ctx.setLong(index * 8, value); + } else { + throw new IllegalArgumentException("invalid index: " + index); + } + } + + @Override + public void setStackPointer(Pointer sp) { + throw new UnsupportedOperationException(); + } + @Override public UnidbgPointer getFpPointer() { return UnidbgPointer.pointer(emulator, getFp());