Skip to content

feat(core): add wildcard module loading in .crproj#35

Merged
mcpolo99 merged 1 commit into
pre-releasefrom
feat/wildcard-module-loading
Jun 7, 2026
Merged

feat(core): add wildcard module loading in .crproj#35
mcpolo99 merged 1 commit into
pre-releasefrom
feat/wildcard-module-loading

Conversation

@mcpolo99

@mcpolo99 mcpolo99 commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #18

Cherry-pick of mkaring/ConfuserEx#481 — allows using wildcards like *.dll in module paths within .crproj files to batch-load modules.

Changes

  • ConfuserProject.Load now accepts an optional baseDirRoot parameter to resolve the base directory relative to the .crproj file location
  • New AddModule helper dispatches between single-file and wildcard module loading
  • New IsWildcard and BatchLoadModules internal methods handle Directory.GetFiles expansion with SearchOption.TopDirectoryOnly
  • Program.cs simplified to pass the project file directory into Load() instead of manually resolving paths afterward
  • OutputDirectory is still resolved to a full path relative to the (now-resolved) BaseDirectory

Example usage in .crproj

<module path="*.dll" />

This will load all .dll files found in the base directory as modules, applying the same protection rules defined on the <module> element.

Test plan

  • Verify existing single-module .crproj files still work as before
  • Test wildcard *.dll pattern loads all matching modules
  • Verify that non-matching wildcard patterns (no files found) are handled gracefully
  • Confirm OutputDirectory resolution still works correctly with relative paths

)

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.
@mcpolo99 mcpolo99 changed the base branch from master to pre-release June 7, 2026 16:52
@mcpolo99 mcpolo99 merged commit fa0b829 into pre-release Jun 7, 2026
4 checks passed
@mcpolo99 mcpolo99 deleted the feat/wildcard-module-loading branch June 7, 2026 16:56
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add wildcard module loading in .crproj (upstream PR #481)

1 participant