On Sat Mar 22 22:32:59 2025 +0000, Robert Lippmann wrote:
> These are additional power related functions that were defined in
> Windows Vista (the current code is like 20 years old).
Oops, I just took the output of winedump and didn't change the numbers to @'s.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7644#note_98761
On Sat Mar 22 22:37:26 2025 +0000, Nikolay Sivov wrote:
> Do you have an application that depends on those functions returning anything?
SteamVR's vrmonitor.exe tries to change the power profile and crashes with an access violation.
Valve has been bugged about this for years, since they really shouldn't be doing it. So, I figure it will never be fixed by them.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7644#note_98760
On Sat Mar 22 22:35:07 2025 +0000, Nikolay Sivov wrote:
> Hi, @rlippmann. This needs some basic cleanup first - fixup commits
> should be merged with main commits so that MR has a clean list of
> wellformed changes. Note that you don't need to create a new MR every
> time you want to change something. Just force push to the same branch.
I've been trying to. Unfortunately the pipeline build fails every time saying it couldn't get my credentials even though I've set git global username and email address.
I've been trying to figure out why that happens, hence the multiple (closed) merge requests.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7644#note_98759
On Sat Mar 22 22:15:29 2025 +0000, Nikolay Sivov wrote:
> Why do you need this?
These are additional power related functions that were defined in Windows Vista (the current code is like 20 years old).
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7644#note_98758
On Sat Mar 22 22:15:29 2025 +0000, Nikolay Sivov wrote:
> You probably don't need a new file for this.
Well, according to the SDK, the header is now powersetting.h, not powrprof.h, which is why I created the new file.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7644#note_98757
This fixes a real problem and improves behavior at the same time.
- Fixes: hanging when trying to run Wine built with epoll_pwait2 headers available
but epoll_pwait2 is missing in the run-time kernel (i.e. build 5.11->run 5.10)
- Improvement: bring the improved timeout resolution to Wine builds
which didn't have epoll_pwait2 at compile time, if the run-time kernel supports it
(i.e. build 5.10->run 6.14)
This last point is especially important in my opinion, as it applies to official Proton builds.
Proton is (currently) built in Debian 11 with kernel 5.10, but SteamOS is a moving target with
a much newer kernel version being used to run these Wine builds.
These builds use the lower resolution timeouts if epoll_pwait2 is only checked for at compile-time,
when it can cheaply and easily be done at run-time instead.
Fixes: 87ca5db40e2c1b37423bdc25101a5c5e39e67e6f
An alternative to !7640 that kills two birds with one stone.
--
v4: server: Fall back to epoll_wait if epoll_pwait2 isn't available at run-time.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7642
This fixes a real problem and improves behavior at the same time.
- Fixes: hanging when trying to run Wine built with epoll_pwait2 headers available
but epoll_pwait2 is missing in the run-time kernel (i.e. build 5.11->run 5.10)
- Improvement: bring the improved timeout resolution to Wine builds
which didn't have epoll_pwait2 at compile time, if the run-time kernel supports it
(i.e. build 5.10->run 6.14)
This last point is especially important in my opinion, as it applies to official Proton builds.
Proton is (currently) built in Debian 11 with kernel 5.10, but SteamOS is a moving target with
a much newer kernel version being used to run these Wine builds.
These builds use the lower resolution timeouts if epoll_pwait2 is only checked for at compile-time,
when it can cheaply and easily be done at run-time instead.
Fixes: 87ca5db40e2c1b37423bdc25101a5c5e39e67e6f
An alternative to !7640 that kills two birds with one stone.
--
v3: server: Fall back to epoll_wait if epoll_pwait2 isn't available at run-time.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7642
This fixes a real problem and improves behavior at the same time.
- Fixes: hanging when trying to run Wine built with epoll_pwait2 headers available
but epoll_pwait2 is missing in the run-time kernel (i.e. build 5.11->run 5.10)
- Improvement: bring the improved timeout resolution to Wine builds
which didn't have epoll_pwait2 at compile time, if the run-time kernel supports it
(i.e. build 5.10->run 6.14)
This last point is especially important in my opinion, as it applies to official Proton builds.
Proton is (currently) built in Debian 11 with kernel 5.10, but SteamOS is a moving target with
a much newer kernel version being used to run these Wine builds.
These builds use the lower resolution timeouts if epoll_pwait2 is only checked for at compile-time,
when it can cheaply and easily be done at run-time instead.
Fixes: 87ca5db40e2c1b37423bdc25101a5c5e39e67e6f
An alternative to !7640 that kills two birds with one stone.
--
v2: server: Fall back to epoll_wait if epoll_pwait2 isn't available at run-time.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7642
This fixes a real problem and improves behavior at the same time.
- Fixes: hanging when trying to run Wine built with epoll_pwait2 headers available
but epoll_pwait2 is missing in the run-time kernel (i.e. build 5.11->run 5.10)
- Improvement: bring the improved timeout resolution to Wine builds
which didn't have epoll_pwait2 at compile time, if the run-time kernel supports it
(i.e. build 5.10->run 6.14)
This last point is especially important in my opinion, as it applies to official Proton builds.
Proton is (currently) built in Debian 11 with kernel 5.10, but SteamOS is a moving target with
a much newer kernel version being used to run these Wine builds.
These builds use the lower resolution timeouts if epoll_pwait2 is only checked for at compile-time,
when it can cheaply and easily be done at run-time instead.
Fixes: 87ca5db40e2c1b37423bdc25101a5c5e39e67e6f
An alternative to !7640 that kills two birds with one stone.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7642
Introduce infrastructure necessary to support receiving, sending and replying (to) Bluetooth authentication/pairing requests:
- During startup, the Bluetooth driver now creates a "pairing agent" and registers it with BlueZ. The pairing agent is a DBus object implementing the `org.bluez.Agent1` interface (documented [here](https://github.com/bluez/bluez/blob/master/doc/org.bluez.Agent.rst)), which receives authentication requests from BlueZ. The pairing agent then forwards the request data to the PE driver, in form of a `WINEBLUETOOTH_EVENT_AUTH_EVENT` event. The agent is unregistered during driver shutdown.
- Right now, the agent only supports Numeric Comparison pairing requests.
- Create a new auxiliary device, `\??\WINEBTHAUTH` during driver startup. This device handles authentication functionality that is independent of radio PDOs on the system, which allows the userspace APIs to not track individual Bluetooth radio objects to implement authentication. `WINEBTHAUTH` right now serves two purposes:
- Serve as the device object for which `GUID_WINEBTH_AUTHENTICATION_REQUEST` PnP events are broadcasted. This event is sent whenever the Bluetooth event loop in (`bluetooth_event_loop_thread_proc`) receives `WINEBLUETOOTH_EVENT_AUTH_EVENT`. The event's buffer contains a `struct winebth_authentication_request` value, which contains data relevant to the incoming auth request.
- Handle the `IOCTL_WINEBTH_AUTH_REGISTER` IOCTL. This simply calls the [`RequestDefaultAgent` BlueZ method](https://github.com/bluez/bluez/blob/master/doc/org.bluez.AgentManag… right now, which asks BlueZ to send all incoming Bluetooth authentication requests to Wine's pairing agent (described above). This is not always strictly necessary, but is useful if there already is a default pairing agent set.
- `WINEBTHAUTH` will also ultimately be in charge of responding to authentication requests, which I'll be adding in the next-ish MR(s).
- Implement `BluetoothRegisterForAuthenticationEx` and `BluetoothUnregisterAuthentication`. Registration is done by invoking `IOCTL_WINEBTH_AUTH_REGISTER`, and then listening for `GUID_WINEBTH_AUTHENTICATION_REQUEST` events on a `HANDLE` to `\??\WINEBTHAUTH` using the newly added `CM_Register_Notifications`.
To keep the MR from getting any larger, I have not included support for `BluetoothSendAuthenticationResponseEx`. That will likely be introduced in the future.
--
v4: bluetoothapis/tests: Add tests for BluetoothRegisterForAuthenticationEx and BluetoothUnregisterAuthentication.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7630
Introduce infrastructure necessary to support receiving, sending and replying (to) Bluetooth authentication/pairing requests:
- During startup, the Bluetooth driver now creates a "pairing agent" and registers it with BlueZ. The pairing agent is a DBus object implementing the `org.bluez.Agent1` interface (documented [here](https://github.com/bluez/bluez/blob/master/doc/org.bluez.Agent.rst)), which receives authentication requests from BlueZ. The pairing agent then forwards the request data to the PE driver, in form of a `WINEBLUETOOTH_EVENT_AUTH_EVENT` event. The agent is unregistered during driver shutdown.
- Right now, the agent only supports Numeric Comparison pairing requests.
- Create a new auxiliary device, `\??\WINEBTHAUTH` during driver startup. This device handles authentication functionality that is independent of radio PDOs on the system, which allows the userspace APIs to not track individual Bluetooth radio objects to implement authentication. `WINEBTHAUTH` right now serves two purposes:
- Serve as the device object for which `GUID_WINEBTH_AUTHENTICATION_REQUEST` PnP events are broadcasted. This event is sent whenever the Bluetooth event loop in (`bluetooth_event_loop_thread_proc`) receives `WINEBLUETOOTH_EVENT_AUTH_EVENT`. The event's buffer contains a `struct winebth_authentication_request` value, which contains data relevant to the incoming auth request.
- Handle the `IOCTL_WINEBTH_AUTH_REGISTER` IOCTL. This simply calls the [`RequestDefaultAgent` BlueZ method](https://github.com/bluez/bluez/blob/master/doc/org.bluez.AgentManag… right now, which asks BlueZ to send all incoming Bluetooth authentication requests to Wine's pairing agent (described above). This is not always strictly necessary, but is useful if there already is a default pairing agent set.
- `WINEBTHAUTH` will also ultimately be in charge of responding to authentication requests, which I'll be adding in the next-ish MR(s).
- Implement `BluetoothRegisterForAuthenticationEx` and `BluetoothUnregisterAuthentication`. Registration is done by invoking `IOCTL_WINEBTH_AUTH_REGISTER`, and then listening for `GUID_WINEBTH_AUTHENTICATION_REQUEST` events on a `HANDLE` to `\??\WINEBTHAUTH` using the newly added `CM_Register_Notifications`.
To keep the MR from getting any larger, I have not included support for `BluetoothSendAuthenticationResponseEx`. That will likely be introduced in the future.
--
v3: bluetoothapis/tests: Add tests for BluetoothRegisterForAuthenticationEx and BluetoothUnregisterAuthentication.
bluetoothapis: Implement BluetoothRegisterForAuthenticationEx and BluetoothUnregisterForAuthentication.
winebth.sys: Implement IOCTL_WINEBTH_AUTH_REGISTER.
winebth.sys: Broadcast a BLUETOOTH_AUTHENTICATION_REQUEST PnP event on receiving a RequestConfirmation request from BlueZ.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7630
Related Wine issue: https://bugs.winehq.org/show_bug.cgi?id=52714
I'm starting work on updating/extending Linux force feedback API and one of my goals is to expose the number and an array that contains the device's ffb-enabled axes. As I'm mainly working with USB PID driver, I already have a POC of obtaining this data.
What prompted this is that currently Wine always creates virtual joysticks with two PID ffb axes. This causes issues with [Richard Burns Rally](https://github.com/ValveSoftware/Proton/issues/6702#issuecomment-267…, as this game incorrectly initializes a `CONSTANT_FORCE` effect with all the FFB axes that contain `DIDOI_FFACTUATOR` flag and then trying to update `cAxes` and `rgdwAxes` values which leads to `DIERR_INVALIDPARAM`.
Now, this flag is set by wine while enumerating virtual device's axes and while `(axis index < FFB axes)`, flag is applied. This means, that every device which has FFB functionality and at least two axes, will report FFB on `X`, `Y`.
While updated API would mean a lot of steering wheels would correctly report only 1 axis, a lot of USB PID wheels still include `X` and `Y` in their `AXES_ENABLE` and `DIRECTION` usages. This, again, would lead to broken FFB (in affected games).
On Windows, there's a possibility of overwriting some joystick capabilities with registry entries, which ends up removing `DIDOI_FFACTUATOR` flag from a selected axis. This doesn't work in Wine.
This MR allows Wine to add an arbitrary number (up to `PID_AXES_MAX`) of axes to the PID descriptor, based on the value of Haptic Axes from SDL or from Linux FF api in the future (I'm working on it). Additionally, to work around RBR and other games with similar, wrong FFB handling, I introduced a [hint](https://github.com/libsdl-org/SDL/issues/12341) to SDL that allows a dynamic overwrite of the number of haptic axes. For the Linux API, I'll figure out a nice way to override when the number of axes will be exposed.
With these changes, I was able to successfully get force feedback on my Moza Racing R9 with all axes usable. With additional traces in the dinput code, I confirmed that with one axis defined in the PID descriptor, the game created a constant force effect with just one axis and `cAxes = 1`.
--
v9: Try fixing tests
https://gitlab.winehq.org/wine/wine/-/merge_requests/7422
Related Wine issue: https://bugs.winehq.org/show_bug.cgi?id=52714
I'm starting work on updating/extending Linux force feedback API and one of my goals is to expose the number and an array that contains the device's ffb-enabled axes. As I'm mainly working with USB PID driver, I already have a POC of obtaining this data.
What prompted this is that currently Wine always creates virtual joysticks with two PID ffb axes. This causes issues with [Richard Burns Rally](https://github.com/ValveSoftware/Proton/issues/6702#issuecomment-267…, as this game incorrectly initializes a `CONSTANT_FORCE` effect with all the FFB axes that contain `DIDOI_FFACTUATOR` flag and then trying to update `cAxes` and `rgdwAxes` values which leads to `DIERR_INVALIDPARAM`.
Now, this flag is set by wine while enumerating virtual device's axes and while `(axis index < FFB axes)`, flag is applied. This means, that every device which has FFB functionality and at least two axes, will report FFB on `X`, `Y`.
While updated API would mean a lot of steering wheels would correctly report only 1 axis, a lot of USB PID wheels still include `X` and `Y` in their `AXES_ENABLE` and `DIRECTION` usages. This, again, would lead to broken FFB (in affected games).
On Windows, there's a possibility of overwriting some joystick capabilities with registry entries, which ends up removing `DIDOI_FFACTUATOR` flag from a selected axis. This doesn't work in Wine.
This MR allows Wine to add an arbitrary number (up to `PID_AXES_MAX`) of axes to the PID descriptor, based on the value of Haptic Axes from SDL or from Linux FF api in the future (I'm working on it). Additionally, to work around RBR and other games with similar, wrong FFB handling, I introduced a [hint](https://github.com/libsdl-org/SDL/issues/12341) to SDL that allows a dynamic overwrite of the number of haptic axes. For the Linux API, I'll figure out a nice way to override when the number of axes will be exposed.
With these changes, I was able to successfully get force feedback on my Moza Racing R9 with all axes usable. With additional traces in the dinput code, I confirmed that with one axis defined in the PID descriptor, the game created a constant force effect with just one axis and `cAxes = 1`.
--
v8: dinput/tests: Add tests for 6-axis ff joystick
winebus: Get the number of haptic axes from SDL
winebus: Support creation of arbitrary number of PID axes
winebus: Use physical->num_axes to compute effect_update report size
winebus: Store the number of FFB axes of a unix_device
winebus: Use PID_AXES_MAX in unix_private.h
dinput: Use PID_AXES_MAX in joystick_hid for axes, directions, conditions
hid: Define the max number of supported PID axes
https://gitlab.winehq.org/wine/wine/-/merge_requests/7422
These tests serve to illustrate the output sample time and duration values from their respective native MFT video decoders with respect to the following circumstances:
1. When no frame rate nor input sample timestamps are provided;
2. When a frame rate is provided but there are no sample timestamps; and
3. When a frame rate is provided, but the input sample timestamps disagree with this value
It also highlights the gap in our implementation. However, I don't believe this can be fixed without first confirming the correct output from our IMFMediaStream implementations.
--
v4: mf/tests: Test timestamps in WMV decoder.
mf/tests: Test timestamps in H264 decoder.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7563
From 2/5:
```
The PE driver then broadcasts a GUID_BLUETOOTH_AUTHENTICATION_REQUEST PnP event on the newly
added WINEBTHAUTH device,
```
That should be GUID_WINEBTH_AUTHENTICATION_REQUEST.
We also need to correctly handle IRP_MJ_PNP requests for this new device.
From 4/5:
```
+ if (!addr)
+ return wine_dbg_sprintf( "%p", addr );
```
Just "(null)" seems more idiomatic.
```
+ work = CreateThreadpoolWork( tp_auth_callback_work_proc, data, NULL );
```
Why the threadpool? Why can't we call the callback right now?
```
+ struct bluetooth_auth_listener *hreg;
```
Bikeshedding, but "hreg" seems an odd variable name; why not "listener"?
```
+static DWORD bluetooth_auth_register( BOOL reg )
+{
+ DWORD ret;
+
+ if (reg)
+ {
+ ...
+ }
+ else
+ {
+ ...
+ }
+
+ return ret;
+}
```
This is what I like to call an "anti-helper". Just make this two separate functions, and probably inline at least the unregister side as it's literally two lines.
```
+ DeviceIoControl( winebth_auth, IOCTL_WINEBTH_AUTH_REGISTER, NULL, 0, NULL, 0, &bytes, NULL );
+ ret = GetLastError();
```
Don't check GetLastError() without also checking the return of DeviceIoControl(). Most functions which update the last error don't update it on success.
From 5/5:
```
SOURCES = \
+ auth.c \
device.c \
radio.c \
sdp.c
```
I really should have said something earlier, but we don't need all these different source files with less than 500 lines in each of them, especially if it's going to necessitate an extra header for helpers.
```
+ if (hreg)
+ ok( BluetoothUnregisterAuthentication( hreg ), "BluetoothUnregisterAuthentication failed: %lu\n", GetLastError() );
+ if (hreg2)
+ ok( BluetoothUnregisterAuthentication( hreg2 ), "BluetoothUnregisterAuthentication failed: %lu\n", GetLastError() );
```
You don't need the checks, you already checked those in an earlier ok().
Also, you don't want to test GetLastError() and the call at the same time, there's no sequence point between those. This is the one point where you *do* need to assign a bool to a temporary variable.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7630#note_98631
This MR adds an initial implementation of the winsock `WSALookupsService*` methods for performing Bluetooth device discovery (`LUP_CONTAINERS`).
Pending !7472, the code will also eventually support performing device inquiry scans.
--
v14: ws2_32: Implement WSALookupServiceNext for Bluetooth device discovery.
ws2_32: Implement WSALookupServiceBegin for Bluetooth device discovery.
ws2_32/tests: Add tests for Bluetooth device discovery in WSALookupServiceBegin/Next.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7542
Some console objects currently do several unique things:
* Delegate waits onto the queue of another object. This is not really a problem
for in-process waits, since we can just return the sync object for the
delegate. However, it's also unnecessary, adds to the complexity of the server
logic, and is one out of one places where this is done.
* Make the wait state dependent on the process. This is difficult to emulate
with ntsync and would require creating separate server objects for each
process, hacking into duplicate_handle.
* Fail a wait entirely in certain circumstances. This is pretty much impossible
to emulate with in-process waits.
Although ntsync has been in development for some time, I have regrettably failed
to notice these problems until now.
Fortunately, none of these behaviours happen on modern Windows. Although I/O on
unbound handles delegates to the console of the current process, the signaled
state does not. As the tests here show, the signaled state of a handle depends
on the active console of the process in which the handle was created. If that
console no longer exists, the signaled state is no longer updated [with one
rather inexplicable exception].
Crucially, in current Windows waits never fail, and the state of an object is
the same across all process which hold handles to it. Therefore this patch
brings our behaviour to closer match current Windows.
In theory these are fds and should use default_fd_signaled(). However, the
points at which the handles are signaled are completely different, and I/O does
not trigger console handles to become signaled when it normally would. Therefore
for the time being I've kept the code using custom signaled ops.
There is one other oddity related to consoles, which is the existence of
console_add_queue(), which seeks to lazily create an input thread when a console
is first waited on. This is one out of two places, after this patch, when the
wait process is hijacked (the other being message queues). Fortunately this is
easy to handle for in-process synchronization objects, by queueing the ioctl
from the callback used to retrieve the in-process synchronization object itself.
--
v4: server: Track unbound output signaled state based on its original console.
server: Track unbound input signaled state based on its original console.
server: Allow waiting on an orphaned screen buffer.
server: Use a list of screen buffers per console.
server: Fail to create an unbound input/output when there is no console.
kernel32/tests: Add more tests for orphaned console handles.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7608
Related Wine issue: https://bugs.winehq.org/show_bug.cgi?id=52714
I'm starting work on updating/extending Linux force feedback API and one of my goals is to expose the number and an array that contains the device's ffb-enabled axes. As I'm mainly working with USB PID driver, I already have a POC of obtaining this data.
What prompted this is that currently Wine always creates virtual joysticks with two PID ffb axes. This causes issues with [Richard Burns Rally](https://github.com/ValveSoftware/Proton/issues/6702#issuecomment-267…, as this game incorrectly initializes a `CONSTANT_FORCE` effect with all the FFB axes that contain `DIDOI_FFACTUATOR` flag and then trying to update `cAxes` and `rgdwAxes` values which leads to `DIERR_INVALIDPARAM`.
Now, this flag is set by wine while enumerating virtual device's axes and while `(axis index < FFB axes)`, flag is applied. This means, that every device which has FFB functionality and at least two axes, will report FFB on `X`, `Y`.
While updated API would mean a lot of steering wheels would correctly report only 1 axis, a lot of USB PID wheels still include `X` and `Y` in their `AXES_ENABLE` and `DIRECTION` usages. This, again, would lead to broken FFB (in affected games).
On Windows, there's a possibility of overwriting some joystick capabilities with registry entries, which ends up removing `DIDOI_FFACTUATOR` flag from a selected axis. This doesn't work in Wine.
This MR allows Wine to add an arbitrary number (up to `PID_AXES_MAX`) of axes to the PID descriptor, based on the value of Haptic Axes from SDL or from Linux FF api in the future (I'm working on it). Additionally, to work around RBR and other games with similar, wrong FFB handling, I introduced a [hint](https://github.com/libsdl-org/SDL/issues/12341) to SDL that allows a dynamic overwrite of the number of haptic axes. For the Linux API, I'll figure out a nice way to override when the number of axes will be exposed.
With these changes, I was able to successfully get force feedback on my Moza Racing R9 with all axes usable. With additional traces in the dinput code, I confirmed that with one axis defined in the PID descriptor, the game created a constant force effect with just one axis and `cAxes = 1`.
--
v7: dinput/tests: Add tests for 6-axis ff joystick
winebus: Get the number of haptic axes from SDL
winebus: Support creation of arbitrary number of PID axes
https://gitlab.winehq.org/wine/wine/-/merge_requests/7422
--
v2: ws2_32: Support bind for Bluetooth RFCOMM addresses.
ws2_32: Add bind tests for Bluetooth RFCOMM sockets.
server: Add support for creating Bluetooth RFCOMM sockets.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7634
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v8: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
If the `FT_MULFIX_ASSEMBLER` macro is not used during the compilation of FreeType,
unsigned extension to `FT_Fixed` will cause `FT_MulFix` to produce incorrect results.
The usage of the attached code is for compilation with GCC on x86_64.
Toggling the `FT_MULFIX_ASSEMBLER` macro will produce different results.
demo: [main.c](/uploads/18e77f790be1cb5acf2ef8f52b61bf39/main.c)
Signed-off-by: YeshunYe <yeyeshun(a)uniontech.com>
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7633
Some console objects currently do several unique things:
* Delegate waits onto the queue of another object. This is not really a problem
for in-process waits, since we can just return the sync object for the
delegate. However, it's also unnecessary, adds to the complexity of the server
logic, and is one out of one places where this is done.
* Make the wait state dependent on the process. This is difficult to emulate
with ntsync and would require creating separate server objects for each
process, hacking into duplicate_handle.
* Fail a wait entirely in certain circumstances. This is pretty much impossible
to emulate with in-process waits.
Although ntsync has been in development for some time, I have regrettably failed
to notice these problems until now.
Fortunately, none of these behaviours happen on modern Windows. Although I/O on
unbound handles delegates to the console of the current process, the signaled
state does not. As the tests here show, the signaled state of a handle depends
on the active console of the process in which the handle was created. If that
console no longer exists, the signaled state is no longer updated [with one
rather inexplicable exception].
Crucially, in current Windows waits never fail, and the state of an object is
the same across all process which hold handles to it. Therefore this patch
brings our behaviour to closer match current Windows.
In theory these are fds and should use default_fd_signaled(). However, the
points at which the handles are signaled are completely different, and I/O does
not trigger console handles to become signaled when it normally would. Therefore
for the time being I've kept the code using custom signaled ops.
There is one other oddity related to consoles, which is the existence of
console_add_queue(), which seeks to lazily create an input thread when a console
is first waited on. This is one out of two places, after this patch, when the
wait process is hijacked (the other being message queues). Fortunately this is
easy to handle for in-process synchronization objects, by queueing the ioctl
from the callback used to retrieve the in-process synchronization object itself.
--
v3: server: Track unbound output signaled state based on its original console.
server: Track unbound input signaled state based on its original console.
server: Allow waiting on an orphaned screen buffer.
server: Use a list of screen buffers per console.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7608
The goal is to make it somewhat easier to define different color schemes. This MR should not result in any changes to the generated bitmap files.
Many more will follow over time for all the other color values used in the SVG files.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7590
Some console objects currently do several unique things:
* Delegate waits onto the queue of another object. This is not really a problem
for in-process waits, since we can just return the sync object for the
delegate. However, it's also unnecessary, adds to the complexity of the server
logic, and is one out of one places where this is done.
* Make the wait state dependent on the process. This is difficult to emulate
with ntsync and would require creating separate server objects for each
process, hacking into duplicate_handle.
* Fail a wait entirely in certain circumstances. This is pretty much impossible
to emulate with in-process waits.
Although ntsync has been in development for some time, I have regrettably failed
to notice these problems until now.
Fortunately, none of these behaviours happen on modern Windows. Although I/O on
unbound handles delegates to the console of the current process, the signaled
state does not. As the tests here show, the signaled state of a handle depends
on the active console of the process in which the handle was created. If that
console no longer exists, the signaled state is no longer updated [with one
rather inexplicable exception].
Crucially, in current Windows waits never fail, and the state of an object is
the same across all process which hold handles to it. Therefore this patch
brings our behaviour to closer match current Windows.
In theory these are fds and should use default_fd_signaled(). However, the
points at which the handles are signaled are completely different, and I/O does
not trigger console handles to become signaled when it normally would. Therefore
for the time being I've kept the code using custom signaled ops.
There is one other oddity related to consoles, which is the existence of
console_add_queue(), which seeks to lazily create an input thread when a console
is first waited on. This is one out of two places, after this patch, when the
wait process is hijacked (the other being message queues). Fortunately this is
easy to handle for in-process synchronization objects, by queueing the ioctl
from the callback used to retrieve the in-process synchronization object itself.
--
v2: server: Track unbound output signaled state based on its original console.
server: Track unbound input signaled state based on its original console.
server: Allow waiting on an orphaned screen buffer.
server: Fail to create an unbound input/output when there is no console.
kernel32/tests: Add more tests for orphaned console handles.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7608
The Kirikiri Z [menu](https://github.com/krkrz/menu/blob/master/Main.cpp) plugin causes an exception to be raised (and the engine unloads the DLL) if GetKeyNameText returns a length of 1 with a null character. The affected applications later fail with script exception dialogs as menu.dll was unloaded.
When using winex11 (and presumably winemac), the function returns the return value of the driver function for GetKeyNameText, and that returns 0 on an unsupported key which works. On winewayland (and the null driver), that isn't implemented, and instead the function continues and calls NtUserMapVirtualKeyEx with MAPVK_VK_TO_CHAR filling the buffer with one character which is 0 (no translation). The function then returns 1 for that null character and the applications don't seem to handle that well.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7628
This MR adds an initial implementation of the winsock `WSALookupsService*` methods for performing Bluetooth device discovery (`LUP_CONTAINERS`).
Pending !7472, the code will also eventually support performing device inquiry scans.
--
v13: ws2_32: Implement WSALookupServiceNext for Bluetooth device discovery.
ws2_32: Implement WSALookupServiceBegin for Bluetooth device discovery.
ws2_32/tests: Add tests for Bluetooth device discovery in WSALookupServiceBegin/Next.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7542
Introduce infrastructure necessary to support receiving, sending and replying (to) Bluetooth authentication/pairing requests:
- During startup, the Bluetooth driver now creates a "pairing agent" and registers it with BlueZ. The pairing agent is a DBus object implementing the `org.bluez.Agent1` interface (documented [here](https://github.com/bluez/bluez/blob/master/doc/org.bluez.Agent.rst)), which receives authentication requests from BlueZ. The pairing agent then forwards the request data to the PE driver, in form of a `WINEBLUETOOTH_EVENT_AUTH_EVENT` event. The agent is unregistered during driver shutdown.
- Right now, the agent only supports Numeric Comparison pairing requests.
- Create a new auxiliary device, `\??\WINEBTHAUTH` during driver startup. This device handles authentication functionality that is independent of radio PDOs on the system, which allows the userspace APIs to not track individual Bluetooth radio objects to implement authentication. `WINEBTHAUTH` right now serves two purposes:
- Serve as the device object for which `GUID_WINEBTH_AUTHENTICATION_REQUEST` PnP events are broadcasted. This event is sent whenever the Bluetooth event loop in (`bluetooth_event_loop_thread_proc`) receives `WINEBLUETOOTH_EVENT_AUTH_EVENT`. The event's buffer contains a `struct winebth_authentication_request` value, which contains data relevant to the incoming auth request.
- Handle the `IOCTL_WINEBTH_AUTH_REGISTER` IOCTL. This simply calls the [`RequestDefaultAgent` BlueZ method](https://github.com/bluez/bluez/blob/master/doc/org.bluez.AgentManag… right now, which asks BlueZ to send all incoming Bluetooth authentication requests to Wine's pairing agent (described above). This is not always strictly necessary, but is useful if there already is a default pairing agent set.
- `WINEBTHAUTH` will also ultimately be in charge of responding to authentication requests, which I'll be adding in the next-ish MR(s).
- Implement `BluetoothRegisterForAuthenticationEx` and `BluetoothUnregisterAuthentication`. Registration is done by invoking `IOCTL_WINEBTH_AUTH_REGISTER`, and then listening for `GUID_WINEBTH_AUTHENTICATION_REQUEST` events on a `HANDLE` to `\??\WINEBTHAUTH` using the newly added `CM_Register_Notifications`.
To keep the MR from getting any larger, I have not included support for `BluetoothSendAuthenticationResponseEx`. That will likely be introduced in the future.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7630
This confuses mutter and it manifests with spurious IconicState WM_STATE
change when it decides to try managing the window, but it also makes it
randomly lose focus or even fail to map the window back on screen.
Adding the flag after the window has been created fixes the issue.
--
v2: winex11: Avoid creating windows with override-redirect flag set.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7181
After this there is one more set of patches to finish up the file saving functions, I split it into two to hopefully make it easier to review. :)
--
v2: d3dx9: Use D3DXSaveVolumeToFileInMemory() inside of D3DXSaveTextureToFileInMemory().
d3dx9: Implement D3DXSaveVolumeToFile{A,W,InMemory}().
d3dx9/tests: Add tests for D3DXSaveVolumeToFile{A,W,InMemory}().
d3dx9: Add stubs for D3DXSaveVolumeToFile{A,W,InMemory}().
https://gitlab.winehq.org/wine/wine/-/merge_requests/7577
These tests serve to illustrate the output sample time and duration values from their respective native MFT video decoders with respect to the following circumstances:
1. When no frame rate nor input sample timestamps are provided;
2. When a frame rate is provided but there are no sample timestamps; and
3. When a frame rate is provided, but the input sample timestamps disagree with this value
It also highlights the gap in our implementation. However, I don't believe this can be fixed without first confirming the correct output from our IMFMediaStream implementations.
--
v3: mf/tests: Test timestamps in WMV decoder.
mf/tests: Test timestamps in H264 decoder.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7563
The Win32 state might not have been updated with the latest X11 state,
and we want to take future updates into account when deciding to accept
focus or not.
At this point, and because we ignore WM_TAKE_FOCUS when a state change
is pending, all the states are the same, we use current_state as the
logic is to accept focus or not according to our current understanding
of the X state.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7626
This fixes failure to play the prologue video in Planet of the Apes: Last Frontier, which unpauses by calling Start() with a location. The exact state leading to this issue does not occur in the Start() tests, and it's not clear how to reproduce it reliably.
--
v4: mf: Reset transform nodes when seeking.
mf: Initialise the grabber sample count when setting state after a seek.
mf: Reset transform node outputs when seeking.
mf: Drop transform node input events when unpausing at a specific position.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7466
This fixes failure to play the prologue video in Planet of the Apes: Last Frontier, which unpauses by calling Start() with a location. The exact state leading to this issue does not occur in the Start() tests, and it's not clear how to reproduce it reliably.
--
v3: mf: Reset transform nodes when seeking.
mf: Initialise the grabber sample count when setting state after a seek.
mf: Reset transform node outputs when seeking.
mf: Drop transform node input events when unpausing at a specific position.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7466
This MR modifies winegstreamer to match Windows behaviour in that:
1. the video decoders will output the PTS and duration of the input sample (if provided); and
2. the WMV decoder will set any value not provided to zero
It also adds support for supplying a DTS value to the MFTs.
I've marked this as draft as it fixes the tests in MR !7563 (in addition to fixing some existing `test_wmv_decoder` tests). Also, as demonstrated in MR !7569, our demuxers output different timestamps to Windows. This change will result in those different timestamps being forwarded from the decoder. So we may also want to address that difference prior to accepting this MR.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7623
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v7: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v6: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
My hardware is Ryzen 7 4700u with the integrated graphics
Flatout (Direct3D 9): 20 fps (renders correctly)
Unigine Heaven (OpenGL): ~40-60 fps (renders correctly)
Unigine Heaven (Direct3D 9): 20-30 fps (renders correctly)
Unigine Heaven (Direct3D 11): 20-30 fps as well (renders correctly)
Elder Scrolls IV (Direct3D 9): 20 fps (renders correctly)
BeamNG Tech Demo 0.3 (Direct3D 9): 2 fps (renders correctly, but still runs poorly)
Massive step up from getting 2 fps across many wined3d games, but it's still pretty bad, ~~and sometimes runs worse than the original code~~. Now with a combination of using the new and old code dynamically you can get the best of both worlds!
Unfortunately, we lose the ability to get lucky with the mapping just happening to be in the 32 bit range.
--
v7: opengl32: speed up wow64 mapping.
https://gitlab.winehq.org/wine/wine/-/merge_requests/5145
This MR adds an initial implementation of the winsock `WSALookupsService*` methods for performing Bluetooth device discovery (`LUP_CONTAINERS`).
Pending !7472, the code will also eventually support performing device inquiry scans.
--
v11: ws2_32: Implement WSALookupServiceNext for Bluetooth device discovery.
ws2_32: Implement WSALookupServiceBegin for Bluetooth device discovery.
ws2_32/tests: Add tests for Bluetooth device discovery in WSALookupServiceBegin/Next.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7542
This MR adds an initial implementation of the winsock `WSALookupsService*` methods for performing Bluetooth device discovery (`LUP_CONTAINERS`).
Pending !7472, the code will also eventually support performing device inquiry scans.
--
v10: ws2_32: Implement WSALookupServiceNext for Bluetooth device discovery.
ws2_32: Implement WSALookupServiceBegin for Bluetooth device discovery.
ws2_32/tests: Add tests for Bluetooth device discovery in WSALookupServiceBegin/Next.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7542
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v5: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
The methods are needed to implement Bluetooth device pairing in `bluetoothapis.dll` without having to create a dummy window for `RegisterDeviceNotification`, as that may break CLI applications.
`CM_Register_Notification` is implemented as a thin wrapper over `I_ScRegisterDeviceNotification`, mapping `DBT_*` flags to their associated `CM_NOTIFY_*` constants.
--
v4: user32: Remove incorrect FIXME warning while registering for DBT_DEVTYP_HANDLE notifications.
cfgmgr32: Implement CM_Register_Notification and CM_Unregister_Notification.
dinput/tests: Add tests for CM_Register_Notification.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7559
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v4: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
This is the continuation of https://gitlab.winehq.org/wine/wine/-/merge_requests/7317.
There are a lot of smaller commits (some even no-op renames), because there are some inconsistencies in the codebase currently of what an NT thread priority vs a base thread priority should be (or even constant names being wrong), and I hope that this clears that up a bit.
I tried making the commits as atomic as possible. I hope this is fine... There are still a few tiny details missing, like boosting and `KeSetPriorityThread` and friends, which are either stubs or not correctly working as well and have been moved to the next part.
I wrote a pretty extensive test for all this too, since pretty much none of how this works is documented (or even misrepresented quite often). For testing, thread priority boosting has been disabled in order to make the behavior on Windows not flaky and dynamic. In fact, on Windows, there is some thread priority boost decay going on after the message has been processed and other mechanisms.
The `last` field of `get_thread_info` reply was moved to a flag in order to make space for the thread base priority, since it is already at the limit of 64 bytes.
--
v8: ntdll/tests: Add tests for process and thread priority.
server, ntdll: Fetch both process priority and base_priority.
server: Add process base priority helper.
kernelbase: Use ProcessPriorityClass info class in GetPriorityClass.
kernelbase: Use correct priority in GetThreadPriority.
server, ntdll: Fetch both thread priority and base_priority.
server, ntdll: Move last thread information to get_thread_info flags.
ntdll: Implement ThreadPriority class in NtSetInformationThread.
server: Implement setting thread priority directly.
server: Add set_thread_priority helper.
server: Rename thread priority to base_priority.
server: Rename base_priority to effective_priority in apply_thread_priority.
server: Infer process priority class in set_thread_priority.
include: Use correct PROCESS_PRIORITY_CLASS_* names.
include: Add thread priority constants.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7516
This MR adds a fallback path that implements clipboard support using the core protocol (wl_data_device) when wlr-data-control-unstable-v1 is missing.
The reasons we want this fallback path, in spite of the extra complexity it introduces, are:
1. Some compositors don't (and likely won't ever) support {wlr,ext}-data-control-unstable-v1.
2. Even compositors that do support {wlr,ext}-data-control-unstable-v1, may not expose it to sandboxed applications.
This MR allows Wine to support clipboard operations in such scenarios, in a way that's good enough for many common user clipboard interactions. A more comprehensive discussion of the limitations can be found in !7236.
This MR differs from !7236 in that it creates a per-process clipboard thread and window, instead of using the desktop process clipboard thread and manually forwarding messages. Note that the per-process clipboard threads/windows are created only if we fall back to wl_data_device. In the wlr-data-control-unstable-v1 case nothing changes, we still use the desktop process clipboard thread as before.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7613
On Tue Mar 18 15:03:51 2025 +0000, Rémi Bernon wrote:
> I haven't found neither the PROCESS_PRIOCLASS nor the
> PROCESS_PRIORITY_CLASS constants in the SDK headers, where are you
> seeing them?
I was originally looking into that since the reported process base priority was not matching what windows reported and they were set to these values, so I thought they were wrong (which turned out to be not true for a different reason...).
In any case, [System Informer](https://systeminformer.sourceforge.io), which is luckily open-source and MIT licensed, displays them like so:
```
static CONST PH_KEY_VALUE_PAIR ProcessPriorityClassTypePairs[] =
{
SIP(SREF(L"Unknown"), PROCESS_PRIORITY_CLASS_UNKNOWN),
SIP(SREF(L"Idle"), PROCESS_PRIORITY_CLASS_IDLE),
SIP(SREF(L"Normal"), PROCESS_PRIORITY_CLASS_NORMAL),
SIP(SREF(L"High"), PROCESS_PRIORITY_CLASS_HIGH),
SIP(SREF(L"Real time"), PROCESS_PRIORITY_CLASS_REALTIME),
SIP(SREF(L"Below normal"), PROCESS_PRIORITY_CLASS_BELOW_NORMAL),
SIP(SREF(L"Above normal"), PROCESS_PRIORITY_CLASS_ABOVE_NORMAL),
};
```
A quick GitHub code search shows that these are used like so in a wide range of projects, whereas the current Wine naming of `PROCESS_PROCLASS_*` is basically only used by Wine.
This also adds the unknown case and starts from `0`, which are both nice-to-haves, and leads me to believe that this is also the original private API naming scheme. If this is still not worth it to do, I can also just drop the commit as well.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7516#note_98393
Main target of this serie is to support properly the
SYMOPT_LOAD_LINES option flag to dbghelp (turning it
off can save some memory).
Adding support for 128bit integers in PDB base types,
and silencing some more types.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7612
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v3: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
For https://gitlab.winehq.org/wine/wine/-/merge_requests/7512 to use it to locate window shared objects.
--
v2: win32u: Use the session shared object to implement is_window.
win32u: Use the session shared object for user handle entries.
server: Move the user object handle table to the shared memory.
server: Use NTUSER_OBJ constants for user object types.
server: Create a shared memory object for the global session.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7610
On Wed Mar 19 05:07:09 2025 +0000, Mohamad Al-Jaf wrote:
> changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/7597/diffs?diff_id=165075&start_sha=0c9df529abfdeb01208ee618b4cb766a0961ba69#d430fdc14e90f656acc7b2f3eb52d29c37bb640f_331_308)
That's a better method, thanks.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7597#note_98370