Format code

This commit is contained in:
2024-10-06 23:32:16 +08:00
parent 851914c8d0
commit 0886e53572
4 changed files with 16 additions and 17 deletions

View File

@@ -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

View File

@@ -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;
@@ -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);
@@ -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;
@@ -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);
@@ -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);

View File

@@ -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;
}

View File

@@ -1799,22 +1799,20 @@ 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;
@@ -1822,11 +1820,12 @@ static void test_x86_ro_segfault(void)
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));
}