rename uchook to uc_hook, ucengine to uc_engine, uc_hook_t to uc_hook_type
This commit is contained in:
@@ -13,7 +13,7 @@ static int count = 1;
|
||||
// @address: address where the code is being executed
|
||||
// @size: size of machine instruction being executed
|
||||
// @user_data: user data passed to tracing APIs.
|
||||
void cb_hookblock(ucengine *uc, uint64_t address, uint32_t size, void *user_data) {
|
||||
void cb_hookblock(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) {
|
||||
fprintf(stderr, "# >>> Tracing basic block at 0x%"PRIx64", block size = 0x%x\n", address, size);
|
||||
if (address != 0x1000000 && address != 0x1000200) {
|
||||
fprintf(stderr, "not ok %d - address != 0x1000000 && address != 0x1000200\n", count++);
|
||||
@@ -28,7 +28,7 @@ void cb_hookblock(ucengine *uc, uint64_t address, uint32_t size, void *user_data
|
||||
}
|
||||
|
||||
int main() {
|
||||
ucengine *uc;
|
||||
uc_engine *uc;
|
||||
|
||||
fprintf(stderr, "# basic block callback test\n");
|
||||
fprintf(stderr, "# there are only two basic blocks 0x1000000-0x10001ff and 0x1000200-0x10003ff\n");
|
||||
@@ -63,7 +63,7 @@ int main() {
|
||||
}
|
||||
fprintf(stderr, "ok %d - uc_mem_write\n", count++);
|
||||
|
||||
uchook h1, h2;
|
||||
uc_hook h1, h2;
|
||||
|
||||
err = uc_hook_add(uc, &h1, UC_HOOK_BLOCK, cb_hookblock, NULL, (uint64_t)1, (uint64_t)0);
|
||||
if (err != UC_ERR_OK) {
|
||||
|
||||
@@ -10,7 +10,7 @@ int main()
|
||||
{
|
||||
int size;
|
||||
uint8_t *buf;
|
||||
ucengine *uc;
|
||||
uc_engine *uc;
|
||||
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);
|
||||
if (err) {
|
||||
fprintf (stderr, "Cannot initialize unicorn\n");
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
ucengine *uc;
|
||||
uc_engine *uc;
|
||||
uint8_t *buf, *buf2;
|
||||
int i;
|
||||
uc_err err;
|
||||
|
||||
@@ -78,7 +78,7 @@ static int log_num = 1;
|
||||
#define CODE_SIZE 0x1000
|
||||
|
||||
// callback for tracing instruction
|
||||
static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
{
|
||||
uint8_t opcode;
|
||||
|
||||
@@ -104,14 +104,14 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat
|
||||
}
|
||||
|
||||
// callback for tracing memory access (READ or WRITE)
|
||||
static void hook_mem_write(ucengine *uc, uc_mem_type type,
|
||||
static void hook_mem_write(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value);
|
||||
}
|
||||
|
||||
// callback for tracing invalid memory access (READ or WRITE)
|
||||
static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
switch(type) {
|
||||
@@ -142,8 +142,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ucengine *uc;
|
||||
uchook trace1, trace2;
|
||||
uc_engine *uc;
|
||||
uc_hook trace1, trace2;
|
||||
uc_err err;
|
||||
uint32_t esp, eip;
|
||||
int32_t buf1[1024], buf2[1024], readbuf[1024];
|
||||
|
||||
@@ -77,7 +77,7 @@ static int log_num = 1;
|
||||
#define CODE_SIZE 0x1000
|
||||
|
||||
// callback for tracing instruction
|
||||
static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
{
|
||||
uint8_t opcode;
|
||||
uint32_t testval;
|
||||
@@ -125,14 +125,14 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat
|
||||
}
|
||||
|
||||
// callback for tracing memory access (READ or WRITE)
|
||||
static void hook_mem_write(ucengine *uc, uc_mem_type type,
|
||||
static void hook_mem_write(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value);
|
||||
}
|
||||
|
||||
// callback for tracing invalid memory access (READ or WRITE)
|
||||
static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
uint32_t testval;
|
||||
@@ -160,8 +160,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ucengine *uc;
|
||||
uchook trace1, trace2;
|
||||
uc_engine *uc;
|
||||
uc_hook trace1, trace2;
|
||||
uc_err err;
|
||||
uint32_t addr, testval;
|
||||
int32_t buf1[1024], buf2[1024], readbuf[1024];
|
||||
|
||||
@@ -72,7 +72,7 @@ static int log_num = 1;
|
||||
#define CODE_SIZE 0x1000
|
||||
|
||||
// callback for tracing instruction
|
||||
static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
{
|
||||
uint8_t opcode;
|
||||
uint32_t testval;
|
||||
@@ -120,14 +120,14 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat
|
||||
}
|
||||
|
||||
// callback for tracing memory access (READ or WRITE)
|
||||
static void hook_mem_write(ucengine *uc, uc_mem_type type,
|
||||
static void hook_mem_write(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value);
|
||||
}
|
||||
|
||||
// callback for tracing invalid memory access (READ or WRITE)
|
||||
static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
uint32_t testval;
|
||||
@@ -155,8 +155,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ucengine *uc;
|
||||
uchook trace1, trace2;
|
||||
uc_engine *uc;
|
||||
uc_hook trace1, trace2;
|
||||
uc_err err;
|
||||
uint32_t addr, testval;
|
||||
int32_t buf1[1024], buf2[1024], readbuf[1024];
|
||||
|
||||
@@ -36,7 +36,7 @@ bits 32
|
||||
*/
|
||||
|
||||
// callback for tracing memory access (READ or WRITE)
|
||||
static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t address, int size, int64_t value, void *user_data)
|
||||
{
|
||||
|
||||
@@ -54,8 +54,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ucengine *uc;
|
||||
uchook trace1, trace2;
|
||||
uc_engine *uc;
|
||||
uc_hook trace1, trace2;
|
||||
uc_err err;
|
||||
uint32_t eax, ebx;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ hlt
|
||||
static int log_num = 1;
|
||||
|
||||
// callback for tracing instruction
|
||||
static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
static void hook_code(uc_engine *uc, uint64_t addr, uint32_t size, void *user_data)
|
||||
{
|
||||
uint8_t opcode;
|
||||
if (uc_mem_read(uc, addr, &opcode, 1) != UC_ERR_OK) {
|
||||
@@ -74,7 +74,7 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat
|
||||
}
|
||||
|
||||
// callback for tracing memory access (READ or WRITE)
|
||||
static void hook_mem_write(ucengine *uc, uc_mem_type type,
|
||||
static void hook_mem_write(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t addr, int size, int64_t value, void *user_data)
|
||||
{
|
||||
printf("# write to memory at 0x%"PRIx64 ", data size = %u, data value = 0x%"PRIx64 "\n", addr, size, value);
|
||||
@@ -89,8 +89,8 @@ static void hook_mem_write(ucengine *uc, uc_mem_type type,
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ucengine *uc;
|
||||
uchook trace1, trace2;
|
||||
uc_engine *uc;
|
||||
uc_hook trace1, trace2;
|
||||
uc_err err;
|
||||
uint8_t buf1[100], readbuf[100];
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ bottom:
|
||||
*/
|
||||
|
||||
// callback for tracing instruction
|
||||
static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data)
|
||||
static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
|
||||
{
|
||||
uint32_t esp;
|
||||
printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size);
|
||||
@@ -57,7 +57,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_
|
||||
}
|
||||
|
||||
// callback for tracing memory access (READ or WRITE)
|
||||
static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
static bool hook_mem_invalid(uc_engine *uc, uc_mem_type type,
|
||||
uint64_t address, int size, int64_t value, void *user_data)
|
||||
{
|
||||
uint32_t esp;
|
||||
@@ -94,8 +94,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
ucengine *uc;
|
||||
uchook trace1, trace2;
|
||||
uc_engine *uc;
|
||||
uc_hook trace1, trace2;
|
||||
uc_err err;
|
||||
uint8_t bytes[8];
|
||||
uint32_t esp;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
int got_sigill = 0;
|
||||
|
||||
void _interrupt(ucengine *uc, uint32_t intno, void *user_data)
|
||||
void _interrupt(uc_engine *uc, uint32_t intno, void *user_data)
|
||||
{
|
||||
if (intno == 6) {
|
||||
uc_emu_stop(uc);
|
||||
@@ -20,8 +20,8 @@ int main()
|
||||
{
|
||||
int size;
|
||||
uint8_t *buf;
|
||||
ucengine *uc;
|
||||
uchook uh_trap;
|
||||
uc_engine *uc;
|
||||
uc_hook uh_trap;
|
||||
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);
|
||||
if (err) {
|
||||
fprintf (stderr, "Cannot initialize unicorn\n");
|
||||
|
||||
@@ -10,7 +10,7 @@ int main()
|
||||
{
|
||||
int size;
|
||||
uint8_t *buf;
|
||||
ucengine *uc;
|
||||
uc_engine *uc;
|
||||
|
||||
uc_err err = uc_open (UC_ARCH_X86, UC_MODE_64, &uc);
|
||||
if (err) {
|
||||
|
||||
@@ -24,21 +24,21 @@ https://github.com/unicorn-engine/unicorn/issues/78
|
||||
// number of seconds to wait before timeout
|
||||
#define TIMEOUT 5
|
||||
|
||||
static void hook_block(ucengine *uc, uint64_t address, uint32_t size, void *user_data)
|
||||
static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
|
||||
{
|
||||
printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size);
|
||||
}
|
||||
|
||||
static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_data)
|
||||
static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
|
||||
{
|
||||
printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size);
|
||||
}
|
||||
|
||||
static void test_arm(void)
|
||||
{
|
||||
ucengine *uc;
|
||||
uc_engine *uc;
|
||||
uc_err err;
|
||||
uchook trace1, trace2;
|
||||
uc_hook trace1, trace2;
|
||||
|
||||
int r0 = 0x1234; // R0 register
|
||||
int r2 = 0x6789; // R1 register
|
||||
@@ -92,9 +92,9 @@ static void test_arm(void)
|
||||
|
||||
static void test_thumb(void)
|
||||
{
|
||||
ucengine *uc;
|
||||
uc_engine *uc;
|
||||
uc_err err;
|
||||
uchook trace1, trace2;
|
||||
uc_hook trace1, trace2;
|
||||
|
||||
int sp = 0x1234; // R0 register
|
||||
|
||||
|
||||
Reference in New Issue
Block a user