Skip to content

Commit

Permalink
Don't unstrip methods that use array opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed May 13, 2024
1 parent 18ba55c commit d145384
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Il2CppInterop.Generator/Utils/UnstripTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,49 @@ public static bool TranslateMethod(MethodDefinition original, MethodDefinition t
{
if (bodyInstruction.Operand is null)
{
switch (bodyInstruction.OpCode.Code)
{
case CilCode.Ldlen:
//This is Il2CppArrayBase.Length
return false;

case CilCode.Ldelema:
//This is Il2CppArrayBase<T>.Pointer + index * sizeof(T) but the T is not known because the operand is null.
return false;

case CilCode.Ldelem:
//This is Il2CppArrayBase<T>.set_Item but the T is not known because the operand is null.
return false;

case CilCode.Stelem:
//This is Il2CppArrayBase<T>.set_Item but the T is not known because the operand is null.
return false;

case CilCode.Ldelem_Ref:
//This is Il2CppReferenceArray<T>.get_Item but the T is not known because the operand is null.
return false;

case CilCode.Stelem_Ref:
//This is Il2CppReferenceArray<T>.set_Item but the T is not known because the operand is null.
return false;

case >= CilCode.Ldelem_I1 and <= CilCode.Ldelem_R8:
//This is Il2CppStructArray<T>.get_Item
return false;

case >= CilCode.Stelem_I and <= CilCode.Stelem_R8:
//This is Il2CppStructArray<T>.set_Item
return false;

case >= CilCode.Ldind_I1 and <= CilCode.Ldind_Ref:
//This is for by ref parameters
break;

case >= CilCode.Stind_Ref and <= CilCode.Stind_R8:
//This is for by ref parameters
break;
}

var newInstruction = targetBuilder.Add(bodyInstruction.OpCode);
instructionMap.Add(bodyInstruction, newInstruction);
}
Expand Down Expand Up @@ -81,6 +124,7 @@ public static bool TranslateMethod(MethodDefinition original, MethodDefinition t
}
else
{
//Ldflda, Ldsflda
return false;
}
}
Expand Down

0 comments on commit d145384

Please sign in to comment.