Commit a306f8c
committed
v2: Fix GenericListData bitfield + reflection null guards + TDEF_FIELD consistency
GenericListData bitfield layout differs between TDB versions:
tdb67 (DMC5): definition_typeid:17, num:14
tdb69+: definition_typeid:19, num:13
Universal build compiled the tdb84 layout, so on DMC5 every direct
->num and ->definition_typeid read got the bits offset by 2 \u2014
typically producing num==0 for non-generic types. This silently
routed many TDB67 types into generate_full_name_via_reflection(),
which then risked an access violation if the reflection pipeline
wasn't ready (System.RuntimeType not found).
Added sdk::generic_list_accessor::{get_num, get_definition_typeid,
get_type_at} that dispatch on tdb_ver() < 69. Wired into 8 call
sites in RETypeDefinition.cpp covering get_full_name(), is_generic_
type_definition(), get_generic_type_definition(), get_generic_
argument_types().
Also fixed:
1. get_crc_hash() fallback used this->type_crc reading the tdb84
offset (0x1C). For DMC5, type_crc is at 0x0C. Changed to
TDEF_FIELD(this, type_crc) for proper dispatch when get_type()
returns null.
2. get_managed_vt() abstract-type-flag check used this->type_flags.
Currently safe because the surrounding tdb_ver() >= 81 guard means
the layout always matches tdb84, but bypassed TDEF_FIELD discipline.
Changed to TDEF_FIELD(this, type_flags) for consistency.
3. generate_full_name_via_reflection() lambda dereferenced
system_runtime_type and get_full_name_method without null checks,
despite either potentially being null on TDB67 where System.
RuntimeType doesn't hash to 0x99ff88e6. Added explicit null guards
that fall through silently \u2014 the string-built full_name from
the surrounding code already populated full_name.
4. get_underlying_type() called get_name_method->call(...) without
first verifying get_name_method != nullptr. Added the guard with
the same g_underlying_types[this] = nullptr cache write that the
sibling guard at line 432 uses.
Audit also confirmed (no fixes needed):
- All REMethodDefinition / REField / REProperty / REParameterDef
bare this->field accesses live inside TDB 71+ paths where the
layout matches the compiled tdb84.
- All needs_18bit() checks are now guarded by needs_pre_impl() first.
- REClassInfo / REObjectInfo access sites are either dispatched via
classinfo_accessor or are compile-time dead code in universal
builds.
Verified: DMC5 ObjectExplorer \u2014 singletons visible, fields and
methods expandable without crash, AutoGenerated Types discovers
inner managed objects.1 parent f171d00 commit a306f8c
2 files changed
Lines changed: 65 additions & 12 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
1846 | 1850 | | |
1847 | 1851 | | |
1848 | 1852 | | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1849 | 1882 | | |
1850 | 1883 | | |
1851 | 1884 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
261 | 269 | | |
262 | 270 | | |
263 | 271 | | |
| |||
268 | 276 | | |
269 | 277 | | |
270 | 278 | | |
271 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
272 | 282 | | |
| 283 | + | |
273 | 284 | | |
274 | 285 | | |
275 | 286 | | |
| |||
281 | 292 | | |
282 | 293 | | |
283 | 294 | | |
284 | | - | |
| 295 | + | |
285 | 296 | | |
286 | 297 | | |
287 | 298 | | |
288 | 299 | | |
289 | 300 | | |
290 | 301 | | |
291 | 302 | | |
292 | | - | |
293 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
294 | 306 | | |
295 | 307 | | |
296 | 308 | | |
| |||
299 | 311 | | |
300 | 312 | | |
301 | 313 | | |
302 | | - | |
| 314 | + | |
303 | 315 | | |
304 | 316 | | |
305 | 317 | | |
| |||
429 | 441 | | |
430 | 442 | | |
431 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
432 | 451 | | |
433 | 452 | | |
434 | 453 | | |
| |||
468 | 487 | | |
469 | 488 | | |
470 | 489 | | |
471 | | - | |
| 490 | + | |
472 | 491 | | |
473 | 492 | | |
474 | 493 | | |
| |||
625 | 644 | | |
626 | 645 | | |
627 | 646 | | |
628 | | - | |
| 647 | + | |
629 | 648 | | |
630 | 649 | | |
631 | | - | |
632 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
633 | 653 | | |
634 | 654 | | |
635 | 655 | | |
| |||
917 | 937 | | |
918 | 938 | | |
919 | 939 | | |
920 | | - | |
| 940 | + | |
921 | 941 | | |
922 | 942 | | |
923 | 943 | | |
| |||
965 | 985 | | |
966 | 986 | | |
967 | 987 | | |
968 | | - | |
| 988 | + | |
969 | 989 | | |
970 | 990 | | |
971 | 991 | | |
| |||
1220 | 1240 | | |
1221 | 1241 | | |
1222 | 1242 | | |
1223 | | - | |
| 1243 | + | |
1224 | 1244 | | |
1225 | 1245 | | |
1226 | 1246 | | |
| |||
0 commit comments