fix confusion betweet UC_MEM_xxx & UC_HOOK_MEM_xxx. fix issue #93
This commit is contained in:
21
hook.c
21
hook.c
@ -67,17 +67,17 @@ size_t hook_add(uch handle, int type, uint64_t begin, uint64_t end, void *callba
|
||||
if (begin > end)
|
||||
uc->hook_insn_idx = i;
|
||||
break;
|
||||
case UC_MEM_READ:
|
||||
case UC_HOOK_MEM_READ:
|
||||
uc->hook_mem_read = true;
|
||||
if (begin > end)
|
||||
uc->hook_read_idx = i;
|
||||
break;
|
||||
case UC_MEM_WRITE:
|
||||
case UC_HOOK_MEM_WRITE:
|
||||
uc->hook_mem_write = true;
|
||||
if (begin > end)
|
||||
uc->hook_write_idx = i;
|
||||
break;
|
||||
case UC_MEM_READ_WRITE:
|
||||
case UC_HOOK_MEM_READ_WRITE:
|
||||
uc->hook_mem_read = true;
|
||||
uc->hook_mem_write = true;
|
||||
if (begin > end) {
|
||||
@ -162,12 +162,13 @@ static struct hook_struct *_hook_find(struct uc_struct *uc, int type, uint64_t a
|
||||
if (uc->hook_insn_idx)
|
||||
return &uc->hook_callbacks[uc->hook_insn_idx];
|
||||
break;
|
||||
case UC_MEM_READ:
|
||||
case UC_HOOK_MEM_READ:
|
||||
// already hooked all memory read?
|
||||
if (uc->hook_read_idx)
|
||||
if (uc->hook_read_idx) {
|
||||
return &uc->hook_callbacks[uc->hook_read_idx];
|
||||
}
|
||||
break;
|
||||
case UC_MEM_WRITE:
|
||||
case UC_HOOK_MEM_WRITE:
|
||||
// already hooked all memory write?
|
||||
if (uc->hook_write_idx)
|
||||
return &uc->hook_callbacks[uc->hook_write_idx];
|
||||
@ -185,14 +186,14 @@ static struct hook_struct *_hook_find(struct uc_struct *uc, int type, uint64_t a
|
||||
return &uc->hook_callbacks[i];
|
||||
}
|
||||
break;
|
||||
case UC_MEM_READ:
|
||||
if (uc->hook_callbacks[i].hook_type == UC_MEM_READ || uc->hook_callbacks[i].hook_type == UC_MEM_READ_WRITE) {
|
||||
case UC_HOOK_MEM_READ:
|
||||
if (uc->hook_callbacks[i].hook_type == UC_HOOK_MEM_READ || uc->hook_callbacks[i].hook_type == UC_HOOK_MEM_READ_WRITE) {
|
||||
if (uc->hook_callbacks[i].begin <= address && address <= uc->hook_callbacks[i].end)
|
||||
return &uc->hook_callbacks[i];
|
||||
}
|
||||
break;
|
||||
case UC_MEM_WRITE:
|
||||
if (uc->hook_callbacks[i].hook_type == UC_MEM_WRITE || uc->hook_callbacks[i].hook_type == UC_MEM_READ_WRITE) {
|
||||
case UC_HOOK_MEM_WRITE:
|
||||
if (uc->hook_callbacks[i].hook_type == UC_HOOK_MEM_WRITE || uc->hook_callbacks[i].hook_type == UC_HOOK_MEM_READ_WRITE) {
|
||||
if (uc->hook_callbacks[i].begin <= address && address <= uc->hook_callbacks[i].end)
|
||||
return &uc->hook_callbacks[i];
|
||||
}
|
||||
|
Reference in New Issue
Block a user