|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | | -//+--------------------------------------------------------------------------- |
4 | | -// |
5 | | -// File: oletls.h |
6 | | -// |
7 | | - |
8 | | -// |
9 | | -// Purpose: manage thread local storage for OLE |
10 | | -// |
11 | | -// Notes: The gTlsIndex is initialized at process attach time. |
12 | | -// The per-thread data is allocated in CoInitialize in |
13 | | -// single-threaded apartments or on first use in |
14 | | -// multi-threaded apartments. |
15 | | -// |
16 | | -//---------------------------------------------------------------------------- |
17 | 3 |
|
18 | 4 | #ifndef _OLETLS_H_ |
19 | 5 | #define _OLETLS_H_ |
|
22 | 8 | #error FEATURE_COMINTEROP_APARTMENT_SUPPORT is required for this file |
23 | 9 | #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT |
24 | 10 |
|
25 | | -//+--------------------------------------------------------------------------- |
26 | | -// |
27 | | -// forward declarations (in order to avoid type casting when accessing |
28 | | -// data members of the SOleTlsData structure). |
29 | | -// |
30 | | -//+--------------------------------------------------------------------------- |
31 | | - |
32 | | -class CAptCallCtrl; // see callctrl.hxx |
33 | | -class CSrvCallState; // see callctrl.hxx |
34 | | -class CObjServer; // see sobjact.hxx |
35 | | -class CSmAllocator; // see stg\h\smalloc.hxx |
36 | | -class CMessageCall; // see call.hxx |
37 | | -class CClientCall; // see call.hxx |
38 | | -class CAsyncCall; // see call.hxx |
39 | | -class CClipDataObject; // see ole232\clipbrd\clipdata.h |
40 | | -class CSurrogatedObjectList; // see com\inc\comsrgt.hxx |
41 | | -class CCtxCall; // see PSTable.hxx |
42 | | -class CPolicySet; // see PSTable.hxx |
43 | | -class CObjectContext; // see context.hxx |
44 | | -class CComApartment; // see aprtmnt.hxx |
45 | | - |
46 | | -//+------------------------------------------------------------------- |
47 | | -// |
48 | | -// Struct: CallEntry |
49 | | -// |
50 | | -// Synopsis: Call Table Entry. |
51 | | -// |
52 | | -//+------------------------------------------------------------------- |
53 | | -typedef struct tagCallEntry |
54 | | -{ |
55 | | - void *pNext; // ptr to next entry |
56 | | - void *pvObject; // Entry object |
57 | | -} CallEntry; |
58 | | - |
59 | | - |
60 | | - |
61 | | -//+--------------------------------------------------------------------------- |
62 | | -// |
63 | | -// Enum: OLETLSFLAGS |
64 | | -// |
65 | | -// Synopsys: bit values for dwFlags field of SOleTlsData. If you just want |
66 | | -// to store a BOOL in TLS, use this enum and the dwFlag field. |
67 | | -// |
68 | | -//+--------------------------------------------------------------------------- |
69 | | -typedef enum tagOLETLSFLAGS |
70 | | -{ |
71 | | - OLETLS_LOCALTID = 0x01, // This TID is in the current process. |
72 | | - OLETLS_UUIDINITIALIZED = 0x02, // This Logical thread is init'd. |
73 | | - OLETLS_INTHREADDETACH = 0x04, // This is in thread detach. Needed |
74 | | - // due to NT's special thread detach |
75 | | - // rules. |
76 | | - OLETLS_CHANNELTHREADINITIALZED = 0x08,// This channel has been init'd |
77 | | - OLETLS_WOWTHREAD = 0x10, // This thread is a 16-bit WOW thread. |
78 | | - OLETLS_THREADUNINITIALIZING = 0x20, // This thread is in CoUninitialize. |
79 | | - OLETLS_DISABLE_OLE1DDE = 0x40, // This thread can't use a DDE window. |
80 | | - OLETLS_APARTMENTTHREADED = 0x80, // This is an STA apartment thread |
81 | | - OLETLS_MULTITHREADED = 0x100, // This is an MTA apartment thread |
82 | | - OLETLS_IMPERSONATING = 0x200, // This thread is impersonating |
83 | | - OLETLS_DISABLE_EVENTLOGGER = 0x400, // Prevent recursion in event logger |
84 | | - OLETLS_INNEUTRALAPT = 0x800, // This thread is in the NTA |
85 | | - OLETLS_DISPATCHTHREAD = 0x1000, // This is a dispatch thread |
86 | | - OLETLS_HOSTTHREAD = 0x2000, // This is a host thread |
87 | | - OLETLS_ALLOWCOINIT = 0x4000, // This thread allows inits |
88 | | - OLETLS_PENDINGUNINIT = 0x8000, // This thread has pending uninit |
89 | | - OLETLS_FIRSTMTAINIT = 0x10000,// First thread to attempt an MTA init |
90 | | - OLETLS_FIRSTNTAINIT = 0x20000,// First thread to attempt an NTA init |
91 | | - OLETLS_APTINITIALIZING = 0x40000 // Apartment Object is initializing |
92 | | -} OLETLSFLAGS; |
93 | | - |
94 | | - |
95 | | -//+--------------------------------------------------------------------------- |
96 | | -// |
97 | | -// Structure: SOleTlsData |
98 | | -// |
99 | | -// Synopsis: structure holding per thread state needed by OLE32 |
100 | | -// |
101 | | -//+--------------------------------------------------------------------------- |
102 | | -typedef struct tagSOleTlsData |
103 | | -{ |
104 | | -#if !defined(_CHICAGO_) |
105 | | - // Docfile multiple allocator support |
106 | | - void *pvThreadBase; // per thread base pointer |
107 | | - CSmAllocator *pSmAllocator; // per thread docfile allocator |
108 | | -#endif |
109 | | - DWORD dwApartmentID; // Per thread "process ID" |
110 | | - DWORD dwFlags; // see OLETLSFLAGS above |
111 | | - |
112 | | - LONG TlsMapIndex; // index in the global TLSMap |
113 | | - void **ppTlsSlot; // Back pointer to the thread tls slot |
114 | | - DWORD cComInits; // number of per-thread inits |
115 | | - DWORD cOleInits; // number of per-thread OLE inits |
116 | | - |
117 | | - DWORD cCalls; // number of outstanding calls |
118 | | - CMessageCall *pCallInfo; // channel call info |
119 | | - CAsyncCall *pFreeAsyncCall; // ptr to available call object for this thread. |
120 | | - CClientCall *pFreeClientCall; // ptr to available call object for this thread. |
121 | | - |
122 | | - CObjServer *pObjServer; // Activation Server Object for this apartment. |
123 | | - DWORD dwTIDCaller; // TID of current calling app |
124 | | - CObjectContext *pCurrentCtx; // Current context |
125 | | - CObjectContext *pEmptyCtx; // Empty context |
126 | | - |
127 | | - CObjectContext *pNativeCtx; // Native context |
128 | | - CComApartment *pNativeApt; // Native apartment for the thread. |
129 | | - IUnknown *pCallContext; // call context object |
130 | | - CCtxCall *pCtxCall; // Context call object |
131 | | - |
132 | | - CPolicySet *pPS; // Policy set |
133 | | - PVOID pvPendingCallsFront;// Per Apt pending async calls |
134 | | - PVOID pvPendingCallsBack; |
135 | | - CAptCallCtrl *pCallCtrl; // call control for RPC for this apartment |
136 | | - |
137 | | - CSrvCallState *pTopSCS; // top server-side callctrl state |
138 | | - IMessageFilter *pMsgFilter; // temp storage for App MsgFilter |
139 | | - HWND hwndSTA; // STA server window same as poxid->hServerSTA |
140 | | - // ...needed on Win95 before oxid registration |
141 | | - LONG cORPCNestingLevel; // call nesting level (DBG only) |
142 | | - |
143 | | - DWORD cDebugData; // count of bytes of debug data in call |
144 | | - ULONG cPreRegOidsAvail; // count of server-side OIDs avail |
145 | | - unsigned hyper *pPreRegOids; // ptr to array of pre-reg OIDs |
146 | | - |
147 | | - UUID LogicalThreadId; // current logical thread id |
148 | | - |
149 | | - HANDLE hThread; // Thread handle used for cancel |
150 | | - HANDLE hRevert; // Token before first impersonate. |
151 | | - IUnknown *pAsyncRelease; // Controlling unknown for async release |
152 | | - // DDE data |
153 | | - HWND hwndDdeServer; // Per thread Common DDE server |
154 | | - |
155 | | - HWND hwndDdeClient; // Per thread Common DDE client |
156 | | - ULONG cServeDdeObjects; // non-zero if objects DDE should serve |
157 | | - // ClassCache data |
158 | | - LPVOID pSTALSvrsFront; // Chain of LServers registers in this thread if STA |
159 | | - // upper layer data |
160 | | - HWND hwndClip; // Clipboard window |
161 | | - |
162 | | - IDataObject *pDataObjClip; // Current Clipboard DataObject |
163 | | - DWORD dwClipSeqNum; // Clipboard Sequence # for the above DataObject |
164 | | - DWORD fIsClipWrapper; // Did we hand out the wrapper Clipboard DataObject? |
165 | | - IUnknown *punkState; // Per thread "state" object |
166 | | - // cancel data |
167 | | - DWORD cCallCancellation; // count of CoEnableCallCancellation |
168 | | - // async sends data |
169 | | - DWORD cAsyncSends; // count of async sends outstanding |
170 | | - |
171 | | - CAsyncCall* pAsyncCallList; // async calls outstanding |
172 | | - CSurrogatedObjectList *pSurrogateList; // Objects in the surrogate |
173 | | - |
174 | | - LockEntry lockEntry; // Locks currently held by the thread |
175 | | - CallEntry CallEntry; // client-side call chain for this thread |
176 | | - |
177 | | -#ifdef WX86OLE |
178 | | - IUnknown *punkStateWx86; // Per thread "state" object for Wx86 |
179 | | -#endif |
180 | | - void *pDragCursors; // Per thread drag cursor table. |
181 | | - |
182 | | -#ifdef _CHICAGO_ |
183 | | - LPVOID pWcstokContext; // Scan context for wcstok |
184 | | -#endif |
185 | | - |
186 | | - IUnknown *punkError; // Per thread error object. |
187 | | - ULONG cbErrorData; // Maximum size of error data. |
188 | | - |
189 | | -#if(_WIN32_WINNT >= 0x0500) |
190 | | - IUnknown *punkActiveXSafetyProvider; |
191 | | -#endif //(_WIN32_WINNT >= 0x0500) |
192 | | - |
193 | | -#if DBG==1 |
194 | | - LONG cTraceNestingLevel; // call nesting level for OLETRACE |
195 | | -#endif |
196 | | - |
197 | | -} SOleTlsData; |
198 | | - |
199 | | -#ifdef INITGUID |
200 | | -#include "initguid.h" |
201 | | -#endif |
202 | | - |
203 | | -#define DEFINE_OLEGUID(name, l, w1, w2) \ |
204 | | - DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46) |
205 | | - |
206 | | -DEFINE_OLEGUID(IID_IStdIdentity, 0x0000001bL, 0, 0); |
207 | | -DEFINE_OLEGUID(IID_IStdWrapper, 0x000001caL, 0, 0); |
| 11 | +// See https://learn.microsoft.com/previous-versions/windows/desktop/legacy/ms690269(v=vs.85) |
| 12 | +typedef struct _SOleTlsData { |
| 13 | + void *pvReserved0[2]; |
| 14 | + DWORD dwReserved0[3]; |
| 15 | + void *pvReserved1[1]; |
| 16 | + DWORD dwReserved1[3]; |
| 17 | + void *pvReserved2[4]; |
| 18 | + DWORD dwReserved2[1]; |
| 19 | + void *pCurrentCtx; |
| 20 | +} SOleTlsData, *PSOleTlsData; |
208 | 21 |
|
209 | 22 | #endif // _OLETLS_H_ |
0 commit comments