The current YUV to RGB conversion provides values in studio-range [16-235], but full-range is required [0-255]. As a result, we currently write the value of 16 to represent black, and so we get gray instead.
This MR changes the coefficients used in the conversion so that the resultant output is in full-range. It actually uses two sets of coefficients as these differ between SD and HD.
Also included is a number of Direct Draw 7 tests.
The coefficients used are documented here:
https://learn.microsoft.com/en-us/windows/win32/medfound/recommended-8-bit-…
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7324
On Thu Feb 13 12:40:06 2025 +0000, Brian Wright wrote:
> I've updated the [bug
> report](https://bugs.winehq.org/show_bug.cgi?id=57603) with some debug
> logs from 10.1 including `+x11drv,+event,+cursor,+win,+hid` if this helps.
@rbernon On the client side, if you wanted to know why the log produces the values it has or had advice on code changes, the relevant file seems to be [yabridge/src/wine-host/editor.cpp](https://github.com/robbert-vdh/yabridge/… and a few routines responsible for coords and mouse handling that might be indirectly showing up in the bug report log include **is_cursor_in_wine_window** (line 1442), **get_current_pointer_position** (line 953), **fix_local_coordinates** (line 785), and `case XCB_CONFIGURE_NOTIFY` (line 552)
I can attach to Wine and/or yabridge in a debugger, but I wouldn't have advice on what to change since I don't know how the handle relationships should look in order to find out which routine is producing incorrect coordinate offsets. If you want me to try anyway, I can put it in the queue of all the other stuff I forget to do once the workday is over.
Thanks to you and @robbert-vdh for maintaining two phenomenal tools.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/6569#note_94461
Recent binutils changes merge .idata sections into the read-only .rdata section.
This is intended to make the IAT read-only, as with other modern linkers, but as
a side effect, it broke delay-load import libraries. Delay-load import libraries
should use separate sections regardless.
Since these new sections are not recognized by the linker, it won’t apply special
handling to maintain proper sorting. In practice, this isn’t an issue as long as
the name table and IAT maintain the same order. This may result in negative IAT
offsets (if the base symbol ends up in the middle of the IAT), but Windows appears
to handle this without issues.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57819
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7328
This MR tries to implement the SetIMECompositionRect user driver function and partially the WINE_IME_POST_UPDATE message call. It requires support for zwp_text_input_v3 from the compositor. It supports submitting committed text to the win32 side and notifying the compositor about the area of the text cursor rectangle.
This doesn't add support for embedded pre-edit because I couldn't immediately get it to appear. Either I did something incorrect, or it has something to do with Wayland. On X11, the pre-edit appears completely separated to the application window and doesn't move with it, which doesn't seem to be compatible with Wayland.
If Windows has the surrounding text feature, it does not seem possible to support it here with the provided interface.
The IME is always enabled on the focused surface, like on X11. If Windows has a facility that applications can use to say that it does or does not accept text entry at certain parts of the UI, it does not seem possible to support it here with the provided interface.
--
v3: winewayland: Implement SetIMECompositionRect.
winewayland: Post IME update for committed text.
winewayland: Enable/disable the zwp_text_input_v3 object.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7241
This MR tries to implement the SetIMECompositionRect user driver function and partially the WINE_IME_POST_UPDATE message call. It requires support for zwp_text_input_v3 from the compositor. It supports submitting committed text to the win32 side and notifying the compositor about the area of the text cursor rectangle.
This doesn't add support for embedded pre-edit because I couldn't immediately get it to appear. Either I did something incorrect, or it has something to do with Wayland. On X11, the pre-edit appears completely separated to the application window and doesn't move with it, which doesn't seem to be compatible with Wayland.
If Windows has the surrounding text feature, it does not seem possible to support it here with the provided interface.
The IME is always enabled on the focused surface, like on X11. If Windows has a facility that applications can use to say that it does or does not accept text entry at certain parts of the UI, it does not seem possible to support it here with the provided interface.
--
v2: winewayland: Implement SetIMECompositionRect.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7241
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56106
I'm not sure why there's a IRandomAccessStreamReferenceStatics interface in WinTypes. Perhaps it was supposed to be queried from one of the classes there? I've seen something similar with other classes.
--
v2: windows.storage: Add error handling in IRandomAccessStreamReferenceStatics::CreateFromStream().
windows.storage: Add IRandomAccessStreamReferenceStatics stub interface.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7308
On Thu Feb 13 05:57:40 2025 +0000, Aida Jonikienė wrote:
> Does iCUE even work on Wine though? I think it does direct USB device
> access for mice/keyboards (and other peripherals)
It's also needed by other programs like PowerToys, but iCUE is the easiest to test since it calls it right away. And Wine has some USB support.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7146#note_94422
Make both method calls;
1. Consistently written with parameter names as per spec.
2. Fix parameter validation to be consistent with spec.
3. Fix szNameBuf parameter semantics as per spec.
4. Fix szNameBuf casing str search as per spec.
5. Factor out common code into TLB_ helpers vastly improves readability.
--
v22: dlls/oleaut32: Bound ITypeLib2_Constructor_SLTG() loop
dlls/oleaut32/connpt.c: Make consistent and validate args
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7286
Make both method calls;
1. Consistently written with parameter names as per spec.
2. Fix parameter validation to be consistent with spec.
3. Fix szNameBuf parameter semantics as per spec.
4. Fix szNameBuf casing str search as per spec.
5. Factor out common code into TLB_ helpers vastly improves readability.
--
v21: dlls/oleaut32/connpt.c: Make consistent and validate args
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7286
This fixes https://bugs.winehq.org/show_bug.cgi?id=52094.
For reference, here's how current_modref is being passed around (before this patch):
```mermaid
graph TB
fii["fixup_imports_ilonly<br><em style='color:#ff0'>(directly sets current_modref)</em>"]
fi["fixup_imports<br><em style='color:#ff0'>(directly sets current_modref)</em>"]
pa["process_attach<br><em style='color:#ff0'>(directly sets current_modref)</em>"]
ld[load_dll]
id["import_dll<br><em style='color:#0f0'>(directly uses current_modref)</em>"]
bin["build_import_name<br><em style='color:#0f0'>(directly uses current_modref)</em>"]
foe["find_ordinal_export<br><em style='color:#0f0'>(uses current_modref for relay)</em>"]
ffe["find_forwarded_export<br><em style='color:#0f0'>(directly uses current_modref)</em>"]
fne[find_named_export]
MI[MODULE_InitDLL]
fii --> ld
fi --> id
pa --> MI -.-> DllMain
id --> bin
id --> ld
id --> foe
id --> fne --> foe --> ffe --> foe
ffe --> fne
ffe --> bin
style DllMain color:red;
```
--
v11: ntdll: Remove superflous NULL check for importer.
ntdll: Properly track refcount on dynamic imports of export forwarders.
ntdll: Explicitly ignore dynamic (GetProcAddress) importers as relay/snoop user module.
ntdll: Properly track refcount on static imports of export forwarders.
ntdll: Register module dependency for export forwarders regardless of whether the dependency is already loaded.
ntdll: Don't re-add a module dependency if it already exists.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7
Make both method calls;
1. Consistently written with parameter names as per spec.
2. Fix parameter validation to be consistent with spec.
3. Fix szNameBuf parameter semantics as per spec.
4. Fix szNameBuf casing str search as per spec.
5. Factor out common code into TLB_ helpers vastly improves readability.
--
v20: dlls/oleaut32/connpt.c: Make consistent and validate args
dlls/oleaut32: Add missing IID case in ITypeLib2::QueryInterface()
dlls/oleaut32: Validate TLB_QueryInterface() params
dlls/oleaut32: Fix QueryInterface() to meet spec
dlls/shell32: Fix IUnknown::QueryInterface() to meet spec
dlls/oleaut32: Invert if-stmt in ITypeLib2_fnRelease()
dlls/oleaut32: Consistently use TLB_REF_NOT_FOUND
dlls/oleaut32: Validate arguments in ITypeLibComp interface
dlls/oleaut32: Validate arguments in ITypeComp interface
dlls/oleaut32: Consistently use TLB_get_bstr()
dlls/oleaut32: Invert if stmt for clarity
dlls/oleaut32: Fix nonsensical memory access in ITypeLib2_Constructor_SLTG()
dlls/oleaut32: Avoid ptr arithmetic in MSFT_DoVars()
dlls/oleaut32: Avoid ptr arithmetic in ITypeLib2_Constructor_SLTG()
dlls/oleaut32: Shink down ITypeLibComp_fnBind() verbosity some
dlls/oleaut32: ptr_size should be a ULONG
dlls/oleaut32: Scope indexer to loops in fn[Is|Find]Name()
dlls/oleaut32: Factor out TLB_get_funcparams_by_name()
dlls/oleaut32: Factor out TLB_get_funcdesc_by_name()
dlls/oleaut32: Validate args of ITypeLib2_fnIsName()
dlls/oleaut32: fn(Is|Find)Name should set szNameBuf with correct case
dlls/oleaut32: Use consistent param identifiers in fnFindName
dlls/oleaut32: Mostly mirror fnFindName impl in typelib.c
dlls/oleaut32: Use common and correct identifiers in typelib.c
dlls/oleaut32: Consistently use lstrcmpiW() while looking for names
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7286
Fixes Indiana Jones and the Great Circle showing system mouse cursor along with its own one after alt-tabbing out and in.
The game hides the cursor and sets up rawinput w/RIDEV_NOLEGACY in WM_ACTIVATE handling. Then, whenever it receives WM_SETCURSORPOS it shows the cursor back. WM_SETCURSORPOS is triggered by WM_MOUSEMOVE in DefWIndowProc; WM_MOUSEMOVE is not queued with rawinput/RIDEV_NOLEGACY but prior hardware messages and system messages from set_cursor_pos are present in the queue.
That's not the case on Windows. That corresponds to the fact that Windows generates those system WM_MOUSEMOVE message "on demand", that is, when Peek or GetMessage is called (see, e. g., [1]). While Wine generates and queues those in internal messages queue in server/queue.c:set_cursor_pos(). My test confirm Windows behaviour. There are corner case specifics which my patch ignores:
- If PeekMesage( PM_NOREMOVE) got the message it will be then delivered even after setting up rawinput;
- Delivery of SendInput() under these conditions depends on MOUSEEVENTF_MOVE_NOCOALESCE flag (which we currently don't support at all); my patch just drops any hardware WM_MOUSEMOVE messages under these conditions (which corresponds to Windows behaviour without MOUSEEVENTF_MOVE_NOCOALESCE).
1. https://devblogs.microsoft.com/oldnewthing/20130523-00/?p=4273
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7321#note_94406
This fixes https://bugs.winehq.org/show_bug.cgi?id=52094.
For reference, here's how current_modref is being passed around (before this patch):
```mermaid
graph TB
fii["fixup_imports_ilonly<br><em style='color:#ff0'>(directly sets current_modref)</em>"]
fi["fixup_imports<br><em style='color:#ff0'>(directly sets current_modref)</em>"]
pa["process_attach<br><em style='color:#ff0'>(directly sets current_modref)</em>"]
ld[load_dll]
id["import_dll<br><em style='color:#0f0'>(directly uses current_modref)</em>"]
bin["build_import_name<br><em style='color:#0f0'>(directly uses current_modref)</em>"]
foe["find_ordinal_export<br><em style='color:#0f0'>(uses current_modref for relay)</em>"]
ffe["find_forwarded_export<br><em style='color:#0f0'>(directly uses current_modref)</em>"]
fne[find_named_export]
MI[MODULE_InitDLL]
fii --> ld
fi --> id
pa --> MI -.-> DllMain
id --> bin
id --> ld
id --> foe
id --> fne --> foe --> ffe --> foe
ffe --> fne
ffe --> bin
style DllMain color:red;
```
--
v10: ntdll: Remove superflous NULL check for importer.
ntdll: Properly track refcount on dynamic imports of export forwarders.
ntdll: Explicitly ignore dynamic (GetProcAddress) importers as relay/snoop user module.
ntdll: Properly track refcount on static imports of export forwarders.
ntdll: Register module dependency for export forwarders regardless of whether the dependency is already loaded.
ntdll: Don't re-add a module dependency if it already exists.
ntdll: Register module dependency for export forwarders only after successful resolution.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7
`mach_continuous_approximate_time()` has the necessary precision for win32 ticks and can be up to 4x faster than `mach_continuous_time()`.
Also `clock_gettime( CLOCK_REALTIME, &ts )` calls always end up in `__commpage_gettimeofday( struct timeval *tp )`:
```
* frame #0: 0x00007ff806788763 libsystem_kernel.dylib`__commpage_gettimeofday
frame #1: 0x00007ff8066709a3 libsystem_c.dylib`gettimeofday + 45
frame #2: 0x00007ff806678b31 libsystem_c.dylib`clock_gettime + 117
```
These extra calls, setup and converting from one struct format to another costs another 60 CPU cycles and in my testing makes `NtQuerySystemTime` approximately 30% faster as well with this MR. This is a fairly hot code path (especially when using certain out-of-tree in process synchronization patch sets), so probably worth the optimization here.
All of these APIs are available since 10.12.
--
v4: ntdll: Replace '0' with 'NULL' in gettimeofday() calls.
ntdll: Use gettimeofday in system_time_precise on macOS.
ntdll: Use __commpage_gettimeofday in NtQuerySystemTime on macOS.
ntdll: Always use mach_continuous_approximate_time on macOS.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7256
Based on Piotr's findings.
On MSVC i386 targets, structs requiring alignment greater than 4 are never passed by value.
Clang follows the same behavior in MSVC mode (see [1] for details and [2] for a follow-up
that applies this logic when fields, not necessarily the entire struct, are aligned).
A number of ios functions take fpos_mbstatet as an argument and expect it to be passed by value.
[1] https://reviews.llvm.org/D72114
[2] https://github.com/llvm/llvm-project/issues/63257
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57817
--
v2: msvcp60/tests: Avoid explicitly aligning structs passed by value.
msvcp60: Avoid explicitly aligning structs passed by value.
msvcp90/tests: Avoid explicitly aligning structs passed by value.
msvcp: Avoid explicitly aligning structs passed by value.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7312
When dlls/win32u fails to load/initialize the \`FreeType font library', a device context object ends up with the only GDI driver attached -- `null_driver`. The latter implements the `pGetTextMetrics` callback function as do-nothing code. This causes the `NtGdiGetTextMetricsW()` function to fail not modifying fields of its `metrics` argument. In result the `normalize_nonclientmetrics()` ends up with uninitialized `tm` local variable after call to the `get_text_metr_size()` function. Using uninitialized fields of the `TEXTMETRICW` structure gives unpredictable results.
This memset(3)'s the `tm` structure before using. After that, even if we failed to load the \`FreeType font library', the \`CaptionHeight', \`SmCaptionHeight' and \`MenuHeight' metrics keep their current values (the `normalize_nonclientmetrics()` function is called after `get_twips_entry()` callback function, thus value of an entry should not be negative).
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7316
This broke after d58e917e2cb36c6ffcb259356c06171d8f6d4dcc in some situations, since it resulted in us calling wined3d_texture_download_from_texture() with CLEARED location. The latter was not aware of CLEARED and incorrectly assumed the source texture was in TEXTURE_SRGB.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7313
Make both method calls;
1. Consistently written with parameter names as per spec.
2. Fix parameter validation to be consistent with spec.
3. Fix szNameBuf parameter semantics as per spec.
4. Fix szNameBuf casing str search as per spec.
5. Factor out common code into TLB_ helpers vastly improves readability.
--
v19: dlls/oleaut32: Add missing IID case in ITypeLib2::QueryInterface()
dlls/oleaut32: Validate TLB_QueryInterface() params
dlls/oleaut32: Fix QueryInterface() to meet spec
dlls/shell32: Fix IUnknown::QueryInterface() to meet spec
dlls/oleaut32: Invert if-stmt in ITypeLib2_fnRelease()
dlls/oleaut32: Consistently use TLB_REF_NOT_FOUND
dlls/oleaut32: Validate arguments in ITypeLibComp interface
dlls/oleaut32: Validate arguments in ITypeComp interface
dlls/oleaut32: Consistently use TLB_get_bstr()
dlls/oleaut32: Invert if stmt for clarity
dlls/oleaut32: Fix nonsensical memory access in ITypeLib2_Constructor_SLTG()
dlls/oleaut32: Avoid ptr arithmetic in MSFT_DoVars()
dlls/oleaut32: Avoid ptr arithmetic in ITypeLib2_Constructor_SLTG()
dlls/oleaut32: Shink down ITypeLibComp_fnBind() verbosity some
dlls/oleaut32: ptr_size should be a ULONG
dlls/oleaut32: Scope indexer to loops in fn[Is|Find]Name()
dlls/oleaut32: Factor out TLB_get_funcparams_by_name()
dlls/oleaut32: Factor out TLB_get_funcdesc_by_name()
dlls/oleaut32: Validate args of ITypeLib2_fnIsName()
dlls/oleaut32: fn(Is|Find)Name should set szNameBuf with correct case
dlls/oleaut32: Use consistent param identifiers in fnFindName
dlls/oleaut32: Mostly mirror fnFindName impl in typelib.c
dlls/oleaut32: Use common and correct identifiers in typelib.c
dlls/oleaut32: Consistently use lstrcmpiW() while looking for names
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7286
This is a cleanup in preparation for !7. Originally, !7 extended the use of `current_modref`, but I think we could avoid that with a more direct approach. Most of these changes are no-ops.
For the relay handler, we no longer treat `GetProcAddress` calls inside `DllMain` as coming from a loaded DLL. I believe this was more of a side effect of how the code was structured rather than an intentional behavior that needs to be preserved.
One more use of `current_modref` remains, which will be removed by !7.
--
v4: ntdll: Remove no longer needed current_modref.
ntdll: Use NULL importer in LdrGetProcedureAddress.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7287
This is a cleanup in preparation for !7. Originally, !7 extended the use of `current_modref`, but I think we could avoid that with a more direct approach. Most of these changes are no-ops.
For the relay handler, we no longer treat `GetProcAddress` calls inside `DllMain` as coming from a loaded DLL. I believe this was more of a side effect of how the code was structured rather than an intentional behavior that needs to be preserved.
One more use of `current_modref` remains, which will be removed by !7.
--
v3: ntdll: Remove no longer needed current_modref.
null: Use NULL importer in LdrGetProcedureAddress.
ntdll: Pass importer pointer to build_import_name.
ntdll: Pass importer pointer to find_forwarded_export.
ntdll: Pass importer pointer to find_named_export.
ntdll: Pass importer pointer to find_ordinal_export.
ntdll: Pass WINE_MODREF to import_dll.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7287
This is a cleanup in preparation for !7. Originally, !7 extended the use of `current_modref`, but I think we could avoid that with a more direct approach. Most of these changes are no-ops.
For the relay handler, we no longer treat `GetProcAddress` calls inside `DllMain` as coming from a loaded DLL. I believe this was more of a side effect of how the code was structured rather than an intentional behavior that needs to be preserved.
One more use of `current_modref` remains, which will be removed by !7.
--
v2: ntdll: Remove no longer needed current_modref.
null: Use NULL importer in LdrGetProcedureAddress.
ntdll: Pass importer pointer to build_import_name.
ntdll: Pass importer pointer to find_forwarded_export.
ntdll: Pass importer pointer to find_named_export.
ntdll: Pass importer pointer to find_ordinal_export.
ntdll: Pass WINE_MODREF to import_dll.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7287
This allows using one single wineprefix, one wineserver and one single wine executable for running both arm and arm64 executables.
This setup actually has worked earlier; Ubuntu 22.04 packages Wine 6.0, where the wine32 + wine64 packages together end up working this way. However, since Wine 6.0, a couple of refactorings has broken this setup along the way; reinstate this way of working.
The new wow64 mode probably won't work on arm, as it's not easily possible to switch between 32 and 64 bit execution mode within a process, as far as I know, but the old wow64 mode is still a great convenience - especially considering distro-packaged use for users who aren't familiar with the particular quirks on this architecture.
--
v2: configure: Allow using --enable-win64 on aarch64
server: Include ARMNT as one of the supported architectures on aarch64
ntdll: Allow running arm/aarch64 in (old) wow64 mode
https://gitlab.winehq.org/wine/wine/-/merge_requests/7204
This is a bit convoluted because of the amount of pieces involved. I'll
try to untangle things a bit.
The container id is meant to be globally unique and stable. We therefore
need a suitable amount of stable entropy that we can feed into a hash
function to get a stable and unique output.
This happens in winebus. The corner stone of hash inputs is the linux
device topology (sysfs path) obtained via udev. Along with all other
possible data we feed this into a hash function to obtain our container
id.
A bunch of extra wine-specific keys needed to be added to carry the
necessary metadata from the driver into the ntoskrnl (where it gets
written to the property registry of the relevant device).
Separate from this we also ingest the linux device topology (sysfs path)
in the winepulse driver.
In mmdevapi we then use winepulse's sysfs path to find the matching
device in the setupapi and query its container id. We now have the same
container id in both the device and the MMDevice, allowing applications
(in particular Games) to find the MMDevice for a given device.
For practical reasons we always resolve the sysfs path to the root
device as early as possible. Container ids are meant to be equal for sub
devices inside a "container" anyway.
--
v3: winebus,mmdevapi: implement audio device container id
https://gitlab.winehq.org/wine/wine/-/merge_requests/7238
This introduces a faster implementation of signal and wait operations on NT
events, semaphores, and mutexes, which improves performance to native levels for
a wide variety of games and other applications.
The goal here is similar to the long-standing out-of-tree "esync" and "fsync"
patch sets, but without the flaws that make those patch sets not upstreamable.
The Linux "ntsync" driver is not currently released. It has been accepted into
the trunk Linux tree for 6.14, so barring any extraordinary circumstances, the
API is frozen and it will be released in its current form in about 2 months.
Since it has passed all relevant reviewers on the kernel side, and the API is
all but released, it seems there is no reason any more not to submit the Wine
side to match.
Some important notes:
* This patch set does *not* include any way to disable ntsync support, since
that kind of configuration often seems to be dispreferred where not necessary.
In essence, ntsync should just work everywhere.
Probably the easiest way to effectively disable ntsync, for the purposes of
testing, is to chmod the /dev/ntsync device to prevent its being opened.
Regardless, a Wine switch to disable ntsync can be added simply enough. Note
that it should probably not take the form of a registry key, however, since it
needs to be easily accessible from the server itself.
* It is, generally speaking, not possible for only some objects, or some
processes, to have backing ntsync objects, while others use the old server
path. The esync/fsync patch sets explicitly protected against this by making
sure every process had a consistent view of whether esync was enabled. This is
not provided here, since no switch is provided to toggle ntsync, and it should
not be possible to get into such an inconsistent state without gross
misconfiguration.
* Similarly, no diagnostic messages are provided to note that ntsync is in use,
or not in use. These messages are part of esync/fsync, as well as part of
ntsync "testing" trees unofficially distributed. However, if ntsync is working
correctly, no message should be necessary.
The basic structure is:
* Each type of server object which can be waited on by the client (including
events, semaphores, mutexes, but also other types such as processes, files)
must store an "inproc_sync" object.
This "inproc_sync" object is a full server object (note that this differs from
esync/fsync). A vector and server request is introduced to retrieve an NT
handle to this object from an arbitrary NT handle.
Since the actual ntsync objects are simply distinct file descriptions, we then
call get_handle_fd from the client to retrieve an fd to the object, and then
perform ioctls on it.
* Objects signaled by the server (processes, files, etc) perform ntsync ioctls
on that object. The backing object in all such cases is simply an event.
* Signal and wait operations on the client side attempt to defer to an
"inproc_\*" function, falling back to the server implementation if it returns
STATUS_NOT_IMPLEMENTED. This mirrors how in-process synchronization objects
(critical sections, SRW locks, etc) used to be implemented—attempting to use
an architecture-specific "fast_\*" function and falling back if it returned
STATUS_NOT_IMPLEMENTED.
* The inproc_sync handles, once retrieved, are cached per-process. This caching
takes a similar form to the fd cache. It does not reuse the same
infrastructure, however.
The primary reason for this is that the fd cache is designed to fit within a
64-bit value and uses 64-bit atomic operations to ensure consistency. However,
we need to store more than 64 bits of information. [We also need to modify
them after caching, in order to correctly implement handle closing—see below.]
The secondary reason is that retrieving the ntsync fd from the inproc_sync
handle itself uses the fd cache.
* In order to keep the Linux driver simple, it does not implement access flags
(EVENT_MODIFY_STATE etc.) Instead, the flags are cached locally and validated
there. This too mirrors the fd cache. Note that this means that a malicious
process can now modify objects it should not be able modify—which is less true
than it is with wineserver—but this is no different from the way other objects
(notably fds) are handled, and would require manual syscalls.
* In order to achieve correct behaviour related to closing objects while they
are used, this patch set essentially relies on refcounting. This is broadly
true of the server as well, but because we need to avoid server calls when
performing object operations, significantly more care must be taken.
In particular, because waits need to be interruptable by signals and then be
restarted, we need the backing ntsync object to remain valid until all users
are done with it. On a process level, this is achieved by letting multiple
processes own handles to the underlying inproc_sync server object.
On a thread level, multiple simultaneous calls need to refcount the process's
local handle. This refcount is stored in the sync object cache. When it
reaches zero, the cache is cleared.
Punting this behaviour to the Linux driver would have introduced a great deal
more complexity, which is best kept in userspace and out of the kernel.
* The cache is, as such, treated as a cache. The penultimate commit, which
introduces client support but does not yet cache the objects, effectively
illustrates this by never actually caching anything, and retrieving a new NT
handle and fd every time.
* Certain waits, on internal handles (such as async, startup_info, completion),
are delegated to the server even when ntsync is used. Those server objects do
not create an underlying ntsync object.
--
v2: ntdll: Cache in-process synchronization objects.
ntdll: Use server_wait_for_object() when waiting on only the queue object.
ntdll: Use in-process synchronization objects.
ntdll: Add some traces to synchronization methods.
ntdll: Introduce a helper to wait on an internal server handle.
server: Allow creating an event object for client-side user APC signaling.
server: Introduce select_inproc_queue and unselect_inproc_queue requests.
server: Add a request to retrieve the in-process synchronization object from a handle.
server: Add a request to retrieve the in-process synchronization device.
server: Create in-process synchronization objects for fd-based objects.
server: Create in-process synchronization objects for timers.
server: Create in-process synchronization objects for threads.
server: Create in-process synchronization objects for message queues.
server: Create in-process synchronization objects for jobs.
server: Create in-process synchronization objects for processes.
server: Create in-process synchronization objects for keyed events.
server: Create in-process synchronization objects for device managers.
server: Create in-process synchronization objects for debug objects.
server: Create in-process synchronization objects for console servers.
server: Create in-process synchronization objects for consoles.
server: Create in-process synchronization objects for completion ports.
server: Create in-process synchronization objects for mutexes.
server: Create in-process synchronization objects for semaphores.
server: Create in-process synchronization objects for events.
server: Add an object operation to retrieve an in-process synchronization object.
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7226
On Mon Feb 10 20:30:31 2025 +0000, Jacek Caban wrote:
> Sorry for not noticing it later, but looking at oleaut32 code, I think
> that we should iterate `data` pointer from 0 index here. I fixed that,
> changed a bit the style to be more consistent with vbscipt and created
> !7304. I hope it's fine for you. Thanks!
Sure. Anything that pushes this through is ok by me.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7052#note_94181
Jacek Caban (@jacek) commented about dlls/vbscript/global.c:
> +
> + hres = SafeArrayAccessData(sa, (void**)&data);
> + if (FAILED(hres))
> + goto cleanup;
> +
> + str_array = (BSTR *)malloc((ubound - lbound + 1) * sizeof(BSTR));
> + if (!str_array) {
> + hres = E_OUTOFMEMORY;
> + goto cleanup_data;
> + }
> + free_str_array = (BSTR *)calloc((ubound - lbound + 1), sizeof(BSTR));
> + if (!free_str_array) {
> + hres = E_OUTOFMEMORY;
> + goto cleanup_data;
> + }
> + for (i = lbound; i <= ubound; i++) {
Sorry for not noticing it later, but looking at oleaut32 code, I think that we should iterate `data` pointer from 0 index here. I fixed that, changed a bit the style to be more consistent with vbscipt and created !7304. I hope it's fine for you. Thanks!
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7052#note_94179
Fixes long uptimes causing Parkan: Iron Strategy to hang shortly after
starting a mission and laggy arrows in GTA San Andreas lowrider
challenge. The games seem to not like low values either so add a 5
minute offset to the counter.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7299
--
v2: windowscodecs: Implement IWICBitmapFlipRotator(WICBitmapTransformRotate90) for bitmaps with bpp >= 8.
windowscodecs: Implement IWICBitmapFlipRotator(WICBitmapTransformFlipHorizontal) for bitmaps with bpp >= 8.
windowscodecs/tests: Add some tests for IWICBitmapFlipRotator.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7211
Startup and lock counts in native Windows are separate, and the lock count does not decrease when an async result is freed if the platform has been started.
--
v4: rtworkq: Introduce an async result object cache.
rtworkq: Introduce a platform startup count.
rtworkq/tests: Test work queue.
mfplat/tests: Test platform startup and lock counts.
mfplat/tests: Test mixing of MF platform functions with their Rtwq equivalents.
mfplat/tests: Introduce a helper to check the platform lock count.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7174