Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
wtdcode committed Oct 6, 2024
1 parent 851914c commit 0886e53
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/unicorn/unicorn.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef size_t uc_hook;
#define UNICORN_DEPRECATED __declspec(deprecated)
#else
#pragma message( \
"WARNING: You need to implement UNICORN_DEPRECATED for this compiler")
"WARNING: You need to implement UNICORN_DEPRECATED for this compiler")
#define UNICORN_DEPRECATED
#endif

Expand Down
10 changes: 5 additions & 5 deletions qemu/target/i386/unicorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ uc_err reg_read(void *_env, int mode, unsigned int regid, void *value,
case UC_X86_REG_XMM7: {
CHECK_REG_TYPE(uint64_t[2]);
uint64_t *dst = (uint64_t *)value;
const ZMMReg* const reg = &env->xmm_regs[regid - UC_X86_REG_XMM0];
const ZMMReg *const reg = &env->xmm_regs[regid - UC_X86_REG_XMM0];
dst[0] = reg->ZMM_Q(0);
dst[1] = reg->ZMM_Q(1);
return ret;
Expand All @@ -314,7 +314,7 @@ uc_err reg_read(void *_env, int mode, unsigned int regid, void *value,
case UC_X86_REG_YMM7: {
CHECK_REG_TYPE(uint64_t[4]);
uint64_t *dst = (uint64_t *)value;
const ZMMReg* const reg = &env->xmm_regs[regid - UC_X86_REG_YMM0];
const ZMMReg *const reg = &env->xmm_regs[regid - UC_X86_REG_YMM0];
dst[0] = reg->ZMM_Q(0);
dst[1] = reg->ZMM_Q(1);
dst[2] = reg->ZMM_Q(2);
Expand Down Expand Up @@ -978,7 +978,7 @@ uc_err reg_read(void *_env, int mode, unsigned int regid, void *value,
case UC_X86_REG_XMM31: {
CHECK_REG_TYPE(uint64_t[2]);
uint64_t *dst = (uint64_t *)value;
const ZMMReg* const reg = &env->xmm_regs[regid - UC_X86_REG_XMM0];
const ZMMReg *const reg = &env->xmm_regs[regid - UC_X86_REG_XMM0];
dst[0] = reg->ZMM_Q(0);
dst[1] = reg->ZMM_Q(1);
break;
Expand Down Expand Up @@ -1009,7 +1009,7 @@ uc_err reg_read(void *_env, int mode, unsigned int regid, void *value,
case UC_X86_REG_YMM31: {
CHECK_REG_TYPE(uint64_t[4]);
uint64_t *dst = (uint64_t *)value;
const ZMMReg* const reg = &env->xmm_regs[regid - UC_X86_REG_YMM0];
const ZMMReg *const reg = &env->xmm_regs[regid - UC_X86_REG_YMM0];
dst[0] = reg->ZMM_Q(0);
dst[1] = reg->ZMM_Q(1);
dst[2] = reg->ZMM_Q(2);
Expand Down Expand Up @@ -1050,7 +1050,7 @@ uc_err reg_read(void *_env, int mode, unsigned int regid, void *value,
case UC_X86_REG_ZMM31: {
CHECK_REG_TYPE(uint64_t[8]);
uint64_t *dst = (uint64_t *)value;
const ZMMReg* const reg = &env->xmm_regs[regid - UC_X86_REG_ZMM0];
const ZMMReg *const reg = &env->xmm_regs[regid - UC_X86_REG_ZMM0];
dst[0] = reg->ZMM_Q(0);
dst[1] = reg->ZMM_Q(1);
dst[2] = reg->ZMM_Q(2);
Expand Down
2 changes: 1 addition & 1 deletion qemu/target/tricore/unicorn.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ uc_err reg_write(void *_env, int mode, unsigned int regid, const void *value,
break;
}
}

CHECK_RET_DEPRECATE(ret, regid);
return ret;
}
Expand Down
19 changes: 9 additions & 10 deletions tests/unit/test_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -1799,34 +1799,33 @@ static void test_rex_x64(void)
}

static bool test_x86_ro_segfault_cb(uc_engine *uc, uc_mem_type type,
uint64_t address, int size,
uint64_t value, void *user_data)
uint64_t address, int size, uint64_t value,
void *user_data)
{
const char code[] =
"\xA1\x00\x10\x00\x00\xA1\x00\x10\x00\x00";
const char code[] = "\xA1\x00\x10\x00\x00\xA1\x00\x10\x00\x00";
OK(uc_mem_write(uc, address, code, sizeof(code) - 1));
return true;
}

static void test_x86_ro_segfault(void)
{
uc_engine* uc;
uc_engine *uc;
// mov eax, [0x1000]
// mov eax, [0x1000]
const char code[] =
"\xA1\x00\x10\x00\x00\xA1\x00\x10\x00\x00";
const char code[] = "\xA1\x00\x10\x00\x00\xA1\x00\x10\x00\x00";
uint32_t out;
uc_hook hh;

OK(uc_open(UC_ARCH_X86, UC_MODE_32, &uc));
OK(uc_mem_map(uc, 0, 0x1000, UC_PROT_ALL));
OK(uc_mem_write(uc, 0, code, sizeof(code) - 1));
OK(uc_mem_map(uc, 0x1000, 0x1000, UC_PROT_READ));

OK(uc_hook_add(uc, &hh, UC_HOOK_MEM_READ, test_x86_ro_segfault_cb, NULL, 1, 0));

OK(uc_hook_add(uc, &hh, UC_HOOK_MEM_READ, test_x86_ro_segfault_cb, NULL, 1,
0));
OK(uc_emu_start(uc, 0, sizeof(code) - 1, 0, 0));

OK(uc_reg_read(uc, UC_X86_REG_EAX, (void*)&out));
OK(uc_reg_read(uc, UC_X86_REG_EAX, (void *)&out));
TEST_CHECK(out == 0x001000a1);
OK(uc_close(uc));
}
Expand Down

0 comments on commit 0886e53

Please sign in to comment.