Commit e8aa714a authored by swift_gan's avatar swift_gan Committed by swift_gan

[NativeHook]fix some inst a64

parent 627b057f
...@@ -158,7 +158,7 @@ void AssemblerA64::Str(RegisterA64 &rt, const MemOperand& memOperand) { ...@@ -158,7 +158,7 @@ void AssemblerA64::Str(RegisterA64 &rt, const MemOperand& memOperand) {
} }
void AssemblerA64::Ldr(RegisterA64 &rt, const MemOperand &memOperand) { void AssemblerA64::Ldr(RegisterA64 &rt, const MemOperand &memOperand) {
if (memOperand.addr_mode == Offset) { if (memOperand.addr_mode == Offset && memOperand.offset >= 0) {
Emit(reinterpret_cast<Unit<Base> *>(new INST_A64(LDR_UIMM)(rt, memOperand))); Emit(reinterpret_cast<Unit<Base> *>(new INST_A64(LDR_UIMM)(rt, memOperand)));
} else { } else {
Emit(reinterpret_cast<Unit<Base> *>(new INST_A64(LDR_IMM)(rt, memOperand))); Emit(reinterpret_cast<Unit<Base> *>(new INST_A64(LDR_IMM)(rt, memOperand)));
......
...@@ -91,7 +91,7 @@ bool InlineHookArm64Android::breakPoint(void *point, void (*callback)(REG regs[] ...@@ -91,7 +91,7 @@ bool InlineHookArm64Android::breakPoint(void *point, void (*callback)(REG regs[]
U8 douRegCount = 30 / 2; U8 douRegCount = 30 / 2;
__ Sub(SP, Operand(&SP, 0xf0)); __ Sub(SP, Operand(&SP, 0xf0));
for (int i = 0; i < douRegCount; ++i) { for (int i = 0; i < douRegCount; ++i) {
__ Stp(*XReg(i), *XReg(i + 1), MemOperand(&SP, i * 16)); __ Stp(*XReg(2 * i), *XReg(2 * i + 1), MemOperand(&SP, i * 16));
} }
__ Mov(X0, SP); __ Mov(X0, SP);
...@@ -102,7 +102,7 @@ bool InlineHookArm64Android::breakPoint(void *point, void (*callback)(REG regs[] ...@@ -102,7 +102,7 @@ bool InlineHookArm64Android::breakPoint(void *point, void (*callback)(REG regs[]
//restore X0 - X29 //restore X0 - X29
for (int i = 0; i < douRegCount; ++i) { for (int i = 0; i < douRegCount; ++i) {
__ Ldp(*XReg(i), *XReg(i + 1), MemOperand(&SP, i * 16)); __ Ldp(*XReg(2 * i), *XReg(2 * i + 1), MemOperand(&SP, i * 16));
} }
__ Add(SP, Operand(&SP, 0xf0)); __ Add(SP, Operand(&SP, 0xf0));
......
...@@ -873,9 +873,9 @@ void A64_ADD_SUB_IMM::decode(A64_STRUCT_ADD_SUB_IMM *inst) { ...@@ -873,9 +873,9 @@ void A64_ADD_SUB_IMM::decode(A64_STRUCT_ADD_SUB_IMM *inst) {
sign = S(inst->S); sign = S(inst->S);
DECODE_SHIFT; DECODE_SHIFT;
if (operand.shift == LSL) { if (operand.shift == LSL) {
operand.immediate = get()->imm12; operand.shift_extend_imm = get()->imm12;
} else if (operand.shift == LSR) { } else if (operand.shift == LSR) {
operand.immediate = get()->imm12 << 12; operand.shift_extend_imm = get()->imm12 << 12;
} else { } else {
valid = false; valid = false;
} }
...@@ -890,9 +890,9 @@ void A64_ADD_SUB_IMM::assembler() { ...@@ -890,9 +890,9 @@ void A64_ADD_SUB_IMM::assembler() {
get()->S = sign; get()->S = sign;
ENCODE_SHIFT; ENCODE_SHIFT;
if (operand.shift == LSL) { if (operand.shift == LSL) {
get()->imm12 = static_cast<InstA64>(operand.immediate); get()->imm12 = operand.shift_extend_imm;
} else if (operand.shift == LSR) { } else if (operand.shift == LSR) {
get()->imm12 = static_cast<InstA64>(operand.immediate) >> 12; get()->imm12 = operand.shift_extend_imm >> 12;
} else { } else {
valid = false; valid = false;
} }
......
...@@ -789,8 +789,8 @@ namespace SandHook { ...@@ -789,8 +789,8 @@ namespace SandHook {
}; };
enum S { enum S {
Sign = 0b0, Sign = 0b1,
UnSign = 0b1 UnSign = 0b0
}; };
enum Size { enum Size {
......
...@@ -222,7 +222,7 @@ DEFINE_STRUCT_A64(ADD_SUB_IMM) { ...@@ -222,7 +222,7 @@ DEFINE_STRUCT_A64(ADD_SUB_IMM) {
InstA64 imm12:12; InstA64 imm12:12;
InstA64 shift:2; InstA64 shift:2;
InstA64 opcode:5; InstA64 opcode:5;
InstA64 S:2; InstA64 S:1;
InstA64 op:1; InstA64 op:1;
InstA64 sf:1; InstA64 sf:1;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment