From 14222bd5f034c782163ed210c53f7412e35f3654 Mon Sep 17 00:00:00 2001 From: bulaza Date: Wed, 17 May 2017 21:12:46 -0400 Subject: [PATCH] Update UC_HOOK_MEM_VALID (#837) * Update UC_HOOK_MEM_VALID UC_HOOK_MEM_READ fires before handlers for invalid memory reads, so UC_HOOK_MEM_VALID would technically also be receiving invalid memory reads. Switching to UC_HOOK_MEM_READ_AFTER ensures that only actually valid reads are hooked * Removed macro change, added comment Removed the macro change, but added a clarifying comment. May submit a future PR with a new macro added * Update unicorn.h will -> may * Update unicorn.h --- include/unicorn/unicorn.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 31d752e0..9dde3378 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -248,6 +248,8 @@ typedef enum uc_hook_type { // Hook type for all events of illegal memory access #define UC_HOOK_MEM_INVALID (UC_HOOK_MEM_UNMAPPED + UC_HOOK_MEM_PROT) // Hook type for all events of valid memory access +// NOTE: UC_HOOK_MEM_READ is triggered before UC_HOOK_MEM_READ_PROT and UC_HOOK_MEM_READ_UNMAPPED, so +// this hook may technically trigger on some invalid reads. #define UC_HOOK_MEM_VALID (UC_HOOK_MEM_READ + UC_HOOK_MEM_WRITE + UC_HOOK_MEM_FETCH) /*