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; \
Arm32Decoder* Arm32Decoder::instant = new Arm32Decoder();
void Arm32Decoder::decode(void *codeStart, Addr codeLen, InstVisitor &visitor) {
bool thumb = isThumbCode(reinterpret_cast<Addr>(codeStart));
if (thumb) {
codeStart = getThumbCodeAddress(codeStart);
}
void *pc = codeStart;
Addr endAddr = (Addr) codeStart + codeLen;
Unit<Base>* unit = nullptr;
while((Addr) pc < endAddr) {
bool thumb = isThumbCode(reinterpret_cast<Addr>(pc));
bool thumb32 = isThumb32(*reinterpret_cast<InstT16*>(pc));
if (thumb && thumb32) {
CASE_T32(B32)
CASE_T32(LDR_LIT)
......@@ -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)));
}
label_matched:
if (!visitor.visit(unit, pc)) {
break;
......
......@@ -371,12 +371,12 @@ T16_PUSH::T16_PUSH(T16_STRUCT_PUSH *inst) : InstructionT16(inst) {
T16_PUSH::T16_PUSH(const RegisterList &registerList) : registerList(registerList) {}
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() {
SET_OPCODE(POP);
U16 regs = registerList.GetList();
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 {
class Decoder {
public:
static InstDecoder* get(Arch arch);
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