Skip to content

Commit 37168ce

Browse files
committed
Fix issue finding GetFieldDefaultValue on 2021.3.23
1 parent a096080 commit 37168ce

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Il2CppInterop.Runtime/Injection/Hooks/Class_GetFieldDefaultValue_Hook.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ internal unsafe class Class_GetFieldDefaultValue_Hook : Hook<Class_GetFieldDefau
7171
mask = "xxxxxxxx????xxxxxxx",
7272
xref = false
7373
},
74+
// Idle Slayer - Unity 2021.3.23 (x64)
75+
new MemoryUtils.SignatureDefinition
76+
{
77+
pattern = "\x40\x53\x48\x83\xEC\x20\x48\x8B\xDA\xE8\xCC\xCC\xCC\xCC\x4C",
78+
mask = "xxxxxxxxxx????x",
79+
xref = false
80+
}
7481
};
7582

7683
private static nint FindClassGetFieldDefaultValueXref(bool forceICallMethod = false)
@@ -106,7 +113,11 @@ private static nint FindClassGetFieldDefaultValueXref(bool forceICallMethod = fa
106113
var getStaticFieldValue = XrefScannerLowLevel.JumpTargets(getStaticFieldValueAPI).Single();
107114
Logger.Instance.LogTrace("Field::StaticGetValue: 0x{GetStaticFieldValueAddress}", getStaticFieldValue.ToInt64().ToString("X2"));
108115

109-
var getStaticFieldValueInternal = XrefScannerLowLevel.JumpTargets(getStaticFieldValue).Last();
116+
var getStaticFieldValueTargets = XrefScannerLowLevel.JumpTargets(getStaticFieldValue).ToArray();
117+
if (getStaticFieldValueTargets.Length > 4)
118+
return getStaticFieldValueTargets[^2];
119+
120+
var getStaticFieldValueInternal = getStaticFieldValueTargets.Last();
110121
Logger.Instance.LogTrace("Field::StaticGetValueInternal: 0x{GetStaticFieldValueInternalAddress}", getStaticFieldValueInternal.ToInt64().ToString("X2"));
111122

112123
var getStaticFieldValueInternalTargets = XrefScannerLowLevel.JumpTargets(getStaticFieldValueInternal).ToArray();

0 commit comments

Comments
 (0)