Commit 65d35307 authored by swift_gan's avatar swift_gan Committed by swift_gan

[NativeHook]fix some insts

parent f6c7aa65
...@@ -24,14 +24,15 @@ goto label_matched; \ ...@@ -24,14 +24,15 @@ goto label_matched; \
Arm32Decoder* Arm32Decoder::instant = new Arm32Decoder(); Arm32Decoder* Arm32Decoder::instant = new Arm32Decoder();
void Arm32Decoder::decode(void *codeStart, Addr codeLen, InstVisitor &visitor) { void Arm32Decoder::decode(void *codeStart, Addr codeLen, InstVisitor &visitor) {
bool thumb = isThumbCode(reinterpret_cast<Addr>(codeStart));
if (thumb) {
codeStart = getThumbCodeAddress(codeStart);
}
void *pc = codeStart; void *pc = codeStart;
Addr endAddr = (Addr) codeStart + codeLen; Addr endAddr = (Addr) codeStart + codeLen;
Unit<Base>* unit = nullptr; Unit<Base>* unit = nullptr;
while((Addr) pc < endAddr) { while((Addr) pc < endAddr) {
bool thumb = isThumbCode(reinterpret_cast<Addr>(pc));
bool thumb32 = isThumb32(*reinterpret_cast<InstT16*>(pc)); bool thumb32 = isThumb32(*reinterpret_cast<InstT16*>(pc));
if (thumb && thumb32) { if (thumb && thumb32) {
CASE_T32(B32) CASE_T32(B32)
CASE_T32(LDR_LIT) CASE_T32(LDR_LIT)
...@@ -63,7 +64,6 @@ void Arm32Decoder::decode(void *codeStart, Addr codeLen, InstVisitor &visitor) { ...@@ -63,7 +64,6 @@ void Arm32Decoder::decode(void *codeStart, Addr codeLen, InstVisitor &visitor) {
unit = reinterpret_cast<Unit<Base> *>(new INST_T32(UNKNOW)(*reinterpret_cast<STRUCT_T32(UNKNOW) *>(pc))); unit = reinterpret_cast<Unit<Base> *>(new INST_T32(UNKNOW)(*reinterpret_cast<STRUCT_T32(UNKNOW) *>(pc)));
} }
label_matched: label_matched:
if (!visitor.visit(unit, pc)) { if (!visitor.visit(unit, pc)) {
break; break;
......
...@@ -371,12 +371,12 @@ T16_PUSH::T16_PUSH(T16_STRUCT_PUSH *inst) : InstructionT16(inst) { ...@@ -371,12 +371,12 @@ T16_PUSH::T16_PUSH(T16_STRUCT_PUSH *inst) : InstructionT16(inst) {
T16_PUSH::T16_PUSH(const RegisterList &registerList) : registerList(registerList) {} T16_PUSH::T16_PUSH(const RegisterList &registerList) : registerList(registerList) {}
void T16_PUSH::decode(T16_STRUCT_PUSH *inst) { void T16_PUSH::decode(T16_STRUCT_PUSH *inst) {
registerList.SetList(COMBINE(inst->M << 7, inst->regs, 8)); registerList.SetList(COMBINE(inst->M << 6, inst->regs, 8));
} }
void T16_PUSH::assembler() { void T16_PUSH::assembler() {
SET_OPCODE(POP); SET_OPCODE(POP);
U16 regs = registerList.GetList(); U16 regs = registerList.GetList();
get()->regs = BITS(regs, 0, 7); get()->regs = BITS(regs, 0, 7);
get()->M = BIT(regs, 15); get()->M = BIT(regs, 14);
} }
\ No newline at end of file
...@@ -26,6 +26,7 @@ namespace SandHook { ...@@ -26,6 +26,7 @@ namespace SandHook {
class Decoder { class Decoder {
public:
static InstDecoder* get(Arch arch); static InstDecoder* get(Arch arch);
static InstDecoder* get(); static InstDecoder* get();
}; };
......
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