From a8781bc5b83a47f4b08b83fd22e19d986d2199ec Mon Sep 17 00:00:00 2001 From: Perfare Date: Wed, 12 Feb 2020 01:53:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84DummyDLL=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Il2CppDumper/Utils/DummyAssemblyGenerator.cs | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Il2CppDumper/Utils/DummyAssemblyGenerator.cs b/Il2CppDumper/Utils/DummyAssemblyGenerator.cs index 8307c1f..a00f6ff 100644 --- a/Il2CppDumper/Utils/DummyAssemblyGenerator.cs +++ b/Il2CppDumper/Utils/DummyAssemblyGenerator.cs @@ -155,11 +155,29 @@ namespace Il2CppDumper methodDefinition.ImplAttributes = (MethodImplAttributes)methodDef.iflags; typeDefinition.Methods.Add(methodDefinition); var methodReturnType = il2Cpp.types[methodDef.returnType]; - methodDefinition.ReturnType = GetTypeReferenceWithByRef(methodDefinition, methodReturnType); + var returnType = GetTypeReferenceWithByRef(methodDefinition, methodReturnType); + methodDefinition.ReturnType = returnType; if (methodDefinition.HasBody && typeDefinition.BaseType?.FullName != "System.MulticastDelegate") { var ilprocessor = methodDefinition.Body.GetILProcessor(); - ilprocessor.Append(ilprocessor.Create(OpCodes.Nop)); + if (returnType.FullName == "System.Void") + { + ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); + } + else if (returnType.IsValueType) + { + var variable = new VariableDefinition(returnType); + methodDefinition.Body.Variables.Add(variable); + ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloca_S, variable)); + ilprocessor.Append(ilprocessor.Create(OpCodes.Initobj, returnType)); + ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0)); + ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); + } + else + { + ilprocessor.Append(ilprocessor.Create(OpCodes.Ldnull)); + ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); + } } methodDefinitionDic.Add(i, methodDefinition); //method parameter