diff --git a/.gitignore b/.gitignore index 1f8a9c52..ae12b8e6 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,4 @@ gh-pages/ .idea/ artifacts/ /Confuser.Protections/runtime -/Confuser.Protections/runtime +*.binlog diff --git a/Confuser.Core/CoreComponent.cs b/Confuser.Core/CoreComponent.cs index 7ae6d7a8..d39ad7fe 100644 --- a/Confuser.Core/CoreComponent.cs +++ b/Confuser.Core/CoreComponent.cs @@ -78,7 +78,7 @@ protected internal override void Initialize(ConfuserContext context) { context.Registry.RegisterService(_RandomServiceId, typeof(IRandomService), new RandomService(_context.Project.Seed)); context.Registry.RegisterService(_MarkerServiceId, typeof(IMarkerService), new MarkerService(context, marker)); context.Registry.RegisterService(_TraceServiceId, typeof(ITraceService), new TraceService()); - context.Registry.RegisterService(_RuntimeServiceId, typeof(IRuntimeService), new RuntimeService()); + context.Registry.RegisterService(_RuntimeServiceId, typeof(IRuntimeService), new RuntimeService(context)); context.Registry.RegisterService(_CompressionServiceId, typeof(ICompressionService), new CompressionService(context)); context.Registry.RegisterService(_APIStoreId, typeof(IAPIStore), new APIStore(context)); } diff --git a/Confuser.Core/Services/RuntimeService.cs b/Confuser.Core/Services/RuntimeService.cs index 4d4edae4..fe94c9ca 100644 --- a/Confuser.Core/Services/RuntimeService.cs +++ b/Confuser.Core/Services/RuntimeService.cs @@ -4,9 +4,14 @@ using dnlib.DotNet; namespace Confuser.Core.Services { - internal class RuntimeService : IRuntimeService { + internal class RuntimeService : IRuntimeService { + private readonly ConfuserContext context; ModuleDef rtModule; + public RuntimeService(ConfuserContext context) { + this.context = context; + } + /// public TypeDef GetRuntimeType(string fullName) { if (rtModule == null) { @@ -16,7 +21,9 @@ public TypeDef GetRuntimeType(string fullName) { } private void LoadConfuserRuntimeModule() { - const string runtimeDllName = "Confuser.Runtime.dll"; + var entryPoint = this.context.Project[0].Resolve(this.context.Project.BaseDirectory); + var hasMscorlib = entryPoint.GetAssemblyRef("mscorlib") != null; + var runtimeDllName = hasMscorlib ? "runtime\\net472\\Confuser.Runtime.dll" : "runtime\\net8.0\\Confuser.Runtime.dll"; var module = typeof(RuntimeService).Assembly.ManifestModule; string rtPath = runtimeDllName; diff --git a/Confuser.Protections/Confuser.Protections.csproj b/Confuser.Protections/Confuser.Protections.csproj index 4a2625df..ed84a3ac 100644 --- a/Confuser.Protections/Confuser.Protections.csproj +++ b/Confuser.Protections/Confuser.Protections.csproj @@ -5,6 +5,7 @@ net472;net8.0 + ..\Confuser.Runtime\Confuser.Runtime.csproj @@ -12,16 +13,56 @@ Protections and packers of ConfuserEx - - - - - + - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + runtime\net8.0\%(Filename)%(Extension) + PreserveNewest + + + runtime\net472\%(Filename)%(Extension) + PreserveNewest + + + + + +