Open hp-psi opened 2 years ago
After some debuging and research, noticed the exception came right after doing assembly resolve.
Confuser.Protections.MildMode
public override void ProcessCall(RPContext ctx, int instrIndex)
if (!target.ResolveThrow().IsPublic && !target.ResolveThrow().IsAssembly)
Confuser.Core.DnlibUtils
public static MethodDef ResolveThrow(this IMethod method)
return ((MemberRef)method).ResolveMethodThrow();
Confuser.Core.ConfuserAssemblyResolver
public AssemblyDef Resolve(IAssembly assembly, ModuleDef sourceModule)
return resolvedAssemblyDef ?? InternalFuzzyResolver.Resolve(assembly, sourceModule);
Throws exception after return, the assembly is {mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089} and the sourceModule is {ExcelDataReader.DataSet.dll}.
ExcelDataReader target framework is .NET Framework 4.5. ExcelDataReader.DataSet target framework is .NET Framework 3.5.
I don't know exactly why it fails, is mscorlib missing? I reinstalled .NET Framework 3.5 and the GAC folder contains mscorlib 2.0.0.0: C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089 C:\Windows\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089
Ran ConfuserEx again and still failed, decided to build ExcelDataReader and ExcelDataReader.DataSet targeting .NET Framework 4.7.2 and ConfuserEx successfully obfuscated the main binary using reference proxy in mild mode.
While this fixes the issue it is a contour of the problem. I still have no clue exactly on why it happens.
Created a new more simplified test project, this includes only a console application (4.7.2) with a Program.cs and a class library (3.5) with Class1.cs.
This always triggers an exception in ConfuserEx when using reference proxy mild.
Your exception looks like it's just missing a reference to the ExcelDataReader.DataSet
assembly. Does it work if you just add that example as external reference to your Confuser project or if you add the location of this assembly to the probe paths?
This should sort the issue out.
Hi, I created a new test sample (link above) that does not use nuggets and uses instead an external referenced dll.
From what I tested I noticed that this only happens when the referenced dll is in .NET Framework 3.5 (atleast in 4.7.2 the issue does not exist) .
.NET Framework 4.7.2 Console Application (will be obfuscated): Contais only one class called Program.cs, has an external reference to a Class Library targeted for .NET Framework 3.5.
using ConfuserEx2IssueTest.Lib;
using System;
namespace ConfuserEx2IssueTest
{
internal class Program
{
static void Main(string[] args)
{
Class1 c = new Class1();
c.FuncTest = () => "";
Console.WriteLine();
Console.ReadKey();
}
}
}
.NET Framework 3.5 Class Library (will NOT be obfuscated) Contais only one class called Class1.cs, will be referenced by the Console Application.
using System;
namespace ConfuserEx2IssueTest.Lib
{
public class Class1
{
public Func<string> FuncTest { get; set; }
}
}
Now one just has to compile and obfuscate the Console Application using reference proxy in mild mode (strong mode works and does not have any issues).
What makes the process fail is the use of Func<> object, if it was any other object like string, int, etc... or the use of an actual function there would be no problem.
I do not really know what makes it fail, my best guess from the debugging I did was that it was interpreting the set Func<> object as an actual function.
This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!
Software version
Problem
ConfuserEx throws an exception when attempting to obfuscate code that sets a Func<> object located in an external library with reference proxy in mild mode.
Exception: Failed to resolve a member, check if all dependencies are present in the correct version. dnlib.DotNet.MemberRefResolveException: Could not resolve method.
Steps to reproduce (with the attached example project)
The attached zip also includes a .log with the CMD output and the .crproj used.
Details
The reference proxy protection causes the issue, if it is set to strong it works, if it is set to mild it throws an exception. In the project Im obfuscating I can't use the strong mode due to incompatibility and other issues. The ExcelDataReader nuggets are in .NET Framework 4.5.
Files
Code (throws exception when obfuscating, requires ExcelDataReader nuggets):
CRPROJ:
LOG: