Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix snapshot restore #1968

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tests/unit/test_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static void test_snapshot(void)
uc_engine *uc;
uc_context *c0, *c1;
uint32_t mem;
uint8_t code_data;
// mov eax, [0x2020]; inc eax; mov [0x2020], eax
char code[] = "\xa1\x20\x20\x00\x00\x00\x00\x00\x00\xff\xc0\xa3\x20\x20\x00"
"\x00\x00\x00\x00\x00";
Expand All @@ -302,13 +303,15 @@ static void test_snapshot(void)
OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem)));
TEST_CHECK(mem == 2);
OK(uc_context_restore(uc, c1));
// TODO check mem

OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem)));
TEST_CHECK(mem == 1);
OK(uc_context_restore(uc, c0));
OK(uc_mem_read(uc, 0x2020, &mem, sizeof(mem)));
TEST_CHECK(mem == 0);
// TODO check mem

OK(uc_mem_read(uc, 0x1000, &code_data, sizeof(code_data)));
TEST_CHECK(code_data == 0xa1);

OK(uc_context_free(c0));
OK(uc_context_free(c1));
Expand Down
2 changes: 1 addition & 1 deletion uc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ static uc_err uc_restore_latest_snapshot(struct uc_struct *uc)
subregions_link, subregion_next)
{
uc->memory_filter_subregions(subregion, uc->snapshot_level);
if (QTAILQ_EMPTY(&subregion->subregions)) {
if (subregion->priority >= uc->snapshot_level || (!subregion->terminates && QTAILQ_EMPTY(&subregion->subregions))) {
uc->memory_unmap(uc, subregion);
}
}
Expand Down
Loading