@@ -245,7 +245,22 @@ typedef uint32_t (*uc_cb_insn_in_t)(uc_engine *uc, uint32_t port, int size,
245
245
typedef void (*uc_cb_insn_out_t )(uc_engine *uc, uint32_t port, int size,
246
246
uint32_t value, void *user_data);
247
247
248
+ // The definitions for `uc_cb_tlbevent_t` callback
249
+ typedef enum uc_prot {
250
+ UC_PROT_NONE = 0 ,
251
+ UC_PROT_READ = 1 ,
252
+ UC_PROT_WRITE = 2 ,
253
+ UC_PROT_EXEC = 4 ,
254
+ UC_PROT_ALL = 7 ,
255
+ } uc_prot;
256
+
257
+ struct uc_tlb_entry {
258
+ uint64_t paddr;
259
+ uc_prot perms;
260
+ };
261
+
248
262
typedef struct uc_tlb_entry uc_tlb_entry;
263
+
249
264
// All type of memory accesses for UC_HOOK_MEM_*
250
265
typedef enum uc_mem_type {
251
266
UC_MEM_READ = 16 , // Memory is read from
@@ -950,16 +965,16 @@ uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *bytes, uint64_t size);
950
965
will not translate the virtual address when the pages are not mapped
951
966
with the given access rights.
952
967
953
- When the pages are mapped with the given access rights the read will
954
- happen indipenden from the access rights of the mapping. So when you
955
- have a page write only mapped, a call with prot == UC_PROT_WRITE will
956
- be able to read the stored data .
968
+ Note the `prot` is different from the underlying protections of the physicall
969
+ memory regions. For instance, if a region of phyiscal memory is mapped with
970
+ write- only permissions, only a call with prot == UC_PROT_WRITE will be able to
971
+ read the contents .
957
972
958
973
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
959
974
for detailed error).
960
975
*/
961
976
UNICORN_EXPORT
962
- uc_err uc_vmem_read (uc_engine *uc, uint64_t address, uint32_t prot,
977
+ uc_err uc_vmem_read (uc_engine *uc, uint64_t address, uc_prot prot,
963
978
void *bytes, size_t size);
964
979
965
980
/*
@@ -987,7 +1002,7 @@ uc_err uc_vmem_read(uc_engine *uc, uint64_t address, uint32_t prot,
987
1002
for detailed error).
988
1003
*/
989
1004
UNICORN_EXPORT
990
- uc_err uc_vmem_write (uc_engine *uc, uint64_t address, uint32_t prot,
1005
+ uc_err uc_vmem_write (uc_engine *uc, uint64_t address, uc_prot prot,
991
1006
void *bytes, size_t size);
992
1007
993
1008
/*
@@ -1007,7 +1022,7 @@ uc_err uc_vmem_write(uc_engine *uc, uint64_t address, uint32_t prot,
1007
1022
for detailed error).
1008
1023
*/
1009
1024
UNICORN_EXPORT
1010
- uc_err uc_vmem_translate (uc_engine *uc, uint64_t address, uint32_t prot,
1025
+ uc_err uc_vmem_translate (uc_engine *uc, uint64_t address, uc_prot prot,
1011
1026
uint64_t *paddress);
1012
1027
1013
1028
/*
@@ -1088,19 +1103,6 @@ uc_err uc_hook_add(uc_engine *uc, uc_hook *hh, int type, void *callback,
1088
1103
UNICORN_EXPORT
1089
1104
uc_err uc_hook_del (uc_engine *uc, uc_hook hh);
1090
1105
1091
- typedef enum uc_prot {
1092
- UC_PROT_NONE = 0 ,
1093
- UC_PROT_READ = 1 ,
1094
- UC_PROT_WRITE = 2 ,
1095
- UC_PROT_EXEC = 4 ,
1096
- UC_PROT_ALL = 7 ,
1097
- } uc_prot;
1098
-
1099
- struct uc_tlb_entry {
1100
- uint64_t paddr;
1101
- uc_prot perms;
1102
- };
1103
-
1104
1106
/*
1105
1107
Variables to control which state should be stored in the context.
1106
1108
Defaults to UC_CTL_CONTEXT_CPU. The options are used in a bitfield
0 commit comments