Commit Graph

347 Commits

Author SHA1 Message Date
Huw Davies 6fdae1979b configure: Stop checking for poll.h and sys/poll.h - always use poll.h.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-31 17:56:54 +01:00
Alexandre Julliard ea2c743668 configure: Define _GNU_SOURCE in config.h.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-11 11:22:53 +02:00
Alexandre Julliard c954e5b9e6 server: Avoid using wine/port.h.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-07 18:03:11 +02:00
Alexandre Julliard d9ca9d455e server: Also set extended registers from the native context even in Wow64 mode.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-19 15:20:19 +02:00
Alexandre Julliard 6c478c304c server: Set YMM registers from the native context even in Wow64 mode.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-17 18:16:49 +02:00
Zebediah Figura bedd92ca06 server: Explicitly return whether a select request was immediately signaled.
This fixes a regression introduced by 97afac469f.

If we make a request on an asynchronous device handle, and the IRP handler
returns STATUS_PENDING, wait_async() will return STATUS_PENDING, as intended.
However, if the async object is signaled before the user has a chance to call
wait_async() [e.g. if get_next_device_request is called quickly enough], select
will return STATUS_PENDING immediately, which causes server_select() to think
the object is not signaled, and wait for a select reply forever.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51277
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51295
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-07-05 19:55:18 +02:00
Alexandre Julliard ad93413c71 server: Store session id in the process and return it at process init time.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-07-01 22:34:31 +02:00
Alexandre Julliard cc63b76833 server: Remove the no longer used pid/tid fields in the init_thread request.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-29 15:25:42 +02:00
Alexandre Julliard 8ac411ed6d server: Support both native and wow64 register contexts.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-27 11:42:32 +02:00
Alexandre Julliard f626349c0a server: Use separate handles for thread and context in get_thread_context.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-24 11:00:24 +02:00
Alexandre Julliard e1716530d9 server: Use a standard user APC also for timers.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-05-25 21:13:00 +02:00
Zebediah Figura 97afac469f ntdll: Avoid accessing the I/O status block in wait_async().
Steam uses WSASend() with completion ports, reusing OVERLAPPED structures as
soon as they are returned from GetQueuedCompletionStatus(). Since completion is
queued during the select request in wait_async(), the I/O status block can be
reused even before the call to NtDeviceIoControl exits.

This works fine with current Wine, because WSASend() doesn't access the I/O
status block after queuing completion. However, a patch that changes it to use
wait_async() like other async requests causes NtDeviceIoControlFile to
consistently return garbage status codes.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-05-24 11:32:28 +02:00
Alexandre Julliard d743c1e6c3 server: Send TEB and PEB in the process_init_done request.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-05-13 16:45:28 +02:00
Alexandre Julliard 384c042fea server: Don't return a handle for user apcs.
Reported by David Torok.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-30 19:32:30 +02:00
Alexandre Julliard f3d41cc789 server: Don't bother queuing APC_NONE apcs.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-30 19:32:30 +02:00
Paul Gofman 02e3327f06 ntdll: Implement NtGetNextThread().
Largely based on a patch by Nikolay Sivov for NtGetNextProcess().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-29 10:48:59 +02:00
Alexandre Julliard 339ed57643 server: Get rid of the CPU type and functions.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-27 10:42:04 +02:00
Alexandre Julliard 308bd35746 server: Store a machine ID instead of a CPU in the context structure.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-27 10:40:53 +02:00
Alexandre Julliard 8d50c34655 server: Check the supported machines list to validate an image mapping.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-27 10:35:16 +02:00
Alexandre Julliard 96865eb7e7 server: Return a list of supported machines instead of a CPU bitmask.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-23 15:17:54 +02:00
Alexandre Julliard 191fd47e38 server: Get rid of the remaining PowerPC support.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-23 12:41:45 +02:00
Rémi Bernon 769a2616ae server: Track desktop users per thread instead of per process.
As some thread may use a different desktop from their process.

This fixes the user32 win tests, which leaks a desktop that never gets
closed. The test_shell_window test creates a new desktop, which spawns
explorer.exe process, incrementing the desktop user count to 1, then
associates the desktop to a thread, which closes it on exit.

Never the user count is incremented to 2, and closing the thread desktop
doesn't either check whether the desktop process should be terminated.

Reversely, it is possible to create a desktop, associate it with a
thread /and/ a process, and this time the desktop process would be
terminated when the process exits, although the thread may still be
using it.

Tracking the users per thread is more robust and fixes the problem as
set_thread_desktop increments the desktop user count, and thread exit
decrements it.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-21 21:00:33 +02:00
Zebediah Figura 5df0f5f6fb ntdll: Use a kernel APC to call NtDuplicateObject() if DUPLICATE_CLOSE_SOURCE is used on another process.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-23 12:29:10 +01:00
Rafał Harabień 77481d36d3 ntdll: Allow getting/setting x86_64 context of x86 processes in wine64.
WoW64 process has two separate contexts:
- x86 context used most of the time (e.g. by application code)
- x86_64 context used by system when it quits x86 emulation and jumps to
  the kernel code
A notable exception are debug registers - their state is shared. Some
debuggers make use of that fact and sets/gets debug registers of x86
processes using x86_64 thread context.

Add support for setting and getting debug registers using x86_64
thread context. Getting other registers is allowed too and will return
values from x86 thread context.

Fixes hardware breakpoints in IDA 7.0 disassembler (x86_64 app) when
debugging x86 (32 bit) applications.

Signed-off-by: Rafał Harabień <rafalh92@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-09 21:33:43 +01:00
Dmitry Timoshkov 050dc49b38 server: Set error to STATUS_UNSUCCESSFUL when the server fails to queue APC for a thread.
I've left another case of returning STATUS_PROCESS_IS_TERMINATING since
that's not covered by the tests.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50704
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-03 21:54:44 +01:00
Zebediah Figura 44fc44880f server: Always set the async result when the APC object is destroyed.
This can happen if the async is terminated while there is no thread to queue
the APC to (as in the relevant test), or if the client dies before getting the
APC, or before transferring the APC results back to the server.

This also fixes a leak of async objects present since 61abc500f5. If a process
dies while accept asyncs are pending, the asyncs will be terminated but will
not find a valid thread to queue the APC to, and thus async_set_result() and
the completion callback are never called.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-25 08:54:41 +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
Alexandre Julliard d6ef9401b3 server: Use the object type information to implement access mapping.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-05 22:53:46 +01:00
Alexandre Julliard 4d646de90d server: Add generic mapping masks for all object types.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-05 15:38:22 +01:00
Alexandre Julliard c6f2aacb57 server: Add a type descriptor to all server objects.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-04 21:25:32 +01:00
Alexandre Julliard d514c64a8c server: Move the ldt_copy pointer to the init_first_thread request.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-02 10:26:20 +01:00
Alexandre Julliard 44699c324f server: Add a separate request to initialize the first thread of a process.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-02 10:22:56 +01:00
Alexandre Julliard 2b6426da65 server: Don't store the debug object in the debugger thread.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-01 16:48:09 +01:00
Alexandre Julliard 7999af8244 ntdll: Implement NtWaitForDebugEvent().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-02-01 16:48:09 +01:00
Alexandre Julliard c1a042cefb server: Rename debug_ctx to debug_obj.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-01-27 10:39:25 +01:00
Paul Gofman 419abd49a1 ntdll: Support AVX registers for other thread in Nt{Get|Set}ContextThread().
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-10-13 22:30:05 +02:00
Alexandre Julliard 2e51f9aae3 server: Add an object operation to retrieve an object name.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-22 16:55:08 +02:00
Zebediah Figura 1ff8fe20bf server: Remove no longer used snapshot requests.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-07-07 19:24:27 +02:00
Alexandre Julliard 64731a8e9f ntdll: Fix a few more thread information access rights.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-06-30 11:05:53 +02:00
Rémi Bernon e1e34cdc37 ntdll: Correctly implement ThreadHideFromDebugger.
At least, store the thread information, instead of pretending and
failing to correctly validate handles and access rights.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-06-30 11:05:53 +02:00
Changping Yu 59ce4e3eb8 kernel32: Adjust thread creation insertion order.
Signed-off-by: Changping Yu <dead.ash@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-06-29 21:07:43 +02:00
Sebastian Lackner 847b93c740 ntdll: Implement NtQueryInformationThread(ThreadTimes) using procfs.
Based on a patch by Ray Hinchliffe <ray@pobox.co.uk>.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=20230
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-06-29 19:51:46 +02:00
Alexandre Julliard 42bd67b576 ntdll: Don't call terminate_thread request if not necessary.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-05-29 16:17:32 +02:00
Jacek Caban 341068aa61 server: Delay setting system registers until suspending select is waken.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 22:05:42 +02:00
Jacek Caban e5a9c256ce server: Don't try to synchronize system registers on not initialized threads in get_thread_context request.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-28 22:05:36 +02:00
Jacek Caban c3fac6e36c server: Fix setting context flags in get_thread_context.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49011
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-27 11:30:30 +02:00
Jacek Caban c4dab9b76e server: Block by waiting on context handle in get_thread_context.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48052
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45546
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-22 16:47:41 +02:00
Jacek Caban aa0c4bb5e7 server: Don't wait for client thread to enter suspended state in set_thread_context.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-22 16:47:41 +02:00
Jacek Caban 2960a973d1 server: Create thread context object in stop_thread.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-22 16:47:41 +02:00
Jacek Caban 40e849ffa4 server: Make thread context a server object.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-04-22 16:47:41 +02:00