Skip to content

Commit

Permalink
snapshot restore don't remove terminating regions (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippTakacs authored Jun 29, 2024
1 parent ddd6b7c commit 7d8b06b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 7d8b06b

Please sign in to comment.