From 2dd79b6fcbbe3886ce5685e335bf320c1481cb20 Mon Sep 17 00:00:00 2001 From: Martin Karing Date: Mon, 20 Dec 2021 15:17:41 +0100 Subject: [PATCH] Fixed rewriter for TypeScramber The problem was that the type scrambler injected a reference of the ConfuserEx runtime framework into the target assembly instead of using the framework of the assembly. --- .../Rewriter/Instructions/MemberRefInstructionRewriter.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MemberRefInstructionRewriter.cs b/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MemberRefInstructionRewriter.cs index f77b30782..596c7fcaf 100644 --- a/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MemberRefInstructionRewriter.cs +++ b/Confuser.Protections/TypeScrambler/Scrambler/Rewriter/Instructions/MemberRefInstructionRewriter.cs @@ -24,8 +24,10 @@ internal override void ProcessOperand(TypeService service, MethodDef method, ILi ModuleDef mod = method.Module; - var gettype = typeof(Type).GetMethod("GetTypeFromHandle"); - var createInstance = typeof(Activator).GetMethod("CreateInstance", new Type[] { typeof(Type) }); + var corlibType = mod.CorLibTypes.GetTypeRef("System", "Type").ResolveThrow(); + var gettype = corlibType.FindMethod("GetTypeFromHandle"); + var createInstance = mod.CorLibTypes.GetTypeRef("System", "Activator").ResolveThrow() + .FindMethod("CreateInstance", MethodSig.CreateStatic(mod.CorLibTypes.Object, corlibType.ToTypeSig())); TypeSig sig = null;