jbevain / mono.reflection

Some useful reflection helpers, including an IL disassembler.
151 stars 51 forks source link

Can we use DelegateDecomiler when we obfuscate the code? #17

Open jojose opened 7 years ago

jojose commented 7 years ago

We are using 'Dotfuscator' to obfuscate the dlls. We started using DelegateDecompiler for supporting some functionality when using entity framework. The issue is that after obfuscation, the EF method call fails. We tried to Exclude the classes used in the EF calls from obfuscation but still the issue is there.

The following is the error we are getting

System.AggregateException: One or more errors occurred. ---> System.ArgumentException: metadataToken Parameter name: Token 0x5d07727e is not a valid MemberInfo token in the scope of module RBS.Advisor.BusinessEntities.dll. at System.Reflection.RuntimeModule.ResolveMember(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at Mono.Reflection.MethodBodyReader.ReadOperand(Instruction instruction) at Mono.Reflection.MethodBodyReader.ReadInstructions() at Mono.Reflection.MethodBodyReader.GetInstructions(MethodBase method) at Mono.Reflection.Disassembler.GetInstructions(MethodBase self) at DelegateDecompiler.MethodBodyDecompiler.Decompile() at DelegateDecompiler.DecompileExtensions.<>cDisplayClass2_0.b0(MethodInfo m) at DelegateDecompiler.Cache2.GetOrAdd(TKey key, Func2 func) at DelegateDecompiler.DecompileExtensions.Decompile(MethodInfo method) at DelegateDecompiler.DecompileExpressionVisitor.Decompile(MethodInfo method, Expression instance, IList1 arguments) at DelegateDecompiler.DecompileExpressionVisitor.VisitMember(MemberExpression node) at System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitMemberAssignment(MemberAssignment node) at System.Linq.Expressions.ExpressionVisitor.VisitMemberBinding(MemberBinding node) at System.Linq.Expressions.ExpressionVisitor.Visit[T](ReadOnlyCollection1 nodes, Func2 elementVisitor) at System.Linq.Expressions.ExpressionVisitor.VisitMemberInit(MemberInitExpression node) at System.Linq.Expressions.MemberInitExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node) at System.Linq.Expressions.Expression1.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node) at System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes) at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node) at DelegateDecompiler.DecompileExpressionVisitor.VisitMethodCall(MethodCallExpression node) at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at DelegateDecompiler.DecompiledQueryProvider.CreateQuery[TElement](Expression expression) at System.Linq.Queryable.Select[TSource,TResult](IQueryable1 source, Expression`1 selector) at RBS.Advisor.AppServices.Households.HouseholdAppService.GetAuditEntries(Int32 householdId) at RBS.Advisor.Presentation.Modules.HouseholdModule.HouseholdView.AuditEntryController.<>cDisplayClass8_0.b0() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of inner exception stack trace --- ---> (Inner Exception #0) System.ArgumentException: metadataToken Parameter name: Token 0x5d07727e is not a valid MemberInfo token in the scope of module RBS.Advisor.BusinessEntities.dll. at System.Reflection.RuntimeModule.ResolveMember(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at Mono.Reflection.MethodBodyReader.ReadOperand(Instruction instruction) at Mono.Reflection.MethodBodyReader.ReadInstructions() at Mono.Reflection.MethodBodyReader.GetInstructions(MethodBase method) at Mono.Reflection.Disassembler.GetInstructions(MethodBase self) at DelegateDecompiler.MethodBodyDecompiler.Decompile() at DelegateDecompiler.DecompileExtensions.<>cDisplayClass2_0.b0(MethodInfo m) at DelegateDecompiler.Cache2.GetOrAdd(TKey key, Func2 func) at DelegateDecompiler.DecompileExtensions.Decompile(MethodInfo method) at DelegateDecompiler.DecompileExpressionVisitor.Decompile(MethodInfo method, Expression instance, IList1 arguments) at DelegateDecompiler.DecompileExpressionVisitor.VisitMember(MemberExpression node) at System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitMemberAssignment(MemberAssignment node) at System.Linq.Expressions.ExpressionVisitor.VisitMemberBinding(MemberBinding node) at System.Linq.Expressions.ExpressionVisitor.Visit[T](ReadOnlyCollection1 nodes, Func2 elementVisitor) at System.Linq.Expressions.ExpressionVisitor.VisitMemberInit(MemberInitExpression node) at System.Linq.Expressions.MemberInitExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node) at System.Linq.Expressions.Expression1.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node) at System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes) at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node) at DelegateDecompiler.DecompileExpressionVisitor.VisitMethodCall(MethodCallExpression node) at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at DelegateDecompiler.DecompiledQueryProvider.CreateQuery[TElement](Expression expression) at System.Linq.Queryable.Select[TSource,TResult](IQueryable1 source, Expression`1 selector) at RBS.Advisor.AppServices.Households.HouseholdAppService.GetAuditEntries(Int32 householdId) at RBS.Advisor.Presentation.Modules.HouseholdModule.HouseholdView.AuditEntryController.<>cDisplayClass8_0.b0() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute()<--- One or more errors occurred. Source:

When I posted this at https://github.com/hazzik/DelegateDecompiler/issues/103

I have been adviced to post it here.

Thanks