2025-04-22 08:58:00 +08:00
|
|
|
|
using dnlib.DotNet;
|
|
|
|
|
using dnlib.DotNet.Emit;
|
|
|
|
|
using System;
|
2025-04-21 21:02:47 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Obfuz
|
|
|
|
|
{
|
|
|
|
|
public class CleanUpInstructionPass : ObfuscationPassBase
|
|
|
|
|
{
|
|
|
|
|
public override void Process(ObfuscatorContext ctx)
|
|
|
|
|
{
|
2025-04-22 08:58:00 +08:00
|
|
|
|
foreach (var ass in ctx.assemblies)
|
|
|
|
|
{
|
|
|
|
|
foreach (TypeDef type in ass.module.GetTypes())
|
|
|
|
|
{
|
|
|
|
|
foreach (MethodDef method in type.Methods)
|
|
|
|
|
{
|
|
|
|
|
if (method.HasBody)
|
|
|
|
|
{
|
|
|
|
|
CilBody body = method.Body;
|
|
|
|
|
body.SimplifyBranches();
|
|
|
|
|
body.OptimizeMacros();
|
|
|
|
|
body.OptimizeBranches();
|
2025-04-22 10:42:58 +08:00
|
|
|
|
// TODO remove dup
|
2025-04-22 08:58:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-21 21:02:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-04-22 10:42:58 +08:00
|
|
|
|
public override void Start(ObfuscatorContext ctx)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-21 21:02:47 +08:00
|
|
|
|
public override void Stop(ObfuscatorContext ctx)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|