@@ -617,11 +617,21 @@ uint32_t RETypeDefinition::get_index() const {
617617
618618int32_t RETypeDefinition::get_fieldptr_offset () const {
619619#if TDB_VER > 49
620- if (this ->managed_vt == nullptr ) {
621- return 0 ;
622- }
620+ #ifdef MHWILDS
621+ REObjectInfo *target_managed_vt = get_managed_vt ();
622+
623+ if (target_managed_vt == nullptr ) {
624+ return 0 ;
625+ }
626+
627+ return *(int32_t *)((uintptr_t )target_managed_vt - sizeof (void *));
628+ #else
629+ if (this ->managed_vt == nullptr ) {
630+ return 0 ;
631+ }
623632
624- return *(int32_t *)((uintptr_t )this ->managed_vt - sizeof (void *));
633+ return *(int32_t *)((uintptr_t )this ->managed_vt - sizeof (void *));
634+ #endif
625635#else
626636 auto vm = sdk::VM::get ();
627637 const auto & vm_type = vm->types [this ->get_index ()];
@@ -632,7 +642,11 @@ int32_t RETypeDefinition::get_fieldptr_offset() const {
632642
633643bool RETypeDefinition::has_fieldptr_offset () const {
634644#if TDB_VER > 49
635- return this ->managed_vt != nullptr ;
645+ #ifdef MHWILDS
646+ return get_managed_vt () != nullptr ;
647+ #else
648+ return this ->managed_vt != nullptr ;
649+ #endif
636650#else
637651 return true ;
638652#endif
@@ -1119,7 +1133,30 @@ ::REManagedObject* RETypeDefinition::create_instance_full(bool simplify) {
11191133
11201134::REObjectInfo* RETypeDefinition::get_managed_vt () const {
11211135#if TDB_VER > 49
1122- return (::REObjectInfo*)this ->managed_vt ;
1136+ #if MHWILDS
1137+ REObjectInfo *target_managed_vt = this ->managed_vt ;
1138+
1139+ if (this ->managed_vt == nullptr ) {
1140+ // Abstract
1141+ if (this ->type_flags & 128 ) {
1142+ // Keep getting parent type until getting a hit
1143+ auto parent_type_def = this ->get_parent_type ();
1144+ while (parent_type_def != nullptr ) {
1145+ target_managed_vt = parent_type_def->managed_vt ;
1146+
1147+ if (target_managed_vt != nullptr ) {
1148+ break ;
1149+ }
1150+
1151+ parent_type_def = parent_type_def->get_parent_type ();
1152+ }
1153+ }
1154+ }
1155+
1156+ return target_managed_vt;
1157+ #else
1158+ return (::REObjectInfo*)this ->managed_vt ;
1159+ #endif
11231160#else
11241161 return (::REObjectInfo*)&sdk::VM::get ()->types [this ->get_index ()];
11251162#endif
0 commit comments