Skip to content

Commit 600a1af

Browse files
committed
2 parents 15f087b + e1e0946 commit 600a1af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+372
-208
lines changed

bindings/go/unicorn/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (u *uc) HookAdd(htype int, cb interface{}, extra ...uint64) (Hook, error) {
9090
}
9191
default:
9292
// special case for mask
93-
if htype&(HOOK_MEM_READ_INVALID|HOOK_MEM_WRITE_INVALID|HOOK_MEM_FETCH_INVALID|
93+
if htype&(HOOK_MEM_READ_UNMAPPED|HOOK_MEM_WRITE_UNMAPPED|HOOK_MEM_FETCH_UNMAPPED|
9494
HOOK_MEM_READ_PROT|HOOK_MEM_WRITE_PROT|HOOK_MEM_FETCH_PROT) != 0 {
9595
rangeMode = true
9696
callback = C.hookMemInvalid_cgo

bindings/go/unicorn/unicorn_const.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,35 @@ const (
3939
ERR_HANDLE = 3
4040
ERR_MODE = 4
4141
ERR_VERSION = 5
42-
ERR_READ_INVALID = 6
43-
ERR_WRITE_INVALID = 7
44-
ERR_FETCH_INVALID = 8
45-
ERR_CODE_INVALID = 9
46-
ERR_HOOK = 10
47-
ERR_INSN_INVALID = 11
48-
ERR_MAP = 12
49-
ERR_WRITE_PROT = 13
50-
ERR_READ_PROT = 14
51-
ERR_FETCH_PROT = 15
52-
ERR_ARG = 16
53-
ERR_READ_UNALIGNED = 17
54-
ERR_WRITE_UNALIGNED = 18
55-
ERR_FETCH_UNALIGNED = 19
42+
ERR_READ_UNMAPPED = 6
43+
ERR_WRITE_UNMAPPED = 7
44+
ERR_FETCH_UNMAPPED = 8
45+
ERR_HOOK = 9
46+
ERR_INSN_INVALID = 10
47+
ERR_MAP = 11
48+
ERR_WRITE_PROT = 12
49+
ERR_READ_PROT = 13
50+
ERR_FETCH_PROT = 14
51+
ERR_ARG = 15
52+
ERR_READ_UNALIGNED = 16
53+
ERR_WRITE_UNALIGNED = 17
54+
ERR_FETCH_UNALIGNED = 18
5655
MEM_READ = 16
5756
MEM_WRITE = 17
5857
MEM_FETCH = 18
59-
MEM_READ_INVALID = 19
60-
MEM_WRITE_INVALID = 20
61-
MEM_FETCH_INVALID = 21
58+
MEM_READ_UNMAPPED = 19
59+
MEM_WRITE_UNMAPPED = 20
60+
MEM_FETCH_UNMAPPED = 21
6261
MEM_WRITE_PROT = 22
6362
MEM_READ_PROT = 23
6463
MEM_FETCH_PROT = 24
6564
HOOK_INTR = 1
6665
HOOK_INSN = 2
6766
HOOK_CODE = 4
6867
HOOK_BLOCK = 8
69-
HOOK_MEM_READ_INVALID = 16
70-
HOOK_MEM_WRITE_INVALID = 32
71-
HOOK_MEM_FETCH_INVALID = 64
68+
HOOK_MEM_READ_UNMAPPED = 16
69+
HOOK_MEM_WRITE_UNMAPPED = 32
70+
HOOK_MEM_FETCH_UNMAPPED = 64
7271
HOOK_MEM_READ_PROT = 128
7372
HOOK_MEM_WRITE_PROT = 256
7473
HOOK_MEM_FETCH_PROT = 512

bindings/java/samples/Sample_x86.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static void test_i386_invalid_mem_write()
419419
u.hook_add(new MyCodeHook(), 1, 0, null);
420420

421421
// intercept invalid memory events
422-
u.hook_add(new MyWriteInvalidHook(), Unicorn.UC_HOOK_MEM_WRITE_INVALID, null);
422+
u.hook_add(new MyWriteInvalidHook(), Unicorn.UC_HOOK_MEM_WRITE_UNMAPPED, null);
423423

424424
// emulate machine code in infinite time
425425
try {

bindings/java/unicorn/Unicorn.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public Tuple(Hook f, Object d) {
7272
//required to load native method implementations
7373
static {
7474
System.loadLibrary("unicorn_java"); //loads unicorn.dll or libunicorn.so
75-
eventMemMap.put(UC_HOOK_MEM_READ_INVALID, UC_MEM_READ_INVALID);
76-
eventMemMap.put(UC_HOOK_MEM_WRITE_INVALID, UC_MEM_WRITE_INVALID);
77-
eventMemMap.put(UC_HOOK_MEM_FETCH_INVALID, UC_MEM_FETCH_INVALID);
75+
eventMemMap.put(UC_HOOK_MEM_READ_UNMAPPED, UC_MEM_READ_UNMAPPED);
76+
eventMemMap.put(UC_HOOK_MEM_WRITE_UNMAPPED, UC_MEM_WRITE_UNMAPPED);
77+
eventMemMap.put(UC_HOOK_MEM_FETCH_UNMAPPED, UC_MEM_FETCH_UNMAPPED);
7878
eventMemMap.put(UC_HOOK_MEM_READ_PROT, UC_MEM_READ_PROT);
7979
eventMemMap.put(UC_HOOK_MEM_WRITE_PROT, UC_MEM_WRITE_PROT);
8080
eventMemMap.put(UC_HOOK_MEM_FETCH_PROT, UC_MEM_FETCH_PROT);
@@ -140,10 +140,10 @@ private static void invokeCodeCallbacks(long eng, long address, int size) {
140140
}
141141

142142
/**
143-
* Invoke all UC_HOOK_MEM_XXX_INVALID andor UC_HOOK_MEM_XXX_PROT callbacks registered
143+
* Invoke all UC_HOOK_MEM_XXX_UNMAPPED andor UC_HOOK_MEM_XXX_PROT callbacks registered
144144
* for a specific Unicorn.
145145
* This function gets invoked from the native C callback registered for
146-
* for UC_HOOK_MEM_XXX_INVALID or UC_HOOK_MEM_XXX_PROT
146+
* for UC_HOOK_MEM_XXX_UNMAPPED or UC_HOOK_MEM_XXX_PROT
147147
*
148148
* @param eng A Unicorn uc_engine* eng returned by uc_open
149149
* @param type The type of event that is taking place
@@ -535,12 +535,12 @@ public void hook_add(MemHook callback, long begin, long end, Object user_data) t
535535
}
536536

537537
/**
538-
* Hook registration for UC_HOOK_MEM_XXX_INVALID and UC_HOOK_MEM_XXX_PROT hooks.
538+
* Hook registration for UC_HOOK_MEM_XXX_UNMAPPED and UC_HOOK_MEM_XXX_PROT hooks.
539539
* The registered callback function will be invoked whenever a read or write is
540540
* attempted from an invalid or protected memory address.
541541
*
542542
* @param callback Implementation of a EventMemHook interface
543-
* @param type Type of memory event being hooked such as UC_HOOK_MEM_READ_INVALID or UC_HOOK_MEM_WRITE_PROT
543+
* @param type Type of memory event being hooked such as UC_HOOK_MEM_READ_UNMAPPED or UC_HOOK_MEM_WRITE_PROT
544544
* @param user_data User data to be passed to the callback function each time the event is triggered
545545
*/
546546
public void hook_add(EventMemHook callback, int type, Object user_data) throws UnicornException {

bindings/java/unicorn/UnicornConst.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,35 @@ public interface UnicornConst {
4141
public static final int UC_ERR_HANDLE = 3;
4242
public static final int UC_ERR_MODE = 4;
4343
public static final int UC_ERR_VERSION = 5;
44-
public static final int UC_ERR_READ_INVALID = 6;
45-
public static final int UC_ERR_WRITE_INVALID = 7;
46-
public static final int UC_ERR_FETCH_INVALID = 8;
47-
public static final int UC_ERR_CODE_INVALID = 9;
48-
public static final int UC_ERR_HOOK = 10;
49-
public static final int UC_ERR_INSN_INVALID = 11;
50-
public static final int UC_ERR_MAP = 12;
51-
public static final int UC_ERR_WRITE_PROT = 13;
52-
public static final int UC_ERR_READ_PROT = 14;
53-
public static final int UC_ERR_FETCH_PROT = 15;
54-
public static final int UC_ERR_ARG = 16;
55-
public static final int UC_ERR_READ_UNALIGNED = 17;
56-
public static final int UC_ERR_WRITE_UNALIGNED = 18;
57-
public static final int UC_ERR_FETCH_UNALIGNED = 19;
44+
public static final int UC_ERR_READ_UNMAPPED = 6;
45+
public static final int UC_ERR_WRITE_UNMAPPED = 7;
46+
public static final int UC_ERR_FETCH_UNMAPPED = 8;
47+
public static final int UC_ERR_HOOK = 9;
48+
public static final int UC_ERR_INSN_INVALID = 10;
49+
public static final int UC_ERR_MAP = 11;
50+
public static final int UC_ERR_WRITE_PROT = 12;
51+
public static final int UC_ERR_READ_PROT = 13;
52+
public static final int UC_ERR_FETCH_PROT = 14;
53+
public static final int UC_ERR_ARG = 15;
54+
public static final int UC_ERR_READ_UNALIGNED = 16;
55+
public static final int UC_ERR_WRITE_UNALIGNED = 17;
56+
public static final int UC_ERR_FETCH_UNALIGNED = 18;
5857
public static final int UC_MEM_READ = 16;
5958
public static final int UC_MEM_WRITE = 17;
6059
public static final int UC_MEM_FETCH = 18;
61-
public static final int UC_MEM_READ_INVALID = 19;
62-
public static final int UC_MEM_WRITE_INVALID = 20;
63-
public static final int UC_MEM_FETCH_INVALID = 21;
60+
public static final int UC_MEM_READ_UNMAPPED = 19;
61+
public static final int UC_MEM_WRITE_UNMAPPED = 20;
62+
public static final int UC_MEM_FETCH_UNMAPPED = 21;
6463
public static final int UC_MEM_WRITE_PROT = 22;
6564
public static final int UC_MEM_READ_PROT = 23;
6665
public static final int UC_MEM_FETCH_PROT = 24;
6766
public static final int UC_HOOK_INTR = 1;
6867
public static final int UC_HOOK_INSN = 2;
6968
public static final int UC_HOOK_CODE = 4;
7069
public static final int UC_HOOK_BLOCK = 8;
71-
public static final int UC_HOOK_MEM_READ_INVALID = 16;
72-
public static final int UC_HOOK_MEM_WRITE_INVALID = 32;
73-
public static final int UC_HOOK_MEM_FETCH_INVALID = 64;
70+
public static final int UC_HOOK_MEM_READ_UNMAPPED = 16;
71+
public static final int UC_HOOK_MEM_WRITE_UNMAPPED = 32;
72+
public static final int UC_HOOK_MEM_FETCH_UNMAPPED = 64;
7473
public static final int UC_HOOK_MEM_READ_PROT = 128;
7574
public static final int UC_HOOK_MEM_WRITE_PROT = 256;
7675
public static final int UC_HOOK_MEM_FETCH_PROT = 512;

bindings/java/unicorn/UnicornErrors.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ public interface UnicornErrors {
3131
public static final int UC_ERR_VERSION = 6; // Unsupported version (bindings)
3232
public static final int UC_ERR_MEM_READ = 7; // Quit emulation due to invalid memory READ: uc_emu_start()
3333
public static final int UC_ERR_MEM_WRITE = 8; // Quit emulation due to invalid memory WRITE: uc_emu_start()
34-
public static final int UC_ERR_CODE_INVALID = 9; // Quit emulation due to invalid code address: uc_emu_start()
35-
public static final int UC_ERR_HOOK = 10; // Invalid hook type: uc_hook_add()
36-
public static final int UC_ERR_INSN_INVALID = 11; // Quit emulation due to invalid instruction: uc_emu_start()
37-
public static final int UC_ERR_MAP = 12; // Invalid memory mapping: uc_mem_map()
34+
public static final int UC_ERR_HOOK = 9; // Invalid hook type: uc_hook_add()
35+
public static final int UC_ERR_INSN_INVALID = 10; // Quit emulation due to invalid instruction: uc_emu_start()
36+
public static final int UC_ERR_MAP = 11; // Invalid memory mapping: uc_mem_map()
3837
}
3938

bindings/java/unicorn_Unicorn.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void cb_hookmem(uc_engine *eng, uc_mem_type type,
160160
(*cachedJVM)->DetachCurrentThread(cachedJVM);
161161
}
162162

163-
// Callback function for handling memory events (for UC_HOOK_MEM_INVALID)
163+
// Callback function for handling memory events (for UC_HOOK_MEM_UNMAPPED)
164164
// @type: this memory is being READ, or WRITE
165165
// @address: address where the code is being executed
166166
// @size: size of data being read or written
@@ -389,9 +389,9 @@ JNIEXPORT jlong JNICALL Java_unicorn_Unicorn_registerHook__JI
389389
}
390390
err = uc_hook_add((uc_engine*)eng, &hh, (uc_hook_type)type, cb_hookintr, env);
391391
break;
392-
case UC_HOOK_MEM_FETCH_INVALID: // Hook for all invalid memory access events
393-
case UC_HOOK_MEM_READ_INVALID: // Hook for all invalid memory access events
394-
case UC_HOOK_MEM_WRITE_INVALID: // Hook for all invalid memory access events
392+
case UC_HOOK_MEM_FETCH_UNMAPPED: // Hook for all invalid memory access events
393+
case UC_HOOK_MEM_READ_UNMAPPED: // Hook for all invalid memory access events
394+
case UC_HOOK_MEM_WRITE_UNMAPPED: // Hook for all invalid memory access events
395395
case UC_HOOK_MEM_FETCH_PROT: // Hook for all invalid memory access events
396396
case UC_HOOK_MEM_READ_PROT: // Hook for all invalid memory access events
397397
case UC_HOOK_MEM_WRITE_PROT: // Hook for all invalid memory access events

bindings/python/sample_x86.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def hook_code(uc, address, size, user_data):
3333

3434
# callback for tracing invalid memory access (READ or WRITE)
3535
def hook_mem_invalid(uc, access, address, size, value, user_data):
36-
if access == UC_MEM_WRITE_INVALID:
36+
if access == UC_MEM_WRITE_UNMAPPED:
3737
print(">>> Missing memory is being WRITE at 0x%x, data size = %u, data value = 0x%x" \
3838
%(address, size, value))
3939
# map this memory in with 2MB in size
@@ -231,7 +231,7 @@ def test_i386_invalid_mem_write():
231231
#mu.hook_add(UC_HOOK_CODE, hook_code)
232232

233233
# intercept invalid memory events
234-
mu.hook_add(UC_HOOK_MEM_READ_INVALID | UC_HOOK_MEM_WRITE_INVALID, hook_mem_invalid)
234+
mu.hook_add(UC_HOOK_MEM_READ_UNMAPPED | UC_HOOK_MEM_WRITE_UNMAPPED, hook_mem_invalid)
235235

236236
try:
237237
# emulate machine code in infinite time

bindings/python/unicorn/unicorn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ def hook_add(self, htype, callback, user_data=None, arg1=1, arg2=0):
272272
cb = ctypes.cast(UC_HOOK_CODE_CB(self._hookcode_cb), UC_HOOK_CODE_CB)
273273
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, cb, \
274274
ctypes.cast(self._callback_count, ctypes.c_void_p), begin, end)
275-
elif htype & UC_HOOK_MEM_READ_INVALID or htype & UC_HOOK_MEM_WRITE_INVALID or \
276-
htype & UC_HOOK_MEM_FETCH_INVALID or htype & UC_HOOK_MEM_READ_PROT or \
275+
elif htype & UC_HOOK_MEM_READ_UNMAPPED or htype & UC_HOOK_MEM_WRITE_UNMAPPED or \
276+
htype & UC_HOOK_MEM_FETCH_UNMAPPED or htype & UC_HOOK_MEM_READ_PROT or \
277277
htype & UC_HOOK_MEM_WRITE_PROT or htype & UC_HOOK_MEM_FETCH_PROT:
278278
cb = ctypes.cast(UC_HOOK_MEM_INVALID_CB(self._hook_mem_invalid_cb), UC_HOOK_MEM_INVALID_CB)
279279
status = _uc.uc_hook_add(self._uch, ctypes.byref(_h2), htype, \

bindings/python/unicorn/unicorn_const.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,35 @@
3737
UC_ERR_HANDLE = 3
3838
UC_ERR_MODE = 4
3939
UC_ERR_VERSION = 5
40-
UC_ERR_READ_INVALID = 6
41-
UC_ERR_WRITE_INVALID = 7
42-
UC_ERR_FETCH_INVALID = 8
43-
UC_ERR_CODE_INVALID = 9
44-
UC_ERR_HOOK = 10
45-
UC_ERR_INSN_INVALID = 11
46-
UC_ERR_MAP = 12
47-
UC_ERR_WRITE_PROT = 13
48-
UC_ERR_READ_PROT = 14
49-
UC_ERR_FETCH_PROT = 15
50-
UC_ERR_ARG = 16
51-
UC_ERR_READ_UNALIGNED = 17
52-
UC_ERR_WRITE_UNALIGNED = 18
53-
UC_ERR_FETCH_UNALIGNED = 19
40+
UC_ERR_READ_UNMAPPED = 6
41+
UC_ERR_WRITE_UNMAPPED = 7
42+
UC_ERR_FETCH_UNMAPPED = 8
43+
UC_ERR_HOOK = 9
44+
UC_ERR_INSN_INVALID = 10
45+
UC_ERR_MAP = 11
46+
UC_ERR_WRITE_PROT = 12
47+
UC_ERR_READ_PROT = 13
48+
UC_ERR_FETCH_PROT = 14
49+
UC_ERR_ARG = 15
50+
UC_ERR_READ_UNALIGNED = 16
51+
UC_ERR_WRITE_UNALIGNED = 17
52+
UC_ERR_FETCH_UNALIGNED = 18
5453
UC_MEM_READ = 16
5554
UC_MEM_WRITE = 17
5655
UC_MEM_FETCH = 18
57-
UC_MEM_READ_INVALID = 19
58-
UC_MEM_WRITE_INVALID = 20
59-
UC_MEM_FETCH_INVALID = 21
56+
UC_MEM_READ_UNMAPPED = 19
57+
UC_MEM_WRITE_UNMAPPED = 20
58+
UC_MEM_FETCH_UNMAPPED = 21
6059
UC_MEM_WRITE_PROT = 22
6160
UC_MEM_READ_PROT = 23
6261
UC_MEM_FETCH_PROT = 24
6362
UC_HOOK_INTR = 1
6463
UC_HOOK_INSN = 2
6564
UC_HOOK_CODE = 4
6665
UC_HOOK_BLOCK = 8
67-
UC_HOOK_MEM_READ_INVALID = 16
68-
UC_HOOK_MEM_WRITE_INVALID = 32
69-
UC_HOOK_MEM_FETCH_INVALID = 64
66+
UC_HOOK_MEM_READ_UNMAPPED = 16
67+
UC_HOOK_MEM_WRITE_UNMAPPED = 32
68+
UC_HOOK_MEM_FETCH_UNMAPPED = 64
7069
UC_HOOK_MEM_READ_PROT = 128
7170
UC_HOOK_MEM_WRITE_PROT = 256
7271
UC_HOOK_MEM_FETCH_PROT = 512

include/uc_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ struct uc_struct {
185185
void *qemu_thread_data; // to support cross compile to Windows (qemu-thread-win32.c)
186186
uint32_t target_page_size;
187187
uint32_t target_page_align;
188+
uint64_t next_pc; // save next PC for some special cases
188189
};
189190

190191
#include "qemu_macro.h"

include/unicorn/unicorn.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ typedef enum uc_err {
111111
UC_ERR_HANDLE, // Invalid handle
112112
UC_ERR_MODE, // Invalid/unsupported mode: uc_open()
113113
UC_ERR_VERSION, // Unsupported version (bindings)
114-
UC_ERR_READ_INVALID, // Quit emulation due to invalid memory READ: uc_emu_start()
115-
UC_ERR_WRITE_INVALID, // Quit emulation due to invalid memory WRITE: uc_emu_start()
116-
UC_ERR_FETCH_INVALID, // Quit emulation due to invalid memory FETCH: uc_emu_start()
117-
UC_ERR_CODE_INVALID, // Quit emulation due to invalid code address: uc_emu_start()
114+
UC_ERR_READ_UNMAPPED, // Quit emulation due to READ on unmapped memory: uc_emu_start()
115+
UC_ERR_WRITE_UNMAPPED, // Quit emulation due to WRITE on unmapped memory: uc_emu_start()
116+
UC_ERR_FETCH_UNMAPPED, // Quit emulation due to FETCH on unmapped memory: uc_emu_start()
118117
UC_ERR_HOOK, // Invalid hook type: uc_hook_add()
119118
UC_ERR_INSN_INVALID, // Quit emulation due to invalid instruction: uc_emu_start()
120119
UC_ERR_MAP, // Invalid memory mapping: uc_mem_map()
@@ -156,23 +155,23 @@ typedef enum uc_mem_type {
156155
UC_MEM_READ = 16, // Memory is read from
157156
UC_MEM_WRITE, // Memory is written to
158157
UC_MEM_FETCH, // Memory is fetched
159-
UC_MEM_READ_INVALID, // Unmapped memory is read from
160-
UC_MEM_WRITE_INVALID, // Unmapped memory is written to
161-
UC_MEM_FETCH_INVALID, // Unmapped memory is fetched
158+
UC_MEM_READ_UNMAPPED, // Unmapped memory is read from
159+
UC_MEM_WRITE_UNMAPPED, // Unmapped memory is written to
160+
UC_MEM_FETCH_UNMAPPED, // Unmapped memory is fetched
162161
UC_MEM_WRITE_PROT, // Write to write protected, but mapped, memory
163162
UC_MEM_READ_PROT, // Read from read protected, but mapped, memory
164163
UC_MEM_FETCH_PROT, // Fetch from non-executable, but mapped, memory
165164
} uc_mem_type;
166165

167166
// All type of hooks for uc_hook_add() API.
168167
typedef enum uc_hook_type {
169-
UC_HOOK_INTR = 1 << 0, // Hook all interrupt events
168+
UC_HOOK_INTR = 1 << 0, // Hook all interrupt/syscall events
170169
UC_HOOK_INSN = 1 << 1, // Hook a particular instruction
171170
UC_HOOK_CODE = 1 << 2, // Hook a range of code
172171
UC_HOOK_BLOCK = 1 << 3, // Hook basic blocks
173-
UC_HOOK_MEM_READ_INVALID = 1 << 4, // Hook for invalid memory read events
174-
UC_HOOK_MEM_WRITE_INVALID = 1 << 5, // Hook for invalid memory write events
175-
UC_HOOK_MEM_FETCH_INVALID = 1 << 6, // Hook for invalid memory fetch for execution events
172+
UC_HOOK_MEM_READ_UNMAPPED = 1 << 4, // Hook for memory read on unmapped memory
173+
UC_HOOK_MEM_WRITE_UNMAPPED = 1 << 5, // Hook for invalid memory write events
174+
UC_HOOK_MEM_FETCH_UNMAPPED = 1 << 6, // Hook for invalid memory fetch for execution events
176175
UC_HOOK_MEM_READ_PROT = 1 << 7, // Hook for memory read on read-protected memory
177176
UC_HOOK_MEM_WRITE_PROT = 1 << 8, // Hook for memory write on write-protected memory
178177
UC_HOOK_MEM_FETCH_PROT = 1 << 9, // Hook for memory fetch on non-executable memory
@@ -182,17 +181,17 @@ typedef enum uc_hook_type {
182181
} uc_hook_type;
183182

184183
// hook type for all events of unmapped memory access
185-
#define UC_HOOK_MEM_INVALID (UC_HOOK_MEM_READ_INVALID + UC_HOOK_MEM_WRITE_INVALID + UC_HOOK_MEM_FETCH_INVALID)
184+
#define UC_HOOK_MEM_UNMAPPED (UC_HOOK_MEM_READ_UNMAPPED + UC_HOOK_MEM_WRITE_UNMAPPED + UC_HOOK_MEM_FETCH_UNMAPPED)
186185
// hook type for all events of illegal protected memory access
187186
#define UC_HOOK_MEM_PROT (UC_HOOK_MEM_READ_PROT + UC_HOOK_MEM_WRITE_PROT + UC_HOOK_MEM_FETCH_PROT)
188187
// hook type for all events of illegal read memory access
189-
#define UC_HOOK_MEM_READ_ERR (UC_HOOK_MEM_READ_PROT + UC_HOOK_MEM_READ_INVALID)
188+
#define UC_HOOK_MEM_READ_INVALID (UC_HOOK_MEM_READ_PROT + UC_HOOK_MEM_READ_UNMAPPED)
190189
// hook type for all events of illegal write memory access
191-
#define UC_HOOK_MEM_WRITE_ERR (UC_HOOK_MEM_WRITE_PROT + UC_HOOK_MEM_WRITE_INVALID)
190+
#define UC_HOOK_MEM_WRITE_INVALID (UC_HOOK_MEM_WRITE_PROT + UC_HOOK_MEM_WRITE_UNMAPPED)
192191
// hook type for all events of illegal fetch memory access
193-
#define UC_HOOK_MEM_FETCH_ERR (UC_HOOK_MEM_FETCH_PROT + UC_HOOK_MEM_FETCH_INVALID)
192+
#define UC_HOOK_MEM_FETCH_INVALID (UC_HOOK_MEM_FETCH_PROT + UC_HOOK_MEM_FETCH_UNMAPPED)
194193
// hook type for all events of illegal memory access
195-
#define UC_HOOK_MEM_ERR (UC_HOOK_MEM_INVALID + UC_HOOK_MEM_PROT)
194+
#define UC_HOOK_MEM_INVALID (UC_HOOK_MEM_UNMAPPED + UC_HOOK_MEM_PROT)
196195

197196
// Callback function for hooking memory (UC_MEM_READ, UC_MEM_WRITE & UC_MEM_FETCH)
198197
// @type: this memory is being READ, or WRITE
@@ -203,7 +202,7 @@ typedef enum uc_hook_type {
203202
typedef void (*uc_cb_hookmem_t)(uc_engine *uc, uc_mem_type type,
204203
uint64_t address, int size, int64_t value, void *user_data);
205204

206-
// Callback function for handling invalid memory access events (UC_MEM_*_INVALID and
205+
// Callback function for handling invalid memory access events (UC_MEM_*_UNMAPPED and
207206
// UC_MEM_*PROT events)
208207
// @type: this memory is being READ, or WRITE
209208
// @address: address where the code is being executed

qemu/aarch64.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Autogen header for Unicorn Engine - DONOT MODIFY */
22
#ifndef UNICORN_AUTOGEN_AARCH64_H
33
#define UNICORN_AUTOGEN_AARCH64_H
4+
#define helper_power_down helper_power_down_aarch64
45
#define check_exit_request check_exit_request_aarch64
56
#define address_space_unregister address_space_unregister_aarch64
67
#define tb_invalidate_phys_page_fast tb_invalidate_phys_page_fast_aarch64

qemu/arm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Autogen header for Unicorn Engine - DONOT MODIFY */
22
#ifndef UNICORN_AUTOGEN_ARM_H
33
#define UNICORN_AUTOGEN_ARM_H
4+
#define helper_power_down helper_power_down_arm
45
#define check_exit_request check_exit_request_arm
56
#define address_space_unregister address_space_unregister_arm
67
#define tb_invalidate_phys_page_fast tb_invalidate_phys_page_fast_arm

0 commit comments

Comments
 (0)