Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
Minor addition to ref proxy API
Browse files Browse the repository at this point in the history
  • Loading branch information
yck1509 committed Nov 18, 2015
1 parent b9d74ba commit 02492b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Confuser.Protections/ReferenceProxy/ReferenceProxyPhase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ void ProcessMethod(RPContext ctx) {
Instruction instr = ctx.Body.Instructions[i];
if (instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt || instr.OpCode.Code == Code.Newobj) {
var operand = (IMethod)instr.Operand;
var def = operand.ResolveMethodDef();

if (def != null && ctx.Context.Annotations.Get<object>(def, ReferenceProxyProtection.TargetExcluded) != null)
return;

// Call constructor
if (instr.OpCode.Code != Code.Newobj && operand.Name == ".ctor")
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Confuser.Protections {
public interface IReferenceProxyService {
void ExcludeMethod(ConfuserContext context, MethodDef method);
void ExcludeTarget(ConfuserContext context, MethodDef method);
}

[AfterProtection("Ki.AntiDebug", "Ki.AntiDump")]
Expand All @@ -15,6 +16,8 @@ internal class ReferenceProxyProtection : Protection, IReferenceProxyService {
public const string _FullId = "Ki.RefProxy";
public const string _ServiceId = "Ki.RefProxy";

internal static object TargetExcluded = new object();

public override string Name {
get { return "Reference Proxy Protection"; }
}
Expand All @@ -39,6 +42,10 @@ public void ExcludeMethod(ConfuserContext context, MethodDef method) {
ProtectionParameters.GetParameters(context, method).Remove(this);
}

public void ExcludeTarget(ConfuserContext context, MethodDef method) {
context.Annotations.Set(method, TargetExcluded, TargetExcluded);
}

protected override void Initialize(ConfuserContext context) {
context.Registry.RegisterService(_ServiceId, typeof(IReferenceProxyService), this);
}
Expand Down

0 comments on commit 02492b3

Please sign in to comment.