Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
For Chromimum issues reported as https://bugs.winehq.org/show_bug.cgi?id=50149. Flags names are taken from dotnet/coreclr headers.
dlls/combase/combase.c | 3 ++ dlls/combase/combase_private.h | 7 ++- dlls/ole32/tests/compobj.c | 96 ++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index 7a85b95a19b..72ff6cc31f9 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -2547,7 +2547,10 @@ HRESULT WINAPI CoGetCurrentLogicalThreadId(GUID *id) return hr;
if (IsEqualGUID(&tlsdata->causality_id, &GUID_NULL)) + { CoCreateGuid(&tlsdata->causality_id); + tlsdata->flags |= OLETLS_UUIDINITIALIZED; + }
*id = tlsdata->causality_id;
diff --git a/dlls/combase/combase_private.h b/dlls/combase/combase_private.h index 55ce02d06f0..4ff46077b45 100644 --- a/dlls/combase/combase_private.h +++ b/dlls/combase/combase_private.h @@ -63,13 +63,18 @@ HRESULT open_appidkey_from_clsid(REFCLSID clsid, REGSAM access, HKEY *subkey) DE
#define CHARS_IN_GUID 39
+enum tlsdataflags +{ + OLETLS_UUIDINITIALIZED = 0x2, +}; + /* this is what is stored in TEB->ReservedForOle */ struct tlsdata { struct apartment *apt; IErrorInfo *errorinfo; DWORD thread_seqid;/* returned with CoGetCurrentProcess */ - DWORD apt_mask; /* apartment mask (+0Ch on x86) */ + DWORD flags; /* apartment mask (+0Ch on x86) */ void *unknown0; DWORD inits; /* number of times CoInitializeEx called */ DWORD ole_inits; /* number of times OleInitialize called */ diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index 0d7f3d8adee..c79e379f92a 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -36,6 +36,7 @@ #include "ctxtcall.h"
#include "wine/test.h" +#include "winternl.h" #include "initguid.h"
#define DEFINE_EXPECT(func) \ @@ -4245,6 +4246,100 @@ static void test_call_cancellation(void) ok(hr == CO_E_CANCEL_DISABLED, "Unexpected hr %#x.\n", hr); }
+enum oletlsflags +{ + OLETLS_UUIDINITIALIZED = 0x2, + OLETLS_DISABLE_OLE1DDE = 0x40, + OLETLS_APARTMENTTHREADED = 0x80, + OLETLS_MULTITHREADED = 0x100, +}; + +struct oletlsdata +{ + void *threadbase; + void *smallocator; + DWORD id; + DWORD flags; +}; + +static DWORD get_oletlsflags(void) +{ + struct oletlsdata *data = NtCurrentTeb()->ReservedForOle; + return data ? data->flags : 0; +} + +static DWORD CALLBACK oletlsdata_test_thread(void *arg) +{ + IUnknown *unk; + DWORD flags; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_InternetZoneManager, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IUnknown_Release(unk); + + /* Flag is not set for implicit MTA. */ + flags = get_oletlsflags(); + ok(!(flags & OLETLS_MULTITHREADED), "Unexpected flags %#x.\n", flags); + + return 0; +} + +static void test_oletlsdata(void) +{ + HANDLE thread; + DWORD flags; + HRESULT hr; + GUID guid; + + /* STA */ + hr = CoInitialize(NULL); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + flags = get_oletlsflags(); +todo_wine + ok(flags & OLETLS_APARTMENTTHREADED && !(flags & OLETLS_DISABLE_OLE1DDE), "Unexpected flags %#x.\n", flags); + CoUninitialize(); + flags = get_oletlsflags(); + ok(!(flags & (OLETLS_APARTMENTTHREADED | OLETLS_MULTITHREADED | OLETLS_DISABLE_OLE1DDE)), "Unexpected flags %#x.\n", flags); + + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + flags = get_oletlsflags(); +todo_wine + ok(flags & OLETLS_APARTMENTTHREADED && flags & OLETLS_DISABLE_OLE1DDE, "Unexpected flags %#x.\n", flags); + CoUninitialize(); + flags = get_oletlsflags(); + ok(!(flags & (OLETLS_APARTMENTTHREADED | OLETLS_MULTITHREADED | OLETLS_DISABLE_OLE1DDE)), "Unexpected flags %#x.\n", flags); + + /* MTA */ + hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + flags = get_oletlsflags(); +todo_wine + ok(flags & OLETLS_MULTITHREADED && flags & OLETLS_DISABLE_OLE1DDE, "Unexpected flags %#x.\n", flags); + + /* Implicit case. */ + thread = CreateThread(NULL, 0, oletlsdata_test_thread, NULL, 0, &flags); + ok(thread != NULL, "Failed to create a test thread, error %d.\n", GetLastError()); + ok(!WaitForSingleObject(thread, 5000), "Wait timed out.\n"); + CloseHandle(thread); + + CoUninitialize(); + flags = get_oletlsflags(); + ok(!(flags & (OLETLS_APARTMENTTHREADED | OLETLS_MULTITHREADED | OLETLS_DISABLE_OLE1DDE)), "Unexpected flags %#x.\n", flags); + + /* Thread ID. */ + flags = get_oletlsflags(); + ok(!(flags & OLETLS_UUIDINITIALIZED), "Unexpected flags %#x.\n", flags); + + hr = CoGetCurrentLogicalThreadId(&guid); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + flags = get_oletlsflags(); + ok(flags & OLETLS_UUIDINITIALIZED && !(flags & (OLETLS_APARTMENTTHREADED | OLETLS_MULTITHREADED)), + "Unexpected flags %#x.\n", flags); +} + START_TEST(compobj) { init_funcs(); @@ -4254,6 +4349,7 @@ START_TEST(compobj) lstrcatA(testlib, "\testlib.dll"); extract_resource("testlib.dll", "TESTDLL", testlib);
+ test_oletlsdata(); test_ProgIDFromCLSID(); test_CLSIDFromProgID(); test_CLSIDFromString();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/apartment.c | 10 +++++++++- dlls/combase/combase_private.h | 3 +++ dlls/ole32/tests/compobj.c | 3 --- 3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/dlls/combase/apartment.c b/dlls/combase/apartment.c index 1181e393ada..108d6a71c5c 100644 --- a/dlls/combase/apartment.c +++ b/dlls/combase/apartment.c @@ -556,6 +556,8 @@ static struct apartment *apartment_get_or_create(DWORD model)
if (!apt) { + com_get_tlsdata(&data); + if (model & COINIT_APARTMENTTHREADED) { EnterCriticalSection(&apt_cs); @@ -568,6 +570,10 @@ static struct apartment *apartment_get_or_create(DWORD model) TRACE("Created main-threaded apartment with OXID %s\n", wine_dbgstr_longlong(apt->oxid)); }
+ data->flags |= OLETLS_APARTMENTTHREADED; + if (model & COINIT_DISABLE_OLE1DDE) + data->flags |= OLETLS_DISABLE_OLE1DDE; + LeaveCriticalSection(&apt_cs);
if (apt->main) @@ -588,11 +594,12 @@ static struct apartment *apartment_get_or_create(DWORD model) else mta = apartment_construct(model);
+ data->flags |= OLETLS_MULTITHREADED | OLETLS_DISABLE_OLE1DDE; + apt = mta;
LeaveCriticalSection(&apt_cs); } - com_get_tlsdata(&data); data->apt = apt; }
@@ -1146,6 +1153,7 @@ void leave_apartment(struct tlsdata *data) WARN( "Uninitializing apartment while Ole is still initialized\n" ); apartment_release(data->apt); data->apt = NULL; + data->flags &= ~(OLETLS_DISABLE_OLE1DDE | OLETLS_APARTMENTTHREADED | OLETLS_MULTITHREADED); } }
diff --git a/dlls/combase/combase_private.h b/dlls/combase/combase_private.h index 4ff46077b45..586ad965363 100644 --- a/dlls/combase/combase_private.h +++ b/dlls/combase/combase_private.h @@ -66,6 +66,9 @@ HRESULT open_appidkey_from_clsid(REFCLSID clsid, REGSAM access, HKEY *subkey) DE enum tlsdataflags { OLETLS_UUIDINITIALIZED = 0x2, + OLETLS_DISABLE_OLE1DDE = 0x40, + OLETLS_APARTMENTTHREADED = 0x80, + OLETLS_MULTITHREADED = 0x100, };
/* this is what is stored in TEB->ReservedForOle */ diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index c79e379f92a..5d44cd5a0ba 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -4296,7 +4296,6 @@ static void test_oletlsdata(void) hr = CoInitialize(NULL); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); flags = get_oletlsflags(); -todo_wine ok(flags & OLETLS_APARTMENTTHREADED && !(flags & OLETLS_DISABLE_OLE1DDE), "Unexpected flags %#x.\n", flags); CoUninitialize(); flags = get_oletlsflags(); @@ -4305,7 +4304,6 @@ todo_wine hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); flags = get_oletlsflags(); -todo_wine ok(flags & OLETLS_APARTMENTTHREADED && flags & OLETLS_DISABLE_OLE1DDE, "Unexpected flags %#x.\n", flags); CoUninitialize(); flags = get_oletlsflags(); @@ -4315,7 +4313,6 @@ todo_wine hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); flags = get_oletlsflags(); -todo_wine ok(flags & OLETLS_MULTITHREADED && flags & OLETLS_DISABLE_OLE1DDE, "Unexpected flags %#x.\n", flags);
/* Implicit case. */
On 18 Nov 2020, at 08:03, Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
For Chromimum issues reported as https://bugs.winehq.org/show_bug.cgi?id=50149. Flags names are taken from dotnet/coreclr headers.
dlls/combase/combase.c | 3 ++ dlls/combase/combase_private.h | 7 ++- dlls/ole32/tests/compobj.c | 96 ++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-)
Hi Nikolay,
I've sent in a v2 that also fixed up the name in ole32's copy of struct tlsdata.
Huw.