2 * msvcrt.dll C++ objects
4 * Copyright 2000 Jon Griffiths
5 * Copyright 2003, 2004 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
29 #include "wine/exception.h"
30 #include "wine/debug.h"
32 #include "cppexcept.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
38 struct __type_info_node
41 struct __type_info_node
* next
;
44 typedef exception bad_cast
;
45 typedef exception bad_typeid
;
46 typedef exception __non_rtti_object
;
48 extern const vtable_ptr MSVCRT_exception_vtable
;
49 extern const vtable_ptr MSVCRT_bad_typeid_vtable
;
50 extern const vtable_ptr MSVCRT_bad_cast_vtable
;
51 extern const vtable_ptr MSVCRT___non_rtti_object_vtable
;
52 extern const vtable_ptr MSVCRT_type_info_vtable
;
54 /* get the vtable pointer for a C++ object */
55 static inline const vtable_ptr
*get_vtable( void *obj
)
57 return *(const vtable_ptr
**)obj
;
60 static inline const rtti_object_locator
*get_obj_locator( void *cppobj
)
62 const vtable_ptr
*vtable
= get_vtable( cppobj
);
63 return (const rtti_object_locator
*)vtable
[-1];
67 static void dump_obj_locator( const rtti_object_locator
*ptr
)
70 const rtti_object_hierarchy
*h
= ptr
->type_hierarchy
;
72 TRACE( "%p: sig=%08x base_offset=%08x flags=%08x type=%p %s hierarchy=%p\n",
73 ptr
, ptr
->signature
, ptr
->base_class_offset
, ptr
->flags
,
74 ptr
->type_descriptor
, dbgstr_type_info(ptr
->type_descriptor
), ptr
->type_hierarchy
);
75 TRACE( " hierarchy: sig=%08x attr=%08x len=%d base classes=%p\n",
76 h
->signature
, h
->attributes
, h
->array_len
, h
->base_classes
);
77 for (i
= 0; i
< h
->array_len
; i
++)
79 TRACE( " base class %p: num %d off %d,%d,%d attr %08x type %p %s\n",
80 h
->base_classes
->bases
[i
],
81 h
->base_classes
->bases
[i
]->num_base_classes
,
82 h
->base_classes
->bases
[i
]->offsets
.this_offset
,
83 h
->base_classes
->bases
[i
]->offsets
.vbase_descr
,
84 h
->base_classes
->bases
[i
]->offsets
.vbase_offset
,
85 h
->base_classes
->bases
[i
]->attributes
,
86 h
->base_classes
->bases
[i
]->type_descriptor
,
87 dbgstr_type_info(h
->base_classes
->bases
[i
]->type_descriptor
) );
93 static void dump_obj_locator( const rtti_object_locator
*ptr
)
96 char *base
= ptr
->signature
== 0 ? RtlPcToFileHeader((void*)ptr
, (void**)&base
) : (char*)ptr
- ptr
->object_locator
;
97 const rtti_object_hierarchy
*h
= (const rtti_object_hierarchy
*)(base
+ ptr
->type_hierarchy
);
98 const type_info
*type_descriptor
= (const type_info
*)(base
+ ptr
->type_descriptor
);
100 TRACE( "%p: sig=%08x base_offset=%08x flags=%08x type=%p %s hierarchy=%p\n",
101 ptr
, ptr
->signature
, ptr
->base_class_offset
, ptr
->flags
,
102 type_descriptor
, dbgstr_type_info(type_descriptor
), h
);
103 TRACE( " hierarchy: sig=%08x attr=%08x len=%d base classes=%p\n",
104 h
->signature
, h
->attributes
, h
->array_len
, base
+ h
->base_classes
);
105 for (i
= 0; i
< h
->array_len
; i
++)
107 const rtti_base_descriptor
*bases
= (rtti_base_descriptor
*)(base
+
108 ((const rtti_base_array
*)(base
+ h
->base_classes
))->bases
[i
]);
110 TRACE( " base class %p: num %d off %d,%d,%d attr %08x type %p %s\n",
112 bases
->num_base_classes
,
113 bases
->offsets
.this_offset
,
114 bases
->offsets
.vbase_descr
,
115 bases
->offsets
.vbase_offset
,
117 base
+ bases
->type_descriptor
,
118 dbgstr_type_info((const type_info
*)(base
+ bases
->type_descriptor
)) );
123 /* Internal common ctor for exception */
124 static void EXCEPTION_ctor(exception
*_this
, const char** name
)
126 _this
->vtable
= &MSVCRT_exception_vtable
;
129 unsigned int name_len
= strlen(*name
) + 1;
130 _this
->name
= MSVCRT_malloc(name_len
);
131 memcpy(_this
->name
, *name
, name_len
);
132 _this
->do_free
= TRUE
;
137 _this
->do_free
= FALSE
;
141 /******************************************************************
142 * ??0exception@@QAE@ABQBD@Z (MSVCRT.@)
144 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_ctor
,8)
145 exception
* __thiscall
MSVCRT_exception_ctor(exception
* _this
, const char ** name
)
147 TRACE("(%p,%s)\n", _this
, *name
);
148 EXCEPTION_ctor(_this
, name
);
152 /******************************************************************
153 * ??0exception@@QAE@ABQBDH@Z (MSVCRT.@)
155 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_ctor_noalloc
,12)
156 exception
* __thiscall
MSVCRT_exception_ctor_noalloc(exception
* _this
, char ** name
, int noalloc
)
158 TRACE("(%p,%s)\n", _this
, *name
);
159 _this
->vtable
= &MSVCRT_exception_vtable
;
161 _this
->do_free
= FALSE
;
165 /******************************************************************
166 * ??0exception@@QAE@ABV0@@Z (MSVCRT.@)
168 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_copy_ctor
,8)
169 exception
* __thiscall
MSVCRT_exception_copy_ctor(exception
* _this
, const exception
* rhs
)
171 TRACE("(%p,%p)\n", _this
, rhs
);
175 _this
->vtable
= &MSVCRT_exception_vtable
;
176 _this
->name
= rhs
->name
;
177 _this
->do_free
= FALSE
;
180 EXCEPTION_ctor(_this
, (const char**)&rhs
->name
);
181 TRACE("name = %s\n", _this
->name
);
185 /******************************************************************
186 * ??0exception@@QAE@XZ (MSVCRT.@)
188 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_default_ctor
,4)
189 exception
* __thiscall
MSVCRT_exception_default_ctor(exception
* _this
)
191 static const char* empty
= NULL
;
193 TRACE("(%p)\n", _this
);
194 EXCEPTION_ctor(_this
, &empty
);
198 /******************************************************************
199 * ??1exception@@UAE@XZ (MSVCRT.@)
201 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_dtor
,4)
202 void __thiscall
MSVCRT_exception_dtor(exception
* _this
)
204 TRACE("(%p)\n", _this
);
205 _this
->vtable
= &MSVCRT_exception_vtable
;
206 if (_this
->do_free
) MSVCRT_free(_this
->name
);
209 /******************************************************************
210 * ??4exception@@QAEAAV0@ABV0@@Z (MSVCRT.@)
212 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_opequals
,8)
213 exception
* __thiscall
MSVCRT_exception_opequals(exception
* _this
, const exception
* rhs
)
215 TRACE("(%p %p)\n", _this
, rhs
);
218 MSVCRT_exception_dtor(_this
);
219 MSVCRT_exception_copy_ctor(_this
, rhs
);
221 TRACE("name = %s\n", _this
->name
);
225 /******************************************************************
226 * ??_Eexception@@UAEPAXI@Z (MSVCRT.@)
228 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_vector_dtor
,8)
229 void * __thiscall
MSVCRT_exception_vector_dtor(exception
* _this
, unsigned int flags
)
231 TRACE("(%p %x)\n", _this
, flags
);
234 /* we have an array, with the number of elements stored before the first object */
235 INT_PTR i
, *ptr
= (INT_PTR
*)_this
- 1;
237 for (i
= *ptr
- 1; i
>= 0; i
--) MSVCRT_exception_dtor(_this
+ i
);
238 MSVCRT_operator_delete(ptr
);
242 MSVCRT_exception_dtor(_this
);
243 if (flags
& 1) MSVCRT_operator_delete(_this
);
248 /******************************************************************
249 * ??_Gexception@@UAEPAXI@Z (MSVCRT.@)
251 DEFINE_THISCALL_WRAPPER(MSVCRT_exception_scalar_dtor
,8)
252 void * __thiscall
MSVCRT_exception_scalar_dtor(exception
* _this
, unsigned int flags
)
254 TRACE("(%p %x)\n", _this
, flags
);
255 MSVCRT_exception_dtor(_this
);
256 if (flags
& 1) MSVCRT_operator_delete(_this
);
260 /******************************************************************
261 * ?what@exception@@UBEPBDXZ (MSVCRT.@)
263 DEFINE_THISCALL_WRAPPER(MSVCRT_what_exception
,4)
264 const char * __thiscall
MSVCRT_what_exception(exception
* _this
)
266 TRACE("(%p) returning %s\n", _this
, _this
->name
);
267 return _this
->name
? _this
->name
: "Unknown exception";
270 /******************************************************************
271 * ??0bad_typeid@@QAE@ABV0@@Z (MSVCRT.@)
273 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_copy_ctor
,8)
274 bad_typeid
* __thiscall
MSVCRT_bad_typeid_copy_ctor(bad_typeid
* _this
, const bad_typeid
* rhs
)
276 TRACE("(%p %p)\n", _this
, rhs
);
277 MSVCRT_exception_copy_ctor(_this
, rhs
);
278 _this
->vtable
= &MSVCRT_bad_typeid_vtable
;
282 /******************************************************************
283 * ??0bad_typeid@@QAE@PBD@Z (MSVCRT.@)
285 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_ctor
,8)
286 bad_typeid
* __thiscall
MSVCRT_bad_typeid_ctor(bad_typeid
* _this
, const char * name
)
288 TRACE("(%p %s)\n", _this
, name
);
289 EXCEPTION_ctor(_this
, &name
);
290 _this
->vtable
= &MSVCRT_bad_typeid_vtable
;
294 /******************************************************************
295 * ??_Fbad_typeid@@QAEXXZ (MSVCRT.@)
297 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_default_ctor
,4)
298 bad_typeid
* __thiscall
MSVCRT_bad_typeid_default_ctor(bad_typeid
* _this
)
300 return MSVCRT_bad_typeid_ctor( _this
, "bad typeid" );
303 /******************************************************************
304 * ??1bad_typeid@@UAE@XZ (MSVCRT.@)
306 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_dtor
,4)
307 void __thiscall
MSVCRT_bad_typeid_dtor(bad_typeid
* _this
)
309 TRACE("(%p)\n", _this
);
310 MSVCRT_exception_dtor(_this
);
313 /******************************************************************
314 * ??4bad_typeid@@QAEAAV0@ABV0@@Z (MSVCRT.@)
316 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_opequals
,8)
317 bad_typeid
* __thiscall
MSVCRT_bad_typeid_opequals(bad_typeid
* _this
, const bad_typeid
* rhs
)
319 TRACE("(%p %p)\n", _this
, rhs
);
320 MSVCRT_exception_opequals(_this
, rhs
);
324 /******************************************************************
325 * ??_Ebad_typeid@@UAEPAXI@Z (MSVCRT.@)
327 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_vector_dtor
,8)
328 void * __thiscall
MSVCRT_bad_typeid_vector_dtor(bad_typeid
* _this
, unsigned int flags
)
330 TRACE("(%p %x)\n", _this
, flags
);
333 /* we have an array, with the number of elements stored before the first object */
334 INT_PTR i
, *ptr
= (INT_PTR
*)_this
- 1;
336 for (i
= *ptr
- 1; i
>= 0; i
--) MSVCRT_bad_typeid_dtor(_this
+ i
);
337 MSVCRT_operator_delete(ptr
);
341 MSVCRT_bad_typeid_dtor(_this
);
342 if (flags
& 1) MSVCRT_operator_delete(_this
);
347 /******************************************************************
348 * ??_Gbad_typeid@@UAEPAXI@Z (MSVCRT.@)
350 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_typeid_scalar_dtor
,8)
351 void * __thiscall
MSVCRT_bad_typeid_scalar_dtor(bad_typeid
* _this
, unsigned int flags
)
353 TRACE("(%p %x)\n", _this
, flags
);
354 MSVCRT_bad_typeid_dtor(_this
);
355 if (flags
& 1) MSVCRT_operator_delete(_this
);
359 /******************************************************************
360 * ??0__non_rtti_object@@QAE@ABV0@@Z (MSVCRT.@)
362 DEFINE_THISCALL_WRAPPER(MSVCRT___non_rtti_object_copy_ctor
,8)
363 __non_rtti_object
* __thiscall
MSVCRT___non_rtti_object_copy_ctor(__non_rtti_object
* _this
,
364 const __non_rtti_object
* rhs
)
366 TRACE("(%p %p)\n", _this
, rhs
);
367 MSVCRT_bad_typeid_copy_ctor(_this
, rhs
);
368 _this
->vtable
= &MSVCRT___non_rtti_object_vtable
;
372 /******************************************************************
373 * ??0__non_rtti_object@@QAE@PBD@Z (MSVCRT.@)
375 DEFINE_THISCALL_WRAPPER(MSVCRT___non_rtti_object_ctor
,8)
376 __non_rtti_object
* __thiscall
MSVCRT___non_rtti_object_ctor(__non_rtti_object
* _this
,
379 TRACE("(%p %s)\n", _this
, name
);
380 EXCEPTION_ctor(_this
, &name
);
381 _this
->vtable
= &MSVCRT___non_rtti_object_vtable
;
385 /******************************************************************
386 * ??1__non_rtti_object@@UAE@XZ (MSVCRT.@)
388 DEFINE_THISCALL_WRAPPER(MSVCRT___non_rtti_object_dtor
,4)
389 void __thiscall
MSVCRT___non_rtti_object_dtor(__non_rtti_object
* _this
)
391 TRACE("(%p)\n", _this
);
392 MSVCRT_bad_typeid_dtor(_this
);
395 /******************************************************************
396 * ??4__non_rtti_object@@QAEAAV0@ABV0@@Z (MSVCRT.@)
398 DEFINE_THISCALL_WRAPPER(MSVCRT___non_rtti_object_opequals
,8)
399 __non_rtti_object
* __thiscall
MSVCRT___non_rtti_object_opequals(__non_rtti_object
* _this
,
400 const __non_rtti_object
*rhs
)
402 TRACE("(%p %p)\n", _this
, rhs
);
403 MSVCRT_bad_typeid_opequals(_this
, rhs
);
407 /******************************************************************
408 * ??_E__non_rtti_object@@UAEPAXI@Z (MSVCRT.@)
410 DEFINE_THISCALL_WRAPPER(MSVCRT___non_rtti_object_vector_dtor
,8)
411 void * __thiscall
MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object
* _this
, unsigned int flags
)
413 TRACE("(%p %x)\n", _this
, flags
);
416 /* we have an array, with the number of elements stored before the first object */
417 INT_PTR i
, *ptr
= (INT_PTR
*)_this
- 1;
419 for (i
= *ptr
- 1; i
>= 0; i
--) MSVCRT___non_rtti_object_dtor(_this
+ i
);
420 MSVCRT_operator_delete(ptr
);
424 MSVCRT___non_rtti_object_dtor(_this
);
425 if (flags
& 1) MSVCRT_operator_delete(_this
);
430 /******************************************************************
431 * ??_G__non_rtti_object@@UAEPAXI@Z (MSVCRT.@)
433 DEFINE_THISCALL_WRAPPER(MSVCRT___non_rtti_object_scalar_dtor
,8)
434 void * __thiscall
MSVCRT___non_rtti_object_scalar_dtor(__non_rtti_object
* _this
, unsigned int flags
)
436 TRACE("(%p %x)\n", _this
, flags
);
437 MSVCRT___non_rtti_object_dtor(_this
);
438 if (flags
& 1) MSVCRT_operator_delete(_this
);
442 /******************************************************************
443 * ??0bad_cast@@AAE@PBQBD@Z (MSVCRT.@)
444 * ??0bad_cast@@QAE@ABQBD@Z (MSVCRT.@)
446 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_ctor
,8)
447 bad_cast
* __thiscall
MSVCRT_bad_cast_ctor(bad_cast
* _this
, const char ** name
)
449 TRACE("(%p %s)\n", _this
, *name
);
450 EXCEPTION_ctor(_this
, name
);
451 _this
->vtable
= &MSVCRT_bad_cast_vtable
;
455 /******************************************************************
456 * ??0bad_cast@@QAE@ABV0@@Z (MSVCRT.@)
458 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_copy_ctor
,8)
459 bad_cast
* __thiscall
MSVCRT_bad_cast_copy_ctor(bad_cast
* _this
, const bad_cast
* rhs
)
461 TRACE("(%p %p)\n", _this
, rhs
);
462 MSVCRT_exception_copy_ctor(_this
, rhs
);
463 _this
->vtable
= &MSVCRT_bad_cast_vtable
;
467 /******************************************************************
468 * ??0bad_cast@@QAE@PBD@Z (MSVCRT.@)
470 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_ctor_charptr
,8)
471 bad_cast
* __thiscall
MSVCRT_bad_cast_ctor_charptr(bad_cast
* _this
, const char * name
)
473 TRACE("(%p %s)\n", _this
, name
);
474 EXCEPTION_ctor(_this
, &name
);
475 _this
->vtable
= &MSVCRT_bad_cast_vtable
;
479 /******************************************************************
480 * ??_Fbad_cast@@QAEXXZ (MSVCRT.@)
482 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_default_ctor
,4)
483 bad_cast
* __thiscall
MSVCRT_bad_cast_default_ctor(bad_cast
* _this
)
485 return MSVCRT_bad_cast_ctor_charptr( _this
, "bad cast" );
488 /******************************************************************
489 * ??1bad_cast@@UAE@XZ (MSVCRT.@)
491 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_dtor
,4)
492 void __thiscall
MSVCRT_bad_cast_dtor(bad_cast
* _this
)
494 TRACE("(%p)\n", _this
);
495 MSVCRT_exception_dtor(_this
);
498 /******************************************************************
499 * ??4bad_cast@@QAEAAV0@ABV0@@Z (MSVCRT.@)
501 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_opequals
,8)
502 bad_cast
* __thiscall
MSVCRT_bad_cast_opequals(bad_cast
* _this
, const bad_cast
* rhs
)
504 TRACE("(%p %p)\n", _this
, rhs
);
505 MSVCRT_exception_opequals(_this
, rhs
);
509 /******************************************************************
510 * ??_Ebad_cast@@UAEPAXI@Z (MSVCRT.@)
512 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_vector_dtor
,8)
513 void * __thiscall
MSVCRT_bad_cast_vector_dtor(bad_cast
* _this
, unsigned int flags
)
515 TRACE("(%p %x)\n", _this
, flags
);
518 /* we have an array, with the number of elements stored before the first object */
519 INT_PTR i
, *ptr
= (INT_PTR
*)_this
- 1;
521 for (i
= *ptr
- 1; i
>= 0; i
--) MSVCRT_bad_cast_dtor(_this
+ i
);
522 MSVCRT_operator_delete(ptr
);
526 MSVCRT_bad_cast_dtor(_this
);
527 if (flags
& 1) MSVCRT_operator_delete(_this
);
532 /******************************************************************
533 * ??_Gbad_cast@@UAEPAXI@Z (MSVCRT.@)
535 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_cast_scalar_dtor
,8)
536 void * __thiscall
MSVCRT_bad_cast_scalar_dtor(bad_cast
* _this
, unsigned int flags
)
538 TRACE("(%p %x)\n", _this
, flags
);
539 MSVCRT_bad_cast_dtor(_this
);
540 if (flags
& 1) MSVCRT_operator_delete(_this
);
544 /******************************************************************
545 * ??8type_info@@QBEHABV0@@Z (MSVCRT.@)
547 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_opequals_equals
,8)
548 int __thiscall
MSVCRT_type_info_opequals_equals(type_info
* _this
, const type_info
* rhs
)
550 int ret
= !strcmp(_this
->mangled
+ 1, rhs
->mangled
+ 1);
551 TRACE("(%p %p) returning %d\n", _this
, rhs
, ret
);
555 /******************************************************************
556 * ??9type_info@@QBEHABV0@@Z (MSVCRT.@)
558 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_opnot_equals
,8)
559 int __thiscall
MSVCRT_type_info_opnot_equals(type_info
* _this
, const type_info
* rhs
)
561 int ret
= !!strcmp(_this
->mangled
+ 1, rhs
->mangled
+ 1);
562 TRACE("(%p %p) returning %d\n", _this
, rhs
, ret
);
566 /******************************************************************
567 * ?before@type_info@@QBEHABV1@@Z (MSVCRT.@)
569 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_before
,8)
570 int __thiscall
MSVCRT_type_info_before(type_info
* _this
, const type_info
* rhs
)
572 int ret
= strcmp(_this
->mangled
+ 1, rhs
->mangled
+ 1) < 0;
573 TRACE("(%p %p) returning %d\n", _this
, rhs
, ret
);
577 /******************************************************************
578 * ??1type_info@@UAE@XZ (MSVCRT.@)
580 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_dtor
,4)
581 void __thiscall
MSVCRT_type_info_dtor(type_info
* _this
)
583 TRACE("(%p)\n", _this
);
584 MSVCRT_free(_this
->name
);
587 /******************************************************************
588 * ?name@type_info@@QBEPBDXZ (MSVCRT.@)
590 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_name
,4)
591 const char * __thiscall
MSVCRT_type_info_name(type_info
* _this
)
595 /* Create and set the demangled name */
596 /* Note: mangled name in type_info struct always starts with a '.', while
597 * it isn't valid for mangled name.
598 * Is this '.' really part of the mangled name, or has it some other meaning ?
600 char* name
= __unDName(0, _this
->mangled
+ 1, 0,
601 MSVCRT_malloc
, MSVCRT_free
, UNDNAME_NO_ARGUMENTS
| UNDNAME_32_BIT_DECODE
);
604 unsigned int len
= strlen(name
);
606 /* It seems _unDName may leave blanks at the end of the demangled name */
607 while (len
&& name
[--len
] == ' ')
610 if (InterlockedCompareExchangePointer((void**)&_this
->name
, name
, NULL
))
612 /* Another thread set this member since we checked above - use it */
617 TRACE("(%p) returning %s\n", _this
, _this
->name
);
621 /******************************************************************
622 * ?raw_name@type_info@@QBEPBDXZ (MSVCRT.@)
624 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_raw_name
,4)
625 const char * __thiscall
MSVCRT_type_info_raw_name(type_info
* _this
)
627 TRACE("(%p) returning %s\n", _this
, _this
->mangled
);
628 return _this
->mangled
;
632 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_vector_dtor
,8)
633 void * __thiscall
MSVCRT_type_info_vector_dtor(type_info
* _this
, unsigned int flags
)
635 TRACE("(%p %x)\n", _this
, flags
);
638 /* we have an array, with the number of elements stored before the first object */
639 INT_PTR i
, *ptr
= (INT_PTR
*)_this
- 1;
641 for (i
= *ptr
- 1; i
>= 0; i
--) MSVCRT_type_info_dtor(_this
+ i
);
642 MSVCRT_operator_delete(ptr
);
646 MSVCRT_type_info_dtor(_this
);
647 if (flags
& 1) MSVCRT_operator_delete(_this
);
653 typedef exception bad_alloc
;
654 extern const vtable_ptr MSVCRT_bad_alloc_vtable
;
656 static void bad_alloc_ctor(bad_alloc
*this, const char **name
)
658 MSVCRT_exception_ctor(this, name
);
659 this->vtable
= &MSVCRT_bad_alloc_vtable
;
662 /* bad_alloc class implementation */
663 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_alloc_copy_ctor
,8)
664 bad_alloc
* __thiscall
MSVCRT_bad_alloc_copy_ctor(bad_alloc
* _this
, const bad_alloc
* rhs
)
666 TRACE("(%p %p)\n", _this
, rhs
);
667 MSVCRT_exception_copy_ctor(_this
, rhs
);
668 _this
->vtable
= &MSVCRT_bad_alloc_vtable
;
672 DEFINE_THISCALL_WRAPPER(MSVCRT_bad_alloc_dtor
,4)
673 void __thiscall
MSVCRT_bad_alloc_dtor(bad_alloc
* _this
)
675 TRACE("(%p)\n", _this
);
676 MSVCRT_exception_dtor(_this
);
680 #if _MSVCR_VER >= 100
684 } scheduler_resource_allocation_error
;
685 extern const vtable_ptr MSVCRT_scheduler_resource_allocation_error_vtable
;
687 /* ??0scheduler_resource_allocation_error@Concurrency@@QAE@PBDJ@Z */
688 /* ??0scheduler_resource_allocation_error@Concurrency@@QEAA@PEBDJ@Z */
689 DEFINE_THISCALL_WRAPPER(scheduler_resource_allocation_error_ctor_name
, 12)
690 scheduler_resource_allocation_error
* __thiscall
scheduler_resource_allocation_error_ctor_name(
691 scheduler_resource_allocation_error
*this, const char *name
, HRESULT hr
)
693 TRACE("(%p %s %x)\n", this, wine_dbgstr_a(name
), hr
);
694 MSVCRT_exception_ctor(&this->e
, &name
);
695 this->e
.vtable
= &MSVCRT_scheduler_resource_allocation_error_vtable
;
700 /* ??0scheduler_resource_allocation_error@Concurrency@@QAE@J@Z */
701 /* ??0scheduler_resource_allocation_error@Concurrency@@QEAA@J@Z */
702 DEFINE_THISCALL_WRAPPER(scheduler_resource_allocation_error_ctor
, 8)
703 scheduler_resource_allocation_error
* __thiscall
scheduler_resource_allocation_error_ctor(
704 scheduler_resource_allocation_error
*this, HRESULT hr
)
706 return scheduler_resource_allocation_error_ctor_name(this, NULL
, hr
);
709 DEFINE_THISCALL_WRAPPER(MSVCRT_scheduler_resource_allocation_error_copy_ctor
,8)
710 scheduler_resource_allocation_error
* __thiscall
MSVCRT_scheduler_resource_allocation_error_copy_ctor(
711 scheduler_resource_allocation_error
*this,
712 const scheduler_resource_allocation_error
*rhs
)
714 TRACE("(%p,%p)\n", this, rhs
);
717 memcpy(this, rhs
, sizeof(*this));
719 scheduler_resource_allocation_error_ctor_name(this, rhs
->e
.name
, rhs
->hr
);
723 /* ?get_error_code@scheduler_resource_allocation_error@Concurrency@@QBEJXZ */
724 /* ?get_error_code@scheduler_resource_allocation_error@Concurrency@@QEBAJXZ */
725 DEFINE_THISCALL_WRAPPER(scheduler_resource_allocation_error_get_error_code
, 4)
726 HRESULT __thiscall
scheduler_resource_allocation_error_get_error_code(
727 const scheduler_resource_allocation_error
*this)
729 TRACE("(%p)\n", this);
733 DEFINE_THISCALL_WRAPPER(MSVCRT_scheduler_resource_allocation_error_dtor
,4)
734 void __thiscall
MSVCRT_scheduler_resource_allocation_error_dtor(
735 scheduler_resource_allocation_error
* this)
737 TRACE("(%p)\n", this);
738 MSVCRT_exception_dtor(&this->e
);
741 typedef exception improper_lock
;
742 extern const vtable_ptr MSVCRT_improper_lock_vtable
;
744 /* ??0improper_lock@Concurrency@@QAE@PBD@Z */
745 /* ??0improper_lock@Concurrency@@QEAA@PEBD@Z */
746 DEFINE_THISCALL_WRAPPER(improper_lock_ctor_str
, 8)
747 improper_lock
* __thiscall
improper_lock_ctor_str(improper_lock
*this, const char *str
)
749 TRACE("(%p %p)\n", this, str
);
750 MSVCRT_exception_ctor(this, &str
);
751 this->vtable
= &MSVCRT_improper_lock_vtable
;
755 /* ??0improper_lock@Concurrency@@QAE@XZ */
756 /* ??0improper_lock@Concurrency@@QEAA@XZ */
757 DEFINE_THISCALL_WRAPPER(improper_lock_ctor
, 4)
758 improper_lock
* __thiscall
improper_lock_ctor(improper_lock
*this)
760 return improper_lock_ctor_str(this, NULL
);
763 DEFINE_THISCALL_WRAPPER(MSVCRT_improper_lock_copy_ctor
,8)
764 improper_lock
* __thiscall
MSVCRT_improper_lock_copy_ctor(improper_lock
* _this
, const improper_lock
* rhs
)
766 TRACE("(%p %p)\n", _this
, rhs
);
767 MSVCRT_exception_copy_ctor(_this
, rhs
);
768 _this
->vtable
= &MSVCRT_improper_lock_vtable
;
772 DEFINE_THISCALL_WRAPPER(MSVCRT_improper_lock_dtor
,4)
773 void __thiscall
MSVCRT_improper_lock_dtor(improper_lock
* _this
)
775 TRACE("(%p)\n", _this
);
776 MSVCRT_exception_dtor(_this
);
779 typedef exception invalid_scheduler_policy_key
;
780 extern const vtable_ptr MSVCRT_invalid_scheduler_policy_key_vtable
;
782 /* ??0invalid_scheduler_policy_key@Concurrency@@QAE@PBD@Z */
783 /* ??0invalid_scheduler_policy_key@Concurrency@@QEAA@PEBD@Z */
784 DEFINE_THISCALL_WRAPPER(invalid_scheduler_policy_key_ctor_str
, 8)
785 invalid_scheduler_policy_key
* __thiscall
invalid_scheduler_policy_key_ctor_str(
786 invalid_scheduler_policy_key
*this, const char *str
)
788 TRACE("(%p %p)\n", this, str
);
789 MSVCRT_exception_ctor(this, &str
);
790 this->vtable
= &MSVCRT_invalid_scheduler_policy_key_vtable
;
794 /* ??0invalid_scheduler_policy_key@Concurrency@@QAE@XZ */
795 /* ??0invalid_scheduler_policy_key@Concurrency@@QEAA@XZ */
796 DEFINE_THISCALL_WRAPPER(invalid_scheduler_policy_key_ctor
, 4)
797 invalid_scheduler_policy_key
* __thiscall
invalid_scheduler_policy_key_ctor(
798 invalid_scheduler_policy_key
*this)
800 return invalid_scheduler_policy_key_ctor_str(this, NULL
);
803 DEFINE_THISCALL_WRAPPER(MSVCRT_invalid_scheduler_policy_key_copy_ctor
,8)
804 invalid_scheduler_policy_key
* __thiscall
MSVCRT_invalid_scheduler_policy_key_copy_ctor(
805 invalid_scheduler_policy_key
* _this
, const invalid_scheduler_policy_key
* rhs
)
807 TRACE("(%p %p)\n", _this
, rhs
);
808 MSVCRT_exception_copy_ctor(_this
, rhs
);
809 _this
->vtable
= &MSVCRT_invalid_scheduler_policy_key_vtable
;
813 DEFINE_THISCALL_WRAPPER(MSVCRT_invalid_scheduler_policy_key_dtor
,4)
814 void __thiscall
MSVCRT_invalid_scheduler_policy_key_dtor(
815 invalid_scheduler_policy_key
* _this
)
817 TRACE("(%p)\n", _this
);
818 MSVCRT_exception_dtor(_this
);
821 typedef exception invalid_scheduler_policy_value
;
822 extern const vtable_ptr MSVCRT_invalid_scheduler_policy_value_vtable
;
824 /* ??0invalid_scheduler_policy_value@Concurrency@@QAE@PBD@Z */
825 /* ??0invalid_scheduler_policy_value@Concurrency@@QEAA@PEBD@Z */
826 DEFINE_THISCALL_WRAPPER(invalid_scheduler_policy_value_ctor_str
, 8)
827 invalid_scheduler_policy_value
* __thiscall
invalid_scheduler_policy_value_ctor_str(
828 invalid_scheduler_policy_value
*this, const char *str
)
830 TRACE("(%p %p)\n", this, str
);
831 MSVCRT_exception_ctor(this, &str
);
832 this->vtable
= &MSVCRT_invalid_scheduler_policy_value_vtable
;
836 /* ??0invalid_scheduler_policy_value@Concurrency@@QAE@XZ */
837 /* ??0invalid_scheduler_policy_value@Concurrency@@QEAA@XZ */
838 DEFINE_THISCALL_WRAPPER(invalid_scheduler_policy_value_ctor
, 4)
839 invalid_scheduler_policy_value
* __thiscall
invalid_scheduler_policy_value_ctor(
840 invalid_scheduler_policy_value
*this)
842 return invalid_scheduler_policy_value_ctor_str(this, NULL
);
845 DEFINE_THISCALL_WRAPPER(MSVCRT_invalid_scheduler_policy_value_copy_ctor
,8)
846 invalid_scheduler_policy_value
* __thiscall
MSVCRT_invalid_scheduler_policy_value_copy_ctor(
847 invalid_scheduler_policy_value
* _this
, const invalid_scheduler_policy_value
* rhs
)
849 TRACE("(%p %p)\n", _this
, rhs
);
850 MSVCRT_exception_copy_ctor(_this
, rhs
);
851 _this
->vtable
= &MSVCRT_invalid_scheduler_policy_value_vtable
;
855 DEFINE_THISCALL_WRAPPER(MSVCRT_invalid_scheduler_policy_value_dtor
,4)
856 void __thiscall
MSVCRT_invalid_scheduler_policy_value_dtor(
857 invalid_scheduler_policy_value
* _this
)
859 TRACE("(%p)\n", _this
);
860 MSVCRT_exception_dtor(_this
);
863 typedef exception invalid_scheduler_policy_thread_specification
;
864 extern const vtable_ptr MSVCRT_invalid_scheduler_policy_thread_specification_vtable
;
866 /* ??0invalid_scheduler_policy_thread_specification@Concurrency@@QAE@PBD@Z */
867 /* ??0invalid_scheduler_policy_thread_specification@Concurrency@@QEAA@PEBD@Z */
868 DEFINE_THISCALL_WRAPPER(invalid_scheduler_policy_thread_specification_ctor_str
, 8)
869 invalid_scheduler_policy_thread_specification
* __thiscall
invalid_scheduler_policy_thread_specification_ctor_str(
870 invalid_scheduler_policy_thread_specification
*this, const char *str
)
872 TRACE("(%p %p)\n", this, str
);
873 MSVCRT_exception_ctor(this, &str
);
874 this->vtable
= &MSVCRT_invalid_scheduler_policy_thread_specification_vtable
;
878 /* ??0invalid_scheduler_policy_thread_specification@Concurrency@@QAE@XZ */
879 /* ??0invalid_scheduler_policy_thread_specification@Concurrency@@QEAA@XZ */
880 DEFINE_THISCALL_WRAPPER(invalid_scheduler_policy_thread_specification_ctor
, 4)
881 invalid_scheduler_policy_thread_specification
* __thiscall
invalid_scheduler_policy_thread_specification_ctor(
882 invalid_scheduler_policy_thread_specification
*this)
884 return invalid_scheduler_policy_thread_specification_ctor_str(this, NULL
);
887 DEFINE_THISCALL_WRAPPER(MSVCRT_invalid_scheduler_policy_thread_specification_copy_ctor
,8)
888 invalid_scheduler_policy_thread_specification
* __thiscall
MSVCRT_invalid_scheduler_policy_thread_specification_copy_ctor(
889 invalid_scheduler_policy_thread_specification
* _this
, const invalid_scheduler_policy_thread_specification
* rhs
)
891 TRACE("(%p %p)\n", _this
, rhs
);
892 MSVCRT_exception_copy_ctor(_this
, rhs
);
893 _this
->vtable
= &MSVCRT_invalid_scheduler_policy_thread_specification_vtable
;
897 DEFINE_THISCALL_WRAPPER(MSVCRT_invalid_scheduler_policy_thread_specification_dtor
,4)
898 void __thiscall
MSVCRT_invalid_scheduler_policy_thread_specification_dtor(
899 invalid_scheduler_policy_thread_specification
* _this
)
901 TRACE("(%p)\n", _this
);
902 MSVCRT_exception_dtor(_this
);
905 typedef exception improper_scheduler_attach
;
906 extern const vtable_ptr MSVCRT_improper_scheduler_attach_vtable
;
908 /* ??0improper_scheduler_attach@Concurrency@@QAE@PBD@Z */
909 /* ??0improper_scheduler_attach@Concurrency@@QEAA@PEBD@Z */
910 DEFINE_THISCALL_WRAPPER(improper_scheduler_attach_ctor_str
, 8)
911 improper_scheduler_attach
* __thiscall
improper_scheduler_attach_ctor_str(
912 improper_scheduler_attach
*this, const char *str
)
914 TRACE("(%p %p)\n", this, str
);
915 MSVCRT_exception_ctor(this, &str
);
916 this->vtable
= &MSVCRT_improper_scheduler_attach_vtable
;
920 /* ??0improper_scheduler_attach@Concurrency@@QAE@XZ */
921 /* ??0improper_scheduler_attach@Concurrency@@QEAA@XZ */
922 DEFINE_THISCALL_WRAPPER(improper_scheduler_attach_ctor
, 4)
923 improper_scheduler_attach
* __thiscall
improper_scheduler_attach_ctor(
924 improper_scheduler_attach
*this)
926 return improper_scheduler_attach_ctor_str(this, NULL
);
929 DEFINE_THISCALL_WRAPPER(MSVCRT_improper_scheduler_attach_copy_ctor
,8)
930 improper_scheduler_attach
* __thiscall
MSVCRT_improper_scheduler_attach_copy_ctor(
931 improper_scheduler_attach
* _this
, const improper_scheduler_attach
* rhs
)
933 TRACE("(%p %p)\n", _this
, rhs
);
934 MSVCRT_exception_copy_ctor(_this
, rhs
);
935 _this
->vtable
= &MSVCRT_improper_scheduler_attach_vtable
;
939 DEFINE_THISCALL_WRAPPER(MSVCRT_improper_scheduler_attach_dtor
,4)
940 void __thiscall
MSVCRT_improper_scheduler_attach_dtor(
941 improper_scheduler_attach
* _this
)
943 TRACE("(%p)\n", _this
);
944 MSVCRT_exception_dtor(_this
);
947 typedef exception improper_scheduler_detach
;
948 extern const vtable_ptr MSVCRT_improper_scheduler_detach_vtable
;
950 /* ??0improper_scheduler_detach@Concurrency@@QAE@PBD@Z */
951 /* ??0improper_scheduler_detach@Concurrency@@QEAA@PEBD@Z */
952 DEFINE_THISCALL_WRAPPER(improper_scheduler_detach_ctor_str
, 8)
953 improper_scheduler_detach
* __thiscall
improper_scheduler_detach_ctor_str(
954 improper_scheduler_detach
*this, const char *str
)
956 TRACE("(%p %p)\n", this, str
);
957 MSVCRT_exception_ctor(this, &str
);
958 this->vtable
= &MSVCRT_improper_scheduler_detach_vtable
;
962 /* ??0improper_scheduler_detach@Concurrency@@QAE@XZ */
963 /* ??0improper_scheduler_detach@Concurrency@@QEAA@XZ */
964 DEFINE_THISCALL_WRAPPER(improper_scheduler_detach_ctor
, 4)
965 improper_scheduler_detach
* __thiscall
improper_scheduler_detach_ctor(
966 improper_scheduler_detach
*this)
968 return improper_scheduler_detach_ctor_str(this, NULL
);
971 DEFINE_THISCALL_WRAPPER(MSVCRT_improper_scheduler_detach_copy_ctor
,8)
972 improper_scheduler_detach
* __thiscall
MSVCRT_improper_scheduler_detach_copy_ctor(
973 improper_scheduler_detach
* _this
, const improper_scheduler_detach
* rhs
)
975 TRACE("(%p %p)\n", _this
, rhs
);
976 MSVCRT_exception_copy_ctor(_this
, rhs
);
977 _this
->vtable
= &MSVCRT_improper_scheduler_detach_vtable
;
981 DEFINE_THISCALL_WRAPPER(MSVCRT_improper_scheduler_detach_dtor
,4)
982 void __thiscall
MSVCRT_improper_scheduler_detach_dtor(
983 improper_scheduler_detach
* _this
)
985 TRACE("(%p)\n", _this
);
986 MSVCRT_exception_dtor(_this
);
991 void __asm_dummy_vtables(void) {
994 __ASM_VTABLE(type_info
,
995 VTABLE_ADD_FUNC(MSVCRT_type_info_vector_dtor
));
996 __ASM_VTABLE(exception
,
997 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
998 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1000 __ASM_VTABLE(exception_old
,
1001 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1002 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1003 __ASM_VTABLE(bad_alloc
,
1004 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1005 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1007 __ASM_VTABLE(bad_typeid
,
1008 VTABLE_ADD_FUNC(MSVCRT_bad_typeid_vector_dtor
)
1009 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1010 __ASM_VTABLE(bad_cast
,
1011 VTABLE_ADD_FUNC(MSVCRT_bad_cast_vector_dtor
)
1012 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1013 __ASM_VTABLE(__non_rtti_object
,
1014 VTABLE_ADD_FUNC(MSVCRT___non_rtti_object_vector_dtor
)
1015 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1016 #if _MSVCR_VER >= 100
1017 __ASM_VTABLE(scheduler_resource_allocation_error
,
1018 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1019 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1020 __ASM_VTABLE(improper_lock
,
1021 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1022 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1023 __ASM_VTABLE(invalid_scheduler_policy_key
,
1024 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1025 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1026 __ASM_VTABLE(invalid_scheduler_policy_value
,
1027 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1028 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1029 __ASM_VTABLE(invalid_scheduler_policy_thread_specification
,
1030 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1031 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1032 __ASM_VTABLE(improper_scheduler_attach
,
1033 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1034 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1035 __ASM_VTABLE(improper_scheduler_detach
,
1036 VTABLE_ADD_FUNC(MSVCRT_exception_vector_dtor
)
1037 VTABLE_ADD_FUNC(MSVCRT_what_exception
));
1044 DEFINE_RTTI_DATA0( type_info
, 0, ".?AVtype_info@@" )
1045 #if _MSVCR_VER >= 80
1046 DEFINE_RTTI_DATA0( exception
, 0, ".?AVexception@std@@" )
1047 DEFINE_RTTI_DATA0( exception_old
, 0, ".?AVexception@@" )
1048 DEFINE_RTTI_DATA1( bad_typeid
, 0, &exception_rtti_base_descriptor
, ".?AVbad_typeid@std@@" )
1049 DEFINE_RTTI_DATA1( bad_cast
, 0, &exception_rtti_base_descriptor
, ".?AVbad_cast@std@@" )
1050 DEFINE_RTTI_DATA2( __non_rtti_object
, 0, &bad_typeid_rtti_base_descriptor
, &exception_rtti_base_descriptor
, ".?AV__non_rtti_object@std@@" )
1051 DEFINE_RTTI_DATA1( bad_alloc
, 0, &exception_rtti_base_descriptor
, ".?AVbad_alloc@std@@" )
1053 DEFINE_RTTI_DATA0( exception
, 0, ".?AVexception@@" )
1054 DEFINE_RTTI_DATA1( bad_typeid
, 0, &exception_rtti_base_descriptor
, ".?AVbad_typeid@@" )
1055 DEFINE_RTTI_DATA1( bad_cast
, 0, &exception_rtti_base_descriptor
, ".?AVbad_cast@@" )
1056 DEFINE_RTTI_DATA2( __non_rtti_object
, 0, &bad_typeid_rtti_base_descriptor
, &exception_rtti_base_descriptor
, ".?AV__non_rtti_object@@" )
1058 #if _MSVCR_VER >= 100
1059 DEFINE_RTTI_DATA1(scheduler_resource_allocation_error
, 0, &exception_rtti_base_descriptor
,
1060 ".?AVscheduler_resource_allocation_error@Concurrency@@")
1061 DEFINE_RTTI_DATA1(improper_lock
, 0, &exception_rtti_base_descriptor
, ".?AVimproper_lock@Concurrency@@" )
1062 DEFINE_RTTI_DATA1(invalid_scheduler_policy_key
, 0, &exception_rtti_base_descriptor
,
1063 ".?AVinvalid_scheduler_policy_key@Concurrency@@" )
1064 DEFINE_RTTI_DATA1(invalid_scheduler_policy_value
, 0, &exception_rtti_base_descriptor
,
1065 ".?AVinvalid_scheduler_policy_value@Concurrency@@" )
1066 DEFINE_RTTI_DATA1(invalid_scheduler_policy_thread_specification
, 0, &exception_rtti_base_descriptor
,
1067 ".?AVinvalid_scheduler_policy_thread_specification@Concurrency@@" )
1068 DEFINE_RTTI_DATA1(improper_scheduler_attach
, 0, &exception_rtti_base_descriptor
,
1069 ".?AVimproper_scheduler_attach@Concurrency@@" )
1070 DEFINE_RTTI_DATA1(improper_scheduler_detach
, 0, &exception_rtti_base_descriptor
,
1071 ".?AVimproper_scheduler_detach@Concurrency@@" )
1074 DEFINE_EXCEPTION_TYPE_INFO( exception
, 0, NULL
, NULL
)
1075 DEFINE_EXCEPTION_TYPE_INFO( bad_typeid
, 1, &exception_cxx_type_info
, NULL
)
1076 DEFINE_EXCEPTION_TYPE_INFO( bad_cast
, 1, &exception_cxx_type_info
, NULL
)
1077 DEFINE_EXCEPTION_TYPE_INFO( __non_rtti_object
, 2, &bad_typeid_cxx_type_info
, &exception_cxx_type_info
)
1078 #if _MSVCR_VER >= 80
1079 DEFINE_EXCEPTION_TYPE_INFO( bad_alloc
, 1, &exception_cxx_type_info
, NULL
)
1081 #if _MSVCR_VER >= 100
1082 DEFINE_EXCEPTION_TYPE_INFO(scheduler_resource_allocation_error
, 1, &exception_cxx_type_info
, NULL
)
1083 DEFINE_EXCEPTION_TYPE_INFO(improper_lock
, 1, &exception_cxx_type_info
, NULL
)
1084 DEFINE_EXCEPTION_TYPE_INFO(invalid_scheduler_policy_key
, 1, &exception_cxx_type_info
, NULL
)
1085 DEFINE_EXCEPTION_TYPE_INFO(invalid_scheduler_policy_value
, 1, &exception_cxx_type_info
, NULL
)
1086 DEFINE_EXCEPTION_TYPE_INFO(invalid_scheduler_policy_thread_specification
, 1, &exception_cxx_type_info
, NULL
)
1087 DEFINE_EXCEPTION_TYPE_INFO(improper_scheduler_attach
, 1, &exception_cxx_type_info
, NULL
)
1088 DEFINE_EXCEPTION_TYPE_INFO(improper_scheduler_detach
, 1, &exception_cxx_type_info
, NULL
)
1091 void msvcrt_init_exception(void *base
)
1094 init_type_info_rtti(base
);
1095 init_exception_rtti(base
);
1096 #if _MSVCR_VER >= 80
1097 init_exception_old_rtti(base
);
1098 init_bad_alloc_rtti(base
);
1100 init_bad_typeid_rtti(base
);
1101 init_bad_cast_rtti(base
);
1102 init___non_rtti_object_rtti(base
);
1103 #if _MSVCR_VER >= 100
1104 init_scheduler_resource_allocation_error_rtti(base
);
1105 init_improper_lock_rtti(base
);
1106 init_invalid_scheduler_policy_key_rtti(base
);
1107 init_invalid_scheduler_policy_value_rtti(base
);
1108 init_invalid_scheduler_policy_thread_specification_rtti(base
);
1109 init_improper_scheduler_attach_rtti(base
);
1110 init_improper_scheduler_detach_rtti(base
);
1113 init_exception_cxx(base
);
1114 init_bad_typeid_cxx(base
);
1115 init_bad_cast_cxx(base
);
1116 init___non_rtti_object_cxx(base
);
1117 #if _MSVCR_VER >= 80
1118 init_bad_alloc_cxx(base
);
1120 #if _MSVCR_VER >= 100
1121 init_scheduler_resource_allocation_error_cxx(base
);
1122 init_improper_lock_cxx(base
);
1123 init_invalid_scheduler_policy_key_cxx(base
);
1124 init_invalid_scheduler_policy_value_cxx(base
);
1125 init_invalid_scheduler_policy_thread_specification_cxx(base
);
1126 init_improper_scheduler_attach_cxx(base
);
1127 init_improper_scheduler_detach_cxx(base
);
1132 #if _MSVCR_VER >= 80
1133 void throw_exception(exception_type et
, HRESULT hr
, const char *str
)
1136 case EXCEPTION_BAD_ALLOC
: {
1138 bad_alloc_ctor(&e
, &str
);
1139 _CxxThrowException(&e
, &bad_alloc_exception_type
);
1141 #if _MSVCR_VER >= 100
1142 case EXCEPTION_SCHEDULER_RESOURCE_ALLOCATION_ERROR
: {
1143 scheduler_resource_allocation_error e
;
1144 scheduler_resource_allocation_error_ctor_name(&e
, str
, hr
);
1145 _CxxThrowException(&e
.e
, &scheduler_resource_allocation_error_exception_type
);
1147 case EXCEPTION_IMPROPER_LOCK
: {
1149 improper_lock_ctor_str(&e
, str
);
1150 _CxxThrowException(&e
, &improper_lock_exception_type
);
1152 case EXCEPTION_INVALID_SCHEDULER_POLICY_KEY
: {
1153 invalid_scheduler_policy_key e
;
1154 invalid_scheduler_policy_key_ctor_str(&e
, str
);
1155 _CxxThrowException(&e
, &invalid_scheduler_policy_key_exception_type
);
1157 case EXCEPTION_INVALID_SCHEDULER_POLICY_VALUE
: {
1158 invalid_scheduler_policy_value e
;
1159 invalid_scheduler_policy_value_ctor_str(&e
, str
);
1160 _CxxThrowException(&e
, &invalid_scheduler_policy_value_exception_type
);
1162 case EXCEPTION_INVALID_SCHEDULER_POLICY_THREAD_SPECIFICATION
: {
1163 invalid_scheduler_policy_thread_specification e
;
1164 invalid_scheduler_policy_thread_specification_ctor_str(&e
, str
);
1165 _CxxThrowException(&e
, &invalid_scheduler_policy_thread_specification_exception_type
);
1167 case EXCEPTION_IMPROPER_SCHEDULER_ATTACH
: {
1168 improper_scheduler_attach e
;
1169 improper_scheduler_attach_ctor_str(&e
, str
);
1170 _CxxThrowException(&e
, &improper_scheduler_attach_exception_type
);
1172 case EXCEPTION_IMPROPER_SCHEDULER_DETACH
: {
1173 improper_scheduler_detach e
;
1174 improper_scheduler_detach_ctor_str(&e
, str
);
1175 _CxxThrowException(&e
, &improper_scheduler_detach_exception_type
);
1182 /******************************************************************
1183 * ?set_terminate@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
1185 * Install a handler to be called when terminate() is called.
1188 * func [I] Handler function to install
1191 * The previously installed handler function, if any.
1193 MSVCRT_terminate_function CDECL
MSVCRT_set_terminate(MSVCRT_terminate_function func
)
1195 thread_data_t
*data
= msvcrt_get_thread_data();
1196 MSVCRT_terminate_function previous
= data
->terminate_handler
;
1197 TRACE("(%p) returning %p\n",func
,previous
);
1198 data
->terminate_handler
= func
;
1202 /******************************************************************
1203 * _get_terminate (MSVCRT.@)
1205 MSVCRT_terminate_function CDECL
MSVCRT__get_terminate(void)
1207 thread_data_t
*data
= msvcrt_get_thread_data();
1208 TRACE("returning %p\n", data
->terminate_handler
);
1209 return data
->terminate_handler
;
1212 /******************************************************************
1213 * ?set_unexpected@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
1215 * Install a handler to be called when unexpected() is called.
1218 * func [I] Handler function to install
1221 * The previously installed handler function, if any.
1223 MSVCRT_unexpected_function CDECL
MSVCRT_set_unexpected(MSVCRT_unexpected_function func
)
1225 thread_data_t
*data
= msvcrt_get_thread_data();
1226 MSVCRT_unexpected_function previous
= data
->unexpected_handler
;
1227 TRACE("(%p) returning %p\n",func
,previous
);
1228 data
->unexpected_handler
= func
;
1232 /******************************************************************
1233 * _get_unexpected (MSVCRT.@)
1235 MSVCRT_unexpected_function CDECL
MSVCRT__get_unexpected(void)
1237 thread_data_t
*data
= msvcrt_get_thread_data();
1238 TRACE("returning %p\n", data
->unexpected_handler
);
1239 return data
->unexpected_handler
;
1242 /******************************************************************
1243 * ?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z (MSVCRT.@)
1245 MSVCRT__se_translator_function CDECL
MSVCRT__set_se_translator(MSVCRT__se_translator_function func
)
1247 thread_data_t
*data
= msvcrt_get_thread_data();
1248 MSVCRT__se_translator_function previous
= data
->se_translator
;
1249 TRACE("(%p) returning %p\n",func
,previous
);
1250 data
->se_translator
= func
;
1254 /******************************************************************
1255 * ?terminate@@YAXXZ (MSVCRT.@)
1257 * Default handler for an unhandled exception.
1263 * This function does not return. Either control resumes from any
1264 * handler installed by calling set_terminate(), or (by default) abort()
1267 void CDECL
MSVCRT_terminate(void)
1269 thread_data_t
*data
= msvcrt_get_thread_data();
1270 if (data
->terminate_handler
) data
->terminate_handler();
1274 /******************************************************************
1275 * ?unexpected@@YAXXZ (MSVCRT.@)
1277 void CDECL
MSVCRT_unexpected(void)
1279 thread_data_t
*data
= msvcrt_get_thread_data();
1280 if (data
->unexpected_handler
) data
->unexpected_handler();
1285 /******************************************************************
1286 * __RTtypeid (MSVCRT.@)
1288 * Retrieve the Run Time Type Information (RTTI) for a C++ object.
1291 * cppobj [I] C++ object to get type information for.
1294 * Success: A type_info object describing cppobj.
1295 * Failure: If the object to be cast has no RTTI, a __non_rtti_object
1296 * exception is thrown. If cppobj is NULL, a bad_typeid exception
1297 * is thrown. In either case, this function does not return.
1300 * This function is usually called by compiler generated code as a result
1301 * of using one of the C++ dynamic cast statements.
1304 const type_info
* CDECL
MSVCRT___RTtypeid(void *cppobj
)
1306 const type_info
*ret
;
1311 MSVCRT_bad_typeid_ctor( &e
, "Attempted a typeid of NULL pointer!" );
1312 _CxxThrowException( &e
, &bad_typeid_exception_type
);
1318 const rtti_object_locator
*obj_locator
= get_obj_locator( cppobj
);
1319 ret
= obj_locator
->type_descriptor
;
1323 __non_rtti_object e
;
1324 MSVCRT___non_rtti_object_ctor( &e
, "Bad read pointer - no RTTI data!" );
1325 _CxxThrowException( &e
, &__non_rtti_object_exception_type
);
1334 const type_info
* CDECL
MSVCRT___RTtypeid(void *cppobj
)
1336 const type_info
*ret
;
1341 MSVCRT_bad_typeid_ctor( &e
, "Attempted a typeid of NULL pointer!" );
1342 _CxxThrowException( &e
, &bad_typeid_exception_type
);
1348 const rtti_object_locator
*obj_locator
= get_obj_locator( cppobj
);
1351 if(obj_locator
->signature
== 0)
1352 base
= RtlPcToFileHeader((void*)obj_locator
, (void**)&base
);
1354 base
= (char*)obj_locator
- obj_locator
->object_locator
;
1356 ret
= (type_info
*)(base
+ obj_locator
->type_descriptor
);
1360 __non_rtti_object e
;
1361 MSVCRT___non_rtti_object_ctor( &e
, "Bad read pointer - no RTTI data!" );
1362 _CxxThrowException( &e
, &__non_rtti_object_exception_type
);
1370 /******************************************************************
1371 * __RTDynamicCast (MSVCRT.@)
1373 * Dynamically cast a C++ object to one of its base classes.
1376 * cppobj [I] Any C++ object to cast
1377 * unknown [I] Reserved, set to 0
1378 * src [I] type_info object describing cppobj
1379 * dst [I] type_info object describing the base class to cast to
1380 * do_throw [I] TRUE = throw an exception if the cast fails, FALSE = don't
1383 * Success: The address of cppobj, cast to the object described by dst.
1384 * Failure: NULL, If the object to be cast has no RTTI, or dst is not a
1385 * valid cast for cppobj. If do_throw is TRUE, a bad_cast exception
1386 * is thrown and this function does not return.
1389 * This function is usually called by compiler generated code as a result
1390 * of using one of the C++ dynamic cast statements.
1393 void* CDECL
MSVCRT___RTDynamicCast(void *cppobj
, int unknown
,
1394 type_info
*src
, type_info
*dst
,
1399 if (!cppobj
) return NULL
;
1401 TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n",
1402 cppobj
, unknown
, src
, dbgstr_type_info(src
), dst
, dbgstr_type_info(dst
), do_throw
);
1404 /* To cast an object at runtime:
1405 * 1.Find out the true type of the object from the typeinfo at vtable[-1]
1406 * 2.Search for the destination type in the class hierarchy
1407 * 3.If destination type is found, return base object address + dest offset
1408 * Otherwise, fail the cast
1410 * FIXME: the unknown parameter doesn't seem to be used for anything
1415 const rtti_object_locator
*obj_locator
= get_obj_locator( cppobj
);
1416 const rtti_object_hierarchy
*obj_bases
= obj_locator
->type_hierarchy
;
1417 const rtti_base_descriptor
* const* base_desc
= obj_bases
->base_classes
->bases
;
1419 if (TRACE_ON(msvcrt
)) dump_obj_locator(obj_locator
);
1422 for (i
= 0; i
< obj_bases
->array_len
; i
++)
1424 const type_info
*typ
= base_desc
[i
]->type_descriptor
;
1426 if (!strcmp(typ
->mangled
, dst
->mangled
))
1428 /* compute the correct this pointer for that base class */
1429 void *this_ptr
= (char *)cppobj
- obj_locator
->base_class_offset
;
1430 ret
= get_this_pointer( &base_desc
[i
]->offsets
, this_ptr
);
1434 /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned
1435 * to a reference, since references cannot be NULL.
1437 if (!ret
&& do_throw
)
1439 const char *msg
= "Bad dynamic_cast!";
1441 MSVCRT_bad_cast_ctor( &e
, &msg
);
1442 _CxxThrowException( &e
, &bad_cast_exception_type
);
1447 __non_rtti_object e
;
1448 MSVCRT___non_rtti_object_ctor( &e
, "Access violation - no RTTI data!" );
1449 _CxxThrowException( &e
, &__non_rtti_object_exception_type
);
1458 void* CDECL
MSVCRT___RTDynamicCast(void *cppobj
, int unknown
,
1459 type_info
*src
, type_info
*dst
,
1464 if (!cppobj
) return NULL
;
1466 TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n",
1467 cppobj
, unknown
, src
, dbgstr_type_info(src
), dst
, dbgstr_type_info(dst
), do_throw
);
1472 const rtti_object_locator
*obj_locator
= get_obj_locator( cppobj
);
1473 const rtti_object_hierarchy
*obj_bases
;
1474 const rtti_base_array
*base_array
;
1477 if (TRACE_ON(msvcrt
)) dump_obj_locator(obj_locator
);
1479 if(obj_locator
->signature
== 0)
1480 base
= RtlPcToFileHeader((void*)obj_locator
, (void**)&base
);
1482 base
= (char*)obj_locator
- obj_locator
->object_locator
;
1484 obj_bases
= (const rtti_object_hierarchy
*)(base
+ obj_locator
->type_hierarchy
);
1485 base_array
= (const rtti_base_array
*)(base
+ obj_bases
->base_classes
);
1488 for (i
= 0; i
< obj_bases
->array_len
; i
++)
1490 const rtti_base_descriptor
*base_desc
= (const rtti_base_descriptor
*)(base
+ base_array
->bases
[i
]);
1491 const type_info
*typ
= (const type_info
*)(base
+ base_desc
->type_descriptor
);
1493 if (!strcmp(typ
->mangled
, dst
->mangled
))
1495 void *this_ptr
= (char *)cppobj
- obj_locator
->base_class_offset
;
1496 ret
= get_this_pointer( &base_desc
->offsets
, this_ptr
);
1500 if (!ret
&& do_throw
)
1502 const char *msg
= "Bad dynamic_cast!";
1504 MSVCRT_bad_cast_ctor( &e
, &msg
);
1505 _CxxThrowException( &e
, &bad_cast_exception_type
);
1510 __non_rtti_object e
;
1511 MSVCRT___non_rtti_object_ctor( &e
, "Access violation - no RTTI data!" );
1512 _CxxThrowException( &e
, &__non_rtti_object_exception_type
);
1521 /******************************************************************
1522 * __RTCastToVoid (MSVCRT.@)
1524 * Dynamically cast a C++ object to a void*.
1527 * cppobj [I] The C++ object to cast
1530 * Success: The base address of the object as a void*.
1531 * Failure: NULL, if cppobj is NULL or has no RTTI.
1534 * This function is usually called by compiler generated code as a result
1535 * of using one of the C++ dynamic cast statements.
1537 void* CDECL
MSVCRT___RTCastToVoid(void *cppobj
)
1541 if (!cppobj
) return NULL
;
1545 const rtti_object_locator
*obj_locator
= get_obj_locator( cppobj
);
1546 ret
= (char *)cppobj
- obj_locator
->base_class_offset
;
1550 __non_rtti_object e
;
1551 MSVCRT___non_rtti_object_ctor( &e
, "Access violation - no RTTI data!" );
1552 _CxxThrowException( &e
, &__non_rtti_object_exception_type
);
1560 /*********************************************************************
1561 * _CxxThrowException (MSVCRT.@)
1564 void WINAPI
_CxxThrowException( exception
*object
, const cxx_exception_type
*type
)
1568 args
[0] = CXX_FRAME_MAGIC_VC6
;
1569 args
[1] = (ULONG_PTR
)object
;
1570 args
[2] = (ULONG_PTR
)type
;
1571 RaiseException( CXX_EXCEPTION
, EH_NONCONTINUABLE
, 3, args
);
1574 void WINAPI
_CxxThrowException( exception
*object
, const cxx_exception_type
*type
)
1578 args
[0] = CXX_FRAME_MAGIC_VC6
;
1579 args
[1] = (ULONG_PTR
)object
;
1580 args
[2] = (ULONG_PTR
)type
;
1581 RtlPcToFileHeader( (void*)type
, (void**)&args
[3]);
1582 RaiseException( CXX_EXCEPTION
, EH_NONCONTINUABLE
, 4, args
);
1586 /*********************************************************************
1587 * ?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z
1588 * ?_is_exception_typeof@@YAHAEBVtype_info@@PEAU_EXCEPTION_POINTERS@@@Z
1591 int __cdecl
_is_exception_typeof(const type_info
*ti
, EXCEPTION_POINTERS
*ep
)
1595 TRACE("(%p %p)\n", ti
, ep
);
1599 EXCEPTION_RECORD
*rec
= ep
->ExceptionRecord
;
1601 if (rec
->ExceptionCode
==CXX_EXCEPTION
&& rec
->NumberParameters
==3 &&
1602 (rec
->ExceptionInformation
[0]==CXX_FRAME_MAGIC_VC6
||
1603 rec
->ExceptionInformation
[0]==CXX_FRAME_MAGIC_VC7
||
1604 rec
->ExceptionInformation
[0]==CXX_FRAME_MAGIC_VC8
))
1606 const cxx_type_info_table
*tit
= ((cxx_exception_type
*)rec
->ExceptionInformation
[2])->type_info_table
;
1609 for (i
=0; i
<tit
->count
; i
++) {
1610 if (ti
==tit
->info
[i
]->type_info
|| !strcmp(ti
->mangled
, tit
->info
[i
]->type_info
->mangled
))
1617 if (i
== tit
->count
)
1629 int __cdecl
_is_exception_typeof(const type_info
*ti
, EXCEPTION_POINTERS
*ep
)
1633 TRACE("(%p %p)\n", ti
, ep
);
1637 EXCEPTION_RECORD
*rec
= ep
->ExceptionRecord
;
1639 if (rec
->ExceptionCode
==CXX_EXCEPTION
&& rec
->NumberParameters
==4 &&
1640 (rec
->ExceptionInformation
[0]==CXX_FRAME_MAGIC_VC6
||
1641 rec
->ExceptionInformation
[0]==CXX_FRAME_MAGIC_VC7
||
1642 rec
->ExceptionInformation
[0]==CXX_FRAME_MAGIC_VC8
))
1644 const cxx_exception_type
*et
= (cxx_exception_type
*)rec
->ExceptionInformation
[2];
1645 const cxx_type_info_table
*tit
= (const cxx_type_info_table
*)(rec
->ExceptionInformation
[3]+et
->type_info_table
);
1648 for (i
=0; i
<tit
->count
; i
++) {
1649 const cxx_type_info
*cti
= (const cxx_type_info
*)(rec
->ExceptionInformation
[3]+tit
->info
[i
]);
1650 const type_info
*except_ti
= (const type_info
*)(rec
->ExceptionInformation
[3]+cti
->type_info
);
1651 if (ti
==except_ti
|| !strcmp(ti
->mangled
, except_ti
->mangled
))
1658 if (i
== tit
->count
)
1671 /*********************************************************************
1672 * __clean_type_info_names_internal (MSVCR100.@)
1674 void CDECL
__clean_type_info_names_internal(void *p
)
1676 FIXME("(%p) stub\n", p
);
1679 /*********************************************************************
1680 * ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z (MSVCR100.@)
1682 DEFINE_THISCALL_WRAPPER(type_info_name_internal_method
,8)
1683 const char * __thiscall
type_info_name_internal_method(type_info
* _this
, struct __type_info_node
*node
)
1686 if (node
&& !once
++) FIXME("type_info_node parameter ignored\n");
1688 return MSVCRT_type_info_name(_this
);
1691 /* std::exception_ptr class helpers */
1694 EXCEPTION_RECORD
*rec
;
1695 int *ref
; /* not binary compatible with native msvcr100 */
1698 /*********************************************************************
1699 * ?__ExceptionPtrCreate@@YAXPAX@Z
1700 * ?__ExceptionPtrCreate@@YAXPEAX@Z
1702 void __cdecl
__ExceptionPtrCreate(exception_ptr
*ep
)
1704 TRACE("(%p)\n", ep
);
1711 static inline void call_dtor(const cxx_exception_type
*type
, void *func
, void *object
)
1713 __asm__
__volatile__("call *%0" : : "m" (func
), "c" (object
) : "eax", "edx", "memory");
1716 static inline void call_dtor(const cxx_exception_type
*type
, unsigned int dtor
, void *object
)
1718 char *base
= RtlPcToFileHeader((void*)type
, (void**)&base
);
1719 void (__cdecl
*func
)(void*) = (void*)(base
+ dtor
);
1723 #define call_dtor(type, func, object) ((void (__cdecl*)(void*))(func))(object)
1726 /*********************************************************************
1727 * ?__ExceptionPtrDestroy@@YAXPAX@Z
1728 * ?__ExceptionPtrDestroy@@YAXPEAX@Z
1730 void __cdecl
__ExceptionPtrDestroy(exception_ptr
*ep
)
1732 TRACE("(%p)\n", ep
);
1737 if (!InterlockedDecrement(ep
->ref
))
1739 if (ep
->rec
->ExceptionCode
== CXX_EXCEPTION
)
1741 const cxx_exception_type
*type
= (void*)ep
->rec
->ExceptionInformation
[2];
1742 void *obj
= (void*)ep
->rec
->ExceptionInformation
[1];
1744 if (type
&& type
->destructor
) call_dtor(type
, type
->destructor
, obj
);
1745 HeapFree(GetProcessHeap(), 0, obj
);
1748 HeapFree(GetProcessHeap(), 0, ep
->rec
);
1749 HeapFree(GetProcessHeap(), 0, ep
->ref
);
1753 /*********************************************************************
1754 * ?__ExceptionPtrCopy@@YAXPAXPBX@Z
1755 * ?__ExceptionPtrCopy@@YAXPEAXPEBX@Z
1757 void __cdecl
__ExceptionPtrCopy(exception_ptr
*ep
, const exception_ptr
*copy
)
1759 TRACE("(%p %p)\n", ep
, copy
);
1761 /* don't destroy object stored in ep */
1764 InterlockedIncrement(copy
->ref
);
1767 /*********************************************************************
1768 * ?__ExceptionPtrAssign@@YAXPAXPBX@Z
1769 * ?__ExceptionPtrAssign@@YAXPEAXPEBX@Z
1771 void __cdecl
__ExceptionPtrAssign(exception_ptr
*ep
, const exception_ptr
*assign
)
1773 TRACE("(%p %p)\n", ep
, assign
);
1775 /* don't destroy object stored in ep */
1777 InterlockedDecrement(ep
->ref
);
1781 InterlockedIncrement(ep
->ref
);
1784 /*********************************************************************
1785 * ?__ExceptionPtrRethrow@@YAXPBX@Z
1786 * ?__ExceptionPtrRethrow@@YAXPEBX@Z
1788 void __cdecl
__ExceptionPtrRethrow(const exception_ptr
*ep
)
1790 TRACE("(%p)\n", ep
);
1794 static const char *exception_msg
= "bad exception";
1797 MSVCRT_exception_ctor(&e
, &exception_msg
);
1798 _CxxThrowException(&e
, &exception_exception_type
);
1802 RaiseException(ep
->rec
->ExceptionCode
, ep
->rec
->ExceptionFlags
& (~EH_UNWINDING
),
1803 ep
->rec
->NumberParameters
, ep
->rec
->ExceptionInformation
);
1807 static inline void call_copy_ctor( void *func
, void *this, void *src
, int has_vbase
)
1809 TRACE( "calling copy ctor %p object %p src %p\n", func
, this, src
);
1811 /* in that case copy ctor takes an extra bool indicating whether to copy the base class */
1812 __asm__
__volatile__("pushl $1; pushl %2; call *%0"
1813 : : "m" (func
), "c" (this), "m" (src
) : "eax", "edx", "memory" );
1815 __asm__
__volatile__("pushl %2; call *%0"
1816 : : "m" (func
), "c" (this), "m" (src
) : "eax", "edx", "memory" );
1819 static inline void call_copy_ctor( void *func
, void *this, void *src
, int has_vbase
)
1821 TRACE( "calling copy ctor %p object %p src %p\n", func
, this, src
);
1823 ((void (__cdecl
*)(void*, void*, BOOL
))func
)(this, src
, 1);
1825 ((void (__cdecl
*)(void*, void*))func
)(this, src
);
1829 /*********************************************************************
1830 * ?__ExceptionPtrCurrentException@@YAXPAX@Z
1831 * ?__ExceptionPtrCurrentException@@YAXPEAX@Z
1834 void __cdecl
__ExceptionPtrCurrentException(exception_ptr
*ep
)
1836 EXCEPTION_RECORD
*rec
= msvcrt_get_thread_data()->exc_record
;
1838 TRACE("(%p)\n", ep
);
1847 ep
->rec
= HeapAlloc(GetProcessHeap(), 0, sizeof(EXCEPTION_RECORD
));
1848 ep
->ref
= HeapAlloc(GetProcessHeap(), 0, sizeof(int));
1853 if (ep
->rec
->ExceptionCode
== CXX_EXCEPTION
)
1855 const cxx_exception_type
*et
= (void*)ep
->rec
->ExceptionInformation
[2];
1856 const cxx_type_info
*ti
;
1859 ti
= et
->type_info_table
->info
[0];
1860 data
= HeapAlloc(GetProcessHeap(), 0, ti
->size
);
1862 obj
= (void*)ep
->rec
->ExceptionInformation
[1];
1863 if (ti
->flags
& CLASS_IS_SIMPLE_TYPE
)
1865 memcpy(data
, obj
, ti
->size
);
1866 if (ti
->size
== sizeof(void *)) *data
= get_this_pointer(&ti
->offsets
, *data
);
1868 else if (ti
->copy_ctor
)
1870 call_copy_ctor(ti
->copy_ctor
, data
, get_this_pointer(&ti
->offsets
, obj
),
1871 ti
->flags
& CLASS_HAS_VIRTUAL_BASE_CLASS
);
1874 memcpy(data
, get_this_pointer(&ti
->offsets
, obj
), ti
->size
);
1875 ep
->rec
->ExceptionInformation
[1] = (ULONG_PTR
)data
;
1880 void __cdecl
__ExceptionPtrCurrentException(exception_ptr
*ep
)
1882 EXCEPTION_RECORD
*rec
= msvcrt_get_thread_data()->exc_record
;
1884 TRACE("(%p)\n", ep
);
1893 ep
->rec
= HeapAlloc(GetProcessHeap(), 0, sizeof(EXCEPTION_RECORD
));
1894 ep
->ref
= HeapAlloc(GetProcessHeap(), 0, sizeof(int));
1899 if (ep
->rec
->ExceptionCode
== CXX_EXCEPTION
)
1901 const cxx_exception_type
*et
= (void*)ep
->rec
->ExceptionInformation
[2];
1902 const cxx_type_info
*ti
;
1904 char *base
= RtlPcToFileHeader((void*)et
, (void**)&base
);
1906 ti
= (const cxx_type_info
*)(base
+ ((const cxx_type_info_table
*)(base
+ et
->type_info_table
))->info
[0]);
1907 data
= HeapAlloc(GetProcessHeap(), 0, ti
->size
);
1909 obj
= (void*)ep
->rec
->ExceptionInformation
[1];
1910 if (ti
->flags
& CLASS_IS_SIMPLE_TYPE
)
1912 memcpy(data
, obj
, ti
->size
);
1913 if (ti
->size
== sizeof(void *)) *data
= get_this_pointer(&ti
->offsets
, *data
);
1915 else if (ti
->copy_ctor
)
1917 call_copy_ctor(base
+ ti
->copy_ctor
, data
, get_this_pointer(&ti
->offsets
, obj
),
1918 ti
->flags
& CLASS_HAS_VIRTUAL_BASE_CLASS
);
1921 memcpy(data
, get_this_pointer(&ti
->offsets
, obj
), ti
->size
);
1922 ep
->rec
->ExceptionInformation
[1] = (ULONG_PTR
)data
;
1928 /*********************************************************************
1929 * ?__ExceptionPtrToBool@@YA_NPBX@Z
1930 * ?__ExceptionPtrToBool@@YA_NPEBX@Z
1932 MSVCRT_bool __cdecl
__ExceptionPtrToBool(exception_ptr
*ep
)
1937 /*********************************************************************
1938 * ?__ExceptionPtrCopyException@@YAXPAXPBX1@Z
1939 * ?__ExceptionPtrCopyException@@YAXPEAXPEBX1@Z
1942 void __cdecl
__ExceptionPtrCopyException(exception_ptr
*ep
,
1943 exception
*object
, const cxx_exception_type
*type
)
1945 const cxx_type_info
*ti
;
1948 __ExceptionPtrDestroy(ep
);
1950 ep
->rec
= HeapAlloc(GetProcessHeap(), 0, sizeof(EXCEPTION_RECORD
));
1951 ep
->ref
= HeapAlloc(GetProcessHeap(), 0, sizeof(int));
1954 memset(ep
->rec
, 0, sizeof(EXCEPTION_RECORD
));
1955 ep
->rec
->ExceptionCode
= CXX_EXCEPTION
;
1956 ep
->rec
->ExceptionFlags
= EH_NONCONTINUABLE
;
1957 ep
->rec
->NumberParameters
= 3;
1958 ep
->rec
->ExceptionInformation
[0] = CXX_FRAME_MAGIC_VC6
;
1959 ep
->rec
->ExceptionInformation
[2] = (ULONG_PTR
)type
;
1961 ti
= type
->type_info_table
->info
[0];
1962 data
= HeapAlloc(GetProcessHeap(), 0, ti
->size
);
1963 if (ti
->flags
& CLASS_IS_SIMPLE_TYPE
)
1965 memcpy(data
, object
, ti
->size
);
1966 if (ti
->size
== sizeof(void *)) *data
= get_this_pointer(&ti
->offsets
, *data
);
1968 else if (ti
->copy_ctor
)
1970 call_copy_ctor(ti
->copy_ctor
, data
, get_this_pointer(&ti
->offsets
, object
),
1971 ti
->flags
& CLASS_HAS_VIRTUAL_BASE_CLASS
);
1974 memcpy(data
, get_this_pointer(&ti
->offsets
, object
), ti
->size
);
1975 ep
->rec
->ExceptionInformation
[1] = (ULONG_PTR
)data
;
1978 void __cdecl
__ExceptionPtrCopyException(exception_ptr
*ep
,
1979 exception
*object
, const cxx_exception_type
*type
)
1981 const cxx_type_info
*ti
;
1985 RtlPcToFileHeader((void*)type
, (void**)&base
);
1986 __ExceptionPtrDestroy(ep
);
1988 ep
->rec
= HeapAlloc(GetProcessHeap(), 0, sizeof(EXCEPTION_RECORD
));
1989 ep
->ref
= HeapAlloc(GetProcessHeap(), 0, sizeof(int));
1992 memset(ep
->rec
, 0, sizeof(EXCEPTION_RECORD
));
1993 ep
->rec
->ExceptionCode
= CXX_EXCEPTION
;
1994 ep
->rec
->ExceptionFlags
= EH_NONCONTINUABLE
;
1995 ep
->rec
->NumberParameters
= 4;
1996 ep
->rec
->ExceptionInformation
[0] = CXX_FRAME_MAGIC_VC6
;
1997 ep
->rec
->ExceptionInformation
[2] = (ULONG_PTR
)type
;
1998 ep
->rec
->ExceptionInformation
[3] = (ULONG_PTR
)base
;
2000 ti
= (const cxx_type_info
*)(base
+ ((const cxx_type_info_table
*)(base
+ type
->type_info_table
))->info
[0]);
2001 data
= HeapAlloc(GetProcessHeap(), 0, ti
->size
);
2002 if (ti
->flags
& CLASS_IS_SIMPLE_TYPE
)
2004 memcpy(data
, object
, ti
->size
);
2005 if (ti
->size
== sizeof(void *)) *data
= get_this_pointer(&ti
->offsets
, *data
);
2007 else if (ti
->copy_ctor
)
2009 call_copy_ctor(base
+ ti
->copy_ctor
, data
, get_this_pointer(&ti
->offsets
, object
),
2010 ti
->flags
& CLASS_HAS_VIRTUAL_BASE_CLASS
);
2013 memcpy(data
, get_this_pointer(&ti
->offsets
, object
), ti
->size
);
2014 ep
->rec
->ExceptionInformation
[1] = (ULONG_PTR
)data
;
2018 MSVCRT_bool __cdecl
__ExceptionPtrCompare(const exception_ptr
*ep1
, const exception_ptr
*ep2
)
2020 return ep1
->rec
== ep2
->rec
;
2023 void* __cdecl
__AdjustPointer(void *obj
, const this_ptr_offsets
*off
)
2025 return get_this_pointer(off
, obj
);
2028 #if _MSVCR_VER >= 140
2041 static void* CDECL
type_info_entry_malloc(MSVCRT_size_t size
)
2043 type_info_entry
*ret
= MSVCRT_malloc(FIELD_OFFSET(type_info_entry
, name
) + size
);
2047 static void CDECL
type_info_entry_free(void *ptr
)
2049 ptr
= (char*)ptr
- FIELD_OFFSET(type_info_entry
, name
);
2053 /******************************************************************
2054 * __std_type_info_compare (UCRTBASE.@)
2056 int CDECL
MSVCRT_type_info_compare(const type_info140
*l
, const type_info140
*r
)
2060 if (l
== r
) ret
= 0;
2061 else ret
= strcmp(l
->mangled
+ 1, r
->mangled
+ 1);
2062 TRACE("(%p %p) returning %d\n", l
, r
, ret
);
2066 /******************************************************************
2067 * __std_type_info_name (UCRTBASE.@)
2069 const char* CDECL
MSVCRT_type_info_name_list(type_info140
*ti
, SLIST_HEADER
*header
)
2073 char* name
= __unDName(0, ti
->mangled
+ 1, 0,
2074 type_info_entry_malloc
, type_info_entry_free
, UNDNAME_NO_ARGUMENTS
| UNDNAME_32_BIT_DECODE
);
2077 unsigned int len
= strlen(name
);
2079 while (len
&& name
[--len
] == ' ')
2082 if (InterlockedCompareExchangePointer((void**)&ti
->name
, name
, NULL
))
2084 type_info_entry_free(name
);
2088 type_info_entry
*entry
= (type_info_entry
*)(name
-FIELD_OFFSET(type_info_entry
, name
));
2089 InterlockedPushEntrySList(header
, &entry
->entry
);
2093 TRACE("(%p) returning %s\n", ti
, ti
->name
);
2097 /******************************************************************
2098 * __std_type_info_destroy_list (UCRTBASE.@)
2100 void CDECL
MSVCRT_type_info_destroy_list(SLIST_HEADER
*header
)
2102 SLIST_ENTRY
*cur
, *next
;
2104 TRACE("(%p)\n", header
);
2106 for(cur
= InterlockedFlushSList(header
); cur
; cur
= next
)
2113 /******************************************************************
2114 * __std_type_info_hash (UCRTBASE.@)
2116 MSVCRT_size_t CDECL
MSVCRT_type_info_hash(const type_info140
*ti
)
2118 MSVCRT_size_t hash
, fnv_prime
;
2122 hash
= 0xcbf29ce484222325;
2123 fnv_prime
= 0x100000001b3;
2126 fnv_prime
= 0x1000193;
2129 TRACE("(%p)->%s\n", ti
, ti
->mangled
);
2131 for(p
= ti
->mangled
+1; *p
; p
++) {
2144 #if _MSVCR_VER >= 100
2145 enum ConcRT_EventType
2147 CONCRT_EVENT_GENERIC
,
2151 CONCRT_EVENT_UNBLOCK
,
2153 CONCRT_EVENT_ATTACH
,
2157 /* ?_Trace_ppl_function@Concurrency@@YAXABU_GUID@@EW4ConcRT_EventType@1@@Z */
2158 /* ?_Trace_ppl_function@Concurrency@@YAXAEBU_GUID@@EW4ConcRT_EventType@1@@Z */
2159 void __cdecl
Concurrency__Trace_ppl_function(const GUID
*guid
, unsigned char level
, enum ConcRT_EventType type
)
2161 FIXME("(%s %u %i) stub\n", debugstr_guid(guid
), level
, type
);