Skip to content

Commit

Permalink
Added Constrained Support
Browse files Browse the repository at this point in the history
thanks to illuZion9999 for suggested
  • Loading branch information
NotPrab committed Jun 21, 2020
1 parent bd9724f commit 5ab508c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ obj/project.nuget.cache
obj/project.packagespec.json
.vs/AntiDecompiler Cleaner/v16/.suo
.vs/AntiDecompiler Cleaner/DesignTimeBuild/.dtbcache.v2
bin/Debug/netcoreapp3.1/AntiDecompiler Cleaner 1.2.rar
5 changes: 4 additions & 1 deletion AntiDecompilerPhase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static void Execute(MethodDef method) {
var instr = method.Body.Instructions;
for (var i = 0; i < instr.Count; i++)
// manually edit numbers, if file broken after used.
switch (AntiDecompilerUtils.Rnd.Next(0, 3)) {
switch (AntiDecompilerUtils.Rnd.Next(0, 4)) {
case 0:
AntiDecompilerUtils.CallsizeOfcalli(method); // thanks to cursedsheep
break;
Expand All @@ -16,6 +16,9 @@ public static void Execute(MethodDef method) {
case 2:
AntiDecompilerUtils.CallBox(method);
break;
case 3:
AntiDecompilerUtils.CallConstrained(method);
break;
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions AntiDecompilerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,16 @@ internal static void CallBox(MethodDef method) {
instr[i + 1].OpCode = OpCodes.Nop;
}
}

// This method solve
internal static void CallConstrained(MethodDef method) {
var instr = method.Body.Instructions;
for (var i = 0; i < instr.Count; i++) {
if (instr[i].IsBr() && instr[i + 1].OpCode == OpCodes.Constrained) {
instr[i].OpCode = OpCodes.Nop;
instr[i + 1].OpCode = OpCodes.Nop;
}
}
}
}
}

0 comments on commit 5ab508c

Please sign in to comment.