rename uc_regstate_restore to uc_context_restore, uc_context_save to uc_context_save
This commit is contained in:
parent
b7cdbe7a88
commit
73577cbcd1
@ -333,7 +333,7 @@ def test_i386_reg_save():
|
||||
mu.emu_start(address, address+1)
|
||||
|
||||
print(">>> save the register state")
|
||||
saved_regs = mu.regstate_save()
|
||||
saved_regs = mu.context_save()
|
||||
|
||||
print(">>> execute 'inc eax'")
|
||||
mu.emu_start(address, address+1)
|
||||
@ -342,7 +342,7 @@ def test_i386_reg_save():
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 3
|
||||
|
||||
print(">>> restore the register state")
|
||||
mu.regstate_restore(saved_regs)
|
||||
mu.context_restore(saved_regs)
|
||||
|
||||
print(">>> assert eax == 2")
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 2
|
||||
@ -354,7 +354,7 @@ def test_i386_reg_save():
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 3
|
||||
|
||||
print(">>> restore the register state")
|
||||
mu.regstate_restore(saved_regs)
|
||||
mu.context_restore(saved_regs)
|
||||
|
||||
print(">>> assert eax == 2")
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 2
|
||||
|
@ -100,8 +100,8 @@ _setup_prototype(_uc, "uc_mem_map_ptr", ucerr, uc_engine, ctypes.c_uint64, ctype
|
||||
_setup_prototype(_uc, "uc_mem_unmap", ucerr, uc_engine, ctypes.c_uint64, ctypes.c_size_t)
|
||||
_setup_prototype(_uc, "uc_mem_protect", ucerr, uc_engine, ctypes.c_uint64, ctypes.c_size_t, ctypes.c_uint32)
|
||||
_setup_prototype(_uc, "uc_query", ucerr, uc_engine, ctypes.c_uint32, ctypes.POINTER(ctypes.c_size_t))
|
||||
_setup_prototype(_uc, "uc_regstate_save", ctypes.c_voidp, uc_engine, ctypes.c_voidp)
|
||||
_setup_prototype(_uc, "uc_regstate_restore", None, uc_engine, ctypes.c_voidp)
|
||||
_setup_prototype(_uc, "uc_context_save", ctypes.c_voidp, uc_engine, ctypes.c_voidp)
|
||||
_setup_prototype(_uc, "uc_context_restore", None, uc_engine, ctypes.c_voidp)
|
||||
_setup_prototype(_uc, "free", None, ctypes.c_voidp)
|
||||
|
||||
# uc_hook_add is special due to variable number of arguments
|
||||
@ -443,20 +443,20 @@ class Uc(object):
|
||||
raise UcError(status)
|
||||
h = 0
|
||||
|
||||
def regstate_save(self, store=None):
|
||||
def context_save(self, store=None):
|
||||
if store is None:
|
||||
ptr = ctypes.cast(0, ctypes.c_voidp)
|
||||
return _ActivePointer(_uc.uc_regstate_save(self._uch, ptr))
|
||||
return _ActivePointer(_uc.uc_context_save(self._uch, ptr))
|
||||
elif type(store) is _ActivePointer:
|
||||
_uc.uc_regstate_save(self._uch, store.pointer)
|
||||
_uc.uc_context_save(self._uch, store.pointer)
|
||||
return store
|
||||
else:
|
||||
raise TypeError("Bad register store %s" % repr(store))
|
||||
|
||||
def regstate_restore(self, store):
|
||||
def context_restore(self, store):
|
||||
if type(store) is not _ActivePointer:
|
||||
raise TYpeError("Bad register store %s" % repr(store))
|
||||
_uc.uc_regstate_restore(self._uch, store.pointer)
|
||||
_uc.uc_context_restore(self._uch, store.pointer)
|
||||
|
||||
class _ActivePointer(object):
|
||||
def __init__(self, pointer):
|
||||
|
@ -625,33 +625,33 @@ UNICORN_EXPORT
|
||||
uc_err uc_mem_regions(uc_engine *uc, uc_mem_region **regions, uint32_t *count);
|
||||
|
||||
/*
|
||||
Save a copy of the current state's registers
|
||||
Save a copy of the internal CPU context.
|
||||
This API should be used to efficiently make or update a saved copy of the
|
||||
state's registers.
|
||||
internal CPU state.
|
||||
|
||||
@uc: handle returned by uc_open()
|
||||
@buffer: pointer to the region to store the registers in. The first call to
|
||||
@buffer: pointer to the region to store the context in. The first call to
|
||||
this function should pass NULL in this parameter, so a region of the
|
||||
appropriate size for the current architecure can be allocated. Further calls
|
||||
appropriate size for the current architecture can be allocated. Further calls
|
||||
to this function may pass in the return value of previous calls.
|
||||
|
||||
@return a pointer to the region the registers were saved in. If buffer was
|
||||
@return a pointer to the region the contexxt was saved in. If buffer was
|
||||
NULL, this is a newly allocated region, otherwise it is the same as buffer.
|
||||
Any allocation performed by this function must be freed by the user.
|
||||
*/
|
||||
UNICORN_EXPORT
|
||||
void *uc_regstate_save(uc_engine *uc, void *buffer);
|
||||
void *uc_context_save(uc_engine *uc, void *buffer);
|
||||
|
||||
/*
|
||||
Restore the current state's registers from a saved copy
|
||||
This API should be used to roll the CPU register state back to a previous
|
||||
state saved by uc_regstate_save().
|
||||
Restore the current CPU context from a saved copy.
|
||||
This API should be used to roll the CPU context back to a previous
|
||||
state saved by uc_context_save().
|
||||
|
||||
@uc: handle returned by uc_open()
|
||||
@buffer: pointer returned by uc_regstate_save()
|
||||
@buffer: pointer returned by uc_context_save()
|
||||
*/
|
||||
UNICORN_EXPORT
|
||||
void uc_regstate_restore(uc_engine *uc, void *buffer);
|
||||
void uc_context_restore(uc_engine *uc, void *buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ static void test_i386_reg_save(void **state)
|
||||
uc_assert_success(uc_emu_start(uc, address, address+1, 0, 0));
|
||||
|
||||
// save the state
|
||||
void *saved_regs = uc_regstate_save(uc, NULL);
|
||||
void *saved_regs = uc_context_save(uc, NULL);
|
||||
|
||||
// step one instruction
|
||||
uc_assert_success(uc_emu_start(uc, address, address+1, 0, 0));
|
||||
@ -775,7 +775,7 @@ static void test_i386_reg_save(void **state)
|
||||
assert_int_equal(eax, 3);
|
||||
|
||||
// restore the state
|
||||
uc_regstate_restore(uc, saved_regs);
|
||||
uc_context_restore(uc, saved_regs);
|
||||
|
||||
// check that eax == 2
|
||||
uc_assert_success(uc_reg_read(uc, UC_X86_REG_EAX, &eax));
|
||||
@ -789,7 +789,7 @@ static void test_i386_reg_save(void **state)
|
||||
assert_int_equal(eax, 3);
|
||||
|
||||
// restore the state
|
||||
uc_regstate_restore(uc, saved_regs);
|
||||
uc_context_restore(uc, saved_regs);
|
||||
|
||||
// check that eax == 2
|
||||
uc_assert_success(uc_reg_read(uc, UC_X86_REG_EAX, &eax));
|
||||
|
4
uc.c
4
uc.c
@ -1174,7 +1174,7 @@ size_t cpu_regs_size(uc_arch arch, uc_mode mode)
|
||||
}
|
||||
|
||||
UNICORN_EXPORT
|
||||
void *uc_regstate_save(uc_engine *uc, void *buffer)
|
||||
void *uc_context_save(uc_engine *uc, void *buffer)
|
||||
{
|
||||
size_t sz = cpu_regs_size(uc->arch, uc->mode);
|
||||
if (!buffer) {
|
||||
@ -1186,7 +1186,7 @@ void *uc_regstate_save(uc_engine *uc, void *buffer)
|
||||
}
|
||||
|
||||
UNICORN_EXPORT
|
||||
void uc_regstate_restore(uc_engine *uc, void *buffer)
|
||||
void uc_context_restore(uc_engine *uc, void *buffer)
|
||||
{
|
||||
size_t sz = cpu_regs_size(uc->arch, uc->mode);
|
||||
memcpy(first_cpu->env_ptr, buffer, sz);
|
||||
|
Loading…
Reference in New Issue
Block a user