I have two memory regions I'm allocating with
0x1E0000 (Size: 0x39000, Reserve)
0x219000 (Size: 0x3000, Commit)
You cannot have two separate reservations within the same allocation boundary.
From the documentation for VirtualAlloc:
lpAddress [in, optional] The starting address of the region to allocate. If the memory is being reserved, the specified address is rounded down to the nearest multiple of the allocation granularity.
So your request to reserve memory starting at
0x219000 actually attempts to reserve memory starting at
0x210000, which is inside the existing allocation and hence illegal.
(It should also be noted that there is no guarantee that any particular region of virtual memory will be available for you to reserve; Windows may have already reserved it for some other purpose. Best practice is to always set the
lpAddress parameter to
NULL, allowing Windows to choose an address for you.)