diff --git a/Confuser.Protections/ReferenceProxy/MildMode.cs b/Confuser.Protections/ReferenceProxy/MildMode.cs index b51f6dc56..fcc50f435 100644 --- a/Confuser.Protections/ReferenceProxy/MildMode.cs +++ b/Confuser.Protections/ReferenceProxy/MildMode.cs @@ -64,6 +64,10 @@ public override void ProcessCall(RPContext ctx, int instrIndex) { } else invoke.Operand = proxy; + + var targetDef = target.ResolveMethodDef(); + if (targetDef != null) + ctx.Context.Annotations.Set(targetDef, ReferenceProxyProtection.Targeted, ReferenceProxyProtection.Targeted); } public override void Finalize(RPContext ctx) { } diff --git a/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs b/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs index 01ee33d49..7a5ecc57b 100644 --- a/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs +++ b/Confuser.Protections/ReferenceProxy/ReferenceProxyProtection.cs @@ -7,6 +7,7 @@ namespace Confuser.Protections { public interface IReferenceProxyService { void ExcludeMethod(ConfuserContext context, MethodDef method); void ExcludeTarget(ConfuserContext context, MethodDef method); + bool IsTargeted(ConfuserContext context, MethodDef method); } [AfterProtection("Ki.AntiDebug", "Ki.AntiDump")] @@ -17,6 +18,7 @@ internal class ReferenceProxyProtection : Protection, IReferenceProxyService { public const string _ServiceId = "Ki.RefProxy"; internal static object TargetExcluded = new object(); + internal static object Targeted = new object(); public override string Name { get { return "Reference Proxy Protection"; } @@ -46,6 +48,10 @@ public void ExcludeTarget(ConfuserContext context, MethodDef method) { context.Annotations.Set(method, TargetExcluded, TargetExcluded); } + public bool IsTargeted(ConfuserContext context, MethodDef method) { + return context.Annotations.Get(method, Targeted) != null; + } + protected override void Initialize(ConfuserContext context) { context.Registry.RegisterService(_ServiceId, typeof(IReferenceProxyService), this); } diff --git a/Confuser.Protections/ReferenceProxy/StrongMode.cs b/Confuser.Protections/ReferenceProxy/StrongMode.cs index 2f0342eb9..22908b287 100644 --- a/Confuser.Protections/ReferenceProxy/StrongMode.cs +++ b/Confuser.Protections/ReferenceProxy/StrongMode.cs @@ -127,6 +127,10 @@ void ProcessBridge(RPContext ctx, int instrIndex) { // Replace instruction instr.OpCode = OpCodes.Call; instr.Operand = proxy.Item2; + + var targetDef = target.ResolveMethodDef(); + if (targetDef != null) + ctx.Context.Annotations.Set(targetDef, ReferenceProxyProtection.Targeted, ReferenceProxyProtection.Targeted); } void ProcessInvoke(RPContext ctx, int instrIndex, int argBeginIndex) { @@ -161,6 +165,10 @@ void ProcessInvoke(RPContext ctx, int instrIndex, int argBeginIndex) { instr.OpCode = OpCodes.Call; instr.Operand = delegateType.FindMethod("Invoke"); } + + var targetDef = target.ResolveMethodDef(); + if (targetDef != null) + ctx.Context.Annotations.Set(targetDef, ReferenceProxyProtection.Targeted, ReferenceProxyProtection.Targeted); } MethodDef CreateBridge(RPContext ctx, TypeDef delegateType, FieldDef field, MethodSig sig) {