[Tizen] Unify dnetmemoryenumlib terms to match the codebase (#291)
[platform/upstream/coreclr.git] / src / utilcode / ex.cpp
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 //
5
6 //
7 // ---------------------------------------------------------------------------
8 // Ex.cpp
9 // ---------------------------------------------------------------------------
10
11 #include "stdafx.h"
12 #include "string.h"
13 #include "ex.h"
14 #include "holder.h"
15
16 // error codes
17 #include "corerror.h"
18
19 #include "../dlls/mscorrc/resource.h"
20
21 #include "olectl.h"
22
23 #include "corexcep.h"
24
25 #define MAX_EXCEPTION_MSG   200
26
27 // Set if fatal error (like stack overflow or out of memory) occurred in this process.
28 GVAL_IMPL_INIT(HRESULT, g_hrFatalError, S_OK);
29
30 // Helper function to get an exception object from outside the exception.  In
31 //  the CLR, it may be from the Thread object.  Non-CLR users have no thread object,
32 //  and it will do nothing.                                                    
33 void GetLastThrownObjectExceptionFromThread(void **ppvException);
34
35 Exception *Exception::g_OOMException = NULL;
36
37 // avoid global constructors
38 static BYTE g_OOMExceptionInstance[sizeof(OutOfMemoryException)];
39
40 Exception * Exception::GetOOMException()
41 {
42     LIMITED_METHOD_CONTRACT;
43     
44     if (!g_OOMException) {
45         // Create a local copy on the stack and then copy it over to the static instance.
46         // This avoids race conditions caused by multiple initializations of vtable in the constructor       
47
48         OutOfMemoryException local(TRUE);  // Construct a "preallocated" instance.
49         memcpy((void*)&g_OOMExceptionInstance, (void*)&local, sizeof(OutOfMemoryException));
50
51         g_OOMException = (OutOfMemoryException*)&g_OOMExceptionInstance;
52     }
53
54     return g_OOMException;
55 }
56
57 /*virtual*/ Exception *OutOfMemoryException::Clone()
58 {
59     LIMITED_METHOD_CONTRACT;
60
61     return GetOOMException();
62 }
63
64 //------------------------------------------------------------------------------
65 void Exception::Delete(Exception* pvMemory)
66 {
67     CONTRACTL
68     {
69         GC_NOTRIGGER;
70         NOTHROW;
71         SUPPORTS_DAC_HOST_ONLY;   // Exceptions aren't currently marshalled by DAC - just used in the host
72     }
73     CONTRACTL_END;
74
75     if ((pvMemory == 0) || pvMemory->IsPreallocatedException())
76     {
77         return;
78     }
79
80     ::delete((Exception *) pvMemory);
81 }
82
83 void Exception::GetMessage(SString &result)
84 {
85     WRAPPER_NO_CONTRACT;
86     
87     return GenerateTopLevelHRExceptionMessage(GetHR(), result);
88 }
89
90 void HRMsgException::GetMessage(SString &result)
91 {
92     WRAPPER_NO_CONTRACT;
93     
94     if (m_msg.IsEmpty())
95         HRException::GetMessage(result);
96     else
97         result = m_msg;
98 }
99
100 Exception *Exception::Clone()
101 {
102     CONTRACTL
103     {
104         GC_NOTRIGGER;
105         THROWS;
106     }
107     CONTRACTL_END;
108     
109     NewHolder<Exception> retExcep(CloneHelper());
110     if (m_innerException)
111     {
112         retExcep->m_innerException = m_innerException->Clone();
113     }
114
115     retExcep.SuppressRelease();
116     return retExcep;
117 }
118
119 Exception *Exception::CloneHelper()
120 {
121     StackSString s;
122     GetMessage(s);
123     return new HRMsgException(GetHR(), s);
124 }
125
126 Exception *Exception::DomainBoundClone()
127 {
128     CONTRACTL
129     {
130         // Because we may call DomainBoundCloneHelper() of ObjrefException or CLRLastThrownObjectException
131         // this should be GC_TRIGGERS, but we can not include EE contracts in Utilcode.
132         THROWS;
133     }
134     CONTRACTL_END;
135
136     NewHolder<Exception> retExcep(DomainBoundCloneHelper());
137     if (m_innerException)
138     {
139         retExcep->m_innerException = m_innerException->DomainBoundClone();
140     }
141
142     retExcep.SuppressRelease();
143     return retExcep;
144 }
145
146 BOOL Exception::IsTerminal()
147 {
148     CONTRACTL
149     {
150         GC_NOTRIGGER;
151         NOTHROW;
152
153         // CLRException::GetHR() can eventually call BaseDomain::CreateHandle(),
154         // which can indirectly cause a lock if we get a miss in the handle table
155         // cache (TableCacheMissOnAlloc).  Since CLRException::GetHR() is virtual,
156         // SCAN won't find this for you (though 40 minutes of one of the sql stress
157         // tests will :-))
158         CAN_TAKE_LOCK;
159     }
160     CONTRACTL_END;
161     
162     HRESULT hr = GetHR();
163     return (COR_E_THREADABORTED == hr);
164 }
165
166 BOOL Exception::IsTransient()
167 {
168     WRAPPER_NO_CONTRACT;
169
170     return IsTransient(GetHR());
171 }
172
173 /* static */
174 BOOL Exception::IsTransient(HRESULT hr)
175 {
176     LIMITED_METHOD_CONTRACT;
177     
178     return (hr == COR_E_THREADABORTED
179             || hr == COR_E_THREADINTERRUPTED
180             || hr == COR_E_THREADSTOP
181             || hr == COR_E_APPDOMAINUNLOADED
182             || hr == E_OUTOFMEMORY
183             || hr == HRESULT_FROM_WIN32(ERROR_COMMITMENT_LIMIT) // ran out of room in pagefile
184             || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY)
185             || hr == (HRESULT)STATUS_NO_MEMORY
186             || hr == COR_E_STACKOVERFLOW
187             || hr == MSEE_E_ASSEMBLYLOADINPROGRESS);
188 }
189
190 //------------------------------------------------------------------------------
191 // Functions to manage the preallocated exceptions.
192 // Virtual 
193 BOOL Exception::IsPreallocatedException()
194 {   // Most exceptions can't be preallocated.  If they can be, their class
195     //  should provide a virtual override of this function.
196     return FALSE;
197 }
198
199 BOOL Exception::IsPreallocatedOOMException()
200 {   // This is the preallocated OOM if it is preallocated and is OOM.
201     return IsPreallocatedException() && (GetInstanceType() == OutOfMemoryException::GetType());
202 }
203
204 //------------------------------------------------------------------------------
205 #ifdef _PREFAST_
206 #pragma warning(push)
207 #pragma warning(disable:21000) // Suppress PREFast warning about overly large function
208 #endif
209 LPCSTR Exception::GetHRSymbolicName(HRESULT hr)
210 {
211     LIMITED_METHOD_CONTRACT;
212
213 #define CASE_HRESULT(hrname) case hrname: return #hrname;
214
215     switch (hr)
216     {
217         CASE_HRESULT(S_OK)//                             0x00000000L
218         CASE_HRESULT(S_FALSE)//                          0x00000001L
219
220         CASE_HRESULT(E_UNEXPECTED)//                     0x8000FFFFL
221         CASE_HRESULT(E_NOTIMPL)//                        0x80004001L
222         CASE_HRESULT(E_OUTOFMEMORY)//                    0x8007000EL
223         CASE_HRESULT(E_INVALIDARG)//                     0x80070057L
224         CASE_HRESULT(E_NOINTERFACE)//                    0x80004002L
225         CASE_HRESULT(E_POINTER)//                        0x80004003L
226         CASE_HRESULT(E_HANDLE)//                         0x80070006L
227         CASE_HRESULT(E_ABORT)//                          0x80004004L
228         CASE_HRESULT(E_FAIL)//                           0x80004005L
229         CASE_HRESULT(E_ACCESSDENIED)//                   0x80070005L
230
231 #ifdef FEATURE_COMINTEROP
232         CASE_HRESULT(CO_E_INIT_TLS)//                    0x80004006L
233         CASE_HRESULT(CO_E_INIT_SHARED_ALLOCATOR)//       0x80004007L
234         CASE_HRESULT(CO_E_INIT_MEMORY_ALLOCATOR)//       0x80004008L
235         CASE_HRESULT(CO_E_INIT_CLASS_CACHE)//            0x80004009L
236         CASE_HRESULT(CO_E_INIT_RPC_CHANNEL)//            0x8000400AL
237         CASE_HRESULT(CO_E_INIT_TLS_SET_CHANNEL_CONTROL)// 0x8000400BL
238         CASE_HRESULT(CO_E_INIT_TLS_CHANNEL_CONTROL)//    0x8000400CL
239         CASE_HRESULT(CO_E_INIT_UNACCEPTED_USER_ALLOCATOR)// 0x8000400DL
240         CASE_HRESULT(CO_E_INIT_SCM_MUTEX_EXISTS)//       0x8000400EL
241         CASE_HRESULT(CO_E_INIT_SCM_FILE_MAPPING_EXISTS)// 0x8000400FL
242         CASE_HRESULT(CO_E_INIT_SCM_MAP_VIEW_OF_FILE)//   0x80004010L
243         CASE_HRESULT(CO_E_INIT_SCM_EXEC_FAILURE)//       0x80004011L
244         CASE_HRESULT(CO_E_INIT_ONLY_SINGLE_THREADED)//   0x80004012L
245
246 // ******************
247 // FACILITY_ITF
248 // ******************
249
250         CASE_HRESULT(OLE_E_OLEVERB)//                    0x80040000L
251         CASE_HRESULT(OLE_E_ADVF)//                       0x80040001L
252         CASE_HRESULT(OLE_E_ENUM_NOMORE)//                0x80040002L
253         CASE_HRESULT(OLE_E_ADVISENOTSUPPORTED)//         0x80040003L
254         CASE_HRESULT(OLE_E_NOCONNECTION)//               0x80040004L
255         CASE_HRESULT(OLE_E_NOTRUNNING)//                 0x80040005L
256         CASE_HRESULT(OLE_E_NOCACHE)//                    0x80040006L
257         CASE_HRESULT(OLE_E_BLANK)//                      0x80040007L
258         CASE_HRESULT(OLE_E_CLASSDIFF)//                  0x80040008L
259         CASE_HRESULT(OLE_E_CANT_GETMONIKER)//            0x80040009L
260         CASE_HRESULT(OLE_E_CANT_BINDTOSOURCE)//          0x8004000AL
261         CASE_HRESULT(OLE_E_STATIC)//                     0x8004000BL
262         CASE_HRESULT(OLE_E_PROMPTSAVECANCELLED)//        0x8004000CL
263         CASE_HRESULT(OLE_E_INVALIDRECT)//                0x8004000DL
264         CASE_HRESULT(OLE_E_WRONGCOMPOBJ)//               0x8004000EL
265         CASE_HRESULT(OLE_E_INVALIDHWND)//                0x8004000FL
266         CASE_HRESULT(OLE_E_NOT_INPLACEACTIVE)//          0x80040010L
267         CASE_HRESULT(OLE_E_CANTCONVERT)//                0x80040011L
268         CASE_HRESULT(OLE_E_NOSTORAGE)//                  0x80040012L
269         CASE_HRESULT(DV_E_FORMATETC)//                   0x80040064L
270         CASE_HRESULT(DV_E_DVTARGETDEVICE)//              0x80040065L
271         CASE_HRESULT(DV_E_STGMEDIUM)//                   0x80040066L
272         CASE_HRESULT(DV_E_STATDATA)//                    0x80040067L
273         CASE_HRESULT(DV_E_LINDEX)//                      0x80040068L
274         CASE_HRESULT(DV_E_TYMED)//                       0x80040069L
275         CASE_HRESULT(DV_E_CLIPFORMAT)//                  0x8004006AL
276         CASE_HRESULT(DV_E_DVASPECT)//                    0x8004006BL
277         CASE_HRESULT(DV_E_DVTARGETDEVICE_SIZE)//         0x8004006CL
278         CASE_HRESULT(DV_E_NOIVIEWOBJECT)//               0x8004006DL
279         CASE_HRESULT(DRAGDROP_E_NOTREGISTERED)//         0x80040100L
280         CASE_HRESULT(DRAGDROP_E_ALREADYREGISTERED)//     0x80040101L
281         CASE_HRESULT(DRAGDROP_E_INVALIDHWND)//           0x80040102L
282         CASE_HRESULT(CLASS_E_NOAGGREGATION)//            0x80040110L
283         CASE_HRESULT(CLASS_E_CLASSNOTAVAILABLE)//        0x80040111L
284         CASE_HRESULT(VIEW_E_DRAW)//                      0x80040140L
285         CASE_HRESULT(REGDB_E_READREGDB)//                0x80040150L
286         CASE_HRESULT(REGDB_E_WRITEREGDB)//               0x80040151L
287         CASE_HRESULT(REGDB_E_KEYMISSING)//               0x80040152L
288         CASE_HRESULT(REGDB_E_INVALIDVALUE)//             0x80040153L
289         CASE_HRESULT(REGDB_E_CLASSNOTREG)//              0x80040154L
290         CASE_HRESULT(CACHE_E_NOCACHE_UPDATED)//          0x80040170L
291         CASE_HRESULT(OLEOBJ_E_NOVERBS)//                 0x80040180L
292         CASE_HRESULT(INPLACE_E_NOTUNDOABLE)//            0x800401A0L
293         CASE_HRESULT(INPLACE_E_NOTOOLSPACE)//            0x800401A1L
294         CASE_HRESULT(CONVERT10_E_OLESTREAM_GET)//        0x800401C0L
295         CASE_HRESULT(CONVERT10_E_OLESTREAM_PUT)//        0x800401C1L
296         CASE_HRESULT(CONVERT10_E_OLESTREAM_FMT)//        0x800401C2L
297         CASE_HRESULT(CONVERT10_E_OLESTREAM_BITMAP_TO_DIB)// 0x800401C3L
298         CASE_HRESULT(CONVERT10_E_STG_FMT)//              0x800401C4L
299         CASE_HRESULT(CONVERT10_E_STG_NO_STD_STREAM)//    0x800401C5L
300         CASE_HRESULT(CONVERT10_E_STG_DIB_TO_BITMAP)//    0x800401C6L
301         CASE_HRESULT(CLIPBRD_E_CANT_OPEN)//              0x800401D0L
302         CASE_HRESULT(CLIPBRD_E_CANT_EMPTY)//             0x800401D1L
303         CASE_HRESULT(CLIPBRD_E_CANT_SET)//               0x800401D2L
304         CASE_HRESULT(CLIPBRD_E_BAD_DATA)//               0x800401D3L
305         CASE_HRESULT(CLIPBRD_E_CANT_CLOSE)//             0x800401D4L
306         CASE_HRESULT(MK_E_CONNECTMANUALLY)//             0x800401E0L
307         CASE_HRESULT(MK_E_EXCEEDEDDEADLINE)//            0x800401E1L
308         CASE_HRESULT(MK_E_NEEDGENERIC)//                 0x800401E2L
309         CASE_HRESULT(MK_E_UNAVAILABLE)//                 0x800401E3L
310         CASE_HRESULT(MK_E_SYNTAX)//                      0x800401E4L
311         CASE_HRESULT(MK_E_NOOBJECT)//                    0x800401E5L
312         CASE_HRESULT(MK_E_INVALIDEXTENSION)//            0x800401E6L
313         CASE_HRESULT(MK_E_INTERMEDIATEINTERFACENOTSUPPORTED)// 0x800401E7L
314         CASE_HRESULT(MK_E_NOTBINDABLE)//                 0x800401E8L
315         CASE_HRESULT(MK_E_NOTBOUND)//                    0x800401E9L
316         CASE_HRESULT(MK_E_CANTOPENFILE)//                0x800401EAL
317         CASE_HRESULT(MK_E_MUSTBOTHERUSER)//              0x800401EBL
318         CASE_HRESULT(MK_E_NOINVERSE)//                   0x800401ECL
319         CASE_HRESULT(MK_E_NOSTORAGE)//                   0x800401EDL
320         CASE_HRESULT(MK_E_NOPREFIX)//                    0x800401EEL
321         CASE_HRESULT(MK_E_ENUMERATION_FAILED)//          0x800401EFL
322         CASE_HRESULT(CO_E_NOTINITIALIZED)//              0x800401F0L
323         CASE_HRESULT(CO_E_ALREADYINITIALIZED)//          0x800401F1L
324         CASE_HRESULT(CO_E_CANTDETERMINECLASS)//          0x800401F2L
325         CASE_HRESULT(CO_E_CLASSSTRING)//                 0x800401F3L
326         CASE_HRESULT(CO_E_IIDSTRING)//                   0x800401F4L
327         CASE_HRESULT(CO_E_APPNOTFOUND)//                 0x800401F5L
328         CASE_HRESULT(CO_E_APPSINGLEUSE)//                0x800401F6L
329         CASE_HRESULT(CO_E_ERRORINAPP)//                  0x800401F7L
330         CASE_HRESULT(CO_E_DLLNOTFOUND)//                 0x800401F8L
331         CASE_HRESULT(CO_E_ERRORINDLL)//                  0x800401F9L
332         CASE_HRESULT(CO_E_WRONGOSFORAPP)//               0x800401FAL
333         CASE_HRESULT(CO_E_OBJNOTREG)//                   0x800401FBL
334         CASE_HRESULT(CO_E_OBJISREG)//                    0x800401FCL
335         CASE_HRESULT(CO_E_OBJNOTCONNECTED)//             0x800401FDL
336         CASE_HRESULT(CO_E_APPDIDNTREG)//                 0x800401FEL
337         CASE_HRESULT(CO_E_RELEASED)//                    0x800401FFL
338
339         CASE_HRESULT(OLE_S_USEREG)//                     0x00040000L
340         CASE_HRESULT(OLE_S_STATIC)//                     0x00040001L
341         CASE_HRESULT(OLE_S_MAC_CLIPFORMAT)//             0x00040002L
342         CASE_HRESULT(DRAGDROP_S_DROP)//                  0x00040100L
343         CASE_HRESULT(DRAGDROP_S_CANCEL)//                0x00040101L
344         CASE_HRESULT(DRAGDROP_S_USEDEFAULTCURSORS)//     0x00040102L
345         CASE_HRESULT(DATA_S_SAMEFORMATETC)//             0x00040130L
346         CASE_HRESULT(VIEW_S_ALREADY_FROZEN)//            0x00040140L
347         CASE_HRESULT(CACHE_S_FORMATETC_NOTSUPPORTED)//   0x00040170L
348         CASE_HRESULT(CACHE_S_SAMECACHE)//                0x00040171L
349         CASE_HRESULT(CACHE_S_SOMECACHES_NOTUPDATED)//    0x00040172L
350         CASE_HRESULT(OLEOBJ_S_INVALIDVERB)//             0x00040180L
351         CASE_HRESULT(OLEOBJ_S_CANNOT_DOVERB_NOW)//       0x00040181L
352         CASE_HRESULT(OLEOBJ_S_INVALIDHWND)//             0x00040182L
353         CASE_HRESULT(INPLACE_S_TRUNCATED)//              0x000401A0L
354         CASE_HRESULT(CONVERT10_S_NO_PRESENTATION)//      0x000401C0L
355         CASE_HRESULT(MK_S_REDUCED_TO_SELF)//             0x000401E2L
356         CASE_HRESULT(MK_S_ME)//                          0x000401E4L
357         CASE_HRESULT(MK_S_HIM)//                         0x000401E5L
358         CASE_HRESULT(MK_S_US)//                          0x000401E6L
359         CASE_HRESULT(MK_S_MONIKERALREADYREGISTERED)//    0x000401E7L
360
361 // ******************
362 // FACILITY_WINDOWS
363 // ******************
364
365         CASE_HRESULT(CO_E_CLASS_CREATE_FAILED)//         0x80080001L
366         CASE_HRESULT(CO_E_SCM_ERROR)//                   0x80080002L
367         CASE_HRESULT(CO_E_SCM_RPC_FAILURE)//             0x80080003L
368         CASE_HRESULT(CO_E_BAD_PATH)//                    0x80080004L
369         CASE_HRESULT(CO_E_SERVER_EXEC_FAILURE)//         0x80080005L
370         CASE_HRESULT(CO_E_OBJSRV_RPC_FAILURE)//          0x80080006L
371         CASE_HRESULT(MK_E_NO_NORMALIZED)//               0x80080007L
372         CASE_HRESULT(CO_E_SERVER_STOPPING)//             0x80080008L
373         CASE_HRESULT(MEM_E_INVALID_ROOT)//               0x80080009L
374         CASE_HRESULT(MEM_E_INVALID_LINK)//               0x80080010L
375         CASE_HRESULT(MEM_E_INVALID_SIZE)//               0x80080011L
376
377 // ******************
378 // FACILITY_DISPATCH
379 // ******************
380
381         CASE_HRESULT(DISP_E_UNKNOWNINTERFACE)//          0x80020001L
382         CASE_HRESULT(DISP_E_MEMBERNOTFOUND)//            0x80020003L
383         CASE_HRESULT(DISP_E_PARAMNOTFOUND)//             0x80020004L
384         CASE_HRESULT(DISP_E_TYPEMISMATCH)//              0x80020005L
385         CASE_HRESULT(DISP_E_UNKNOWNNAME)//               0x80020006L
386         CASE_HRESULT(DISP_E_NONAMEDARGS)//               0x80020007L
387         CASE_HRESULT(DISP_E_BADVARTYPE)//                0x80020008L
388         CASE_HRESULT(DISP_E_EXCEPTION)//                 0x80020009L
389         CASE_HRESULT(DISP_E_OVERFLOW)//                  0x8002000AL
390         CASE_HRESULT(DISP_E_BADINDEX)//                  0x8002000BL
391         CASE_HRESULT(DISP_E_UNKNOWNLCID)//               0x8002000CL
392         CASE_HRESULT(DISP_E_ARRAYISLOCKED)//             0x8002000DL
393         CASE_HRESULT(DISP_E_BADPARAMCOUNT)//             0x8002000EL
394         CASE_HRESULT(DISP_E_PARAMNOTOPTIONAL)//          0x8002000FL
395         CASE_HRESULT(DISP_E_BADCALLEE)//                 0x80020010L
396         CASE_HRESULT(DISP_E_NOTACOLLECTION)//            0x80020011L
397         CASE_HRESULT(TYPE_E_BUFFERTOOSMALL)//            0x80028016L
398         CASE_HRESULT(TYPE_E_INVDATAREAD)//               0x80028018L
399         CASE_HRESULT(TYPE_E_UNSUPFORMAT)//               0x80028019L
400         CASE_HRESULT(TYPE_E_REGISTRYACCESS)//            0x8002801CL
401         CASE_HRESULT(TYPE_E_LIBNOTREGISTERED)//          0x8002801DL
402         CASE_HRESULT(TYPE_E_UNDEFINEDTYPE)//             0x80028027L
403         CASE_HRESULT(TYPE_E_QUALIFIEDNAMEDISALLOWED)//   0x80028028L
404         CASE_HRESULT(TYPE_E_INVALIDSTATE)//              0x80028029L
405         CASE_HRESULT(TYPE_E_WRONGTYPEKIND)//             0x8002802AL
406         CASE_HRESULT(TYPE_E_ELEMENTNOTFOUND)//           0x8002802BL
407         CASE_HRESULT(TYPE_E_AMBIGUOUSNAME)//             0x8002802CL
408         CASE_HRESULT(TYPE_E_NAMECONFLICT)//              0x8002802DL
409         CASE_HRESULT(TYPE_E_UNKNOWNLCID)//               0x8002802EL
410         CASE_HRESULT(TYPE_E_DLLFUNCTIONNOTFOUND)//       0x8002802FL
411         CASE_HRESULT(TYPE_E_BADMODULEKIND)//             0x800288BDL
412         CASE_HRESULT(TYPE_E_SIZETOOBIG)//                0x800288C5L
413         CASE_HRESULT(TYPE_E_DUPLICATEID)//               0x800288C6L
414         CASE_HRESULT(TYPE_E_INVALIDID)//                 0x800288CFL
415         CASE_HRESULT(TYPE_E_TYPEMISMATCH)//              0x80028CA0L
416         CASE_HRESULT(TYPE_E_OUTOFBOUNDS)//               0x80028CA1L
417         CASE_HRESULT(TYPE_E_IOERROR)//                   0x80028CA2L
418         CASE_HRESULT(TYPE_E_CANTCREATETMPFILE)//         0x80028CA3L
419         CASE_HRESULT(TYPE_E_CANTLOADLIBRARY)//           0x80029C4AL
420         CASE_HRESULT(TYPE_E_INCONSISTENTPROPFUNCS)//     0x80029C83L
421         CASE_HRESULT(TYPE_E_CIRCULARTYPE)//              0x80029C84L
422
423 // ******************
424 // FACILITY_STORAGE
425 // ******************
426
427         CASE_HRESULT(STG_E_INVALIDFUNCTION)//            0x80030001L
428         CASE_HRESULT(STG_E_FILENOTFOUND)//               0x80030002L
429         CASE_HRESULT(STG_E_PATHNOTFOUND)//               0x80030003L
430         CASE_HRESULT(STG_E_TOOMANYOPENFILES)//           0x80030004L
431         CASE_HRESULT(STG_E_ACCESSDENIED)//               0x80030005L
432         CASE_HRESULT(STG_E_INVALIDHANDLE)//              0x80030006L
433         CASE_HRESULT(STG_E_INSUFFICIENTMEMORY)//         0x80030008L
434         CASE_HRESULT(STG_E_INVALIDPOINTER)//             0x80030009L
435         CASE_HRESULT(STG_E_NOMOREFILES)//                0x80030012L
436         CASE_HRESULT(STG_E_DISKISWRITEPROTECTED)//       0x80030013L
437         CASE_HRESULT(STG_E_SEEKERROR)//                  0x80030019L
438         CASE_HRESULT(STG_E_WRITEFAULT)//                 0x8003001DL
439         CASE_HRESULT(STG_E_READFAULT)//                  0x8003001EL
440         CASE_HRESULT(STG_E_SHAREVIOLATION)//             0x80030020L
441         CASE_HRESULT(STG_E_LOCKVIOLATION)//              0x80030021L
442         CASE_HRESULT(STG_E_FILEALREADYEXISTS)//          0x80030050L
443         CASE_HRESULT(STG_E_INVALIDPARAMETER)//           0x80030057L
444         CASE_HRESULT(STG_E_MEDIUMFULL)//                 0x80030070L
445         CASE_HRESULT(STG_E_ABNORMALAPIEXIT)//            0x800300FAL
446         CASE_HRESULT(STG_E_INVALIDHEADER)//              0x800300FBL
447         CASE_HRESULT(STG_E_INVALIDNAME)//                0x800300FCL
448         CASE_HRESULT(STG_E_UNKNOWN)//                    0x800300FDL
449         CASE_HRESULT(STG_E_UNIMPLEMENTEDFUNCTION)//      0x800300FEL
450         CASE_HRESULT(STG_E_INVALIDFLAG)//                0x800300FFL
451         CASE_HRESULT(STG_E_INUSE)//                      0x80030100L
452         CASE_HRESULT(STG_E_NOTCURRENT)//                 0x80030101L
453         CASE_HRESULT(STG_E_REVERTED)//                   0x80030102L
454         CASE_HRESULT(STG_E_CANTSAVE)//                   0x80030103L
455         CASE_HRESULT(STG_E_OLDFORMAT)//                  0x80030104L
456         CASE_HRESULT(STG_E_OLDDLL)//                     0x80030105L
457         CASE_HRESULT(STG_E_SHAREREQUIRED)//              0x80030106L
458         CASE_HRESULT(STG_E_NOTFILEBASEDSTORAGE)//        0x80030107L
459         CASE_HRESULT(STG_S_CONVERTED)//                  0x00030200L
460
461 // ******************
462 // FACILITY_RPC
463 // ******************
464
465         CASE_HRESULT(RPC_E_CALL_REJECTED)//              0x80010001L
466         CASE_HRESULT(RPC_E_CALL_CANCELED)//              0x80010002L
467         CASE_HRESULT(RPC_E_CANTPOST_INSENDCALL)//        0x80010003L
468         CASE_HRESULT(RPC_E_CANTCALLOUT_INASYNCCALL)//    0x80010004L
469         CASE_HRESULT(RPC_E_CANTCALLOUT_INEXTERNALCALL)// 0x80010005L
470         CASE_HRESULT(RPC_E_CONNECTION_TERMINATED)//      0x80010006L
471         CASE_HRESULT(RPC_E_SERVER_DIED)//                0x80010007L
472         CASE_HRESULT(RPC_E_CLIENT_DIED)//                0x80010008L
473         CASE_HRESULT(RPC_E_INVALID_DATAPACKET)//         0x80010009L
474         CASE_HRESULT(RPC_E_CANTTRANSMIT_CALL)//          0x8001000AL
475         CASE_HRESULT(RPC_E_CLIENT_CANTMARSHAL_DATA)//    0x8001000BL
476         CASE_HRESULT(RPC_E_CLIENT_CANTUNMARSHAL_DATA)//  0x8001000CL
477         CASE_HRESULT(RPC_E_SERVER_CANTMARSHAL_DATA)//    0x8001000DL
478         CASE_HRESULT(RPC_E_SERVER_CANTUNMARSHAL_DATA)//  0x8001000EL
479         CASE_HRESULT(RPC_E_INVALID_DATA)//               0x8001000FL
480         CASE_HRESULT(RPC_E_INVALID_PARAMETER)//          0x80010010L
481         CASE_HRESULT(RPC_E_CANTCALLOUT_AGAIN)//          0x80010011L
482         CASE_HRESULT(RPC_E_SERVER_DIED_DNE)//            0x80010012L
483         CASE_HRESULT(RPC_E_SYS_CALL_FAILED)//            0x80010100L
484         CASE_HRESULT(RPC_E_OUT_OF_RESOURCES)//           0x80010101L
485         CASE_HRESULT(RPC_E_ATTEMPTED_MULTITHREAD)//      0x80010102L
486         CASE_HRESULT(RPC_E_NOT_REGISTERED)//             0x80010103L
487         CASE_HRESULT(RPC_E_FAULT)//                      0x80010104L
488         CASE_HRESULT(RPC_E_SERVERFAULT)//                0x80010105L
489         CASE_HRESULT(RPC_E_CHANGED_MODE)//               0x80010106L
490         CASE_HRESULT(RPC_E_INVALIDMETHOD)//              0x80010107L
491         CASE_HRESULT(RPC_E_DISCONNECTED)//               0x80010108L
492         CASE_HRESULT(RPC_E_RETRY)//                      0x80010109L
493         CASE_HRESULT(RPC_E_SERVERCALL_RETRYLATER)//      0x8001010AL
494         CASE_HRESULT(RPC_E_SERVERCALL_REJECTED)//        0x8001010BL
495         CASE_HRESULT(RPC_E_INVALID_CALLDATA)//           0x8001010CL
496         CASE_HRESULT(RPC_E_CANTCALLOUT_ININPUTSYNCCALL)// 0x8001010DL
497         CASE_HRESULT(RPC_E_WRONG_THREAD)//               0x8001010EL
498         CASE_HRESULT(RPC_E_THREAD_NOT_INIT)//            0x8001010FL
499         CASE_HRESULT(RPC_E_UNEXPECTED)//                 0x8001FFFFL   
500
501 // ******************
502 // FACILITY_CTL
503 // ******************
504
505         CASE_HRESULT(CTL_E_ILLEGALFUNCTIONCALL)       
506         CASE_HRESULT(CTL_E_OVERFLOW)                  
507         CASE_HRESULT(CTL_E_OUTOFMEMORY)               
508         CASE_HRESULT(CTL_E_DIVISIONBYZERO)            
509         CASE_HRESULT(CTL_E_OUTOFSTRINGSPACE)          
510         CASE_HRESULT(CTL_E_OUTOFSTACKSPACE)           
511         CASE_HRESULT(CTL_E_BADFILENAMEORNUMBER)       
512         CASE_HRESULT(CTL_E_FILENOTFOUND)              
513         CASE_HRESULT(CTL_E_BADFILEMODE)               
514         CASE_HRESULT(CTL_E_FILEALREADYOPEN)           
515         CASE_HRESULT(CTL_E_DEVICEIOERROR)             
516         CASE_HRESULT(CTL_E_FILEALREADYEXISTS)         
517         CASE_HRESULT(CTL_E_BADRECORDLENGTH)           
518         CASE_HRESULT(CTL_E_DISKFULL)                  
519         CASE_HRESULT(CTL_E_BADRECORDNUMBER)           
520         CASE_HRESULT(CTL_E_BADFILENAME)               
521         CASE_HRESULT(CTL_E_TOOMANYFILES)              
522         CASE_HRESULT(CTL_E_DEVICEUNAVAILABLE)         
523         CASE_HRESULT(CTL_E_PERMISSIONDENIED)          
524         CASE_HRESULT(CTL_E_DISKNOTREADY)              
525         CASE_HRESULT(CTL_E_PATHFILEACCESSERROR)       
526         CASE_HRESULT(CTL_E_PATHNOTFOUND)              
527         CASE_HRESULT(CTL_E_INVALIDPATTERNSTRING)      
528         CASE_HRESULT(CTL_E_INVALIDUSEOFNULL)          
529         CASE_HRESULT(CTL_E_INVALIDFILEFORMAT)         
530         CASE_HRESULT(CTL_E_INVALIDPROPERTYVALUE)      
531         CASE_HRESULT(CTL_E_INVALIDPROPERTYARRAYINDEX) 
532         CASE_HRESULT(CTL_E_SETNOTSUPPORTEDATRUNTIME)  
533         CASE_HRESULT(CTL_E_SETNOTSUPPORTED)           
534         CASE_HRESULT(CTL_E_NEEDPROPERTYARRAYINDEX)    
535         CASE_HRESULT(CTL_E_SETNOTPERMITTED)           
536         CASE_HRESULT(CTL_E_GETNOTSUPPORTEDATRUNTIME)  
537         CASE_HRESULT(CTL_E_GETNOTSUPPORTED)           
538         CASE_HRESULT(CTL_E_PROPERTYNOTFOUND)          
539         CASE_HRESULT(CTL_E_INVALIDCLIPBOARDFORMAT)    
540         CASE_HRESULT(CTL_E_INVALIDPICTURE)            
541         CASE_HRESULT(CTL_E_PRINTERERROR)              
542         CASE_HRESULT(CTL_E_CANTSAVEFILETOTEMP)        
543         CASE_HRESULT(CTL_E_SEARCHTEXTNOTFOUND)        
544         CASE_HRESULT(CTL_E_REPLACEMENTSTOOLONG)       
545 #endif // FEATURE_COMINTEROP
546
547 #ifdef _DEBUG  // @todo: do we want to burn strings for this in a free build?
548
549     CASE_HRESULT(CEE_E_CVTRES_NOT_FOUND)
550     CASE_HRESULT(COR_E_APPDOMAINUNLOADED)
551     CASE_HRESULT(COR_E_CANNOTUNLOADAPPDOMAIN)
552     CASE_HRESULT(MSEE_E_ASSEMBLYLOADINPROGRESS)
553     CASE_HRESULT(COR_E_FIXUPSINEXE)
554     CASE_HRESULT(COR_E_MODULE_HASH_CHECK_FAILED)
555     CASE_HRESULT(FUSION_E_LOADFROM_BLOCKED)
556     CASE_HRESULT(FUSION_E_CACHEFILE_FAILED)
557     CASE_HRESULT(FUSION_E_REF_DEF_MISMATCH)
558     CASE_HRESULT(FUSION_E_INVALID_PRIVATE_ASM_LOCATION)
559     CASE_HRESULT(FUSION_E_ASM_MODULE_MISSING)
560     CASE_HRESULT(FUSION_E_PRIVATE_ASM_DISALLOWED)
561     CASE_HRESULT(FUSION_E_SIGNATURE_CHECK_FAILED)
562     CASE_HRESULT(FUSION_E_INVALID_NAME)
563     CASE_HRESULT(FUSION_E_CODE_DOWNLOAD_DISABLED)
564     CASE_HRESULT(CLDB_E_FILE_BADREAD)
565     CASE_HRESULT(CLDB_E_FILE_BADWRITE)
566     CASE_HRESULT(CLDB_S_TRUNCATION)
567     CASE_HRESULT(CLDB_E_FILE_OLDVER)
568     CASE_HRESULT(CLDB_E_SMDUPLICATE)
569     CASE_HRESULT(CLDB_E_NO_DATA)
570     CASE_HRESULT(CLDB_E_INCOMPATIBLE)
571     CASE_HRESULT(CLDB_E_FILE_CORRUPT)
572     CASE_HRESULT(CLDB_E_BADUPDATEMODE)
573     CASE_HRESULT(CLDB_E_INDEX_NOTFOUND)
574     CASE_HRESULT(CLDB_E_RECORD_NOTFOUND)
575     CASE_HRESULT(CLDB_E_RECORD_OUTOFORDER)
576     CASE_HRESULT(CLDB_E_TOO_BIG)
577     CASE_HRESULT(META_E_BADMETADATA)
578     CASE_HRESULT(META_E_BAD_SIGNATURE)
579     CASE_HRESULT(META_E_BAD_INPUT_PARAMETER)
580     CASE_HRESULT(META_E_CANNOTRESOLVETYPEREF)
581     CASE_HRESULT(META_S_DUPLICATE)
582     CASE_HRESULT(META_E_STRINGSPACE_FULL)
583     CASE_HRESULT(META_E_HAS_UNMARKALL)
584     CASE_HRESULT(META_E_MUST_CALL_UNMARKALL)
585     CASE_HRESULT(META_E_CA_INVALID_TARGET)
586     CASE_HRESULT(META_E_CA_INVALID_VALUE)
587     CASE_HRESULT(META_E_CA_INVALID_BLOB)
588     CASE_HRESULT(META_E_CA_REPEATED_ARG)
589     CASE_HRESULT(META_E_CA_UNKNOWN_ARGUMENT)
590     CASE_HRESULT(META_E_CA_UNEXPECTED_TYPE)
591     CASE_HRESULT(META_E_CA_INVALID_ARGTYPE)
592     CASE_HRESULT(META_E_CA_INVALID_ARG_FOR_TYPE)
593     CASE_HRESULT(META_E_CA_INVALID_UUID)
594     CASE_HRESULT(META_E_CA_INVALID_MARSHALAS_FIELDS)
595     CASE_HRESULT(META_E_CA_NT_FIELDONLY)
596     CASE_HRESULT(META_E_CA_NEGATIVE_PARAMINDEX)
597     CASE_HRESULT(META_E_CA_NEGATIVE_CONSTSIZE)
598     CASE_HRESULT(META_E_CA_FIXEDSTR_SIZE_REQUIRED)
599     CASE_HRESULT(META_E_CA_CUSTMARSH_TYPE_REQUIRED)
600     CASE_HRESULT(META_E_CA_BAD_FRIENDS_ARGS)
601     CASE_HRESULT(VLDTR_E_RID_OUTOFRANGE)
602     CASE_HRESULT(VLDTR_E_STRING_INVALID)
603     CASE_HRESULT(VLDTR_E_GUID_INVALID)
604     CASE_HRESULT(VLDTR_E_BLOB_INVALID)
605     CASE_HRESULT(VLDTR_E_MR_BADCALLINGCONV)
606     CASE_HRESULT(VLDTR_E_SIGNULL)
607     CASE_HRESULT(VLDTR_E_MD_BADCALLINGCONV)
608     CASE_HRESULT(VLDTR_E_MD_THISSTATIC)
609     CASE_HRESULT(VLDTR_E_MD_NOTTHISNOTSTATIC)
610     CASE_HRESULT(VLDTR_E_MD_NOARGCNT)
611     CASE_HRESULT(VLDTR_E_SIG_MISSELTYPE)
612     CASE_HRESULT(VLDTR_E_SIG_MISSTKN)
613     CASE_HRESULT(VLDTR_E_SIG_TKNBAD)
614     CASE_HRESULT(VLDTR_E_SIG_MISSFPTR)
615     CASE_HRESULT(VLDTR_E_SIG_MISSFPTRARGCNT)
616     CASE_HRESULT(VLDTR_E_SIG_MISSRANK)
617     CASE_HRESULT(VLDTR_E_SIG_MISSNSIZE)
618     CASE_HRESULT(VLDTR_E_SIG_MISSSIZE)
619     CASE_HRESULT(VLDTR_E_SIG_MISSNLBND)
620     CASE_HRESULT(VLDTR_E_SIG_MISSLBND)
621     CASE_HRESULT(VLDTR_E_SIG_BADELTYPE)
622     CASE_HRESULT(VLDTR_E_TD_ENCLNOTNESTED)
623     CASE_HRESULT(VLDTR_E_FMD_PINVOKENOTSTATIC)
624     CASE_HRESULT(VLDTR_E_SIG_SENTINMETHODDEF)
625     CASE_HRESULT(VLDTR_E_SIG_SENTMUSTVARARG)
626     CASE_HRESULT(VLDTR_E_SIG_MULTSENTINELS)
627     CASE_HRESULT(VLDTR_E_SIG_MISSARG)
628     CASE_HRESULT(VLDTR_E_SIG_BYREFINFIELD)
629     CASE_HRESULT(VLDTR_E_SIG_BADVOID)
630     CASE_HRESULT(CORDBG_E_UNRECOVERABLE_ERROR)
631     CASE_HRESULT(CORDBG_E_PROCESS_TERMINATED)
632     CASE_HRESULT(CORDBG_E_PROCESS_NOT_SYNCHRONIZED)
633     CASE_HRESULT(CORDBG_E_CLASS_NOT_LOADED)
634     CASE_HRESULT(CORDBG_E_IL_VAR_NOT_AVAILABLE)
635     CASE_HRESULT(CORDBG_E_BAD_REFERENCE_VALUE)
636     CASE_HRESULT(CORDBG_E_FIELD_NOT_AVAILABLE)
637     CASE_HRESULT(CORDBG_E_NON_NATIVE_FRAME)
638     CASE_HRESULT(CORDBG_E_CODE_NOT_AVAILABLE)
639     CASE_HRESULT(CORDBG_E_FUNCTION_NOT_IL)
640     CASE_HRESULT(CORDBG_S_BAD_START_SEQUENCE_POINT)
641     CASE_HRESULT(CORDBG_S_BAD_END_SEQUENCE_POINT)
642     CASE_HRESULT(CORDBG_E_CANT_SET_IP_INTO_FINALLY)
643     CASE_HRESULT(CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY)
644     CASE_HRESULT(CORDBG_E_CANT_SET_IP_INTO_CATCH)
645     CASE_HRESULT(CORDBG_E_SET_IP_NOT_ALLOWED_ON_NONLEAF_FRAME)
646     CASE_HRESULT(CORDBG_E_SET_IP_IMPOSSIBLE)
647     CASE_HRESULT(CORDBG_E_FUNC_EVAL_BAD_START_POINT)
648     CASE_HRESULT(CORDBG_E_INVALID_OBJECT)
649     CASE_HRESULT(CORDBG_E_FUNC_EVAL_NOT_COMPLETE)
650     CASE_HRESULT(CORDBG_S_FUNC_EVAL_HAS_NO_RESULT)
651     CASE_HRESULT(CORDBG_S_VALUE_POINTS_TO_VOID)
652     CASE_HRESULT(CORDBG_S_FUNC_EVAL_ABORTED)
653     CASE_HRESULT(CORDBG_E_STATIC_VAR_NOT_AVAILABLE)
654     CASE_HRESULT(CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER)
655     CASE_HRESULT(CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE)
656     CASE_HRESULT(CORDBG_E_CANT_SET_TO_JMC)
657     CASE_HRESULT(CORDBG_E_BAD_THREAD_STATE)
658     CASE_HRESULT(CORDBG_E_DEBUGGER_ALREADY_ATTACHED)
659     CASE_HRESULT(CORDBG_E_SUPERFLOUS_CONTINUE)
660     CASE_HRESULT(CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME)
661     CASE_HRESULT(CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED)
662     CASE_HRESULT(CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION)
663     CASE_HRESULT(CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL)
664     CASE_HRESULT(CORDBG_E_PROCESS_DETACHED)
665     CASE_HRESULT(CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS)
666     CASE_HRESULT(CORDBG_E_FIELD_NOT_STATIC)
667     CASE_HRESULT(CORDBG_E_FIELD_NOT_INSTANCE)
668     CASE_HRESULT(CORDBG_E_ENC_JIT_CANT_UPDATE)
669     CASE_HRESULT(CORDBG_E_ENC_INTERNAL_ERROR)
670     CASE_HRESULT(CORDBG_E_ENC_HANGING_FIELD)
671     CASE_HRESULT(CORDBG_E_MODULE_NOT_LOADED)
672     CASE_HRESULT(CORDBG_E_UNABLE_TO_SET_BREAKPOINT)
673     CASE_HRESULT(CORDBG_E_DEBUGGING_NOT_POSSIBLE)
674     CASE_HRESULT(CORDBG_E_KERNEL_DEBUGGER_ENABLED)
675     CASE_HRESULT(CORDBG_E_KERNEL_DEBUGGER_PRESENT)
676     CASE_HRESULT(CORDBG_E_INCOMPATIBLE_PROTOCOL)
677     CASE_HRESULT(CORDBG_E_TOO_MANY_PROCESSES)
678     CASE_HRESULT(CORDBG_E_INTEROP_NOT_SUPPORTED)
679     CASE_HRESULT(CORDBG_E_NO_REMAP_BREAKPIONT)
680     CASE_HRESULT(CORDBG_E_OBJECT_NEUTERED)
681     CASE_HRESULT(CORPROF_E_FUNCTION_NOT_COMPILED)
682     CASE_HRESULT(CORPROF_E_DATAINCOMPLETE)
683     CASE_HRESULT(CORPROF_E_FUNCTION_NOT_IL)
684     CASE_HRESULT(CORPROF_E_NOT_MANAGED_THREAD)
685     CASE_HRESULT(CORPROF_E_CALL_ONLY_FROM_INIT)
686     CASE_HRESULT(CORPROF_E_NOT_YET_AVAILABLE)
687     CASE_HRESULT(SECURITY_E_INCOMPATIBLE_SHARE)
688     CASE_HRESULT(SECURITY_E_UNVERIFIABLE)
689     CASE_HRESULT(SECURITY_E_INCOMPATIBLE_EVIDENCE)
690     CASE_HRESULT(CLDB_E_INTERNALERROR)
691     CASE_HRESULT(CORSEC_E_POLICY_EXCEPTION)
692     CASE_HRESULT(CORSEC_E_MIN_GRANT_FAIL)
693     CASE_HRESULT(CORSEC_E_NO_EXEC_PERM)
694     CASE_HRESULT(CORSEC_E_XMLSYNTAX)
695     CASE_HRESULT(CORSEC_E_INVALID_STRONGNAME)
696     CASE_HRESULT(CORSEC_E_MISSING_STRONGNAME)
697     CASE_HRESULT(CORSEC_E_INVALID_IMAGE_FORMAT)
698     CASE_HRESULT(CORSEC_E_CRYPTO)
699     CASE_HRESULT(CORSEC_E_CRYPTO_UNEX_OPER)
700     CASE_HRESULT(CORSECATTR_E_BAD_ACTION)
701     CASE_HRESULT(COR_E_APPLICATION)
702     CASE_HRESULT(COR_E_ARGUMENTOUTOFRANGE)
703     CASE_HRESULT(COR_E_ARITHMETIC)
704     CASE_HRESULT(COR_E_ARRAYTYPEMISMATCH)
705     CASE_HRESULT(COR_E_CONTEXTMARSHAL)
706     CASE_HRESULT(COR_E_TIMEOUT)
707     CASE_HRESULT(COR_E_DIVIDEBYZERO)
708     CASE_HRESULT(COR_E_EXCEPTION)
709     CASE_HRESULT(COR_E_EXECUTIONENGINE)
710     CASE_HRESULT(COR_E_FIELDACCESS)
711     CASE_HRESULT(COR_E_FORMAT)
712     CASE_HRESULT(COR_E_BADIMAGEFORMAT)
713     CASE_HRESULT(COR_E_ASSEMBLYEXPECTED)
714     CASE_HRESULT(COR_E_TYPEUNLOADED)
715     CASE_HRESULT(COR_E_INDEXOUTOFRANGE)
716     CASE_HRESULT(COR_E_INVALIDOPERATION)
717     CASE_HRESULT(COR_E_INVALIDPROGRAM)
718     CASE_HRESULT(COR_E_MEMBERACCESS)
719     CASE_HRESULT(COR_E_METHODACCESS)
720     CASE_HRESULT(COR_E_MISSINGFIELD)
721     CASE_HRESULT(COR_E_MISSINGMANIFESTRESOURCE)
722     CASE_HRESULT(COR_E_MISSINGMEMBER)
723     CASE_HRESULT(COR_E_MISSINGMETHOD)
724     CASE_HRESULT(COR_E_MULTICASTNOTSUPPORTED)
725     CASE_HRESULT(COR_E_NOTFINITENUMBER)
726     CASE_HRESULT(COR_E_DUPLICATEWAITOBJECT)
727     CASE_HRESULT(COR_E_PLATFORMNOTSUPPORTED)
728     CASE_HRESULT(COR_E_NOTSUPPORTED)
729     CASE_HRESULT(COR_E_OVERFLOW)
730     CASE_HRESULT(COR_E_RANK)
731     CASE_HRESULT(COR_E_SECURITY)
732     CASE_HRESULT(COR_E_SERIALIZATION)
733     CASE_HRESULT(COR_E_STACKOVERFLOW)
734     CASE_HRESULT(COR_E_SYNCHRONIZATIONLOCK)
735     CASE_HRESULT(COR_E_SYSTEM)
736     CASE_HRESULT(COR_E_THREADABORTED)
737     CASE_HRESULT(COR_E_THREADINTERRUPTED)
738     CASE_HRESULT(COR_E_THREADSTATE)
739     CASE_HRESULT(COR_E_THREADSTOP)
740     CASE_HRESULT(COR_E_TYPEINITIALIZATION)
741     CASE_HRESULT(COR_E_TYPELOAD)
742     CASE_HRESULT(COR_E_ENTRYPOINTNOTFOUND)
743     CASE_HRESULT(COR_E_DLLNOTFOUND)
744     CASE_HRESULT(COR_E_VERIFICATION)
745     CASE_HRESULT(COR_E_INVALIDCOMOBJECT)
746     CASE_HRESULT(COR_E_MARSHALDIRECTIVE)
747     CASE_HRESULT(COR_E_INVALIDOLEVARIANTTYPE)
748     CASE_HRESULT(COR_E_SAFEARRAYTYPEMISMATCH)
749     CASE_HRESULT(COR_E_SAFEARRAYRANKMISMATCH)
750     CASE_HRESULT(COR_E_INVALIDFILTERCRITERIA)
751     CASE_HRESULT(COR_E_REFLECTIONTYPELOAD)
752     CASE_HRESULT(COR_E_TARGET)
753     CASE_HRESULT(COR_E_TARGETINVOCATION)
754     CASE_HRESULT(COR_E_CUSTOMATTRIBUTEFORMAT)
755     CASE_HRESULT(COR_E_ENDOFSTREAM)
756     CASE_HRESULT(COR_E_FILELOAD)
757     CASE_HRESULT(COR_E_FILENOTFOUND)
758     CASE_HRESULT(COR_E_IO)
759     CASE_HRESULT(COR_E_DIRECTORYNOTFOUND)
760     CASE_HRESULT(COR_E_PATHTOOLONG)
761     CASE_HRESULT(COR_E_OBJECTDISPOSED)
762     CASE_HRESULT(COR_E_NEWER_RUNTIME)
763     CASE_HRESULT(CLR_E_SHIM_RUNTIMELOAD)
764     CASE_HRESULT(VER_E_FIELD_SIG)
765     CASE_HRESULT(CORDBG_E_THREAD_NOT_SCHEDULED)
766 #endif
767
768         default:
769             return NULL;
770     }
771 }
772 #ifdef _PREFAST_
773 #pragma warning(pop)
774 #endif
775
776
777 // ---------------------------------------------------------------------------
778 // HRException class.  Implements exception API for exceptions from HRESULTS
779 // ---------------------------------------------------------------------------
780
781 HRESULT HRException::GetHR()
782 {
783     LIMITED_METHOD_DAC_CONTRACT;
784     return m_hr; 
785 }
786
787 // ---------------------------------------------------------------------------
788 // COMException class. - moved to COMEx.cpp
789 // ---------------------------------------------------------------------------
790
791 // ---------------------------------------------------------------------------
792 // SEHException class.  Implements exception API for SEH exception info
793 // ---------------------------------------------------------------------------
794
795 HRESULT SEHException::GetHR()
796 {
797     LIMITED_METHOD_DAC_CONTRACT;
798
799     if (IsComPlusException(&m_exception)) // EE exception
800         return (HRESULT) m_exception.ExceptionInformation[0];
801     else
802         return m_exception.ExceptionCode;
803 }
804
805 IErrorInfo *SEHException::GetErrorInfo() 
806 {
807     LIMITED_METHOD_CONTRACT;
808     return NULL;
809 }
810
811 void SEHException::GetMessage(SString &string)
812 {
813     WRAPPER_NO_CONTRACT;
814     
815     if (IsComPlusException(&m_exception)) // EE exception
816     {
817         GenerateTopLevelHRExceptionMessage(GetHR(), string);
818     }
819     else
820     {
821         if (m_exception.ExceptionCode != 0)
822         {
823             string.Printf("Exception code 0x%.8x", m_exception.ExceptionCode);
824         }
825         else
826         {
827             // If we don't have a valid exception code, then give a generic message that's a little nicer than
828             // "code 0x00000000".
829             string.Printf("Unknown exception");
830         }
831     }
832 }
833
834 //==============================================================================
835 // DelegatingException class.  Implements exception API for "foreign" exceptions.
836 //==============================================================================
837
838 DelegatingException::DelegatingException()
839  : m_delegatedException((Exception*)DELEGATE_NOT_YET_SET)
840 {
841     LIMITED_METHOD_DAC_CONTRACT;
842 } // DelegatingException::DelegatingException()
843
844 //------------------------------------------------------------------------------
845 DelegatingException::~DelegatingException()
846 {
847     WRAPPER_NO_CONTRACT;
848     
849     // If there is a valid delegate pointer (inited and non-NULL), delete it.
850     if (IsDelegateValid())
851         Delete(m_delegatedException);
852
853     // Avoid confusion.
854     m_delegatedException = NULL;
855 } // DelegatingException::~DelegatingException()
856
857 //------------------------------------------------------------------------------
858 // Retrieve the delegating exception, or get one from the Thread, or get NULL.
859 Exception* DelegatingException::GetDelegate()
860 {
861     WRAPPER_NO_CONTRACT;
862     
863     // If we haven't gotten the exception pointer before..
864     if (!IsDelegateSet())
865     {
866         // .. get it now.  NULL in case there isn't one and we take default action.
867         m_delegatedException = NULL;
868         GetLastThrownObjectExceptionFromThread(reinterpret_cast<void**>(&m_delegatedException));
869     }
870
871     return m_delegatedException;
872 } // Exception* DelegatingException::GetDelegate()
873
874 //------------------------------------------------------------------------------
875 // Virtual overrides
876 HRESULT DelegatingException::GetHR()
877 {
878     WRAPPER_NO_CONTRACT;
879     SUPPORTS_DAC_HOST_ONLY;
880
881     // Retrieve any delegating exception.
882     Exception *pDelegate = GetDelegate();
883
884     // If there is a delegate exception, defer to it.  Otherwise,
885     //  default to E_FAIL.
886     return pDelegate ? pDelegate->GetHR() : E_FAIL;
887
888 } // HRESULT DelegatingException::GetHR()
889
890 //------------------------------------------------------------------------------
891 IErrorInfo *DelegatingException::GetErrorInfo()
892 {
893     WRAPPER_NO_CONTRACT;
894     
895     // Retrieve any delegating exception.
896     Exception *pDelegate = GetDelegate();
897
898     // If there is a delegate exception, defer to it.  Otherwise,
899     //  default to NULL.
900     return pDelegate ? pDelegate->GetErrorInfo() : NULL;
901
902 } // IErrorInfo *DelegatingException::GetErrorInfo()
903
904 //------------------------------------------------------------------------------
905 void DelegatingException::GetMessage(SString &result)
906 {
907     WRAPPER_NO_CONTRACT;
908     
909     // Retrieve any delegating exception.
910     Exception *pDelegate = GetDelegate();
911
912     // If there is a delegate exception, defer to it.  Otherwise,
913     //  default to a generic message.
914     if (pDelegate)
915     {
916         pDelegate->GetMessage(result);
917     }
918     else
919     {
920         // If we don't have a valid exception code, then give a generic message 
921         //  that's a little nicer than "code 0x00000000".
922         result.Printf("Unknown exception");
923     }
924 } // void DelegatingException::GetMessage()
925
926 //------------------------------------------------------------------------------
927 Exception *DelegatingException::Clone()
928 {
929     WRAPPER_NO_CONTRACT;
930
931     // Clone the base exception, this will also take care of cloning the inner 
932     // exception if there is one.
933     NewHolder<DelegatingException> retExcep((DelegatingException*)Exception::Clone());
934         
935     // If there is a valid delegating exception...
936     if (IsDelegateValid())
937     {   // ... clone it.
938         retExcep->m_delegatedException = m_delegatedException->Clone();
939     }
940     else
941     {   // ... but if there is not, just copy -- either NULL or DELEGATE_NOT_YET_SET
942         retExcep->m_delegatedException = m_delegatedException;
943     }
944
945     retExcep.SuppressRelease();
946     return retExcep;
947 } // virtual Exception *DelegatingException::Clone()
948
949 //==============================================================================
950 //==============================================================================
951
952 void DECLSPEC_NORETURN ThrowHR(HRESULT hr)
953 {
954     WRAPPER_NO_CONTRACT;
955
956     STRESS_LOG1(LF_EH, LL_INFO100, "ThrowHR: HR = %x\n", hr);
957     
958     if (hr == E_OUTOFMEMORY)
959         ThrowOutOfMemory();
960
961     // Catchers assume only failing hresults
962     _ASSERTE(FAILED(hr));   
963     if (hr == S_OK)
964         hr = E_FAIL;
965
966     EX_THROW(HRException, (hr));
967 }
968
969 void DECLSPEC_NORETURN ThrowHR(HRESULT hr, SString const &msg)
970 {
971     WRAPPER_NO_CONTRACT;
972
973     STRESS_LOG1(LF_EH, LL_INFO100, "ThrowHR: HR = %x\n", hr);
974     
975     if (hr == E_OUTOFMEMORY)
976         ThrowOutOfMemory();
977
978     // Catchers assume only failing hresults
979     _ASSERTE(FAILED(hr));   
980     if (hr == S_OK)
981         hr = E_FAIL;
982
983     EX_THROW(HRMsgException, (hr, msg));
984 }
985
986 void DECLSPEC_NORETURN ThrowHR(HRESULT hr, UINT uText)
987 {
988     WRAPPER_NO_CONTRACT;
989     SUPPORTS_DAC_HOST_ONLY;
990
991     if (hr == E_OUTOFMEMORY)
992         ThrowOutOfMemory();
993
994     // Catchers assume only failing hresults
995     _ASSERTE(FAILED(hr));   
996     if (hr == S_OK)
997         hr = E_FAIL;
998
999     SString sExceptionText;
1000
1001     // We won't check the return value here. If it fails, we'll just
1002     // throw the HR
1003     sExceptionText.LoadResource(CCompRC::Error, uText);
1004
1005     EX_THROW(HRMsgException, (hr, sExceptionText));
1006 }
1007
1008 void DECLSPEC_NORETURN ThrowWin32(DWORD err)
1009 {
1010     WRAPPER_NO_CONTRACT;
1011     if (err == ERROR_NOT_ENOUGH_MEMORY)
1012     {
1013         ThrowOutOfMemory();
1014     }
1015     else
1016     {
1017         ThrowHR(HRESULT_FROM_WIN32(err));
1018     }
1019 }
1020
1021 void DECLSPEC_NORETURN ThrowLastError()
1022 {
1023     WRAPPER_NO_CONTRACT;
1024     SUPPORTS_DAC;
1025
1026     ThrowWin32(GetLastError());
1027 }
1028
1029 void DECLSPEC_NORETURN ThrowOutOfMemory()
1030 {
1031     CONTRACTL
1032     {
1033         THROWS;
1034         GC_NOTRIGGER;
1035         SUPPORTS_DAC;
1036     }
1037     CONTRACTL_END;
1038     
1039 #ifndef DACCESS_COMPILE
1040
1041     // Use volatile store to prevent compiler from optimizing the static variable away
1042     VolatileStoreWithoutBarrier<HRESULT>(&g_hrFatalError, COR_E_OUTOFMEMORY);
1043
1044     // Regular CLR builds - throw our pre-created OOM exception object
1045     PAL_CPP_THROW(Exception *, Exception::GetOOMException());
1046
1047 #else
1048
1049     // DAC builds - raise a DacError
1050     DacError(E_OUTOFMEMORY);
1051
1052     // DacError always throws but isn't marked DECLSPEC_NORETURN so we have to
1053     // tell the compiler that this code is unreachable. We could mark DacError
1054     // (and DacNotImpl) as DECLSPEC_NORETURN, but then we've have to update a
1055     // lot of code where we do something afterwards. Also, due to inlining,
1056     // we'd sometimes have to change functions which call functions that only
1057     // call DacNotImpl. I have these changes in a bbpack and some of them look
1058     // nice, but I'm not sure if it's worth the risk of merge conflicts.
1059     UNREACHABLE();
1060
1061 #endif
1062 }
1063
1064 #include "corexcep.h"
1065
1066 //--------------------------------------------------------------------------------
1067 // Helper for EX_THROW_WITH_INNER()
1068 //
1069 // Clones an exception into the current domain. Also handles special cases for
1070 // OOM and other stuff. Making this a function so we don't inline all this logic
1071 // every place we call EX_THROW_WITH_INNER.
1072 //
1073 // If the "inner" is a transient exception such as OOM or ThreadAbort, this function
1074 // will just throw it rather than allow it to be wrapped in another exception.
1075 //--------------------------------------------------------------------------------
1076 Exception *ExThrowWithInnerHelper(Exception *inner)
1077 {
1078     CONTRACTL
1079     {
1080         THROWS;
1081         GC_NOTRIGGER;
1082     }
1083     CONTRACTL_END
1084
1085     // Yes, NULL is a legal case. Makes it easier to author uniform helpers for
1086     // both wrapped and normal exceptions.
1087     if (inner == NULL)
1088     {
1089         return NULL;
1090     }
1091
1092     if (inner == Exception::GetOOMException())
1093     {
1094         // We don't want to do allocations if we're already throwing an OOM!
1095         PAL_CPP_THROW(Exception*, inner);
1096     }
1097
1098     inner = inner->DomainBoundClone();
1099
1100     // It isn't useful to wrap OOMs and StackOverflows in other exceptions. Just throw them now.
1101     // 
1102     if (inner->IsTransient())
1103     {
1104         PAL_CPP_THROW(Exception*, inner);
1105     }
1106     return inner;
1107 }
1108
1109 #ifdef _DEBUG
1110
1111 #ifdef _MSC_VER
1112 #pragma optimize("", off)
1113 #endif // _MSC_VER
1114
1115 void ExThrowTrap(const char *fcn, const char *file, int line, const char *szType, HRESULT hr, const char *args)
1116 {
1117     SUPPORTS_DAC;
1118     return;
1119 }
1120
1121 #ifdef _MSC_VER
1122 #pragma optimize("", on)
1123 #endif // _MSC_VER
1124
1125 #endif
1126
1127
1128
1129
1130 //-------------------------------------------------------------------------------------------
1131 // This routine will generate the most descriptive possible error message for an hresult.
1132 // It will generate at minimum the hex value. It will also try to generate the symbolic name
1133 // (E_POINTER) and the friendly description (from the message tables.)
1134 //
1135 // bNoGeekStuff suppresses hex HR codes. Use this sparingly as most error strings generated by the
1136 // CLR are aimed at developers, not end-users.
1137 //-------------------------------------------------------------------------------------------
1138 void GetHRMsg(HRESULT hr, SString &result, BOOL bNoGeekStuff/* = FALSE*/)
1139 {
1140     CONTRACTL
1141     {
1142         GC_NOTRIGGER;
1143         THROWS;
1144     }
1145     CONTRACTL_END;
1146
1147     result = W("");     // Make sure this routine isn't an inadvertent data-leak exploit!
1148
1149     
1150
1151     SString strDescr;
1152     BOOL    fHaveDescr = FALSE;
1153
1154     if (FAILED(hr) && HRESULT_FACILITY(hr) == FACILITY_URT && HRESULT_CODE(hr) < MAX_URT_HRESULT_CODE)
1155     {
1156         fHaveDescr = strDescr.LoadResource(CCompRC::Error, MSG_FOR_URT_HR(hr));
1157     }
1158     else
1159     {
1160         DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM;
1161         dwFlags |= FORMAT_MESSAGE_MAX_WIDTH_MASK;
1162
1163         fHaveDescr = strDescr.FormatMessage(dwFlags, 0, hr, 0);
1164     }
1165
1166     LPCSTR name = Exception::GetHRSymbolicName(hr);
1167
1168     // If we can't get a resource string, print the hresult regardless.
1169     if (!fHaveDescr)
1170     {
1171         bNoGeekStuff = FALSE;
1172     }
1173
1174     if (fHaveDescr)
1175     {
1176         result.Append(strDescr);
1177     }
1178
1179     if (!bNoGeekStuff)
1180     {
1181         if (fHaveDescr)
1182         {
1183             result.Append(W(" ("));
1184         }
1185
1186         result.AppendPrintf(W("0x%.8X"), hr);
1187         if (name != NULL)
1188         {
1189             result.AppendPrintf(W(" (%S)"), name);
1190         }
1191
1192         if (fHaveDescr)
1193         {
1194             result.Append(W(")"));
1195         }
1196     }
1197 }
1198
1199
1200 //-------------------------------------------------------------------------------------------
1201 // Similar to GetHRMsg but phrased for top-level exception message.
1202 //-------------------------------------------------------------------------------------------
1203 void GenerateTopLevelHRExceptionMessage(HRESULT hresult, SString &result)
1204 {
1205     CONTRACTL
1206     {
1207         GC_NOTRIGGER;
1208         THROWS;
1209     }
1210     CONTRACTL_END;
1211
1212     result = W("");     // Make sure this routine isn't an inadvertent data-leak exploit!
1213
1214     GetHRMsg(hresult, result);
1215 }
1216
1217 #if !defined(DACCESS_COMPILE)
1218
1219 void GetCurrentExceptionPointers(PEXCEPTION_POINTERS pExceptionInfo)
1220 {
1221     WRAPPER_NO_CONTRACT;
1222
1223     PEXCEPTION_RECORD pRecord = (PEXCEPTION_RECORD)ClrFlsGetValue(TlsIdx_PEXCEPTION_RECORD);
1224     PCONTEXT pContext = (PCONTEXT)ClrFlsGetValue(TlsIdx_PCONTEXT);
1225
1226     pExceptionInfo->ContextRecord = pContext;
1227     pExceptionInfo->ExceptionRecord = pRecord;
1228
1229 #ifdef _DEBUG
1230     if (pRecord != NULL)
1231     {
1232         _ASSERTE ((PVOID)(pRecord) > (PVOID)(&pRecord));
1233     }
1234 #endif
1235 }
1236 #endif // !defined(DACCESS_COMPILE)
1237
1238 DWORD GetCurrentExceptionCode()
1239 {
1240     WRAPPER_NO_CONTRACT;
1241     SUPPORTS_DAC_HOST_ONLY; 
1242
1243     return (DWORD)(size_t)ClrFlsGetValue(TlsIdx_EXCEPTION_CODE);
1244 }
1245
1246 //=========================================================================================== 
1247 // These abstractions hide the difference between legacy desktop CLR's (that don't support
1248 // side-by-side-inproc and rely on a fixed SEH code to identify managed exceptions) and
1249 // new CLR's that support side-by-side inproc.
1250 //
1251 // The new CLR's use a different set of SEH codes to avoid conflicting with the legacy CLR's.
1252 // In addition, to distinguish between EH's raised by different inproc instances of the CLR,
1253 // the module handle of the owning CLR is stored in ExceptionRecord.ExceptionInformation[4].
1254 //
1255 // (Note: all existing SEH's use either only slot [0] or no slots at all. We are leaving
1256 //  slots [1] thru [3] open for future expansion.) 
1257 //===========================================================================================
1258
1259 // Is this exception code one of the special CLR-specific SEH codes that participate in the
1260 // instance-tagging scheme?
1261 BOOL IsInstanceTaggedSEHCode(DWORD dwExceptionCode)
1262 {
1263    LIMITED_METHOD_DAC_CONTRACT;
1264
1265     return dwExceptionCode == EXCEPTION_COMPLUS;
1266 }
1267
1268 // This set of overloads generates the NumberParameters and ExceptionInformation[] array to
1269 // pass to RaiseException().
1270 //
1271 // Parameters:
1272 //    exceptionArgs:   a fixed-size array of size INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE.
1273 //                     This will get filled in by this function. (The module handle goes
1274 //                     in the last slot if this is a side-by-side-inproc enabled build.)
1275 //
1276 //    exceptionArg1... up to four arguments that go in slots [0]..[3]. These depends
1277 //                     the specific requirements of your exception code.
1278 //
1279 // Returns:
1280 //    The NumberParameters to pass to RaiseException().
1281 //
1282 //    Basically, this is  either INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE or the count of your
1283 //    fixed arguments depending on whether this tagged-SEH-enabled build.
1284 //
1285 // This function is not permitted to fail.
1286
1287 // (the existing system can support more overloads up to 4 fixed arguments but we don't need them at this time.)
1288
1289 static DWORD MarkAsThrownByUsWorker(UINT numArgs, /*out*/ ULONG_PTR exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE], ULONG_PTR arg0 = 0)
1290 {
1291     STATIC_CONTRACT_NOTHROW;
1292     STATIC_CONTRACT_GC_NOTRIGGER;
1293     STATIC_CONTRACT_FORBID_FAULT;
1294
1295
1296     _ASSERTE(numArgs < INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE);
1297     FillMemory(exceptionArgs, sizeof(ULONG_PTR) * INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE, 0);
1298
1299     exceptionArgs[0] = arg0;
1300
1301 #if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
1302     exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE - 1] = (ULONG_PTR) (GetCLRModule());
1303 #endif // !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
1304     
1305     return INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE;
1306 }
1307
1308 DWORD MarkAsThrownByUs(/*out*/ ULONG_PTR exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE])
1309 {
1310     STATIC_CONTRACT_NOTHROW;
1311     STATIC_CONTRACT_GC_NOTRIGGER;
1312     STATIC_CONTRACT_FORBID_FAULT;
1313
1314     return MarkAsThrownByUsWorker(0, exceptionArgs);
1315 }
1316
1317 DWORD MarkAsThrownByUs(/*out*/ ULONG_PTR exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE], ULONG_PTR arg0)
1318 {
1319     STATIC_CONTRACT_NOTHROW;
1320     STATIC_CONTRACT_GC_NOTRIGGER;
1321     STATIC_CONTRACT_FORBID_FAULT;
1322
1323     return MarkAsThrownByUsWorker(1, exceptionArgs, arg0);
1324 }
1325
1326 // Given an exception record, checks if it's exception code matches a specific exception code
1327 // *and* whether it was tagged by the calling instance of the CLR.
1328 //
1329 // If this is a non-tagged-SEH-enabled build, it is blindly assumed to be tagged by the
1330 // calling instance of the CLR. 
1331 BOOL WasThrownByUs(const EXCEPTION_RECORD *pcER, DWORD dwExceptionCode)
1332 {
1333     STATIC_CONTRACT_NOTHROW;
1334     STATIC_CONTRACT_GC_NOTRIGGER;
1335     STATIC_CONTRACT_FORBID_FAULT;
1336     STATIC_CONTRACT_SUPPORTS_DAC;
1337
1338     _ASSERTE(IsInstanceTaggedSEHCode(dwExceptionCode));
1339     _ASSERTE(pcER != NULL);
1340     if (dwExceptionCode != pcER->ExceptionCode)
1341     {
1342         return FALSE;
1343     }
1344
1345     if (pcER->NumberParameters != INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE)
1346     {
1347         return FALSE;
1348     }
1349 #if!defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
1350     if ( ((ULONG_PTR)(GetCLRModule())) != pcER->ExceptionInformation[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE - 1] )
1351     {
1352         return FALSE;
1353     }
1354     return TRUE;
1355 #else // !(!defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
1356     return FALSE;
1357 #endif // !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
1358 }
1359
1360
1361
1362 //-----------------------------------------------------------------------------------
1363 // The following group wraps the basic abstracts specifically for EXCEPTION_COMPLUS.
1364 //-----------------------------------------------------------------------------------
1365 BOOL IsComPlusException(const EXCEPTION_RECORD *pcER)
1366 {
1367     STATIC_CONTRACT_WRAPPER;
1368
1369     return WasThrownByUs(pcER, EXCEPTION_COMPLUS);
1370 }
1371
1372 VOID RaiseComPlusException()
1373 {
1374     STATIC_CONTRACT_THROWS;
1375     STATIC_CONTRACT_GC_NOTRIGGER;
1376     STATIC_CONTRACT_FORBID_FAULT; 
1377
1378
1379     ULONG_PTR exceptionArgs[INSTANCE_TAGGED_SEH_PARAM_ARRAY_SIZE];
1380     DWORD     numParams = MarkAsThrownByUs(exceptionArgs);
1381     RaiseException(EXCEPTION_COMPLUS, 0, numParams, exceptionArgs);
1382 }
1383
1384 //=========================================================================================== 
1385 //===========================================================================================