diff --git a/include/uc_priv.h b/include/uc_priv.h index aeeac888..30992570 100644 --- a/include/uc_priv.h +++ b/include/uc_priv.h @@ -247,10 +247,7 @@ struct uc_struct { // Metadata stub for the variable-size cpu context used with uc_context_*() struct uc_context { - uc_arch arch; - uc_mode mode; size_t size; - bool used; char data[0]; }; diff --git a/uc.c b/uc.c index 7980e96f..9d224242 100644 --- a/uc.c +++ b/uc.c @@ -1181,9 +1181,6 @@ uc_err uc_context_alloc(uc_engine *uc, uc_context **context) *_context = malloc(size + sizeof(uc_context)); if (*_context) { (*_context)->size = size; - (*_context)->arch = uc->arch; - (*_context)->mode = uc->mode; - (*_context)->used = false; return UC_ERR_OK; } else { return UC_ERR_NOMEM; @@ -1201,23 +1198,14 @@ UNICORN_EXPORT uc_err uc_context_save(uc_engine *uc, uc_context *context) { struct uc_context *_context = context; - if (_context->arch != uc->arch || _context->mode != uc->mode) { - return UC_ERR_ARG; - } else { - memcpy(_context->data, uc->cpu->env_ptr, _context->size); - _context->used = true; - return UC_ERR_OK; - } + memcpy(_context->data, uc->cpu->env_ptr, _context->size); + return UC_ERR_OK; } UNICORN_EXPORT uc_err uc_context_restore(uc_engine *uc, uc_context *context) { struct uc_context *_context = context; - if (_context->arch != uc->arch || _context->mode != uc->mode || !_context->used) { - return UC_ERR_ARG; - } else { - memcpy(uc->cpu->env_ptr, _context->data, _context->size); - return UC_ERR_OK; - } + memcpy(uc->cpu->env_ptr, _context->data, _context->size); + return UC_ERR_OK; }