Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhkl0228 committed Dec 31, 2020
1 parent dd50944 commit 077938f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
Expand Down

0 comments on commit 077938f

Please sign in to comment.