Repository navigation
Conversation
On clang builds Field::StaticGetValueInternal calls Class::GetDefaultFieldValue(field, &type) followed by BlobReader::GetConstantValueFromBlob, so the 'last of three targets' heuristic hooks the blob reader. Find the direct call whose second argument is the address of a stack slot instead, and keep the old heuristic as the fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the signatures don't match,
Class_GetFieldDefaultValue_HookfindsClass::GetDefaultFieldValueby walking xrefs intoField::StaticGetValueInternal, then picks the last of three jump targets or the first one otherwise. That order comes from MSVC builds. In the clang-built macOSGameAssembly.dylibof Dofus 3 (Unity 6000.3.16f1, x86-64 slice), the targets are:+0x4a0c80+0x4a4610Class::GetDefaultFieldValue(field, &type)+0x464fa0BlobReader::GetConstantValueFromBlob(...)So the hook is installed on
BlobReader::GetConstantValueFromBlob. Its arguments don't match the detour's signature, so reading any constant through reflection (FieldInfo.GetValueon a literal field) gets a garbage result. In the game this shows up as randomSIGSEGVs insideClass::IsAssignableFrom(fault address0x8bc) once the options manager serializes its settings through reflection.The fix applies on non-Windows only. Before the position-based choice, it decodes
Field::StaticGetValueInternalup to its firstretand looks for the single directcallwhose second System V argument (rsi) was just set withlea rsi, [rsp/rbp+x], which is the&typeout parameter. If there is exactly one such call, its target is used. Otherwise the existing heuristic runs unchanged, and Windows behaviour is untouched because I can't verify the MSVC layout.Related: #284 (a false signature match for the same hook on Windows).
Validation
CachedDataService.SaveAllOptionsManager()every frame andIl2CppSystem.GC.Collect()every 30 frames.SIGSEGVon the first save, every run.+0x4a4610, and 3,000 saves ran with no crash. The game was then played normally for 10+ minutes (moving around, fights) without the crashes it had before.Il2CppInterop.Runtimebuilds with no new warnings.Limits: Only tested on macOS x86-64 (Rosetta). Linux clang builds probably have the same layout, but I didn't check one.