yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.57k stars 1.64k forks source link

RunTimeBinderException from dynamic type in method arguments. #488

Open JordanAlimi opened 8 years ago

JordanAlimi commented 8 years ago

Warning: I've read the open issue #316 and issue #203 and this might be a merge of the two.

I'm using Confuser.CLI with mono. I use .crproj to configure with the following rules:

<?xml version="1.0" encoding="utf-8"?>
<project baseDir="../dir/dlls" outputDir="." probePath=".">
  <rule preset="none" pattern="true">
    <protection id="anti debug" action="remove"/>
    <protection id="anti dump" action="remove"/>
    <protection id="anti ildasm" action="add"/>
    <protection id="anti tamper" action="remove"/>
    <protection id="constants" action="add"/>
    <protection id="ctrl flow" action="add"/>
    <protection id="invalid metadata" action="remove"/>
    <protection id="ref proxy" action="add"/>
    <protection id="rename" action="add">
      <argument name="mode" value="unicode"/>
    </protection>
    <protection id="resources" action="add"/>
  </rule>
  <module path="Party.dll" />
  <module path="Member.dll" />
</project> 

I have a method definition that takes in a dynamic type as so:

public void Congo(dynamic lead, JObject music, params string[] members)

A RunTimeBinderException is thrown when called because of a mismatch between the call and definition from obfuscation.

I'm able to solve this by using the attribute [Obfuscation( Exclude = true )] above the method but this is undesired and is more of a band-aid.

I've also attempted using the pattern 'is-type' to exclude the dynamic type as shown here. This is without the [Obfuscation( Exclude = true )] above the method. I added this to my config:

<rule preset="none" pattern="is-type('dynamic')">
    <protection id="rename" action="remove"/>
</rule>

but the same exception was thrown indicating non action from the new rule or a different issue.

JordanAlimi commented 8 years ago

@yck1509 Is this an issue with obfuscating dynamic variable or an issue with configuration?