rename uchook to uc_hook, ucengine to uc_engine, uc_hook_t to uc_hook_type

This commit is contained in:
Nguyen Anh Quynh
2015-09-05 11:20:32 +08:00
parent 74c069dc22
commit d1bdbd11e7
29 changed files with 190 additions and 190 deletions

View File

@ -31,7 +31,7 @@
static int insts_executed;
// callback for tracing instructions, detect HLT and terminate emulation
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;
unsigned char buf[256];
@ -72,7 +72,7 @@ static void hook_code(ucengine *uc, uint64_t addr, uint32_t size, void *user_dat
}
// callback for tracing invalid memory access (READ/WRITE/EXEC)
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) {
@ -99,8 +99,8 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
static void do_nx_demo(bool cause_fault)
{
ucengine *uc;
uchook trace1, trace2;
uc_engine *uc;
uc_hook trace1, trace2;
uc_err err;
uint8_t code_buf[0x3000];
@ -181,8 +181,8 @@ static const uint8_t WRITE_DEMO[] =
static void do_perms_demo(bool change_perms)
{
ucengine *uc;
uchook trace1, trace2;
uc_engine *uc;
uc_hook trace1, trace2;
uc_err err;
uint8_t code_buf[0x3000];
@ -257,8 +257,8 @@ static void perms_test()
static void do_unmap_demo(bool do_unmap)
{
ucengine *uc;
uchook trace1, trace2;
uc_engine *uc;
uc_hook trace1, trace2;
uc_err err;
uint8_t code_buf[0x3000];

View File

@ -15,21 +15,21 @@
// memory address where emulation starts
#define ADDRESS 0x10000
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
@ -83,9 +83,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

View File

@ -14,21 +14,21 @@
// memory address where emulation starts
#define ADDRESS 0x10000
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_arm64(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int64_t x11 = 0x1234; // X11 register
int64_t x13 = 0x6789; // X13 register

View File

@ -12,20 +12,20 @@
// memory address where emulation starts
#define ADDRESS 0x10000
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_m68k(void)
{
ucengine *uc;
uchook trace1, trace2;
uc_engine *uc;
uc_hook trace1, trace2;
uc_err err;
int d0 = 0x0000; // d0 data register

View File

@ -15,21 +15,21 @@
// memory address where emulation starts
#define ADDRESS 0x10000
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_mips_eb(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int r1 = 0x6789; // R1 register
@ -76,9 +76,9 @@ static void test_mips_eb(void)
static void test_mips_el(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int r1 = 0x6789; // R1 register

View File

@ -15,21 +15,21 @@
// memory address where emulation starts
#define ADDRESS 0x10000
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_sparc(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int g1 = 0x1230; // G1 register
int g2 = 0x6789; // G2 register

View File

@ -32,13 +32,13 @@
#define ADDRESS 0x1000000
// callback for tracing basic blocks
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);
}
// 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)
{
int eflags;
printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size);
@ -52,7 +52,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_
}
// callback for tracing instruction
static void hook_code64(ucengine *uc, uint64_t address, uint32_t size, void *user_data)
static void hook_code64(uc_engine *uc, uint64_t address, uint32_t size, void *user_data)
{
uint64_t rip;
@ -66,7 +66,7 @@ static void hook_code64(ucengine *uc, uint64_t address, uint32_t size, void *use
}
// 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)
{
switch(type) {
@ -83,7 +83,7 @@ static bool hook_mem_invalid(ucengine *uc, uc_mem_type type,
}
}
static void hook_mem64(ucengine *uc, uc_mem_type type,
static void hook_mem64(uc_engine *uc, uc_mem_type type,
uint64_t address, int size, int64_t value, void *user_data)
{
switch(type) {
@ -101,7 +101,7 @@ static void hook_mem64(ucengine *uc, uc_mem_type type,
// callback for IN instruction (X86).
// this returns the data read from the port
static uint32_t hook_in(ucengine *uc, uint32_t port, int size, void *user_data)
static uint32_t hook_in(uc_engine *uc, uint32_t port, int size, void *user_data)
{
uint32_t eip;
@ -126,7 +126,7 @@ static uint32_t hook_in(ucengine *uc, uint32_t port, int size, void *user_data)
}
// callback for OUT instruction (X86).
static void hook_out(ucengine *uc, uint32_t port, int size, uint32_t value, void *user_data)
static void hook_out(uc_engine *uc, uint32_t port, int size, uint32_t value, void *user_data)
{
uint32_t tmp;
uint32_t eip;
@ -154,7 +154,7 @@ static void hook_out(ucengine *uc, uint32_t port, int size, uint32_t value, void
}
// callback for SYSCALL instruction (X86).
static void hook_syscall(ucengine *uc, void *user_data)
static void hook_syscall(uc_engine *uc, void *user_data)
{
uint64_t rax;
@ -168,10 +168,10 @@ static void hook_syscall(ucengine *uc, void *user_data)
static void test_i386(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uint32_t tmp;
uchook trace1, trace2;
uc_hook trace1, trace2;
int r_ecx = 0x1234; // ECX register
int r_edx = 0x7890; // EDX register
@ -230,9 +230,9 @@ static void test_i386(void)
static void test_i386_jump(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
printf("===================================\n");
printf("Emulate i386 code with jump\n");
@ -275,7 +275,7 @@ static void test_i386_jump(void)
// emulate code that loop forever
static void test_i386_loop(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
int r_ecx = 0x1234; // ECX register
@ -326,9 +326,9 @@ static void test_i386_loop(void)
// emulate code that read invalid memory
static void test_i386_invalid_mem_read(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int r_ecx = 0x1234; // ECX register
int r_edx = 0x7890; // EDX register
@ -383,9 +383,9 @@ static void test_i386_invalid_mem_read(void)
// emulate code that read invalid memory
static void test_i386_invalid_mem_write(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2, trace3;
uc_hook trace1, trace2, trace3;
uint32_t tmp;
int r_ecx = 0x1234; // ECX register
@ -455,9 +455,9 @@ static void test_i386_invalid_mem_write(void)
// emulate code that jump to invalid memory
static void test_i386_jump_invalid(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int r_ecx = 0x1234; // ECX register
int r_edx = 0x7890; // EDX register
@ -511,9 +511,9 @@ static void test_i386_jump_invalid(void)
static void test_i386_inout(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2, trace3, trace4;
uc_hook trace1, trace2, trace3, trace4;
int r_eax = 0x1234; // EAX register
int r_ecx = 0x6789; // ECX register
@ -572,9 +572,9 @@ static void test_i386_inout(void)
static void test_x86_64(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2, trace3, trace4;
uc_hook trace1, trace2, trace3, trace4;
int64_t rax = 0x71f3029efd49d41d;
int64_t rbx = 0xd87b45277f133ddb;
@ -688,8 +688,8 @@ static void test_x86_64(void)
static void test_x86_64_syscall(void)
{
ucengine *uc;
uchook trace1;
uc_engine *uc;
uc_hook trace1;
uc_err err;
int64_t rax = 0x100;
@ -739,7 +739,7 @@ static void test_x86_64_syscall(void)
static void test_x86_16(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uint8_t tmp;

View File

@ -20,7 +20,7 @@
#define MIN(a, b) (a < b? a : b)
// 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)
{
int r_eip;
char tmp[16];
@ -42,7 +42,7 @@ static void hook_code(ucengine *uc, uint64_t address, uint32_t size, void *user_
// callback for handling interrupt
// ref: http://syscalls.kernelgrok.com/
static void hook_intr(ucengine *uc, uint32_t intno, void *user_data)
static void hook_intr(uc_engine *uc, uint32_t intno, void *user_data)
{
int32_t r_eax, r_ecx, r_eip;
uint32_t r_edx, size;
@ -87,9 +87,9 @@ static void hook_intr(ucengine *uc, uint32_t intno, void *user_data)
static void test_i386(void)
{
ucengine *uc;
uc_engine *uc;
uc_err err;
uchook trace1, trace2;
uc_hook trace1, trace2;
int r_esp = ADDRESS + 0x200000; // ESP register