diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index 0aca12f3..5ac2bb49 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -313,7 +313,7 @@ uc_err uc_reg_read(uc_engine *uc, int regid, void *value); for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_write(uc_engine *uc, uint64_t address, const uint8_t *bytes, size_t size); +uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *bytes, size_t size); /* Read a range of bytes in memory. @@ -329,7 +329,7 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const uint8_t *bytes, size_ for detailed error). */ UNICORN_EXPORT -uc_err uc_mem_read(uc_engine *uc, uint64_t address, uint8_t *bytes, size_t size); +uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *bytes, size_t size); /* Emulate machine code in a specific duration of time. diff --git a/uc.c b/uc.c index b204c75c..0ea5cf03 100644 --- a/uc.c +++ b/uc.c @@ -331,8 +331,10 @@ static bool check_mem_area(uc_engine *uc, uint64_t address, size_t size) UNICORN_EXPORT -uc_err uc_mem_read(uc_engine *uc, uint64_t address, uint8_t *bytes, size_t size) +uc_err uc_mem_read(uc_engine *uc, uint64_t address, void *_bytes, size_t size) { + uint8_t *bytes = _bytes; + if (!check_mem_area(uc, address, size)) return UC_ERR_MEM_READ; @@ -359,8 +361,10 @@ uc_err uc_mem_read(uc_engine *uc, uint64_t address, uint8_t *bytes, size_t size) } UNICORN_EXPORT -uc_err uc_mem_write(uc_engine *uc, uint64_t address, const uint8_t *bytes, size_t size) +uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes, size_t size) { + const uint8_t *bytes = _bytes; + if (!check_mem_area(uc, address, size)) return UC_ERR_MEM_WRITE;