Sync (45): msvcrt cpp update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This should be applied after "Sync (29): msvcrt cpp". It turns out
that depending on how our vtables get laid out by the compiler, we
can actually end up with a valid pointer (to invalid data) in the
dword immediately before the vtable. So, we should check for our
exported vtables before we try to read the vtables rtti pointer.

Also, type_info never compares the first byte of the raw names, as
confirmed by the test coming next.

Cheers,
Jon
License: X11

ChangeLog:

  Jon Griffiths <jon_p_griffiths@yahoo.com>

  +dlls/msvcrt/cpp.c
   Check for our exported vtables before rtti pointers
   Fix typeinfo comparason functions

=====
"Don't wait for the seas to part, or messiahs to come;
 Don't you sit around and waste this chance..." - Live

jon_p_griffiths@yahoo.com

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
--- wine-develop3/dlls/msvcrt/cpp.c	Fri Jul 18 03:29:57 2003
+++ wine-develop/dlls/msvcrt/cpp.c	Fri Jul 18 02:41:37 2003
@@ -480,7 +480,7 @@
 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_opequals_equals);
 int __stdcall MSVCRT_type_info_opequals_equals(type_info * _this, const type_info * rhs)
 {
-    int ret = !strcmp(_this->mangled, rhs->mangled);
+    int ret = !strcmp(_this->mangled + 1, rhs->mangled + 1);
     TRACE("(%p %p) returning %d\n", _this, rhs, ret);
     return ret;
 }
@@ -491,7 +491,7 @@
 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_opnot_equals);
 int __stdcall MSVCRT_type_info_opnot_equals(type_info * _this, const type_info * rhs)
 {
-    int ret = !!strcmp(_this->mangled, rhs->mangled);
+    int ret = !!strcmp(_this->mangled + 1, rhs->mangled + 1);
     TRACE("(%p %p) returning %d\n", _this, rhs, ret);
     return ret;
 }
@@ -502,7 +502,7 @@
 DEFINE_THISCALL_WRAPPER(MSVCRT_type_info_before);
 int __stdcall MSVCRT_type_info_before(type_info * _this, const type_info * rhs)
 {
-    int ret = strcmp(_this->mangled, rhs->mangled) < 0;
+    int ret = strcmp(_this->mangled + 1, rhs->mangled + 1) < 0;
     TRACE("(%p %p) returning %d\n", _this, rhs, ret);
     return ret;
 }
@@ -1017,31 +1017,44 @@
 {
   const rtti_object_locator *obj_locator = NULL;
 
+#ifdef __i386__
+  const exception_vtable* vtable = (const exception_vtable*)cppobj->vtable;
+
+  /* Perhaps this is one of classes we export? */
+  if (vtable == &MSVCRT_exception_vtable)
+  {
+    TRACE("returning exception_rtti\n");
+    return &exception_rtti;
+  }
+  else if (vtable == &MSVCRT_bad_typeid_vtable)
+  {
+    TRACE("returning bad_typeid_rtti\n");
+    return &bad_typeid_rtti;
+  }
+  else if (vtable == &MSVCRT_bad_cast_vtable)
+  {
+    TRACE("returning bad_cast_rtti\n");
+    return &bad_cast_rtti;
+  }
+  else if (vtable == &MSVCRT___non_rtti_object_vtable)
+  {
+    TRACE("returning __non_rtti_object_rtti\n");
+    return &__non_rtti_object_rtti;
+  }
+  else if (vtable == &MSVCRT_type_info_vtable)
+  {
+    TRACE("returning type_info_rtti\n");
+    return &type_info_rtti;
+  }
+#endif
+
   if (!IsBadReadPtr(cppobj, sizeof(void *)) &&
       !IsBadReadPtr(cppobj->vtable - 1,sizeof(void *)) &&
       !IsBadReadPtr((void*)cppobj->vtable[-1], sizeof(rtti_object_locator)))
   {
     obj_locator = (rtti_object_locator *)cppobj->vtable[-1];
+    TRACE("returning type_info from vtable (%p)\n", obj_locator);
   }
-
-#ifdef __i386__
-  if (!obj_locator)
-  {
-    const exception_vtable* vtable = (const exception_vtable*)cppobj->vtable;
-
-    /* Perhaps this is one of classes we export? */
-    if (vtable == &MSVCRT_exception_vtable)
-      obj_locator = &exception_rtti;
-    else if (vtable == &MSVCRT_bad_typeid_vtable)
-      obj_locator = &bad_cast_rtti;
-    else if (vtable == &MSVCRT_bad_cast_vtable)
-      obj_locator = &bad_typeid_rtti;
-    else if (vtable == &MSVCRT___non_rtti_object_vtable)
-      obj_locator = &__non_rtti_object_rtti;
-    else if (vtable == &MSVCRT_type_info_vtable)
-      obj_locator = &type_info_rtti;
-  }
-#endif
 
   return obj_locator;
 }

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux