-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
ex.cpp
1358 lines (1177 loc) · 51.6 KB
/
ex.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
//
// ---------------------------------------------------------------------------
// Ex.cpp
// ---------------------------------------------------------------------------
#include "stdafx.h"
#include "string.h"
#include "ex.h"
#include "holder.h"
// error codes
#include "corerror.h"
#include "../dlls/mscorrc/resource.h"
#include "olectl.h"
#include "corexcep.h"
#define MAX_EXCEPTION_MSG 200
// Set if fatal error (like stack overflow or out of memory) occurred in this process.
GVAL_IMPL_INIT(HRESULT, g_hrFatalError, S_OK);
// Helper function to get an exception object from outside the exception. In
// the CLR, it may be from the Thread object. Non-CLR users have no thread object,
// and it will do nothing.
void GetLastThrownObjectExceptionFromThread(Exception **ppException);
// Helper function to get pointer to clr module base
void* GetClrModuleBase();
Exception *Exception::g_OOMException = NULL;
// avoid global constructors
static BYTE g_OOMExceptionInstance[sizeof(OutOfMemoryException)];
Exception * Exception::GetOOMException()
{
LIMITED_METHOD_CONTRACT;
if (!g_OOMException) {
// Create a local copy on the stack and then copy it over to the static instance.
// This avoids race conditions caused by multiple initializations of vtable in the constructor
OutOfMemoryException local(TRUE); // Construct a "preallocated" instance.
memcpy((void*)&g_OOMExceptionInstance, (void*)&local, sizeof(OutOfMemoryException));
g_OOMException = (OutOfMemoryException*)&g_OOMExceptionInstance;
}
return g_OOMException;
}
/*virtual*/ Exception *OutOfMemoryException::Clone()
{
LIMITED_METHOD_CONTRACT;
return GetOOMException();
}
//------------------------------------------------------------------------------
void Exception::Delete(Exception* pvMemory)
{
CONTRACTL
{
GC_NOTRIGGER;
NOTHROW;
SUPPORTS_DAC_HOST_ONLY; // Exceptions aren't currently marshalled by DAC - just used in the host
}
CONTRACTL_END;
if ((pvMemory == 0) || pvMemory->IsPreallocatedException())
{
return;
}
::delete((Exception *) pvMemory);
}
void Exception::GetMessage(SString &result)
{
WRAPPER_NO_CONTRACT;
return GenerateTopLevelHRExceptionMessage(GetHR(), result);
}
void HRMsgException::GetMessage(SString &result)
{
WRAPPER_NO_CONTRACT;
if (m_msg.IsEmpty())
HRException::GetMessage(result);
else
result = m_msg;
}
Exception *Exception::Clone()
{
CONTRACTL
{
GC_NOTRIGGER;
THROWS;
}
CONTRACTL_END;
NewHolder<Exception> retExcep(CloneHelper());
if (m_innerException)
{
retExcep->m_innerException = m_innerException->Clone();
}
retExcep.SuppressRelease();
return retExcep;
}
Exception *Exception::CloneHelper()
{
StackSString s;
GetMessage(s);
return new HRMsgException(GetHR(), s);
}
Exception *Exception::DomainBoundClone()
{
CONTRACTL
{
// Because we may call DomainBoundCloneHelper() of ObjrefException or CLRLastThrownObjectException
// this should be GC_TRIGGERS, but we can not include EE contracts in Utilcode.
THROWS;
}
CONTRACTL_END;
NewHolder<Exception> retExcep(DomainBoundCloneHelper());
if (m_innerException)
{
retExcep->m_innerException = m_innerException->DomainBoundClone();
}
retExcep.SuppressRelease();
return retExcep;
}
BOOL Exception::IsTerminal()
{
CONTRACTL
{
GC_NOTRIGGER;
NOTHROW;
// CLRException::GetHR() can eventually call BaseDomain::CreateHandle(),
// which can indirectly cause a lock if we get a miss in the handle table
// cache (TableCacheMissOnAlloc). Since CLRException::GetHR() is virtual,
// SCAN won't find this for you (though 40 minutes of one of the sql stress
// tests will :-))
CAN_TAKE_LOCK;
}
CONTRACTL_END;
HRESULT hr = GetHR();
return (COR_E_THREADABORTED == hr);
}
BOOL Exception::IsTransient()
{
WRAPPER_NO_CONTRACT;
return IsTransient(GetHR());
}
/* static */
BOOL Exception::IsTransient(HRESULT hr)
{
LIMITED_METHOD_CONTRACT;
return (hr == COR_E_THREADABORTED
|| hr == COR_E_THREADINTERRUPTED
|| hr == COR_E_THREADSTOP
|| hr == COR_E_APPDOMAINUNLOADED
|| hr == E_OUTOFMEMORY
|| hr == HRESULT_FROM_WIN32(ERROR_COMMITMENT_LIMIT) // ran out of room in pagefile
|| hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY)
|| hr == (HRESULT)STATUS_NO_MEMORY
|| hr == COR_E_STACKOVERFLOW
|| hr == MSEE_E_ASSEMBLYLOADINPROGRESS);
}
//------------------------------------------------------------------------------
// Functions to manage the preallocated exceptions.
// Virtual
BOOL Exception::IsPreallocatedException()
{ // Most exceptions can't be preallocated. If they can be, their class
// should provide a virtual override of this function.
return FALSE;
}
BOOL Exception::IsPreallocatedOOMException()
{ // This is the preallocated OOM if it is preallocated and is OOM.
return IsPreallocatedException() && (GetInstanceType() == OutOfMemoryException::GetType());
}
//------------------------------------------------------------------------------
#ifdef _PREFAST_
#pragma warning(push)
#pragma warning(disable:21000) // Suppress PREFast warning about overly large function
#endif
LPCSTR Exception::GetHRSymbolicName(HRESULT hr)
{
LIMITED_METHOD_CONTRACT;
#define CASE_HRESULT(hrname) case hrname: return #hrname;
switch (hr)
{
CASE_HRESULT(S_OK)// 0x00000000L
CASE_HRESULT(S_FALSE)// 0x00000001L
CASE_HRESULT(E_UNEXPECTED)// 0x8000FFFFL
CASE_HRESULT(E_NOTIMPL)// 0x80004001L
CASE_HRESULT(E_OUTOFMEMORY)// 0x8007000EL
CASE_HRESULT(E_INVALIDARG)// 0x80070057L
CASE_HRESULT(E_NOINTERFACE)// 0x80004002L
CASE_HRESULT(E_POINTER)// 0x80004003L
CASE_HRESULT(E_HANDLE)// 0x80070006L
CASE_HRESULT(E_ABORT)// 0x80004004L
CASE_HRESULT(E_FAIL)// 0x80004005L
CASE_HRESULT(E_ACCESSDENIED)// 0x80070005L
#ifdef FEATURE_COMINTEROP
CASE_HRESULT(CO_E_INIT_TLS)// 0x80004006L
CASE_HRESULT(CO_E_INIT_SHARED_ALLOCATOR)// 0x80004007L
CASE_HRESULT(CO_E_INIT_MEMORY_ALLOCATOR)// 0x80004008L
CASE_HRESULT(CO_E_INIT_CLASS_CACHE)// 0x80004009L
CASE_HRESULT(CO_E_INIT_RPC_CHANNEL)// 0x8000400AL
CASE_HRESULT(CO_E_INIT_TLS_SET_CHANNEL_CONTROL)// 0x8000400BL
CASE_HRESULT(CO_E_INIT_TLS_CHANNEL_CONTROL)// 0x8000400CL
CASE_HRESULT(CO_E_INIT_UNACCEPTED_USER_ALLOCATOR)// 0x8000400DL
CASE_HRESULT(CO_E_INIT_SCM_MUTEX_EXISTS)// 0x8000400EL
CASE_HRESULT(CO_E_INIT_SCM_FILE_MAPPING_EXISTS)// 0x8000400FL
CASE_HRESULT(CO_E_INIT_SCM_MAP_VIEW_OF_FILE)// 0x80004010L
CASE_HRESULT(CO_E_INIT_SCM_EXEC_FAILURE)// 0x80004011L
CASE_HRESULT(CO_E_INIT_ONLY_SINGLE_THREADED)// 0x80004012L
// ******************
// FACILITY_ITF
// ******************
CASE_HRESULT(OLE_E_OLEVERB)// 0x80040000L
CASE_HRESULT(OLE_E_ADVF)// 0x80040001L
CASE_HRESULT(OLE_E_ENUM_NOMORE)// 0x80040002L
CASE_HRESULT(OLE_E_ADVISENOTSUPPORTED)// 0x80040003L
CASE_HRESULT(OLE_E_NOCONNECTION)// 0x80040004L
CASE_HRESULT(OLE_E_NOTRUNNING)// 0x80040005L
CASE_HRESULT(OLE_E_NOCACHE)// 0x80040006L
CASE_HRESULT(OLE_E_BLANK)// 0x80040007L
CASE_HRESULT(OLE_E_CLASSDIFF)// 0x80040008L
CASE_HRESULT(OLE_E_CANT_GETMONIKER)// 0x80040009L
CASE_HRESULT(OLE_E_CANT_BINDTOSOURCE)// 0x8004000AL
CASE_HRESULT(OLE_E_STATIC)// 0x8004000BL
CASE_HRESULT(OLE_E_PROMPTSAVECANCELLED)// 0x8004000CL
CASE_HRESULT(OLE_E_INVALIDRECT)// 0x8004000DL
CASE_HRESULT(OLE_E_WRONGCOMPOBJ)// 0x8004000EL
CASE_HRESULT(OLE_E_INVALIDHWND)// 0x8004000FL
CASE_HRESULT(OLE_E_NOT_INPLACEACTIVE)// 0x80040010L
CASE_HRESULT(OLE_E_CANTCONVERT)// 0x80040011L
CASE_HRESULT(OLE_E_NOSTORAGE)// 0x80040012L
CASE_HRESULT(DV_E_FORMATETC)// 0x80040064L
CASE_HRESULT(DV_E_DVTARGETDEVICE)// 0x80040065L
CASE_HRESULT(DV_E_STGMEDIUM)// 0x80040066L
CASE_HRESULT(DV_E_STATDATA)// 0x80040067L
CASE_HRESULT(DV_E_LINDEX)// 0x80040068L
CASE_HRESULT(DV_E_TYMED)// 0x80040069L
CASE_HRESULT(DV_E_CLIPFORMAT)// 0x8004006AL
CASE_HRESULT(DV_E_DVASPECT)// 0x8004006BL
CASE_HRESULT(DV_E_DVTARGETDEVICE_SIZE)// 0x8004006CL
CASE_HRESULT(DV_E_NOIVIEWOBJECT)// 0x8004006DL
CASE_HRESULT(DRAGDROP_E_NOTREGISTERED)// 0x80040100L
CASE_HRESULT(DRAGDROP_E_ALREADYREGISTERED)// 0x80040101L
CASE_HRESULT(DRAGDROP_E_INVALIDHWND)// 0x80040102L
CASE_HRESULT(CLASS_E_NOAGGREGATION)// 0x80040110L
CASE_HRESULT(CLASS_E_CLASSNOTAVAILABLE)// 0x80040111L
CASE_HRESULT(VIEW_E_DRAW)// 0x80040140L
CASE_HRESULT(REGDB_E_READREGDB)// 0x80040150L
CASE_HRESULT(REGDB_E_WRITEREGDB)// 0x80040151L
CASE_HRESULT(REGDB_E_KEYMISSING)// 0x80040152L
CASE_HRESULT(REGDB_E_INVALIDVALUE)// 0x80040153L
CASE_HRESULT(REGDB_E_CLASSNOTREG)// 0x80040154L
CASE_HRESULT(CACHE_E_NOCACHE_UPDATED)// 0x80040170L
CASE_HRESULT(OLEOBJ_E_NOVERBS)// 0x80040180L
CASE_HRESULT(INPLACE_E_NOTUNDOABLE)// 0x800401A0L
CASE_HRESULT(INPLACE_E_NOTOOLSPACE)// 0x800401A1L
CASE_HRESULT(CONVERT10_E_OLESTREAM_GET)// 0x800401C0L
CASE_HRESULT(CONVERT10_E_OLESTREAM_PUT)// 0x800401C1L
CASE_HRESULT(CONVERT10_E_OLESTREAM_FMT)// 0x800401C2L
CASE_HRESULT(CONVERT10_E_OLESTREAM_BITMAP_TO_DIB)// 0x800401C3L
CASE_HRESULT(CONVERT10_E_STG_FMT)// 0x800401C4L
CASE_HRESULT(CONVERT10_E_STG_NO_STD_STREAM)// 0x800401C5L
CASE_HRESULT(CONVERT10_E_STG_DIB_TO_BITMAP)// 0x800401C6L
CASE_HRESULT(CLIPBRD_E_CANT_OPEN)// 0x800401D0L
CASE_HRESULT(CLIPBRD_E_CANT_EMPTY)// 0x800401D1L
CASE_HRESULT(CLIPBRD_E_CANT_SET)// 0x800401D2L
CASE_HRESULT(CLIPBRD_E_BAD_DATA)// 0x800401D3L
CASE_HRESULT(CLIPBRD_E_CANT_CLOSE)// 0x800401D4L
CASE_HRESULT(MK_E_CONNECTMANUALLY)// 0x800401E0L
CASE_HRESULT(MK_E_EXCEEDEDDEADLINE)// 0x800401E1L
CASE_HRESULT(MK_E_NEEDGENERIC)// 0x800401E2L
CASE_HRESULT(MK_E_UNAVAILABLE)// 0x800401E3L
CASE_HRESULT(MK_E_SYNTAX)// 0x800401E4L
CASE_HRESULT(MK_E_NOOBJECT)// 0x800401E5L
CASE_HRESULT(MK_E_INVALIDEXTENSION)// 0x800401E6L
CASE_HRESULT(MK_E_INTERMEDIATEINTERFACENOTSUPPORTED)// 0x800401E7L
CASE_HRESULT(MK_E_NOTBINDABLE)// 0x800401E8L
CASE_HRESULT(MK_E_NOTBOUND)// 0x800401E9L
CASE_HRESULT(MK_E_CANTOPENFILE)// 0x800401EAL
CASE_HRESULT(MK_E_MUSTBOTHERUSER)// 0x800401EBL
CASE_HRESULT(MK_E_NOINVERSE)// 0x800401ECL
CASE_HRESULT(MK_E_NOSTORAGE)// 0x800401EDL
CASE_HRESULT(MK_E_NOPREFIX)// 0x800401EEL
CASE_HRESULT(MK_E_ENUMERATION_FAILED)// 0x800401EFL
CASE_HRESULT(CO_E_NOTINITIALIZED)// 0x800401F0L
CASE_HRESULT(CO_E_ALREADYINITIALIZED)// 0x800401F1L
CASE_HRESULT(CO_E_CANTDETERMINECLASS)// 0x800401F2L
CASE_HRESULT(CO_E_CLASSSTRING)// 0x800401F3L
CASE_HRESULT(CO_E_IIDSTRING)// 0x800401F4L
CASE_HRESULT(CO_E_APPNOTFOUND)// 0x800401F5L
CASE_HRESULT(CO_E_APPSINGLEUSE)// 0x800401F6L
CASE_HRESULT(CO_E_ERRORINAPP)// 0x800401F7L
CASE_HRESULT(CO_E_DLLNOTFOUND)// 0x800401F8L
CASE_HRESULT(CO_E_ERRORINDLL)// 0x800401F9L
CASE_HRESULT(CO_E_WRONGOSFORAPP)// 0x800401FAL
CASE_HRESULT(CO_E_OBJNOTREG)// 0x800401FBL
CASE_HRESULT(CO_E_OBJISREG)// 0x800401FCL
CASE_HRESULT(CO_E_OBJNOTCONNECTED)// 0x800401FDL
CASE_HRESULT(CO_E_APPDIDNTREG)// 0x800401FEL
CASE_HRESULT(CO_E_RELEASED)// 0x800401FFL
CASE_HRESULT(OLE_S_USEREG)// 0x00040000L
CASE_HRESULT(OLE_S_STATIC)// 0x00040001L
CASE_HRESULT(OLE_S_MAC_CLIPFORMAT)// 0x00040002L
CASE_HRESULT(DRAGDROP_S_DROP)// 0x00040100L
CASE_HRESULT(DRAGDROP_S_CANCEL)// 0x00040101L
CASE_HRESULT(DRAGDROP_S_USEDEFAULTCURSORS)// 0x00040102L
CASE_HRESULT(DATA_S_SAMEFORMATETC)// 0x00040130L
CASE_HRESULT(VIEW_S_ALREADY_FROZEN)// 0x00040140L
CASE_HRESULT(CACHE_S_FORMATETC_NOTSUPPORTED)// 0x00040170L
CASE_HRESULT(CACHE_S_SAMECACHE)// 0x00040171L
CASE_HRESULT(CACHE_S_SOMECACHES_NOTUPDATED)// 0x00040172L
CASE_HRESULT(OLEOBJ_S_INVALIDVERB)// 0x00040180L
CASE_HRESULT(OLEOBJ_S_CANNOT_DOVERB_NOW)// 0x00040181L
CASE_HRESULT(OLEOBJ_S_INVALIDHWND)// 0x00040182L
CASE_HRESULT(INPLACE_S_TRUNCATED)// 0x000401A0L
CASE_HRESULT(CONVERT10_S_NO_PRESENTATION)// 0x000401C0L
CASE_HRESULT(MK_S_REDUCED_TO_SELF)// 0x000401E2L
CASE_HRESULT(MK_S_ME)// 0x000401E4L
CASE_HRESULT(MK_S_HIM)// 0x000401E5L
CASE_HRESULT(MK_S_US)// 0x000401E6L
CASE_HRESULT(MK_S_MONIKERALREADYREGISTERED)// 0x000401E7L
// ******************
// FACILITY_WINDOWS
// ******************
CASE_HRESULT(CO_E_CLASS_CREATE_FAILED)// 0x80080001L
CASE_HRESULT(CO_E_SCM_ERROR)// 0x80080002L
CASE_HRESULT(CO_E_SCM_RPC_FAILURE)// 0x80080003L
CASE_HRESULT(CO_E_BAD_PATH)// 0x80080004L
CASE_HRESULT(CO_E_SERVER_EXEC_FAILURE)// 0x80080005L
CASE_HRESULT(CO_E_OBJSRV_RPC_FAILURE)// 0x80080006L
CASE_HRESULT(MK_E_NO_NORMALIZED)// 0x80080007L
CASE_HRESULT(CO_E_SERVER_STOPPING)// 0x80080008L
CASE_HRESULT(MEM_E_INVALID_ROOT)// 0x80080009L
CASE_HRESULT(MEM_E_INVALID_LINK)// 0x80080010L
CASE_HRESULT(MEM_E_INVALID_SIZE)// 0x80080011L
// ******************
// FACILITY_DISPATCH
// ******************
CASE_HRESULT(DISP_E_UNKNOWNINTERFACE)// 0x80020001L
CASE_HRESULT(DISP_E_MEMBERNOTFOUND)// 0x80020003L
CASE_HRESULT(DISP_E_PARAMNOTFOUND)// 0x80020004L
CASE_HRESULT(DISP_E_TYPEMISMATCH)// 0x80020005L
CASE_HRESULT(DISP_E_UNKNOWNNAME)// 0x80020006L
CASE_HRESULT(DISP_E_NONAMEDARGS)// 0x80020007L
CASE_HRESULT(DISP_E_BADVARTYPE)// 0x80020008L
CASE_HRESULT(DISP_E_EXCEPTION)// 0x80020009L
CASE_HRESULT(DISP_E_OVERFLOW)// 0x8002000AL
CASE_HRESULT(DISP_E_BADINDEX)// 0x8002000BL
CASE_HRESULT(DISP_E_UNKNOWNLCID)// 0x8002000CL
CASE_HRESULT(DISP_E_ARRAYISLOCKED)// 0x8002000DL
CASE_HRESULT(DISP_E_BADPARAMCOUNT)// 0x8002000EL
CASE_HRESULT(DISP_E_PARAMNOTOPTIONAL)// 0x8002000FL
CASE_HRESULT(DISP_E_BADCALLEE)// 0x80020010L
CASE_HRESULT(DISP_E_NOTACOLLECTION)// 0x80020011L
CASE_HRESULT(TYPE_E_BUFFERTOOSMALL)// 0x80028016L
CASE_HRESULT(TYPE_E_INVDATAREAD)// 0x80028018L
CASE_HRESULT(TYPE_E_UNSUPFORMAT)// 0x80028019L
CASE_HRESULT(TYPE_E_REGISTRYACCESS)// 0x8002801CL
CASE_HRESULT(TYPE_E_LIBNOTREGISTERED)// 0x8002801DL
CASE_HRESULT(TYPE_E_UNDEFINEDTYPE)// 0x80028027L
CASE_HRESULT(TYPE_E_QUALIFIEDNAMEDISALLOWED)// 0x80028028L
CASE_HRESULT(TYPE_E_INVALIDSTATE)// 0x80028029L
CASE_HRESULT(TYPE_E_WRONGTYPEKIND)// 0x8002802AL
CASE_HRESULT(TYPE_E_ELEMENTNOTFOUND)// 0x8002802BL
CASE_HRESULT(TYPE_E_AMBIGUOUSNAME)// 0x8002802CL
CASE_HRESULT(TYPE_E_NAMECONFLICT)// 0x8002802DL
CASE_HRESULT(TYPE_E_UNKNOWNLCID)// 0x8002802EL
CASE_HRESULT(TYPE_E_DLLFUNCTIONNOTFOUND)// 0x8002802FL
CASE_HRESULT(TYPE_E_BADMODULEKIND)// 0x800288BDL
CASE_HRESULT(TYPE_E_SIZETOOBIG)// 0x800288C5L
CASE_HRESULT(TYPE_E_DUPLICATEID)// 0x800288C6L
CASE_HRESULT(TYPE_E_INVALIDID)// 0x800288CFL
CASE_HRESULT(TYPE_E_TYPEMISMATCH)// 0x80028CA0L
CASE_HRESULT(TYPE_E_OUTOFBOUNDS)// 0x80028CA1L
CASE_HRESULT(TYPE_E_IOERROR)// 0x80028CA2L
CASE_HRESULT(TYPE_E_CANTCREATETMPFILE)// 0x80028CA3L
CASE_HRESULT(TYPE_E_CANTLOADLIBRARY)// 0x80029C4AL
CASE_HRESULT(TYPE_E_INCONSISTENTPROPFUNCS)// 0x80029C83L
CASE_HRESULT(TYPE_E_CIRCULARTYPE)// 0x80029C84L
// ******************
// FACILITY_STORAGE
// ******************
CASE_HRESULT(STG_E_INVALIDFUNCTION)// 0x80030001L
CASE_HRESULT(STG_E_FILENOTFOUND)// 0x80030002L
CASE_HRESULT(STG_E_PATHNOTFOUND)// 0x80030003L
CASE_HRESULT(STG_E_TOOMANYOPENFILES)// 0x80030004L
CASE_HRESULT(STG_E_ACCESSDENIED)// 0x80030005L
CASE_HRESULT(STG_E_INVALIDHANDLE)// 0x80030006L
CASE_HRESULT(STG_E_INSUFFICIENTMEMORY)// 0x80030008L
CASE_HRESULT(STG_E_INVALIDPOINTER)// 0x80030009L
CASE_HRESULT(STG_E_NOMOREFILES)// 0x80030012L
CASE_HRESULT(STG_E_DISKISWRITEPROTECTED)// 0x80030013L
CASE_HRESULT(STG_E_SEEKERROR)// 0x80030019L
CASE_HRESULT(STG_E_WRITEFAULT)// 0x8003001DL
CASE_HRESULT(STG_E_READFAULT)// 0x8003001EL
CASE_HRESULT(STG_E_SHAREVIOLATION)// 0x80030020L
CASE_HRESULT(STG_E_LOCKVIOLATION)// 0x80030021L
CASE_HRESULT(STG_E_FILEALREADYEXISTS)// 0x80030050L
CASE_HRESULT(STG_E_INVALIDPARAMETER)// 0x80030057L
CASE_HRESULT(STG_E_MEDIUMFULL)// 0x80030070L
CASE_HRESULT(STG_E_ABNORMALAPIEXIT)// 0x800300FAL
CASE_HRESULT(STG_E_INVALIDHEADER)// 0x800300FBL
CASE_HRESULT(STG_E_INVALIDNAME)// 0x800300FCL
CASE_HRESULT(STG_E_UNKNOWN)// 0x800300FDL
CASE_HRESULT(STG_E_UNIMPLEMENTEDFUNCTION)// 0x800300FEL
CASE_HRESULT(STG_E_INVALIDFLAG)// 0x800300FFL
CASE_HRESULT(STG_E_INUSE)// 0x80030100L
CASE_HRESULT(STG_E_NOTCURRENT)// 0x80030101L
CASE_HRESULT(STG_E_REVERTED)// 0x80030102L
CASE_HRESULT(STG_E_CANTSAVE)// 0x80030103L
CASE_HRESULT(STG_E_OLDFORMAT)// 0x80030104L
CASE_HRESULT(STG_E_OLDDLL)// 0x80030105L
CASE_HRESULT(STG_E_SHAREREQUIRED)// 0x80030106L
CASE_HRESULT(STG_E_NOTFILEBASEDSTORAGE)// 0x80030107L
CASE_HRESULT(STG_S_CONVERTED)// 0x00030200L
// ******************
// FACILITY_RPC
// ******************
CASE_HRESULT(RPC_E_CALL_REJECTED)// 0x80010001L
CASE_HRESULT(RPC_E_CALL_CANCELED)// 0x80010002L
CASE_HRESULT(RPC_E_CANTPOST_INSENDCALL)// 0x80010003L
CASE_HRESULT(RPC_E_CANTCALLOUT_INASYNCCALL)// 0x80010004L
CASE_HRESULT(RPC_E_CANTCALLOUT_INEXTERNALCALL)// 0x80010005L
CASE_HRESULT(RPC_E_CONNECTION_TERMINATED)// 0x80010006L
CASE_HRESULT(RPC_E_SERVER_DIED)// 0x80010007L
CASE_HRESULT(RPC_E_CLIENT_DIED)// 0x80010008L
CASE_HRESULT(RPC_E_INVALID_DATAPACKET)// 0x80010009L
CASE_HRESULT(RPC_E_CANTTRANSMIT_CALL)// 0x8001000AL
CASE_HRESULT(RPC_E_CLIENT_CANTMARSHAL_DATA)// 0x8001000BL
CASE_HRESULT(RPC_E_CLIENT_CANTUNMARSHAL_DATA)// 0x8001000CL
CASE_HRESULT(RPC_E_SERVER_CANTMARSHAL_DATA)// 0x8001000DL
CASE_HRESULT(RPC_E_SERVER_CANTUNMARSHAL_DATA)// 0x8001000EL
CASE_HRESULT(RPC_E_INVALID_DATA)// 0x8001000FL
CASE_HRESULT(RPC_E_INVALID_PARAMETER)// 0x80010010L
CASE_HRESULT(RPC_E_CANTCALLOUT_AGAIN)// 0x80010011L
CASE_HRESULT(RPC_E_SERVER_DIED_DNE)// 0x80010012L
CASE_HRESULT(RPC_E_SYS_CALL_FAILED)// 0x80010100L
CASE_HRESULT(RPC_E_OUT_OF_RESOURCES)// 0x80010101L
CASE_HRESULT(RPC_E_ATTEMPTED_MULTITHREAD)// 0x80010102L
CASE_HRESULT(RPC_E_NOT_REGISTERED)// 0x80010103L
CASE_HRESULT(RPC_E_FAULT)// 0x80010104L
CASE_HRESULT(RPC_E_SERVERFAULT)// 0x80010105L
CASE_HRESULT(RPC_E_CHANGED_MODE)// 0x80010106L
CASE_HRESULT(RPC_E_INVALIDMETHOD)// 0x80010107L
CASE_HRESULT(RPC_E_DISCONNECTED)// 0x80010108L
CASE_HRESULT(RPC_E_RETRY)// 0x80010109L
CASE_HRESULT(RPC_E_SERVERCALL_RETRYLATER)// 0x8001010AL
CASE_HRESULT(RPC_E_SERVERCALL_REJECTED)// 0x8001010BL
CASE_HRESULT(RPC_E_INVALID_CALLDATA)// 0x8001010CL
CASE_HRESULT(RPC_E_CANTCALLOUT_ININPUTSYNCCALL)// 0x8001010DL
CASE_HRESULT(RPC_E_WRONG_THREAD)// 0x8001010EL
CASE_HRESULT(RPC_E_THREAD_NOT_INIT)// 0x8001010FL
CASE_HRESULT(RPC_E_UNEXPECTED)// 0x8001FFFFL
// ******************
// FACILITY_CTL
// ******************
CASE_HRESULT(CTL_E_ILLEGALFUNCTIONCALL)
CASE_HRESULT(CTL_E_OVERFLOW)
CASE_HRESULT(CTL_E_OUTOFMEMORY)
CASE_HRESULT(CTL_E_DIVISIONBYZERO)
CASE_HRESULT(CTL_E_OUTOFSTRINGSPACE)
CASE_HRESULT(CTL_E_OUTOFSTACKSPACE)
CASE_HRESULT(CTL_E_BADFILENAMEORNUMBER)
CASE_HRESULT(CTL_E_FILENOTFOUND)
CASE_HRESULT(CTL_E_BADFILEMODE)
CASE_HRESULT(CTL_E_FILEALREADYOPEN)
CASE_HRESULT(CTL_E_DEVICEIOERROR)
CASE_HRESULT(CTL_E_FILEALREADYEXISTS)
CASE_HRESULT(CTL_E_BADRECORDLENGTH)
CASE_HRESULT(CTL_E_DISKFULL)
CASE_HRESULT(CTL_E_BADRECORDNUMBER)
CASE_HRESULT(CTL_E_BADFILENAME)
CASE_HRESULT(CTL_E_TOOMANYFILES)
CASE_HRESULT(CTL_E_DEVICEUNAVAILABLE)
CASE_HRESULT(CTL_E_PERMISSIONDENIED)
CASE_HRESULT(CTL_E_DISKNOTREADY)
CASE_HRESULT(CTL_E_PATHFILEACCESSERROR)
CASE_HRESULT(CTL_E_PATHNOTFOUND)
CASE_HRESULT(CTL_E_INVALIDPATTERNSTRING)
CASE_HRESULT(CTL_E_INVALIDUSEOFNULL)
CASE_HRESULT(CTL_E_INVALIDFILEFORMAT)
CASE_HRESULT(CTL_E_INVALIDPROPERTYVALUE)
CASE_HRESULT(CTL_E_INVALIDPROPERTYARRAYINDEX)
CASE_HRESULT(CTL_E_SETNOTSUPPORTEDATRUNTIME)
CASE_HRESULT(CTL_E_SETNOTSUPPORTED)
CASE_HRESULT(CTL_E_NEEDPROPERTYARRAYINDEX)
CASE_HRESULT(CTL_E_SETNOTPERMITTED)
CASE_HRESULT(CTL_E_GETNOTSUPPORTEDATRUNTIME)
CASE_HRESULT(CTL_E_GETNOTSUPPORTED)
CASE_HRESULT(CTL_E_PROPERTYNOTFOUND)
CASE_HRESULT(CTL_E_INVALIDCLIPBOARDFORMAT)
CASE_HRESULT(CTL_E_INVALIDPICTURE)
CASE_HRESULT(CTL_E_PRINTERERROR)
CASE_HRESULT(CTL_E_CANTSAVEFILETOTEMP)
CASE_HRESULT(CTL_E_SEARCHTEXTNOTFOUND)
CASE_HRESULT(CTL_E_REPLACEMENTSTOOLONG)
#endif // FEATURE_COMINTEROP
#ifdef _DEBUG // @todo: do we want to burn strings for this in a free build?
CASE_HRESULT(CEE_E_CVTRES_NOT_FOUND)
CASE_HRESULT(COR_E_APPDOMAINUNLOADED)
CASE_HRESULT(COR_E_CANNOTUNLOADAPPDOMAIN)
CASE_HRESULT(MSEE_E_ASSEMBLYLOADINPROGRESS)
CASE_HRESULT(COR_E_FIXUPSINEXE)
CASE_HRESULT(COR_E_MODULE_HASH_CHECK_FAILED)
CASE_HRESULT(FUSION_E_LOADFROM_BLOCKED)
CASE_HRESULT(FUSION_E_CACHEFILE_FAILED)
CASE_HRESULT(FUSION_E_REF_DEF_MISMATCH)
CASE_HRESULT(FUSION_E_INVALID_PRIVATE_ASM_LOCATION)
CASE_HRESULT(FUSION_E_ASM_MODULE_MISSING)
CASE_HRESULT(FUSION_E_PRIVATE_ASM_DISALLOWED)
CASE_HRESULT(FUSION_E_SIGNATURE_CHECK_FAILED)
CASE_HRESULT(FUSION_E_INVALID_NAME)
CASE_HRESULT(FUSION_E_CODE_DOWNLOAD_DISABLED)
CASE_HRESULT(CLDB_E_FILE_BADREAD)
CASE_HRESULT(CLDB_E_FILE_BADWRITE)
CASE_HRESULT(CLDB_S_TRUNCATION)
CASE_HRESULT(CLDB_E_FILE_OLDVER)
CASE_HRESULT(CLDB_E_SMDUPLICATE)
CASE_HRESULT(CLDB_E_NO_DATA)
CASE_HRESULT(CLDB_E_INCOMPATIBLE)
CASE_HRESULT(CLDB_E_FILE_CORRUPT)
CASE_HRESULT(CLDB_E_BADUPDATEMODE)
CASE_HRESULT(CLDB_E_INDEX_NOTFOUND)
CASE_HRESULT(CLDB_E_RECORD_NOTFOUND)
CASE_HRESULT(CLDB_E_RECORD_OUTOFORDER)
CASE_HRESULT(CLDB_E_TOO_BIG)
CASE_HRESULT(META_E_BADMETADATA)
CASE_HRESULT(META_E_BAD_SIGNATURE)
CASE_HRESULT(META_E_BAD_INPUT_PARAMETER)
CASE_HRESULT(META_E_CANNOTRESOLVETYPEREF)
CASE_HRESULT(META_S_DUPLICATE)
CASE_HRESULT(META_E_STRINGSPACE_FULL)
CASE_HRESULT(META_E_HAS_UNMARKALL)
CASE_HRESULT(META_E_MUST_CALL_UNMARKALL)
CASE_HRESULT(META_E_CA_INVALID_TARGET)
CASE_HRESULT(META_E_CA_INVALID_VALUE)
CASE_HRESULT(META_E_CA_INVALID_BLOB)
CASE_HRESULT(META_E_CA_REPEATED_ARG)
CASE_HRESULT(META_E_CA_UNKNOWN_ARGUMENT)
CASE_HRESULT(META_E_CA_UNEXPECTED_TYPE)
CASE_HRESULT(META_E_CA_INVALID_ARGTYPE)
CASE_HRESULT(META_E_CA_INVALID_ARG_FOR_TYPE)
CASE_HRESULT(META_E_CA_INVALID_UUID)
CASE_HRESULT(META_E_CA_INVALID_MARSHALAS_FIELDS)
CASE_HRESULT(META_E_CA_NT_FIELDONLY)
CASE_HRESULT(META_E_CA_NEGATIVE_PARAMINDEX)
CASE_HRESULT(META_E_CA_NEGATIVE_CONSTSIZE)
CASE_HRESULT(META_E_CA_FIXEDSTR_SIZE_REQUIRED)
CASE_HRESULT(META_E_CA_CUSTMARSH_TYPE_REQUIRED)
CASE_HRESULT(META_E_CA_BAD_FRIENDS_ARGS)
CASE_HRESULT(VLDTR_E_RID_OUTOFRANGE)
CASE_HRESULT(VLDTR_E_STRING_INVALID)
CASE_HRESULT(VLDTR_E_GUID_INVALID)
CASE_HRESULT(VLDTR_E_BLOB_INVALID)
CASE_HRESULT(VLDTR_E_MR_BADCALLINGCONV)
CASE_HRESULT(VLDTR_E_SIGNULL)
CASE_HRESULT(VLDTR_E_MD_BADCALLINGCONV)
CASE_HRESULT(VLDTR_E_MD_THISSTATIC)
CASE_HRESULT(VLDTR_E_MD_NOTTHISNOTSTATIC)
CASE_HRESULT(VLDTR_E_MD_NOARGCNT)
CASE_HRESULT(VLDTR_E_SIG_MISSELTYPE)
CASE_HRESULT(VLDTR_E_SIG_MISSTKN)
CASE_HRESULT(VLDTR_E_SIG_TKNBAD)
CASE_HRESULT(VLDTR_E_SIG_MISSFPTR)
CASE_HRESULT(VLDTR_E_SIG_MISSFPTRARGCNT)
CASE_HRESULT(VLDTR_E_SIG_MISSRANK)
CASE_HRESULT(VLDTR_E_SIG_MISSNSIZE)
CASE_HRESULT(VLDTR_E_SIG_MISSSIZE)
CASE_HRESULT(VLDTR_E_SIG_MISSNLBND)
CASE_HRESULT(VLDTR_E_SIG_MISSLBND)
CASE_HRESULT(VLDTR_E_SIG_BADELTYPE)
CASE_HRESULT(VLDTR_E_TD_ENCLNOTNESTED)
CASE_HRESULT(VLDTR_E_FMD_PINVOKENOTSTATIC)
CASE_HRESULT(VLDTR_E_SIG_SENTINMETHODDEF)
CASE_HRESULT(VLDTR_E_SIG_SENTMUSTVARARG)
CASE_HRESULT(VLDTR_E_SIG_MULTSENTINELS)
CASE_HRESULT(VLDTR_E_SIG_MISSARG)
CASE_HRESULT(VLDTR_E_SIG_BYREFINFIELD)
CASE_HRESULT(VLDTR_E_SIG_BADVOID)
CASE_HRESULT(CORDBG_E_UNRECOVERABLE_ERROR)
CASE_HRESULT(CORDBG_E_PROCESS_TERMINATED)
CASE_HRESULT(CORDBG_E_PROCESS_NOT_SYNCHRONIZED)
CASE_HRESULT(CORDBG_E_CLASS_NOT_LOADED)
CASE_HRESULT(CORDBG_E_IL_VAR_NOT_AVAILABLE)
CASE_HRESULT(CORDBG_E_BAD_REFERENCE_VALUE)
CASE_HRESULT(CORDBG_E_FIELD_NOT_AVAILABLE)
CASE_HRESULT(CORDBG_E_NON_NATIVE_FRAME)
CASE_HRESULT(CORDBG_E_CODE_NOT_AVAILABLE)
CASE_HRESULT(CORDBG_E_FUNCTION_NOT_IL)
CASE_HRESULT(CORDBG_S_BAD_START_SEQUENCE_POINT)
CASE_HRESULT(CORDBG_S_BAD_END_SEQUENCE_POINT)
CASE_HRESULT(CORDBG_E_CANT_SET_IP_INTO_FINALLY)
CASE_HRESULT(CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY)
CASE_HRESULT(CORDBG_E_CANT_SET_IP_INTO_CATCH)
CASE_HRESULT(CORDBG_E_SET_IP_NOT_ALLOWED_ON_NONLEAF_FRAME)
CASE_HRESULT(CORDBG_E_SET_IP_IMPOSSIBLE)
CASE_HRESULT(CORDBG_E_FUNC_EVAL_BAD_START_POINT)
CASE_HRESULT(CORDBG_E_INVALID_OBJECT)
CASE_HRESULT(CORDBG_E_FUNC_EVAL_NOT_COMPLETE)
CASE_HRESULT(CORDBG_S_FUNC_EVAL_HAS_NO_RESULT)
CASE_HRESULT(CORDBG_S_VALUE_POINTS_TO_VOID)
CASE_HRESULT(CORDBG_S_FUNC_EVAL_ABORTED)
CASE_HRESULT(CORDBG_E_STATIC_VAR_NOT_AVAILABLE)
CASE_HRESULT(CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER)
CASE_HRESULT(CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE)
CASE_HRESULT(CORDBG_E_CANT_SET_TO_JMC)
CASE_HRESULT(CORDBG_E_BAD_THREAD_STATE)
CASE_HRESULT(CORDBG_E_DEBUGGER_ALREADY_ATTACHED)
CASE_HRESULT(CORDBG_E_SUPERFLOUS_CONTINUE)
CASE_HRESULT(CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME)
CASE_HRESULT(CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED)
CASE_HRESULT(CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION)
CASE_HRESULT(CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL)
CASE_HRESULT(CORDBG_E_PROCESS_DETACHED)
CASE_HRESULT(CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS)
CASE_HRESULT(CORDBG_E_FIELD_NOT_STATIC)
CASE_HRESULT(CORDBG_E_FIELD_NOT_INSTANCE)
CASE_HRESULT(CORDBG_E_ENC_JIT_CANT_UPDATE)
CASE_HRESULT(CORDBG_E_ENC_INTERNAL_ERROR)
CASE_HRESULT(CORDBG_E_ENC_HANGING_FIELD)
CASE_HRESULT(CORDBG_E_MODULE_NOT_LOADED)
CASE_HRESULT(CORDBG_E_UNABLE_TO_SET_BREAKPOINT)
CASE_HRESULT(CORDBG_E_DEBUGGING_NOT_POSSIBLE)
CASE_HRESULT(CORDBG_E_KERNEL_DEBUGGER_ENABLED)
CASE_HRESULT(CORDBG_E_KERNEL_DEBUGGER_PRESENT)
CASE_HRESULT(CORDBG_E_INCOMPATIBLE_PROTOCOL)
CASE_HRESULT(CORDBG_E_TOO_MANY_PROCESSES)
CASE_HRESULT(CORDBG_E_INTEROP_NOT_SUPPORTED)
CASE_HRESULT(CORDBG_E_NO_REMAP_BREAKPIONT)
CASE_HRESULT(CORDBG_E_OBJECT_NEUTERED)
CASE_HRESULT(CORPROF_E_FUNCTION_NOT_COMPILED)
CASE_HRESULT(CORPROF_E_DATAINCOMPLETE)
CASE_HRESULT(CORPROF_E_FUNCTION_NOT_IL)
CASE_HRESULT(CORPROF_E_NOT_MANAGED_THREAD)
CASE_HRESULT(CORPROF_E_CALL_ONLY_FROM_INIT)
CASE_HRESULT(CORPROF_E_NOT_YET_AVAILABLE)
CASE_HRESULT(SECURITY_E_INCOMPATIBLE_SHARE)
CASE_HRESULT(SECURITY_E_UNVERIFIABLE)
CASE_HRESULT(SECURITY_E_INCOMPATIBLE_EVIDENCE)
CASE_HRESULT(CLDB_E_INTERNALERROR)
CASE_HRESULT(CORSEC_E_POLICY_EXCEPTION)
CASE_HRESULT(CORSEC_E_MIN_GRANT_FAIL)
CASE_HRESULT(CORSEC_E_NO_EXEC_PERM)
CASE_HRESULT(CORSEC_E_XMLSYNTAX)
CASE_HRESULT(CORSEC_E_INVALID_STRONGNAME)
CASE_HRESULT(CORSEC_E_MISSING_STRONGNAME)
CASE_HRESULT(CORSEC_E_INVALID_IMAGE_FORMAT)
CASE_HRESULT(CORSEC_E_CRYPTO)
CASE_HRESULT(CORSEC_E_CRYPTO_UNEX_OPER)
CASE_HRESULT(CORSECATTR_E_BAD_ACTION)
CASE_HRESULT(COR_E_APPLICATION)
CASE_HRESULT(COR_E_ARGUMENTOUTOFRANGE)
CASE_HRESULT(COR_E_ARITHMETIC)
CASE_HRESULT(COR_E_ARRAYTYPEMISMATCH)
CASE_HRESULT(COR_E_CONTEXTMARSHAL)
CASE_HRESULT(COR_E_TIMEOUT)
CASE_HRESULT(COR_E_DIVIDEBYZERO)
CASE_HRESULT(COR_E_EXCEPTION)
CASE_HRESULT(COR_E_EXECUTIONENGINE)
CASE_HRESULT(COR_E_FIELDACCESS)
CASE_HRESULT(COR_E_FORMAT)
CASE_HRESULT(COR_E_BADIMAGEFORMAT)
CASE_HRESULT(COR_E_ASSEMBLYEXPECTED)
CASE_HRESULT(COR_E_TYPEUNLOADED)
CASE_HRESULT(COR_E_INDEXOUTOFRANGE)
CASE_HRESULT(COR_E_INVALIDOPERATION)
CASE_HRESULT(COR_E_INVALIDPROGRAM)
CASE_HRESULT(COR_E_MEMBERACCESS)
CASE_HRESULT(COR_E_METHODACCESS)
CASE_HRESULT(COR_E_MISSINGFIELD)
CASE_HRESULT(COR_E_MISSINGMANIFESTRESOURCE)
CASE_HRESULT(COR_E_MISSINGMEMBER)
CASE_HRESULT(COR_E_MISSINGMETHOD)
CASE_HRESULT(COR_E_MULTICASTNOTSUPPORTED)
CASE_HRESULT(COR_E_NOTFINITENUMBER)
CASE_HRESULT(COR_E_DUPLICATEWAITOBJECT)
CASE_HRESULT(COR_E_PLATFORMNOTSUPPORTED)
CASE_HRESULT(COR_E_NOTSUPPORTED)
CASE_HRESULT(COR_E_OVERFLOW)
CASE_HRESULT(COR_E_RANK)
CASE_HRESULT(COR_E_SECURITY)
CASE_HRESULT(COR_E_SERIALIZATION)
CASE_HRESULT(COR_E_STACKOVERFLOW)
CASE_HRESULT(COR_E_SYNCHRONIZATIONLOCK)
CASE_HRESULT(COR_E_SYSTEM)
CASE_HRESULT(COR_E_THREADABORTED)
CASE_HRESULT(COR_E_THREADINTERRUPTED)
CASE_HRESULT(COR_E_THREADSTATE)
CASE_HRESULT(COR_E_THREADSTOP)
CASE_HRESULT(COR_E_TYPEINITIALIZATION)
CASE_HRESULT(COR_E_TYPELOAD)
CASE_HRESULT(COR_E_ENTRYPOINTNOTFOUND)
CASE_HRESULT(COR_E_DLLNOTFOUND)
CASE_HRESULT(COR_E_VERIFICATION)
CASE_HRESULT(COR_E_INVALIDCOMOBJECT)
CASE_HRESULT(COR_E_MARSHALDIRECTIVE)
CASE_HRESULT(COR_E_INVALIDOLEVARIANTTYPE)
CASE_HRESULT(COR_E_SAFEARRAYTYPEMISMATCH)
CASE_HRESULT(COR_E_SAFEARRAYRANKMISMATCH)
CASE_HRESULT(COR_E_INVALIDFILTERCRITERIA)
CASE_HRESULT(COR_E_REFLECTIONTYPELOAD)
CASE_HRESULT(COR_E_TARGET)
CASE_HRESULT(COR_E_TARGETINVOCATION)
CASE_HRESULT(COR_E_CUSTOMATTRIBUTEFORMAT)
CASE_HRESULT(COR_E_ENDOFSTREAM)
CASE_HRESULT(COR_E_FILELOAD)
CASE_HRESULT(COR_E_FILENOTFOUND)
CASE_HRESULT(COR_E_IO)
CASE_HRESULT(COR_E_DIRECTORYNOTFOUND)
CASE_HRESULT(COR_E_PATHTOOLONG)
CASE_HRESULT(COR_E_OBJECTDISPOSED)
CASE_HRESULT(COR_E_NEWER_RUNTIME)
CASE_HRESULT(CLR_E_SHIM_RUNTIMELOAD)
CASE_HRESULT(VER_E_FIELD_SIG)
CASE_HRESULT(CORDBG_E_THREAD_NOT_SCHEDULED)
#endif
default:
return NULL;
}
}
#ifdef _PREFAST_
#pragma warning(pop)
#endif
// ---------------------------------------------------------------------------
// HRException class. Implements exception API for exceptions from HRESULTS
// ---------------------------------------------------------------------------
HRESULT HRException::GetHR()
{
LIMITED_METHOD_DAC_CONTRACT;
return m_hr;
}
// ---------------------------------------------------------------------------
// COMException class. - moved to COMEx.cpp
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// SEHException class. Implements exception API for SEH exception info
// ---------------------------------------------------------------------------
HRESULT SEHException::GetHR()
{
LIMITED_METHOD_DAC_CONTRACT;
if (IsComPlusException(&m_exception)) // EE exception
return (HRESULT) m_exception.ExceptionInformation[0];
else
return m_exception.ExceptionCode;
}
IErrorInfo *SEHException::GetErrorInfo()
{
LIMITED_METHOD_CONTRACT;
return NULL;
}
void SEHException::GetMessage(SString &string)
{
WRAPPER_NO_CONTRACT;
if (IsComPlusException(&m_exception)) // EE exception
{
GenerateTopLevelHRExceptionMessage(GetHR(), string);
}
else
{
if (m_exception.ExceptionCode != 0)
{
string.Printf("Exception code 0x%.8x", m_exception.ExceptionCode);
}
else
{
// If we don't have a valid exception code, then give a generic message that's a little nicer than
// "code 0x00000000".
string.Printf("Unknown exception");
}
}
}
//==============================================================================
// DelegatingException class. Implements exception API for "foreign" exceptions.
//==============================================================================
DelegatingException::DelegatingException()
: m_delegatedException((Exception*)DELEGATE_NOT_YET_SET)
{
LIMITED_METHOD_DAC_CONTRACT;
} // DelegatingException::DelegatingException()
//------------------------------------------------------------------------------
DelegatingException::~DelegatingException()
{
WRAPPER_NO_CONTRACT;
// If there is a valid delegate pointer (inited and non-NULL), delete it.
if (IsDelegateValid())
Delete(m_delegatedException);
// Avoid confusion.
m_delegatedException = NULL;
} // DelegatingException::~DelegatingException()
//------------------------------------------------------------------------------
// Retrieve the delegating exception, or get one from the Thread, or get NULL.
Exception* DelegatingException::GetDelegate()
{
WRAPPER_NO_CONTRACT;
// If we haven't gotten the exception pointer before..
if (!IsDelegateSet())
{
// .. get it now. NULL in case there isn't one and we take default action.
m_delegatedException = NULL;
GetLastThrownObjectExceptionFromThread(&m_delegatedException);
}
return m_delegatedException;
} // Exception* DelegatingException::GetDelegate()
//------------------------------------------------------------------------------
// Virtual overrides
HRESULT DelegatingException::GetHR()
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC_HOST_ONLY;
// Retrieve any delegating exception.
Exception *pDelegate = GetDelegate();
// If there is a delegate exception, defer to it. Otherwise,
// default to E_FAIL.
return pDelegate ? pDelegate->GetHR() : E_FAIL;
} // HRESULT DelegatingException::GetHR()
//------------------------------------------------------------------------------
IErrorInfo *DelegatingException::GetErrorInfo()
{
WRAPPER_NO_CONTRACT;
// Retrieve any delegating exception.
Exception *pDelegate = GetDelegate();
// If there is a delegate exception, defer to it. Otherwise,
// default to NULL.
return pDelegate ? pDelegate->GetErrorInfo() : NULL;
} // IErrorInfo *DelegatingException::GetErrorInfo()
//------------------------------------------------------------------------------
void DelegatingException::GetMessage(SString &result)
{
WRAPPER_NO_CONTRACT;
// Retrieve any delegating exception.
Exception *pDelegate = GetDelegate();
// If there is a delegate exception, defer to it. Otherwise,
// default to a generic message.
if (pDelegate)
{
pDelegate->GetMessage(result);
}
else
{
// If we don't have a valid exception code, then give a generic message
// that's a little nicer than "code 0x00000000".
result.Printf("Unknown exception");
}
} // void DelegatingException::GetMessage()
//------------------------------------------------------------------------------
Exception *DelegatingException::Clone()
{
WRAPPER_NO_CONTRACT;
// Clone the base exception, this will also take care of cloning the inner
// exception if there is one.
NewHolder<DelegatingException> retExcep((DelegatingException*)Exception::Clone());
// If there is a valid delegating exception...
if (IsDelegateValid())
{ // ... clone it.
retExcep->m_delegatedException = m_delegatedException->Clone();
}
else
{ // ... but if there is not, just copy -- either NULL or DELEGATE_NOT_YET_SET
retExcep->m_delegatedException = m_delegatedException;
}
retExcep.SuppressRelease();
return retExcep;
} // virtual Exception *DelegatingException::Clone()
//==============================================================================
//==============================================================================
void DECLSPEC_NORETURN ThrowHR(HRESULT hr)
{
WRAPPER_NO_CONTRACT;
STRESS_LOG1(LF_EH, LL_INFO100, "ThrowHR: HR = %x\n", hr);
if (hr == E_OUTOFMEMORY)
ThrowOutOfMemory();
// Catchers assume only failing hresults
_ASSERTE(FAILED(hr));
if (hr == S_OK)
hr = E_FAIL;
EX_THROW(HRException, (hr));
}
void DECLSPEC_NORETURN ThrowHR(HRESULT hr, SString const &msg)
{
WRAPPER_NO_CONTRACT;
STRESS_LOG1(LF_EH, LL_INFO100, "ThrowHR: HR = %x\n", hr);
if (hr == E_OUTOFMEMORY)
ThrowOutOfMemory();
// Catchers assume only failing hresults
_ASSERTE(FAILED(hr));
if (hr == S_OK)
hr = E_FAIL;
EX_THROW(HRMsgException, (hr, msg));
}
void DECLSPEC_NORETURN ThrowHR(HRESULT hr, UINT uText)
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC_HOST_ONLY;
if (hr == E_OUTOFMEMORY)
ThrowOutOfMemory();
// Catchers assume only failing hresults
_ASSERTE(FAILED(hr));
if (hr == S_OK)
hr = E_FAIL;