LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

Support Mac for Unity / Mono #53

Closed AlexKnauth closed 9 months ago

AlexKnauth commented 1 year ago

This adds Mac support to asr::game_engine::unity::SceneManager and asr::game_engine::unity::mono.

The SceneManager support does not rely on std, but the mono support does need std, which can be activated with the std feature.

During development at Image classes table detect cycles, I got cycles in the classes iterator, which I had to detect and break. But at Offsets for 64-bit MachO V2, I found the cause of those cycles was the wrong offset for monoclassdef_next_class_cache. It should have been using 0x100 as the offset to that, but had been incorrectly using 0x108 as the offset.

AlexKnauth commented 1 year ago

If I can reduce the size and complexity of asr/src/game_engine/unity/mono.rs by moving some of the PE-specific code there into asr/src/file_format/pe.rs, should I include that in this PR to add Mac support?

In this PR, I'm already trying to put the MachO-specific code that mono.rs needs into a macho.rs file next to pe.rs, so it seems related. Or should I submit a separate PR now, submit a separate PR later to avoid potential merge conflicts, or just leave it as-is, not broken don't fix?

Edit: After #67, the pe::symbols iterator greatly reduces the amount of PE-specific code there.

AlexKnauth commented 1 year ago

I have a version of this ready to rebase on top of https://github.com/LiveSplit/asr/pull/63 if/when that gets merged. It just requires another commit analogous to Fix assemblies_pointer vs assemblies, but to fix SceneManager base_address vs address instead, here: https://github.com/AlexKnauth/asr/commit/ff298b7fca046cb4da2b34fb02226a07a4c502f5

AlexKnauth commented 9 months ago

I have a version of this ready to rebase on top of #71 if/when that gets merged.

AlexKnauth commented 9 months ago

Marking as a draft for now until the cattrs stuff is figured out.

My hope is that some of the differences in offsets I found might turn out to turn out to melt away into differences between cattrs and no-cattrs. If that's the case then it could simplify what's needed for Mac support by a lot.

(Edit: it didn't melt it away, or at least didn't melt most of it)

AlexKnauth commented 9 months ago

Closing in favor of https://github.com/LiveSplit/asr/pull/93