From 020e7ca3f6af6becc16b6044ff08a3dfd4974dc4 Mon Sep 17 00:00:00 2001 From: 66hh <49398720+66hh@users.noreply.github.com> Date: Sun, 28 Dec 2025 19:14:42 +0800 Subject: [PATCH] Fix the base address alignment issue --- src/windows-emulator/syscalls/memory.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/windows-emulator/syscalls/memory.cpp b/src/windows-emulator/syscalls/memory.cpp index 0b8e45c3..52e95445 100644 --- a/src/windows-emulator/syscalls/memory.cpp +++ b/src/windows-emulator/syscalls/memory.cpp @@ -208,6 +208,16 @@ namespace syscalls { potential_base = c.win_emu.memory.find_free_allocation_base(static_cast(allocation_bytes)); } + else + { + // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntallocatevirtualmemory + // BaseAddress + // A pointer to a variable that will receive the base address of the allocated region of pages. If the + // initial value of BaseAddress is non-NULL, the region is allocated starting at the specified virtual + // address rounded down to the next host page size address boundary. If the initial value of BaseAddress + // is NULL, the operating system will determine where to allocate the region. + potential_base = page_align_up(potential_base); + } if (!potential_base) {