Bionic Commando regressed (doesn't start) after the change introduced in commit 800fc4164f9d4ef4af23c2249b5c8ee92f48c673 ("ntdll: Reimplement fill_basic_memory_info() without using a callback."). Before that commit the space which is completely outside of reserved area were reported as allocated. Now it is reported as free. The game uses the following algorithm to determine its internal memory allocation size and does not expect the allocation to fail: ``` void *allocate() { MEMORY_BASIC_INFORMATION i; SYSTEM_INFO si; SIZE_T max_size = 0;
GetSystemInfo(&si); for (addr = si.lpMinimumApplicationAddress; VirtualQuery(addr, &i, sizeof(i)) == sizeof(i); addr += i.RegionSize) { if (i.State != MEM_FREE) continue; if (i.RegionSize > max_size) max_size = i.RegionSize; } max_size &= 0xfff00000; max_size = max(max_size, 0x10000000); return VirtualAlloc(NULL, max_size, MEM_RESERVE, PAGE_READWRITE); } ```
The game has Large address aware flag set on executable. So now this algorithm finds the size of 0x7fe00000 in the upper 2GB. This size cannot be allocated, first because an extra 64k requested in map_view() to perform proper alignment and next because the space is not free really, there are Unix side allocated areas which are out of our control.
It is probably not ideal to report the whole high 2GB as allocated, but so Far I didn't find an obviously better way to avoid such issues and fix the regression.