Merge pull request #1919 from PhilippTakacs/fix_cow

fix cow when using uc_mem_write
This commit is contained in:
lazymio 2024-01-11 14:52:21 +08:00 committed by GitHub
commit 5e39cc602a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -98,6 +98,9 @@ MemoryRegion *memory_cow(struct uc_struct *uc, MemoryRegion *current, hwaddr beg
hwaddr current_offset;
MemoryRegion *ram = g_new(MemoryRegion, 1);
assert((begin & ~TARGET_PAGE_MASK) == 0);
assert((size & ~TARGET_PAGE_MASK) == 0);
if (current->container == uc->system_memory) {
make_contained(uc, current);
}

5
uc.c
View File

@ -788,7 +788,10 @@ uc_err uc_mem_write(uc_engine *uc, uint64_t address, const void *_bytes,
len = memory_region_len(uc, mr, address, size - count);
if (uc->snapshot_level && uc->snapshot_level > mr->priority) {
mr = uc->memory_cow(uc, mr, address, len);
mr = uc->memory_cow(uc, mr, address & ~uc->target_page_align,
(len + (address & uc->target_page_align) +
uc->target_page_align) &
~uc->target_page_align);
if (!mr) {
return UC_ERR_NOMEM;
}