Commit graph

180 commits

Author SHA1 Message Date
Connor McAdams
a42f5f1970 combase: Use correct destination context in CoUnmarshalInterface when using the standard marshaler.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54609
Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
2023-07-13 11:51:47 +02:00
Alexandre Julliard
420a7d0604 combase: Use nameless union/structs. 2023-07-05 17:03:30 +02:00
Alistair Leslie-Hughes
5312580a57 combase: Remove DECLSPEC_HIDDEN usage. 2023-07-05 11:19:15 +02:00
Alex Henrie
f4a8ad89d4 include: Introduce wine_dbgstr_hstring and debugstr_hstring. 2023-07-04 21:25:03 +02:00
Alex Henrie
f9785543a8 combase: Don't export hProxyDll or rpc_execute_call. 2023-06-19 13:15:31 +02:00
Jinoh Kang
e308b19ac8 combase: Prevent use-after-free due to a race with proxy_manager_destroy.
Today, find_proxy_manager() may return a proxy manager that is about to
be freed.  This happens when the proxy manager's reference count reaches
zero, but proxy_manager_destroy() has not removed the proxy manager from
the apartment proxy list.

Fix this by incrementing the reference count only if it is already
nonzero.  If the reference count is zero, any reference to the proxy
manager will become invalid after the current thread leaves the critical
section (apt->cs).  This is because proxy_manager_destroy() will proceed
to destroy the proxy manager after the apartment lock (apt->cs) is
released.

An alternative solution would be to prevent find_proxy_manager from
observing the zero reference count in the first place.  Multiple
approaches have been considered for implementing this solution, but were
eventually dropped due to several disadvantages when applied to the
current Wine codebase:

1. Always acquire the apartment lock from the proxy manager's Release()
   method, and hold the lock until the proxy manager is completely
   removed from the list if the reference count drops to zero.

   This requires handling the special case when the proxy manager's
   parent apartment has been destroyed.  When an apartment is destroyed,
   it sets the `parent` field of each proxy manager that was previously
   owned by the apartment to NULL.  This means that each access to
   `This->parent->cs` has to be guarded by a NULL check for
   `This->parent`.

   Even if `parent` were never NULL, unconditionally acquiring a lock
   may unnecessarily block the subroutine and introduce contention.

2. Opportunistically decrement the reference count without holding the
   lock, but only if the count is greater than 1.  This approach is
   still not free from the NULL parent apartment problem.

3. Check for any concurrent reference count change from
   proxy_manager_destroy(), and bail out if such change has occurred.
   This makes it possible for the proxy manager's AddRef() method to
   return 1, which is unusual.
2023-05-18 05:27:44 -05:00
Jinoh Kang
f55f0b8342 combase: Compare AddRef() return value against 1 instead of 0 in find_proxy_manager.
Today, find_proxy_manager() tests if AddRef() returns 0 in an attempt to
protect against a race condition bug.

Note that AddRef does not return zero in normal circumstances, since
AddRef returns the reference count after the increment, not before.

Fix this by comparing the return value of AddRef() against 1, not 0.
2023-05-18 05:27:41 -05:00
Jinoh Kang
d54e7cd51d combase: Fix reading from beyond the end of a HGLOBAL stream. 2023-05-15 11:26:12 -05:00
Connor McAdams
8d11327ecf combase: Check that process ID matches before searching the MTA for a stub manager.
Now that MTA objects across processes share a value of 0 in the Data2
field of the stub manager IPID, make sure that we only search the MTA
for stub managers that reside in the current process.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
2023-05-08 20:01:10 +02:00
Alex Henrie
5a1d2dde3b combase: Avoid calling RtlInitUnicodeString on a static constant. 2023-02-07 17:46:14 +01:00
Alexandre Julliard
3de15569fe include: Use proper dllimports for OLE functions. 2022-12-07 13:51:37 +01:00
Connor McAdams
00c8117a72 combase: Omit thread ID from the stub manager ipid for MTA objects.
It is possible for a thread that creates an MTA to call
CoUninitialize() and not destroy the MTA if another thread has
entered the MTA in the meantime. If the original thread then creates
an STA, subsequent attempts to find the MTA with 'apartment_findfromtid'
will get the original thread's STA. To avoid this, don't set a TID value
in the stub manager IPID value to indicate that the stub resides in the
MTA.

Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
2022-08-30 21:38:39 +02:00
Dmitry Timoshkov
3c9720f4a6 combase: Execute local server for correct architecture in a WoW64 setup.
Based on implementation of create_surrogate_server().

This patch makes 64-bit application work with its own shipped 32-bit COM server.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-04 23:33:23 +02:00
Dmitry Timoshkov
9ba69dce36 combase: Use file system redirection path only for an opposite architecture in a WoW64 setup.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-07-04 23:33:23 +02:00
Rémi Bernon
ea0fa9f1dc combase: Lookup activatable class library in the activation context.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-20 12:24:38 +02:00
Rémi Bernon
9d1beee6c7 combase: Use CRT memory allocation functions.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-20 12:24:38 +02:00
Eric Pouech
b7f839e583 combase: Use I64 width modifier for 64-bit integers.
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-11 10:12:05 +02:00
Rémi Bernon
ee7eaca877 combase/tests: Add some RoGetActivationFactory tests with manifest.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-07 22:44:39 +02:00
Huw Davies
2192f2de1b combase: Don't start dllhost if the CLSID key doesn't exist.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-06 23:07:20 +02:00
Dmitry Timoshkov
13064f9914 combase: Execute dllhost.exe for correct architecture in a WoW64 setup.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-16 21:16:21 +01:00
Dmitry Timoshkov
cd2904fa1a combase: Make ProgIDFromCLSID() work in WoW64 setup.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-16 21:16:21 +01:00
Dmitry Timoshkov
f0461bb165 combase: Always pass explicit access to the registry helpers.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-16 21:16:21 +01:00
Dmitry Timoshkov
f9cd4c915f combase: Start surrogate local server when required.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=20296
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-10 18:27:43 +01:00
Matteo Bruni
430583893e combase: Add RoSetErrorReportingFlags() stub.
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-02 20:17:25 +01:00
Nikolay Sivov
a3b8fbc24f combase/tests: Build without -DWINE_NO_LONG_TYPES.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-11 10:57:17 +01:00
Nikolay Sivov
652aef3007 combase: Build without WINE_NO_LONG_TYPES.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-08 20:24:15 +01:00
Alexandre Julliard
f0cd33c69e include: Add support for defining Win32 types as 'long' where possible.
Add -DWINE_NO_LONG_TYPES to modules that still have compilation
warnings with long types.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-27 20:38:22 +01:00
Bernhard Kölbl
ba9737ba82 combase: Reorder hstring_private elements.
Put the string buffer at the end of the struct to
match the Windows behaviour and avoid unnecessary
pointer arithmetic.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51017
Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 21:53:56 +01:00
Bernhard Kölbl
369e4e3609 combase: Add padding and string reference pointer to hstring_header.
Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 21:53:56 +01:00
Bernhard Kölbl
f7609ac2e6 combase: Move length from hstring_private to hstring_header.
Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 21:53:56 +01:00
Bernhard Kölbl
059795be42 combase: Introduce a hstring_header struct to hstring_private.
Also move the reference flag to the hstring_header struct.

Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 21:53:56 +01:00
Bernhard Kölbl
d372fdfd7d combase/tests: Add tests for the hstring_private struct.
The goal of these tests is to show, that the memory layout
of hstring_private is different on Windows, than currently
used in Wine. This creates issues with the WinRT SDK, which
allocates HSTRINGs without using the functions provided by
the combase dll.

Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-26 21:53:56 +01:00
Louis Lenders
6b59b26fff combase: Add stub for RoOriginateError.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51983
Signed-off-by: Louis Lenders <xerox.xerox2000x@gmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-11 18:39:48 +01:00
Nikolay Sivov
ecd8fdfb38 combase: Clarify stream data format used by FT marshaler.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-29 09:24:54 +02:00
Alexandre Julliard
088a787a2c makefiles: Make -mno-cygwin the default.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-20 22:45:48 +02:00
Dmitry Timoshkov
b4da140357 combase: When looking up an apartment which has a given creator thread ID use multi-threaded apartment only if the thread doesn't have an apartment-threaded one.
CoIncrementMTAUsage() always creates the MTA if it doesn't already exist,
and mta->tid may accidently match the apt->tid of the apartment-threaded
apartment of the thread.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-06 19:56:59 +02:00
Jacek Caban
a2f6ddeedd combase: Add CoDecodeProxy stub.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-07-29 10:20:24 +02:00
Zebediah Figura
141c182e4b combase/tests: Link directly to combase.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-15 17:41:40 +02:00
Nikolay Sivov
d63ed91c28 combase: Return initial values for global options.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-04-01 18:18:59 +02:00
Nikolay Sivov
c1cb171315 combase: Move IGlobalOptions implementation.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-31 22:16:25 +02:00
Jacek Caban
49b97bad94 combase: Use nameless unions.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-23 09:31:36 +01:00
Jacek Caban
b39b9eea39 include: Don't default to WINE_NO_NAMELESS_EXTENSION for Wine build.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-22 21:48:38 +01:00
Rémi Bernon
3c502f40c4 windows.media.speech: Add stub dll.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-03-15 22:22:13 +01:00
Nikolay Sivov
7cae17c134 combase: Update thread flags when entering/leaving apartments.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-19 21:23:22 +01:00
Nikolay Sivov
ffce592cc3 combase: Set a flag on thread id initialization.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-11-19 21:23:22 +01:00
Michael Stefaniuc
4c4ac8a987 combase/tests: Use wide-char string literals.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-10-05 12:33:31 +02:00
Michael Stefaniuc
e2ac51d89e combase: Use wide-char string literals.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-10-05 12:33:31 +02:00
Nikolay Sivov
4b8756e0b4 combase: Remove dead assignment (Coverity).
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-30 15:50:46 +02:00
Nikolay Sivov
609c311a81 combase: Manage per-thread call cancellation counter.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-16 17:13:50 +02:00
Nikolay Sivov
5466a3dccf combase: Use public symbol for special PS context flag.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-09-15 09:48:45 +02:00