Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b46eafe3
Commit
b46eafe3
authored
Sep 12, 2023
by
Paul Gofman
Committed by
Alexandre Julliard
Nov 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
combase: Ensure MTA existence in RoGetActivationFactory().
parent
2f1b288a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
6 deletions
+48
-6
apartment.c
dlls/combase/apartment.c
+31
-0
combase.c
dlls/combase/combase.c
+3
-0
combase_private.h
dlls/combase/combase_private.h
+2
-0
roapi.c
dlls/combase/roapi.c
+5
-0
roapi.c
dlls/combase/tests/roapi.c
+6
-6
compobj_private.h
dlls/ole32/compobj_private.h
+1
-0
No files found.
dlls/combase/apartment.c
View file @
b46eafe3
...
...
@@ -1157,6 +1157,11 @@ void leave_apartment(struct tlsdata *data)
if
(
data
->
ole_inits
)
WARN
(
"Uninitializing apartment while Ole is still initialized
\n
"
);
apartment_release
(
data
->
apt
);
if
(
data
->
implicit_mta_cookie
)
{
apartment_decrement_mta_usage
(
data
->
implicit_mta_cookie
);
data
->
implicit_mta_cookie
=
NULL
;
}
data
->
apt
=
NULL
;
data
->
flags
&=
~
(
OLETLS_DISABLE_OLE1DDE
|
OLETLS_APARTMENTTHREADED
|
OLETLS_MULTITHREADED
);
}
...
...
@@ -1288,3 +1293,29 @@ void apartment_global_cleanup(void)
apartment_release_dlls
();
DeleteCriticalSection
(
&
apt_cs
);
}
HRESULT
ensure_mta
(
void
)
{
struct
apartment
*
apt
;
struct
tlsdata
*
data
;
HRESULT
hr
;
if
(
FAILED
(
hr
=
com_get_tlsdata
(
&
data
)))
return
hr
;
if
((
apt
=
data
->
apt
)
&&
(
data
->
implicit_mta_cookie
||
apt
->
multi_threaded
))
return
S_OK
;
EnterCriticalSection
(
&
apt_cs
);
if
(
apt
||
mta
)
hr
=
apartment_increment_mta_usage
(
&
data
->
implicit_mta_cookie
);
else
hr
=
CO_E_NOTINITIALIZED
;
LeaveCriticalSection
(
&
apt_cs
);
if
(
FAILED
(
hr
))
{
ERR
(
"Failed, hr %#lx.
\n
"
,
hr
);
return
hr
;
}
return
S_OK
;
}
dlls/combase/combase.c
View file @
b46eafe3
...
...
@@ -407,6 +407,9 @@ static void com_cleanup_tlsdata(void)
if
(
tlsdata
->
apt
)
apartment_release
(
tlsdata
->
apt
);
if
(
tlsdata
->
implicit_mta_cookie
)
apartment_decrement_mta_usage
(
tlsdata
->
implicit_mta_cookie
);
if
(
tlsdata
->
errorinfo
)
IErrorInfo_Release
(
tlsdata
->
errorinfo
);
if
(
tlsdata
->
state
)
...
...
dlls/combase/combase_private.h
View file @
b46eafe3
...
...
@@ -92,6 +92,7 @@ struct tlsdata
struct
list
spies
;
/* Spies installed with CoRegisterInitializeSpy */
DWORD
spies_lock
;
DWORD
cancelcount
;
CO_MTA_USAGE_COOKIE
implicit_mta_cookie
;
/* mta referenced by roapi from sta thread */
};
extern
HRESULT
WINAPI
InternalTlsAllocData
(
struct
tlsdata
**
data
);
...
...
@@ -161,6 +162,7 @@ void apartment_release(struct apartment *apt);
struct
apartment
*
apartment_get_current_or_mta
(
void
);
HRESULT
apartment_increment_mta_usage
(
CO_MTA_USAGE_COOKIE
*
cookie
);
void
apartment_decrement_mta_usage
(
CO_MTA_USAGE_COOKIE
cookie
);
HRESULT
ensure_mta
(
void
);
struct
apartment
*
apartment_get_mta
(
void
);
HRESULT
apartment_get_inproc_class_object
(
struct
apartment
*
apt
,
const
struct
class_reg_data
*
regdata
,
REFCLSID
rclsid
,
REFIID
riid
,
DWORD
class_context
,
void
**
ppv
);
...
...
dlls/combase/roapi.c
View file @
b46eafe3
...
...
@@ -24,6 +24,8 @@
#include "roerrorapi.h"
#include "winstring.h"
#include "combase_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
combase
);
...
...
@@ -154,6 +156,9 @@ HRESULT WINAPI RoGetActivationFactory(HSTRING classid, REFIID iid, void **class_
if
(
!
iid
||
!
class_factory
)
return
E_INVALIDARG
;
if
(
FAILED
(
hr
=
ensure_mta
()))
return
hr
;
hr
=
get_library_for_classid
(
WindowsGetStringRawBuffer
(
classid
,
NULL
),
&
library
);
if
(
FAILED
(
hr
))
{
...
...
dlls/combase/tests/roapi.c
View file @
b46eafe3
...
...
@@ -211,7 +211,7 @@ static void test_implicit_mta(void)
ok
(
hr
==
S_OK
,
"got %#lx.
\n
"
,
hr
);
/* RoGetActivationFactory doesn't implicitly initialize COM. */
hr
=
RoGetActivationFactory
(
str
,
&
IID_IActivationFactory
,
(
void
**
)
&
factory
);
todo_wine
ok
(
hr
==
CO_E_NOTINITIALIZED
,
"got %#lx.
\n
"
,
hr
);
ok
(
hr
==
CO_E_NOTINITIALIZED
,
"got %#lx.
\n
"
,
hr
);
check_thread_apartment
(
CO_E_NOTINITIALIZED
);
...
...
@@ -227,10 +227,10 @@ static void test_implicit_mta(void)
check_thread_apartment
(
tests
[
i
].
mta
?
S_OK
:
CO_E_NOTINITIALIZED
);
hr
=
RoGetActivationFactory
(
str
,
&
IID_IActivationFactory
,
(
void
**
)
&
factory
);
ok
(
hr
==
REGDB_E_CLASSNOTREG
,
"got %#lx.
\n
"
,
hr
);
todo_wine_if
(
!
tests
[
i
].
mta
)
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
hr
=
RoGetActivationFactory
(
str
,
&
IID_IActivationFactory
,
(
void
**
)
&
factory
);
ok
(
hr
==
REGDB_E_CLASSNOTREG
,
"got %#lx.
\n
"
,
hr
);
todo_wine_if
(
!
tests
[
i
].
mta
)
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
if
(
tests
[
i
].
ro_init
)
RoUninitialize
();
else
...
...
@@ -270,7 +270,7 @@ static void test_implicit_mta(void)
SetEvent
(
mta_init_thread_done_event
);
WaitForSingleObject
(
thread
,
INFINITE
);
CloseHandle
(
thread
);
todo_wine
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
CoUninitialize
();
check_thread_apartment
(
CO_E_NOTINITIALIZED
);
...
...
@@ -292,7 +292,7 @@ static void test_implicit_mta(void)
SetEvent
(
mta_init_thread_done_event
);
WaitForSingleObject
(
thread
,
INFINITE
);
CloseHandle
(
thread
);
todo_wine
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
CoUninitialize
();
check_thread_apartment
(
CO_E_NOTINITIALIZED
);
...
...
@@ -300,7 +300,7 @@ static void test_implicit_mta(void)
thread
=
CreateThread
(
NULL
,
0
,
mta_init_implicit_thread
,
NULL
,
0
,
NULL
);
ok
(
!!
thread
,
"failed.
\n
"
);
WaitForSingleObject
(
mta_init_thread_init_done_event
,
INFINITE
);
todo_wine
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
check_thread_apartment_broken
(
S_OK
);
/* Broken on Win8. */
SetEvent
(
mta_init_thread_done_event
);
WaitForSingleObject
(
thread
,
INFINITE
);
CloseHandle
(
thread
);
...
...
dlls/ole32/compobj_private.h
View file @
b46eafe3
...
...
@@ -63,6 +63,7 @@ struct oletls
struct
list
spies
;
/* Spies installed with CoRegisterInitializeSpy */
DWORD
spies_lock
;
DWORD
cancelcount
;
CO_MTA_USAGE_COOKIE
implicit_mta_cookie
;
/* mta referenced by roapi from sta thread */
};
/* Global Interface Table Functions */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment