infinite-mac
infinite-mac copied to clipboard
machfs subtly corrupts system images when modifying them
Spun off from audio not working (#67), now that I understand a bit better what is going on. Starting with 5be16f62c095759e1907d9a68301e6bf095bcf6b we would run all system images through a read-modify-write machfs
operation (to insert the dynamically-generated Stickies file). This had the side effect of introducing some (as yet undetermined) corruption the main manifestation being that sound did not work.
Sound is handled by batching a driver loaded by the OS, and thus we need to hook resource loading (see https://github.com/mihaip/macemu/blob/infinite-mac-kanjitalk755/BasiliskII/src/rsrc_patches.cpp#L282-L305). When running as expected, we end up seeing a bunch of resource loads and hooking some:
DRVR -20066 found
patch 1 applied
vCheckLoad DLOG (444c4f47) ID -20065, data 0x639728, size 48
vCheckLoad DITL (4449544c) ID -20065, data 0x639758, size 208
vCheckLoad thng (74686e67) ID -16738, data 0x634e18, size 80
69 32 63 20 6d 33 74 76 61 70 70 6c 80 00 00 00 00 00 00 00 69 32 63 20 be 9e 53 54 52 20 be ad 53 54 52 20 be ac 00 00 00 00 00 00 00 02 00 02 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00
vCheckLoad thng (74686e67) ID -16738, data 0x6391e8, size 80
69 32 63 20 6d 33 74 76 61 70 70 6c 80 00 00 00 00 00 00 00 69 32 63 20 be 9e 53 54 52 20 be ad 53 54 52 20 be ac 00 00 00 00 00 00 00 02 00 02 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 c0 00 00 00 00
vCheckLoad i2c (69326320) ID -16738, data 0x689278, size 2160
vCheckLoad thng (74686e67) ID -16729, data 0x6391e8, size 64
vCheckLoad thng (74686e67) ID -16729, data 0x639338, size 64
vCheckLoad vdig (76646967) ID -16728, data 0x7a8178, size 28848
vCheckLoad thng (74686e67) ID -20225, data 0x639338, size 64
vCheckLoad tdig (74646967) ID -20225, data 0x689278, size 7872
vCheckLoad thng (74686e67) ID -20035, data 0x639338, size 64
vCheckLoad vdig (76646967) ID -20035, data 0x7b3028, size 23632
vCheckLoad thng (74686e67) ID -16731, data 0x639338, size 96
vCheckLoad vdig (76646967) ID -16731, data 0x7a8178, size 29152
vCheckLoad thng (74686e67) ID -20272, data 0x639338, size 96
vCheckLoad thng (74686e67) ID -16572, data 0x639338, size 96
vCheckLoad thng (74686e67) ID -20030, data 0x639338, size 80
vCheckLoad sift (73696674) ID -20030, data 0x79efb8, size 5136
vCheckLoad thng (74686e67) ID -16570, data 0x639338, size 80
vCheckLoad adio (6164696f) ID -16570, data 0x689278, size 1168
vCheckLoad thng (74686e67) ID -16569, data 0x639338, size 80
vCheckLoad sift (73696674) ID -16569, data 0x79eff8, size 6416
vCheckLoad thng (74686e67) ID -20025, data 0x639338, size 80
vCheckLoad sift (73696674) ID -20025, data 0x689278, size 5136
vCheckLoad thng (74686e67) ID -16573, data 0x639338, size 80
vCheckLoad adio (6164696f) ID -16573, data 0x689278, size 3312
vCheckLoad thng (74686e67) ID -16563, data 0x639338, size 80
thng -16563 found
patch 1 applied
vCheckLoad sift (73696674) ID -16563, data 0x689278, size 5648
sift -16563 found
patch 1 applied
vCheckLoad thng (74686e67) ID -16730, data 0x6392f8, size 64
vCheckLoad vdig (76646967) ID -16730, data 0x7a8178, size 27024
vCheckLoad thng (74686e67) ID -16497, data 0x6392f8, size 80
vCheckLoad sift (73696674) ID -16497, data 0x689278, size 3856
vCheckLoad thng (74686e67) ID -20555, data 0x6393f8, size 64
vCheckLoad tdig (74646967) ID -20555, data 0x7a1f88, size 6992
vCheckLoad thng (74686e67) ID -20491, data 0x6393f8, size 96
vCheckLoad thng (74686e67) ID -20493, data 0x6393f8, size 96
vCheckLoad thng (74686e67) ID -20490, data 0x6393f8, size 96
vCheckLoad thng (74686e67) ID -20489, data 0x6393f8, size 96
However, once run through machfs we see a lot fewer:
DRVR -20066 found
patch 1 applied
vCheckLoad DLOG (444c4f47) ID -20065, data 0x639728, size 48
vCheckLoad DITL (4449544c) ID -20065, data 0x639758, size 208
vCheckLoad thng (74686e67) ID -16738, data 0x634e18, size 80
459 69 32 63 20 6d 33 74 76 61 70 70 6c 80 00 00 00 00 00 00 00 69 32 63 20 be 9e 53 54 52 20 be ad 53 54 52 20 be ac 00 00 00 00 00 00 00 02 00 02 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00
vCheckLoad thng (74686e67) ID -16729, data 0x639388, size 64
It is interesting that in the working case we end up loading thng
ID -16738 twice (with slightly different contents), unclear where the second instance (that differs by one byte is coming from).