Module: wine
Branch: master
Commit: 6153eefcbaff492bf08ed19dba5c7e1b4e94c5dc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6153eefcbaff492bf08ed19d…
Author: Nikolay Sivov <nsivov(a)codeweavers.com>
Date: Mon Aug 17 10:20:49 2020 +0300
combase: Add a function to allocate OLE thread data.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
dlls/combase/combase.c | 16 ++++++++++++++++
dlls/combase/combase.spec | 2 +-
dlls/combase/combase_private.h | 42 ++++++++++++++++++++++++++++++++++++++++++
dlls/ole32/compobj_private.h | 11 +++++------
4 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c
index 8d8d83005b..cceb36a593 100644
--- a/dlls/combase/combase.c
+++ b/dlls/combase/combase.c
@@ -27,6 +27,8 @@
#include "oleauto.h"
#include "winternl.h"
+#include "combase_private.h"
+
#include "wine/debug.h"
#include "wine/heap.h"
@@ -223,6 +225,20 @@ static HRESULT open_key_for_clsid(REFCLSID clsid, const WCHAR *keyname, REGSAM a
return S_OK;
}
+/***********************************************************************
+ * InternalTlsAllocData (combase.@)
+ */
+HRESULT WINAPI InternalTlsAllocData(struct tlsdata **data)
+{
+ if (!(*data = heap_alloc_zero(sizeof(**data))))
+ return E_OUTOFMEMORY;
+
+ list_init(&(*data)->spies);
+ NtCurrentTeb()->ReservedForOle = *data;
+
+ return S_OK;
+}
+
/***********************************************************************
* FreePropVariantArray (combase.@)
*/
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
index 0f34dc6918..1298fedd9e 100644
--- a/dlls/combase/combase.spec
+++ b/dlls/combase/combase.spec
@@ -274,7 +274,7 @@
@ stub InternalSetAptCallCtrlOnTlsIfRequired
@ stub InternalSetOleThunkWowPtr
@ stub InternalStubInvoke
-@ stub InternalTlsAllocData
+@ stdcall InternalTlsAllocData(ptr)
@ stub InternalUnmarshalObjRef
@ stub IsErrorPropagationEnabled
@ stub NdrExtStubInitialize
diff --git a/dlls/combase/combase_private.h b/dlls/combase/combase_private.h
new file mode 100644
index 0000000000..5ba9c84650
--- /dev/null
+++ b/dlls/combase/combase_private.h
@@ -0,0 +1,42 @@
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/list.h"
+
+struct apartment;
+
+/* 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) */
+ void *unknown0;
+ DWORD inits; /* number of times CoInitializeEx called */
+ DWORD ole_inits; /* number of times OleInitialize called */
+ GUID causality_id; /* unique identifier for each COM call */
+ LONG pending_call_count_client; /* number of client calls pending */
+ LONG pending_call_count_server; /* number of server calls pending */
+ DWORD unknown;
+ IObjContext *context_token; /* (+38h on x86) */
+ IUnknown *call_state; /* current call context (+3Ch on x86) */
+ DWORD unknown2[46];
+ IUnknown *cancel_object; /* cancel object set by CoSetCancelObject (+F8h on x86) */
+ IUnknown *state; /* see CoSetState */
+ struct list spies; /* Spies installed with CoRegisterInitializeSpy */
+ DWORD spies_lock;
+};
diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h
index b64dfbf4f4..5d7bf50b73 100644
--- a/dlls/ole32/compobj_private.h
+++ b/dlls/ole32/compobj_private.h
@@ -269,16 +269,15 @@ APARTMENT *apartment_get_current_or_mta(void) DECLSPEC_HIDDEN;
* Per-thread values are stored in the TEB on offset 0xF80
*/
+extern HRESULT WINAPI InternalTlsAllocData(struct oletls **tlsdata);
+
/* will create if necessary */
static inline struct oletls *COM_CurrentInfo(void)
{
+ struct oletls *oletls;
+
if (!NtCurrentTeb()->ReservedForOle)
- {
- struct oletls *oletls = heap_alloc_zero(sizeof(*oletls));
- if (oletls)
- list_init(&oletls->spies);
- NtCurrentTeb()->ReservedForOle = oletls;
- }
+ InternalTlsAllocData(&oletls);
return NtCurrentTeb()->ReservedForOle;
}