mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-25 19:46:25 +00:00
06a64dc3b0
* 001-bad_condition_code_0xe.c (ARM) * 002-qemu__fatal__unimplemented_control_register_write_0xffb___0x0.c (M68K) * 003-qemu__fatal__wdebug_not_implemented.c (M68K) * 004-segmentation_fault_1.c (ARM) * 005-qemu__fatal__illegal_instruction__0000___00000404.c (M68K) * 006-qemu__fatal__illegal_instruction__0421___00040026.c (M68K) ``` $ ./001-bad_condition_code_0xe # ARM uc_emu_start(…) Bad condition code 0xe Aborted $ ./002-qemu__fatal__unimplemented_control_register_write_0xffb___0x0 # M68K uc_emu_start(…) hook_code(…) called qemu: fatal: Unimplemented control register write 0xffb = 0x0 Aborted $ ./003-qemu__fatal__wdebug_not_implemented # M68K uc_emu_start(…) qemu: fatal: WDEBUG not implemented Aborted $ ./004-segmentation_fault_1 # ARM uc_emu_start(…) hook_code(…) called Segmentation fault $ ./005-qemu__fatal__illegal_instruction__0000___00000404 # M68K uc_emu_start(…) qemu: fatal: Illegal instruction: 0000 @ 00000404 Aborted $ ./006-qemu__fatal__illegal_instruction__0421___00040026 # M68K uc_emu_start(…) hook_code(…) called qemu: fatal: Illegal instruction: 0421 @ 00040026 Aborted ```
31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
#include <unicorn/unicorn.h>
|
|
|
|
#define HARDWARE_ARCHITECTURE UC_ARCH_ARM
|
|
#define HARDWARE_MODE 16
|
|
#define MEMORY_STARTING_ADDRESS 1024
|
|
#define MEMORY_SIZE 1796096
|
|
#define MEMORY_PERMISSIONS 7
|
|
#define BINARY_CODE "\x20\xbf\xbf\xbf\xbf\xdd\x5d\x74\x5e\x66\x72\x10"
|
|
|
|
static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) {
|
|
printf("hook_code(…) called\n");
|
|
}
|
|
|
|
int main(int argc, char **argv, char **envp) {
|
|
uc_engine *uc;
|
|
if (uc_open(HARDWARE_ARCHITECTURE, HARDWARE_MODE, &uc)) {
|
|
printf("uc_open(…) failed\n");
|
|
return 1;
|
|
}
|
|
uc_mem_map(uc, MEMORY_STARTING_ADDRESS, MEMORY_SIZE, MEMORY_PERMISSIONS);
|
|
if (uc_mem_write(uc, MEMORY_STARTING_ADDRESS, BINARY_CODE, sizeof(BINARY_CODE) - 1)) {
|
|
printf("uc_mem_write(…) failed\n");
|
|
return 1;
|
|
}
|
|
uc_hook trace;
|
|
uc_hook_add(uc, &trace, UC_HOOK_CODE, hook_code, NULL, (uint64_t)MEMORY_STARTING_ADDRESS, (uint64_t)(MEMORY_STARTING_ADDRESS + 1));
|
|
printf("uc_emu_start(…)\n");
|
|
uc_emu_start(uc, MEMORY_STARTING_ADDRESS, MEMORY_STARTING_ADDRESS + sizeof(BINARY_CODE) - 1, 0, 0);
|
|
printf("done\n");
|
|
return 0;
|
|
}
|