Commit graph

6481 commits

Author SHA1 Message Date
Tim Clem f86a66b660 ntdll: Move SEH exception info logs back to the seh channel.
These were accidentally moved as part of the introduction of +unwind.

Signed-off-by: Tim Clem <tclem@codeweavers.com>
2022-06-13 22:56:21 +02:00
Rémi Bernon 4ca954ad0b ntdll: Remove heap pointer from SUBHEAP structure.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-13 19:57:31 +02:00
Rémi Bernon a6fcf059a7 ntdll: Use block_size and data_size in subheap structure.
Respectively describing allocated size vs commit size, relative to the
first subheap block, instead of size / commitSize.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-13 19:57:31 +02:00
Rémi Bernon 2ef69e4492 ntdll: Rename HEAP_GetPtr to unsafe_heap_from_handle.
And related heap variables to handle and heapPtr to heap.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-13 19:57:31 +02:00
Rémi Bernon fef774f953 ntdll: Consistently name heap handles and pointers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-13 19:57:31 +02:00
Rémi Bernon 4b05b2bcb7 ntdll: Rename HEAP to struct heap and remove typedef.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-13 19:57:31 +02:00
Daniel Lehman dd95979b0a ntdll/tests: Test if RtlFormatMessage modifies va_list on error.
Signed-off-by: Daniel Lehman <dlehman25@gmail.com>
2022-06-13 16:54:30 +02:00
Rémi Bernon bffeff3819 ntdll: Implement RtlGetUserValueHeap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-10 18:24:34 +02:00
Rémi Bernon ff864e5621 ntdll: Implement RtlSetUserValueHeap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-09 20:55:20 +02:00
Rémi Bernon 31df70a3de ntdll: Add block padding when HEAP_ADD_USER_INFO flag is set.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-09 20:55:20 +02:00
Alexandre Julliard 21a1c30972 ntdll: Move the user locale initialization to the Unix side.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-09 13:20:13 +02:00
Alexandre Julliard c5eb9cb25e ntdll: Share a few more locale functions with the Unix side.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-09 13:20:13 +02:00
Paul Gofman 7c597313f8 ntdll: Cancel asyncs when thread is terminated.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
2022-06-09 13:20:13 +02:00
Martin Storsjö 94dc5714ac ntdll/tests: Test returning an exception handler on arm/arm64.
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-09 13:20:13 +02:00
Martin Storsjö f1f7e096db ntdll/tests: Fix printing of incorrect exception handler data.
*(DWORD *)data is the value being compared; printing the 'data'
pointer itself provides little value here.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-09 13:20:13 +02:00
Martin Storsjö 94f7f52dac ntdll: Take ControlPcIsUnwound into account on arm64 too.
This is the same modification as the previous patch, applied on arm64.
It doesn't change the outcome for any of my tests though.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-07 15:27:21 +02:00
Martin Storsjö d007c91d46 ntdll: Use ControlPcIsUnwound for the RtlVirtualUnwind pc parameter in virtual_unwind.
Don't just use ControlPcIsUnwound for picking which RUNTIME_FUNCTION
to use, but also use it for adjusting the pc value that is passed
to RtlVirtualUnwind.

This fixes one testcase (that I had missed to build and run before),
where the pc points at the start of an epilogue (which would mean
that no handler is returned from RtlVirtualUnwind). By taking
ControlPcIsUnwound and adjusting the pc pointer, the unwind handler
is returned and executed.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-07 15:27:19 +02:00
Martin Storsjö 2d43653a2e ntdll: Add SEH unwind info in ARM assembly functions/trampolines.
Clang generates SEH unwind info on ARM in both MSVC and mingw mode
since Clang 15. The unwind info gets which gets enabled automatically
by building with a new enough compiler.

For functions/trampolines that are implemented in assembly, the unwind
information needs to be provided by hand - in particular for cases
where unwinding should be diverted.

Contrary to AArch64, Clang got SEH assembler directives directly from
the start when SEH was implemented (when the __SEH__ compiler define
gets set), so there's no need for compiler version checks (like for
AArch64 in include/wine/asm.h), but the default check for __SEH__
works fine for enabling the __ARM_SEH() macro.

Use a custom unwind opcode in the private opcode space for unwinding
to a specific CONTEXT instead of up to the caller. (Contrary to
AArch64, there's no specific unwind opcode for restoring a full
CONTEXT, but the unwind opcode space does have a couple
unallocated values marked as "available", which can be used
for vendor specific needs here.)

This fixes unwinding in ARM PE builds.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-06-07 15:27:18 +02:00
Alexandre Julliard 8d0b3b0898 ntdll/tests: Add tests for high Unicode planes.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-06-06 20:46:24 +02:00
Nikolay Sivov afdfb382d8 ntdll/tests: Add some tests for VM regions splitting.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2022-06-06 12:16:33 +02:00
Rémi Bernon a18ffeae21 ntdll: Use a more compact block layout.
With a separate block_flags field.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:54 +02:00
Rémi Bernon ff12dc1247 ntdll: Round free block size to block size alignment.
Block sizes are now always rounded to ALIGNMENT multiple, except for
the last free block in a region. This makes it consistent and will let
us use a more compact block layout.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:52 +02:00
Rémi Bernon deaf0891b0 ntdll: Improve block size rounding compatibility.
This also increase the default heap size to 2MiB (32bit) / 4MiB (64bit),
for the tests to pass.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:51 +02:00
Rémi Bernon adae12e9f3 ntdll: Remove unnecessary constants and typedefs.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:51 +02:00
Rémi Bernon 1b23283396 ntdll: Use a fixed block tail size.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:51 +02:00
Rémi Bernon 36d32eb8fa ntdll: Call mark_block_tail outside of initialize_block.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:51 +02:00
Rémi Bernon e3acf755e1 ntdll: Fix handling of free blocks in RtlWalkHeap.
The entry lpData pointer isn't a block but a pointer to the block data,
which has a different offset for free blocks and used blocks.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-06-02 17:24:49 +02:00
Rémi Bernon 526fc34a39 ntdll: Remove tail checking on large blocks.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-31 22:51:34 +02:00
Rémi Bernon 75b78517ce ntdll: Merge common resize case in heap_realloc.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-31 22:51:34 +02:00
Rémi Bernon 0b4266c7a4 ntdll: Call valgrind alloc notifications at the topmost level.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-31 22:51:34 +02:00
Rémi Bernon 3f52b3a741 ntdll: Correctly free pending pointer in RtlDestroyHeap.
It's allocated from the heap itself, should be freed even for the main
process heap, and before destroying the CS or notifying valgrind of used
block being freed.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-31 22:51:34 +02:00
Rémi Bernon e4e8cabf2f ntdll: Split valgrind memory access control to separate helpers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-31 22:51:33 +02:00
Rémi Bernon 75f2af284f ntdll: Fix handling of back pointer in heap_set_debug_flags.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-31 22:51:33 +02:00
Jinoh Kang e2412025b2 ntdll: Properly parse UDF instruction in ARM.
Today, the UDF instruction handler code assumes Thumb mode code, and
cannot recognise the UDF.W form or equivalent instructions in ARM mode
encoding.

Fix this by generalising the UDF instruction parser code.

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
2022-05-31 18:28:07 +02:00
Jinoh Kang c4c9a6951b ntdll: Implement __fastfail().
__fastfail() is used by the Visual C++ runtime and Windows system
libraries to signal that the in-process state is corrupted and
unrecoverable.

If __fastfail() is invoked, the NT kernel raises a second-chance
non-continuable exception STATUS_STACK_BUFFER_OVERRUN.  This quickly
terminates the process, bypassing all in-process exception handlers
(since they all rely on the potentially corrupted process state).

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
2022-05-31 18:28:06 +02:00
Jinoh Kang 7fbe8b8ebf ntdll/tests: Add tests for __fastfail().
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
2022-05-31 11:43:28 +02:00
Rémi Bernon 0044e52784 ntdll: Use struct entry directly for the free lists.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-27 15:26:01 +02:00
Rémi Bernon 2cc6f00a78 ntdll: Rename freeList variables to free_list.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-27 15:26:01 +02:00
Rémi Bernon 7964d64122 ntdll: Use a block member in the free list entry struct.
And use ARENA_FLAG_FREE|ARENA_FLAG_PREV_FREE flag combination to mark
and ignore free list links.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-27 15:26:00 +02:00
Rémi Bernon ea533f1869 ntdll: Use flag combination to mark free list headers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-27 15:26:00 +02:00
Rémi Bernon b57dca8826 ntdll: Rename block specific flag constants.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-27 15:26:00 +02:00
Brendan Shanks 93c5353ee7 ntdll: Set up 32-bit segments to support Wow64 on macOS 10.15+.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-26 19:12:36 +02:00
Brendan Shanks e8a5da7d86 ntdll: Store Wow64 FS selector in thread_data.
Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
2022-05-26 19:08:15 +02:00
Nikolay Sivov f97f5e1350 ntdll/tests: Use NtQueryInformationProcess() directly.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-25 18:25:43 +02:00
Alistair Leslie-Hughes bf86dfbcad ntdll: Fake success for ThreadPowerThrottlingState.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52956
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-25 18:25:43 +02:00
Rémi Bernon 4c3cc858f8 ntdll: Store the block size directly in block headers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-25 18:25:43 +02:00
Rémi Bernon 86b2ca98a4 ntdll: Prefer using block size rather than data size.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-25 18:25:43 +02:00
Rémi Bernon 7f9efcd416 ntdll: Add a first heap block member to the subheap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-25 18:25:43 +02:00
Rémi Bernon 74453b7c24 ntdll: Move min commit size to main heap struct.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-25 18:25:43 +02:00
Rémi Bernon 0f49c99a10 ntdll: Remove base member from SUBHEAP struct.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
2022-05-25 18:25:43 +02:00