Skip to content

feat(core): tolerate missing dependencies — warn instead of crash#58

Merged
mcpolo99 merged 1 commit into
pre-releasefrom
fix/tolerate-missing-dependencies
Jun 8, 2026
Merged

feat(core): tolerate missing dependencies — warn instead of crash#58
mcpolo99 merged 1 commit into
pre-releasefrom
fix/tolerate-missing-dependencies

Conversation

@mcpolo99

@mcpolo99 mcpolo99 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Fixes #4
Upstream: mkaring#155

Problem

ConfuserEx crashes during the Inspection phase if ANY assembly dependency cannot be resolved, even if that dependency isn't needed for the protections being applied.

Fix

Inspection phase (ConfuserEngine.cs)

  • Replace ResolveThrow with Resolve (non-throwing)
  • Log a warning for unresolved dependencies instead of crashing
  • Obfuscation continues with best-effort results

DnlibUtils.cs — null-safe type resolution

  • InheritsFromCorlib: use ResolveTypeDef() with null check instead of ResolveTypeDefThrow()
  • InheritsFrom: same pattern
  • Implements: same pattern, removed unreachable throw
  • IsImplicitImplementedInterfaceMember: same pattern

These are the core changes from upstream PR mkaring#155 (which touched 215 files). The rest of that PR was project restructuring and test deletions — not applicable to our fork.

Impact

Assemblies with missing third-party dependencies can now be obfuscated. Protections that need the missing types will skip them gracefully (via our earlier fixes in PRs #42, #43, #45).

@mcpolo99 mcpolo99 added enhancement New feature or request needs-testing Fix awaiting reporter confirmation labels Jun 8, 2026
@mcpolo99 mcpolo99 merged commit ff01e84 into pre-release Jun 8, 2026
4 checks passed
@mcpolo99 mcpolo99 deleted the fix/tolerate-missing-dependencies branch June 8, 2026 10:54
mcpolo99 added a commit that referenced this pull request Jun 10, 2026
* fix(ci): add pre-release branch to CI triggers (#36)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(renamer): fix WPF relative resource renaming (#30)

* fix WPF relative resource renaming

* Update Confuser.Renamer/Analyzers/WPFAnalyzer.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Ryan <smbserv@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(core): support .NET Standard library obfuscation (#31)

* Add types in referencing assembly to netstandard DLL.

Types defined in AssemblyRefs of netstandard (e.g. mscorlib) will be moved to netstandard. Therefore, subsequence ModuleDef.Find will return AssemblyRef to netstandard. As a result, the confused module will only reference to netstandard.

* Remove AssemblyAttributes.PA_NoPlatform from assembly.

Net standard project may refer to NuGet package (e.g. System.ComponentModel.Composition) in order to use the Framework libraries. However, DLL in NuGet may have this attribute set but the actual Framework DLL does not. As a result, dnlib treats them as different assemblies and confused DLL will reference to two identical assemblies.

* Fix assembly reference to assemblies that hidden by netstandard assembly.

TargetModule.GetAssemblyRef returns null if type is defined in assembly hidden by netstandard. This change searches assemblies hidden by netstandard and returns the fixed type reference.

* Returns the method from CorLib of module to be confused instead from runtime.

MSBuild may runs on .net framework and runtime help will reference to mscorlib instead of netstandard. This change try resolve it from CorLib before from runtime type.

---------

Co-authored-by: KC Ip <kamchuen.ip@hidglobal.com>

* fix(core): don't create PDB files when debug=false (upstream mkaring#532) (#32)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(renamer): fix generic name parsing null case (upstream mkaring#516) (#33)

When preserveGenericParams is true but name is null or empty,
ParseGenericName would crash. Add a null/empty guard to prevent this.

Cherry-pick of mkaring#516.

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* 修复控制流保护在#153的错误 (#34)

注意到 mkaring 在 1.4.0版本中对控制流保护做出了误操作(272行)
将src => statementLast.Contains(src),错误修改成了src => !statementLast.Contains(src),导致了保护后的程序出现了错误的循环,这里特此做出修复!

Co-authored-by: wujiayang2007 <52036257+wujiayang2007@users.noreply.github.com>

* feat(core): add wildcard module loading in .crproj (upstream mkaring#481) (#35)

Cherry-pick of mkaring#481 — allows using wildcards like
*.dll in module paths to batch-load modules from the base directory.

The Load method now accepts an optional baseDirRoot parameter to
resolve relative base directory paths. New internal helpers AddModule,
IsWildcard, and BatchLoadModules handle wildcard expansion using
Directory.GetFiles with TopDirectoryOnly search.

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(renamer): skip renaming of DataContract/DataMember/JsonProperty attributed types and members (#38)

Detect serialization-related attributes and exclude decorated types and
members from renaming to prevent WCF/DataContract serialization breakage
at runtime.

Attributes now checked:
- DataContractAttribute on types
- DataMemberAttribute on fields and properties
- EnumMemberAttribute on enum fields

Fixes mcpolo99/private-ConfuserEx#9
Upstream: mkaring#147

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(renamer): preserve anonymous type constructor arg names for JSON serialization (#39)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* feat(cli): add --snkey and --snkeypass options for CI/CD signing (#40)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(runtime): catch ReflectionTypeLoadException in packer startup (#41)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(protections): use non-throwing resolution in ref proxy mild mode for external types (#42)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(renamer): handle FnPtr type signatures instead of throwing NotSupportedException (#43)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(renamer): skip renaming WPF theme resources in themes/Generic.xaml (#44)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(protections): skip unresolvable external types in ref proxy phase (#45)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* feat(analysis): enable .NET analyzers and configure severity rules (#50)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* feat(analysis): add Roslynator.Analyzers for broader code quality coverage (#51)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(analysis): resolve analyzer warnings and suppress noisy rules (#52)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* fix(core): improve error message for .NET 6+ native host .exe files (#19) (#56)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* docs: update README for ConfuserExx fork — fix links, add features, modernize (#57)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* feat(core): tolerate missing dependencies — warn instead of crash (#4) (#58)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* feat(renamer): add opt-in overload confusion — rename methods with different signatures to same name (#25)

* feat(ci): add pre-release builds with downloadable binaries (#pre-release) (#61)

Co-authored-by: RandomCrocodile <mawi@polosab.com>

* feat(core): auto-detect .NET runtime paths for assembly resolution (#55)

* feat(core): auto-detect .NET Core/5+/6/7/8+ runtime paths for assembly resolution (#12)

* fix(core): probe all installed .NET runtime versions for cross-version dependencies (#12)

* refactor(core): add logging to DotNetCorePathResolver, address review feedback (#12)

---------

Co-authored-by: RandomCrocodile <mawi@polosab.com>

---------

Co-authored-by: RandomCrocodile <mawi@polosab.com>
Co-authored-by: Ryan <smbserv@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: KC Ip <kamchuen.ip@hidglobal.com>
Co-authored-by: wujiayang2007 <52036257+wujiayang2007@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs-testing Fix awaiting reporter confirmation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant