Commit Graph

188 Commits

Author SHA1 Message Date
Rémi Bernon ba21d8fd54 ntdll: Mask block flags when computing HEAP_InsertFreeBlock size.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-20 12:24:38 +02:00
Rémi Bernon 61bc8abd1f ntdll: Use block size helpers in heap_reallocate.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-19 15:54:05 +02:00
Rémi Bernon eb931b8421 ntdll: Rename HEAP_FindFreeBlock size parameter.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-19 15:54:05 +02:00
Rémi Bernon b20f466628 ntdll: Rename local variables in heap_allocate.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-19 15:54:05 +02:00
Rémi Bernon a3acd63581 ntdll: Rename local variables in heap_reallocate.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-19 15:54:05 +02:00
Rémi Bernon 9325bfada7 ntdll: Use block helpers in subheap_notify_free_all.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-19 15:54:05 +02:00
Rémi Bernon 2815c117bc ntdll: Ignore back pointer when validating free block pattern.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-19 15:54:05 +02:00
Rémi Bernon 0c856978f1 ntdll: Update block unused_bytes in shrink_used_block.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-18 18:29:03 +02:00
Rémi Bernon 481ecc2d72 ntdll: Cleanup HEAP_ShrinkBlock and rename it to shrink_used_block.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-18 18:29:03 +02:00
Rémi Bernon c662992de4 ntdll: Create free block after updating the size in HEAP_ShrinkBlock.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-18 18:29:03 +02:00
Rémi Bernon 419e4730ba ntdll: Simplify the fallback case in heap_reallocate.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-18 18:29:03 +02:00
Rémi Bernon 3728b2b7d2 ntdll: Fail to allocate large blocks if heap isn't growable.
This tweaks the test sizes so that it passes on Wine too. The created
heap should be large enough to hold the requested alloc size, but the
allocation still fails.

Windows seems to have a specific lower threshold for large blocks with
non growable heaps, but it's probably not very useful to match it.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-18 18:28:59 +02:00
Rémi Bernon 69c75b2b1d ntdll: Increase heap large block min size for sizeof(void *) == 8.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-18 18:28:58 +02:00
Rémi Bernon 90f766fa76 ntdll: Use next_block helper in heap_reallocate.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-17 10:23:50 +02:00
Rémi Bernon 39697a2c00 ntdll: Check that ptr is in committed blocks in find_subheap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-17 10:23:50 +02:00
Rémi Bernon 8fc51f3c21 ntdll: Use next_block helper to iterate in heap_set_debug_flags.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-17 10:23:50 +02:00
Rémi Bernon 3001a2ff31 ntdll: Use block helpers to iterate blocks in heap_validate.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-17 10:23:50 +02:00
Rémi Bernon 06681774af ntdll: Remove unused QUIET/NOISY constants and parameters.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-17 10:23:50 +02:00
Rémi Bernon 279a6b1e48 ntdll: Simplify validate_free_block.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 20:46:49 +02:00
Rémi Bernon 12d611a03b ntdll: Simplify validate_used_block.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 20:46:49 +02:00
Rémi Bernon 6ab0200119 ntdll: Simplify validate_large_arena.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 20:46:49 +02:00
Rémi Bernon 585f52231d ntdll: Simplify validate_block_pointer.
And rename it to unsafe_block_from_ptr.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 20:46:49 +02:00
Rémi Bernon 13c836626d ntdll: Use heap_validate_ptr in validate_block_pointer.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-16 20:46:49 +02:00
Rémi Bernon 074177b8b0 ntdll: Rewrite RtlWalkHeap and enumerate large blocks.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 22:11:41 +02:00
Rémi Bernon 1196b46b29 ntdll: Check subheap sizes for consistency before using them.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 22:11:41 +02:00
Rémi Bernon 4d2dedb22b ntdll: Cleanup HEAP_FindSubHeap and rename it to find_subheap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 22:11:41 +02:00
Rémi Bernon accaf8f29a ntdll: Use block size helpers in heap_size.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 22:11:41 +02:00
Rémi Bernon adad22d1c2 ntdll: Introduce new block metadata access helpers.
And use them to cleanup HEAP_Dump, renaming it to heap_dump.

They will be used to cleanup and simplify the heap implementation. They
will make changing the block and subheap layouts easier later.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-13 22:11:41 +02:00
Rémi Bernon 1c873e8719 ntdll: Split RtlSizeHeap to a separate heap_size helper.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 12:50:18 +02:00
Rémi Bernon 8dd04c77cb ntdll: Split RtlReAllocateHeap to a separate heap_reallocate helper.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 12:50:18 +02:00
Rémi Bernon e2258ef559 ntdll: Split RtlFreeHeap to a separate heap_free helper.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 12:50:18 +02:00
Rémi Bernon dadb1fa72f ntdll: Split RtlAllocateHeap to a separate heap_allocate helper.
Factoring out locking and status handling.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 12:50:18 +02:00
Rémi Bernon 80a1155ca8 ntdll: Split HEAP_IsRealArena to heap_validate and heap_validate_ptr.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 12:50:18 +02:00
Rémi Bernon e264831804 ntdll: Lock heap critical section outside of HEAP_IsRealArena.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-12 12:50:18 +02:00
Rémi Bernon 00c64fcb01 ntdll: Ignore HEAP_(TAIL|FREE)_CHECKING_ENABLED flags in RtlCreateHeap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:33:28 +02:00
Rémi Bernon 1f490ec1a5 ntdll: Respect HEAP_NO_SERIALIZE flag in HeapLock / HeapUnlock.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:33:28 +02:00
Rémi Bernon 005ed5773c ntdll: Factor out heap serialization to heap_(lock|unlock) helpers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:33:28 +02:00
Rémi Bernon 94051290f6 ntdll: Stub RtlGetUserInfoHeap and RtlSetUser(Value|Flags)Heap.
Returning TRUE from RtlGetUserInfoHeap as tests in next patch suggest it
always does.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-25 12:26:58 +02:00
Rémi Bernon 43fe980818 ntdll: Fix main heap struct layout and flags members.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-19 21:41:49 +02:00
Rémi Bernon 9d34933f24 ntdll: Use a dedicated member for shared heap flag.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-19 21:41:46 +02:00
Alexandre Julliard 0bce76d830 ntdll: Move the loading of the global options to the Unix side.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-04 11:45:51 +02:00
Alexandre Julliard 58eceff167 ntdll: Don't use wine/server.h from the PE side.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-16 23:01:37 +01:00
Alexandre Julliard 584427fc89 server: Avoid redefining the DuplicateHandle() constants.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-16 21:20:47 +01:00
Rémi Bernon 255270373e ntdll: Raise debug exceptions when invalid heap is destroyed.
And when PEB->BeingDebugged is set to 1. Lords Of The Fallen anti-tamper
does this and only continues if a DBG_PRINTEXCEPTION_C is received.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-20 19:01:04 +01:00
Brendan Shanks fd80e0300c ntdll: Pad HEAP structure so 'flags' offset matches recent Windows.
Needed for Red Dead Redemption 2 to pass anti-debugger checks, it
accesses 'flags' and 'force_flags' at a fixed offset of the ProcessHeap.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49666
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-08-11 18:20:20 +02:00
Alexandre Julliard 704d0662be ntdll: Fix RtlSizeHeap() error value for 64-bit.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-07-15 16:33:02 +02:00
Alexandre Julliard 8a169390c9 ntdll: Build with msvcrt.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-06-30 12:25:08 +02:00
Alexandre Julliard 6b4de51027 ntdll: Don't use a custom alignment for large heap blocks.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 12:33:11 +02:00
Alexandre Julliard f5f1737456 ntdll: Store the pending free list in the main process heap.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 12:33:11 +02:00
Alexandre Julliard 33937344a0 ntdll: Fix heap validation when large heap blocks are present.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-03-12 21:18:18 +01:00