This repository was archived by the owner on Jan 9, 2025. It is now read-only.

Description
At the time of writing, the documentation for MEM_ADDRESS_REQUIREMENTS mentions the following regarding the valid values of its fields:
LowestStartingAddress
Specifies the lowest acceptable address. This address must be a multiple of the allocation granularity returned by GetSystemInfo, or a multiple of the large page size returned by GetLargePageMinimum if large pages are being requested. If this member is NULL, then there is no lower limit.
HighestEndingAddress
Specifies the highest acceptable address (inclusive). This address must not exceed lpMaximumApplicationAddress returned by GetSystemInfo. If this member is NULL, then there is no upper limit.
Alignment
Specifies power-of-2 alignment. Specifying 0 aligns the returned address on the system allocation granularity.
Based on my testing with VirtualAlloc2 on Windows 10.0.19045, this documentation is missing the following key information:
- If
HighestEndingAddress is not NULL, then it must be 1 less than a multiple of the allocation granularity.
- If
Alignment is nonzero, it must be larger or equal to the allocation granularity.
This information would have saved me quite a bit of time wondering why VirtualAlloc2 kept failing with ERROR_INVALID_PARAMETER when the values I was passing seemed perfectly valid.