mkaring / ConfuserEx

An open-source, free protector for .NET applications
https://mkaring.github.io/ConfuserEx/
MIT License
2.31k stars 350 forks source link

Error in confuse an app embedded com dll like ‘Microsoft.Office.Core.dll’ #478

Closed 0x7d9 closed 2 years ago

0x7d9 commented 2 years ago

Error message:

  [INFO] Confuser.Core 1.6.0+447341964f Copyright © 2014 Ki, 2018 - 2022 Martin Karing
 [INFO] Running on Microsoft Windows NT 6.2.9200.0, .NET Framework v4.0.30319.42000, 64 bits
[DEBUG] Discovering plugins...
 [INFO] Discovered 13 protections, 1 packers.
[DEBUG] Resolving component dependency...
 [INFO] Loading input modules...
 [INFO] Loading 'D:\ClassLibrary1.dll'...
 [INFO] Initializing...
[DEBUG] Building pipeline...
[DEBUG] Executing 'Type scanner' phase...
 [INFO] Resolving dependencies...
[DEBUG] Checking Strong Name...
[DEBUG] Creating global .cctors...
[DEBUG] Executing 'Name analysis' phase...
[DEBUG] Building VTables & identifier list...
[DEBUG] Analyzing...
[ERROR] Failed to resolve a type, check if all dependencies are present in the correct version.
Exception: dnlib.DotNet.TypeResolveException: Could not resolve type: Microsoft.Office.Interop.Excel.Microsoft.Office.Interop.Excel1429666.RefreshEvents (ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
   在 dnlib.DotNet.TypeRef.ResolveThrow(ModuleDef sourceModule)
   在 dnlib.DotNet.Extensions.ResolveTypeDefThrow(ITypeDefOrRef tdr)
   在 Confuser.Renamer.Analyzers.TypeBlobAnalyzer.AnalyzeCAArgument(ICollection`1 modules, INameService service, CAArgument arg)
   在 Confuser.Renamer.Analyzers.TypeBlobAnalyzer.Analyze(INameService service, ICollection`1 modules, ILogger logger, ModuleDefMD module)
   在 Confuser.Renamer.AnalyzePhase.Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer)
   在 Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters)
   在 Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action`1 func, Func`1 targets, ConfuserContext context)
   在 Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context)
   在 Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token)
[ERROR] ---BEGIN DEBUG INFO---
[ERROR] Installed Framework Versions:
[ERROR]     v2.0.50727  2.0.50727.4927
[ERROR]     v3.0  3.0.30729.4926
[ERROR]     v3.5  3.5.30729.4926
[ERROR]     v4
[ERROR]     Client  4.8.03752
[ERROR]     Full  4.8.03752
[ERROR]     v4.0
[ERROR]     Client  4.0.0.0
[ERROR]     v4.5 528040
[ERROR] 
[ERROR] Cached assemblies:
[ERROR]     ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (D:\ClassLibrary1.dll)
[ERROR]         mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
[ERROR]         stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR]         office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
[ERROR]         Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
[ERROR]     mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 (C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll)
[ERROR]     stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (C:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll)
[ERROR]         mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
[ERROR]     office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c (D:\office.dll)
[ERROR]         mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
[ERROR]         stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR]     Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c (D:\Microsoft.Vbe.Interop.dll)
[ERROR]         mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
[ERROR]         office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
[ERROR]     ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (D:\ClassLibrary1.dll)
[ERROR]         mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
[ERROR]         stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
[ERROR]         office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
[ERROR]         Microsoft.Vbe.Interop, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
[ERROR] ---END DEBUG INFO---
Failed at 20:17, 0:03 elapsed.

There was this problem in version 1.6, but no problem in version 1.5.

And use the ILMerge.exe /allowDup command to merge dlls before obfuscation.

mkaring commented 2 years ago

Are you absolutely positive that the assembly is still in working order after the execution of ILMerge? According to the log there is no reference to Microsoft.Office.Core.dll anymore and the ClassLibrary1 should contain the type Microsoft.Office.Interop.Excel.Microsoft.Office.Interop.Excel1429666.RefreshEvents, but does not. Are the embedded interop types handled correctly?

0x7d9 commented 2 years ago

I created a sample project to show where the exception occurs, see: https://github.com/0x7d9/ConfuserExTest/tree/main/ConfuserEx-sequential-rename-bug

github-actions[bot] commented 2 years ago

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!

github-actions[bot] commented 2 years ago

Closing this issue because it needs more information and has not had recent activity. Please re-open this issue if more details can be provided. Thanks!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.