Microsoft Powerpoint expects that free spaces be at-least 64K bytes in size, so internally allocating at a higher granularity can cause trouble with this assertion. This patch does exhaust a bit more of the address space, which is a problem on 32-bit, so I'm curious about what you guys think we could do instead.
Signed-off-by: Derek Lesho dlesho@codeweavers.com --- dlls/ntdll/directory.c | 4 ++-- dlls/ntdll/heap.c | 4 ++-- dlls/ntdll/thread.c | 2 +- dlls/ntdll/virtual.c | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c index 7554934701..f04348a40f 100644 --- a/dlls/ntdll/directory.c +++ b/dlls/ntdll/directory.c @@ -1743,14 +1743,14 @@ static KERNEL_DIRENT *start_vfat_ioctl( int fd ) SIZE_T size = 2 * sizeof(*de) + page_size; void *addr = NULL;
- if (virtual_alloc_aligned( &addr, 0, &size, MEM_RESERVE, PAGE_READWRITE, 1 )) + if (virtual_alloc_aligned( &addr, 0, &size, MEM_RESERVE, PAGE_READWRITE, 0 )) return NULL; /* commit only the size needed for the dir entries */ /* this leaves an extra unaccessible page, which should make the kernel */ /* fail with -EFAULT before it stomps all over our memory */ de = addr; size = 2 * sizeof(*de); - virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT, PAGE_READWRITE, 1 ); + virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT, PAGE_READWRITE, 0 ); }
/* set d_reclen to 65535 to work around an AFS kernel bug */ diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index e8ac1ffa7a..8bbf4f2262 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -726,7 +726,7 @@ static void *allocate_large_block( HEAP *heap, DWORD flags, SIZE_T size ) LPVOID address = NULL;
if (block_size < size) return NULL; /* overflow */ - if (virtual_alloc_aligned( &address, 0, &block_size, MEM_COMMIT, get_protection_type( flags ), 5 )) + if (virtual_alloc_aligned( &address, 0, &block_size, MEM_COMMIT, get_protection_type( flags ), 0 )) { WARN("Could not allocate block for %08lx bytes\n", size ); return NULL; @@ -1520,7 +1520,7 @@ void heap_set_debug_flags( HANDLE handle ) void *ptr = NULL; SIZE_T size = MAX_FREE_PENDING * sizeof(*heap->pending_free);
- if (!virtual_alloc_aligned( &ptr, 0, &size, MEM_COMMIT, PAGE_READWRITE, 4 )) + if (!virtual_alloc_aligned( &ptr, 0, &size, MEM_COMMIT, PAGE_READWRITE, 0 )) { heap->pending_free = ptr; heap->pending_pos = 0; diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index be54f89082..aaa19ee69e 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -250,7 +250,7 @@ void thread_init(void)
addr = NULL; size = sizeof(*peb); - virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE, 1 ); + virtual_alloc_aligned( &addr, 0, &size, MEM_COMMIT | MEM_TOP_DOWN, PAGE_READWRITE, 0 ); peb = addr;
peb->FastPebLock = &peb_lock; diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c index d15b49f6fd..27b7e3fab7 100644 --- a/dlls/ntdll/virtual.c +++ b/dlls/ntdll/virtual.c @@ -411,8 +411,7 @@ static struct file_view *VIRTUAL_FindView( const void *addr, size_t size ) */ static inline UINT_PTR get_mask( ULONG alignment ) { - if (!alignment) return 0xffff; /* allocations are aligned to 64K by default */ - if (alignment < page_shift) alignment = page_shift; + if (alignment <= 16) return 0xffff; /* allocations must be aligned to 64K */ if (alignment > 21) return 0; return (1 << alignment) - 1; }
On Oct 28, 2019, at 1:48 PM, Derek Lesho dlesho@codeweavers.com wrote:
Microsoft Powerpoint expects that free spaces be at-least 64K bytes in size, so internally allocating at a higher granularity can cause trouble with this assertion. This patch does exhaust a bit more of the address space, which is a problem on 32-bit, so I'm curious about what you guys think we could do instead.
We could maybe recover some of the wasted space by having Wine internal allocations sub-allocate from the excess. That would probably be a pain to track, though.
As I understand it, Powerpoint is probing for free space by attempting memory access and looking for access violations. We could maybe turn the excess into a Wine reserved area but make it readable. That way, it would be free for subsequent allocations but would look reserved to Powerpoint.
-Ken