From 551ff84706df76e94155777ced523255f1139d51 Mon Sep 17 00:00:00 2001 From: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> Date: Sat, 14 Sep 2024 10:58:10 -0700 Subject: [PATCH] Expand Macros Before Unstripping (#168) --- Il2CppInterop.Generator/Utils/UnstripTranslator.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Il2CppInterop.Generator/Utils/UnstripTranslator.cs b/Il2CppInterop.Generator/Utils/UnstripTranslator.cs index 6c20ced1..52bbfcae 100644 --- a/Il2CppInterop.Generator/Utils/UnstripTranslator.cs +++ b/Il2CppInterop.Generator/Utils/UnstripTranslator.cs @@ -34,6 +34,11 @@ public static bool TranslateMethod(MethodDefinition original, MethodDefinition t localVariableMap.Add(variableDefinition, newVariableDefinition); } + // We expand macros because our instructions are not mapped one-to-one, + // so specialized instructions like Br_S need to be expanded to Br for safety. + // In pass 90, we optimize all macros, so we won't need to worry about that here. + original.CilMethodBody.Instructions.ExpandMacros(); + List> labelMap = new(); Dictionary instructionMap = new();