On Wed Jan 31 01:02:28 2024 +0000, Felix Münchhalfen wrote:
Oh! To my shame i must admit i tested this with wine-staging patches applied. There is one patch in there that modifies how views are handled. But anyways, i fixed the tests now, and i believe using VirtualFree in that way is more correct. I was just curious before, if it would be possible to split a big placeholder allocation into two, with a hole in the middle (this works with wine-staging, but not in dev). But when i think about it, i dont think that this is how it's supposed to work. You would rather have to start chewing off of a big placeholder from the start to the end. Please test again now. I tested with both pure wine and with staging patches. The tests work in both.
VirtualFree supports splitting placeholders in Wine, including in the middle of the view like in your test. The actual problem in your patch is that ```map_start = (void*)(((ULONG_PTR)allocation + system_info.dwPageSize) & ~(system_info.dwPageSize-1));``` truncates the address wtih & part, should be ```map_start = (void*)(((ULONG_PTR)allocation + system_info.dwPageSize) & ~((ULONG_PTR)system_info.dwPageSize-1));``` or you can actually drop that alignment at all, allocation + page_size is already aligned.
Why it works on Windows (and with some Wine-Staging patches) is because the memory is allocated top-down and you happen to get the address below 4gb so truncation doesn't matter.
I suggest to keep your test as it was with mapping in the middle of the initial view, it is probably a bit more interesting this way, fixing just the truncation part.