Browse Source

Check that it only matches if the method performs one call and only with arguments without modification

pull/903/head
mohe2015 8 years ago
parent
commit
1486cd4b62
  1. 15
      ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs

15
ICSharpCode.Decompiler/IL/Transforms/ProxyCallReplacer.cs

@ -57,6 +57,17 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -57,6 +57,17 @@ namespace ICSharpCode.Decompiler.IL.Transforms
Call currentCall = new ProxyMethodVisitor().GetCalledMethod(function, context);
if (currentCall != null) {
Call newInst = (Call)currentCall.Clone();
// check if original arguments are only correct ldloc calls
for (int i = 0; i < currentCall.Arguments.Count; i++) {
var originalArg = currentCall.Arguments.ElementAtOrDefault(i);
if (originalArg.OpCode != OpCode.LdLoc ||
originalArg.Children.Count != 0 ||
((LdLoc)originalArg).Variable.Kind != VariableKind.Parameter ||
((LdLoc)originalArg).Variable.Index != i-1) {
return;
}
}
newInst.Arguments.Clear();
ILInstruction thisArg = inst.Arguments.ElementAtOrDefault(0).Clone();
@ -119,7 +130,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -119,7 +130,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
protected internal override void VisitCall(Call inst)
{
if (currentCall == null) {
currentCall = inst;
} else {
invalidInstructions++; // more than one call in the function
}
}
}
}

Loading…
Cancel
Save