diff --git a/tests/unit/test_x86.c b/tests/unit/test_x86.c index ec1aa6f1..6daa1322 100644 --- a/tests/unit/test_x86.c +++ b/tests/unit/test_x86.c @@ -740,7 +740,7 @@ static void test_i386_reg_save(void **state) int32_t eax = 1; // Initialize emulator - uc_assert_success(uc_open(UC_ARCH_X86, UC_MODE_16, &uc)); + uc_assert_success(uc_open(UC_ARCH_X86, UC_MODE_32, &uc)); // map 8KB memory for this emulation uc_assert_success(uc_mem_map(uc, address, 8 * 1024, UC_PROT_ALL)); diff --git a/uc.c b/uc.c index d9a9282d..5694dd81 100644 --- a/uc.c +++ b/uc.c @@ -1184,12 +1184,12 @@ void *uc_save_regstate(uc_engine *uc, void *buffer) { buffer = malloc(sz); } - memcpy(buffer, uc->current_cpu->env_ptr, sz); + memcpy(buffer, first_cpu->env_ptr, sz); return buffer; } UNICORN_EXPORT void uc_restore_regstate(uc_engine *uc, void *buffer) { size_t sz = cpu_regs_size(uc->arch, uc->mode); - memcpy(uc->current_cpu->env_ptr, buffer, sz); + memcpy(first_cpu->env_ptr, buffer, sz); }